From 587d347178848c6045520327aa97abc8fd5b46bc Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 15 Jan 2016 17:01:30 +0800 Subject: [PATCH 001/507] added wechat --- Gemfile | 1 + app/controllers/wechats_controller.rb | 119 + config/routes.rb | 3 + config/wechat.yml | 33 + db/schema.rb | 6004 ++++++++----------------- 5 files changed, 2151 insertions(+), 4009 deletions(-) create mode 100644 app/controllers/wechats_controller.rb create mode 100644 config/wechat.yml diff --git a/Gemfile b/Gemfile index c739e1085..0e4e456ca 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end +gem 'wechat' gem 'grack', path:'lib/grack' gem 'gitlab', path: 'lib/gitlab-cli' gem 'rest-client' diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb new file mode 100644 index 000000000..fd3050e05 --- /dev/null +++ b/app/controllers/wechats_controller.rb @@ -0,0 +1,119 @@ +class WechatsController < ActionController::Base + wechat_responder + + # default text responder when no other match + on :text do |request, content| + request.reply.text "echo: #{content}" # Just echo + end + + # When receive 'help', will trigger this responder + on :text, with: 'help' do |request| + request.reply.text 'help content' + end + + # When receive 'news', will match and will got count as as parameter + on :text, with: /^(\d+) news$/ do |request, count| + # Wechat article can only contain max 10 items, large than 10 will dropped. + news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } + request.reply.news(news) do |article, n, index| # article is return object + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' + end + end + + on :event, with: 'subscribe' do |request| + request.reply.text "#{request[:FromUserName]} subscribe now" + end + + # When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account + # notice user will subscribe public account at same time, so wechat won't trigger subscribe event any more + on :scan, with: 'qrscene_xxxxxx' do |request, ticket| + request.reply.text "Unsubscribe user #{request[:FromUserName]} Ticket #{ticket}" + end + + # When subscribe user scan scene_id in public account + on :scan, with: 'scene_id' do |request, ticket| + request.reply.text "Subscribe user #{request[:FromUserName]} Ticket #{ticket}" + end + + # When no any on :scan responder can match subscribe user scaned scene_id + on :event, with: 'scan' do |request| + if request[:EventKey].present? + request.reply.text "event scan got EventKey #{request[:EventKey]} Ticket #{request[:Ticket]}" + end + end + + # When enterprise user press menu BINDING_QR_CODE and success to scan bar code + on :scan, with: 'BINDING_QR_CODE' do |request, scan_result, scan_type| + request.reply.text "User #{request[:FromUserName]} ScanResult #{scan_result} ScanType #{scan_type}" + end + + # Except QR code, wechat can also scan CODE_39 bar code in enterprise account + on :scan, with: 'BINDING_BARCODE' do |message, scan_result| + if scan_result.start_with? 'CODE_39,' + message.reply.text "User: #{message[:FromUserName]} scan barcode, result is #{scan_result.split(',')[1]}" + end + end + + # When user click the menu button + on :click, with: 'BOOK_LUNCH' do |request, key| + request.reply.text "User: #{request[:FromUserName]} click #{key}" + end + + # When user view URL in the menu button + on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| + request.reply.text "#{request[:FromUserName]} view #{view}" + end + + # When user sent the imsage + on :image do |request| + request.reply.image(request[:MediaId]) # Echo the sent image to user + end + + # When user sent the voice + on :voice do |request| + request.reply.voice(request[:MediaId]) # Echo the sent voice to user + end + + # When user sent the video + on :video do |request| + nickname = wechat.user(request[:FromUserName])['nickname'] # Call wechat api to get sender nickname + request.reply.video(request[:MediaId], title: 'Echo', description: "Got #{nickname} sent video") # Echo the sent video to user + end + + # When user sent location + on :location do |request| + request.reply.text("Latitude: #{message[:Latitude]} Longitude: #{message[:Longitude]} Precision: #{message[:Precision]}") + end + + on :event, with: 'unsubscribe' do |request| + request.reply.success # user can not receive this message + end + + # When user enter the app / agent app + on :event, with: 'enter_agent' do |request| + request.reply.text "#{request[:FromUserName]} enter agent app now" + end + + # When batch job create/update user (incremental) finished. + on :batch_job, with: 'sync_user' do |request, batch_job| + request.reply.text "sync_user job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}" + end + + # When batch job replace user (full sync) finished. + on :batch_job, with: 'replace_user' do |request, batch_job| + request.reply.text "replace_user job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}" + end + + # When batch job invent user finished. + on :batch_job, with: 'invite_user' do |request, batch_job| + request.reply.text "invite_user job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}" + end + + # When batch job replace department (full sync) finished. + on :batch_job, with: 'replace_party' do |request, batch_job| + request.reply.text "replace_party job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}" + end + + # Any not match above will fail to below + on :fallback, respond: 'fallback message' +end diff --git a/config/routes.rb b/config/routes.rb index 6afd5e011..02220864d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,6 +26,7 @@ # Example: :via => :get ====> :via => :get RedmineApp::Application.routes.draw do + mount Mobile::API => '/api' # Enable Grack support @@ -1119,6 +1120,8 @@ RedmineApp::Application.routes.draw do resources :at + resource :wechat, only:[:show, :create] + Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| file = File.join(plugin_dir, "config/routes.rb") if File.exists?(file) diff --git a/config/wechat.yml b/config/wechat.yml new file mode 100644 index 000000000..af795654f --- /dev/null +++ b/config/wechat.yml @@ -0,0 +1,33 @@ +default: &default + corpid: "corpid" + corpsecret: "corpsecret" + agentid: 1 +# Or if using public account, only need above two line +# appid: "my_appid" +# secret: "my_secret" + token: "my_token" + access_token: "1234567" + encrypt_mode: true # if true must fill encoding_aes_key + encoding_aes_key: "TJP8IMYwdcW1EkBIKIcQ193bCe7uB0RVqZDC2eAmkjz" + jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" + +production: + corpid: <%= ENV['WECHAT_CORPID'] %> + corpsecret: <%= ENV['WECHAT_CORPSECRET'] %> + agentid: <%= ENV['WECHAT_AGENTID'] %> +# Or if using public account, only need above two line +# appid: +# secret: + token: <%= ENV['WECHAT_TOKEN'] %> + timeout: 30, + skip_verify_ssl: true + access_token: <%= ENV['WECHAT_ACCESS_TOKEN'] %> + encrypt_mode: false # if true must fill encoding_aes_key + encoding_aes_key: <%= ENV['WECHAT_ENCODING_AES_KEY'] %> + jsapi_ticket: + +development: + <<: *default + +test: + <<: *default \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 6e599f520..2e0e4d238 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,2018 +1,3 @@ -<<<<<<< HEAD -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20160113090435) do - - create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - t.integer "activity_container_id" - t.string "activity_container_type", :default => "" - t.datetime "created_at" - end - - add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" - add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" - add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - - create_table "activity_notifies", :force => true do |t| - t.integer "activity_container_id" - t.string "activity_container_type" - t.integer "activity_id" - t.string "activity_type" - t.integer "notify_to" - t.datetime "created_on" - t.integer "is_read" - end - - add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" - add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" - add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" - - create_table "api_keys", :force => true do |t| - t.string "access_token" - t.datetime "expires_at" - t.integer "user_id" - t.boolean "active", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" - add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" - - create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - end - - create_table "apply_project_masters", :force => true do |t| - t.integer "user_id" - t.string "apply_type" - t.integer "apply_id" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "at_messages", :force => true do |t| - t.integer "user_id" - t.integer "at_message_id" - t.string "at_message_type" - t.boolean "viewed", :default => false - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sender_id" - end - - add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" - - create_table "attachment_histories", :force => true do |t| - t.integer "container_id" - t.string "container_type" - t.string "filename", :default => "" - t.string "disk_filename", :default => "" - t.integer "filesize", :default => 0 - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "" - t.integer "downloads", :default => 0 - t.integer "author_id" - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.integer "copy_from" - t.integer "quotes" - t.integer "version" - t.integer "attachment_id" - end - - create_table "attachments", :force => true do |t| - t.integer "container_id" - t.string "container_type", :limit => 30 - t.string "filename", :default => "", :null => false - t.string "disk_filename", :default => "", :null => false - t.integer "filesize", :default => 0, :null => false - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "", :null => false - t.integer "downloads", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype", :default => 1 - t.integer "is_public", :default => 1 - t.integer "copy_from" - t.integer "quotes" - end - - add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" - add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" - add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" - - create_table "attachmentstypes", :force => true do |t| - t.integer "typeId", :null => false - t.string "typeName", :limit => 50 - end - - create_table "auth_sources", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 60, :default => "", :null => false - t.string "host", :limit => 60 - t.integer "port" - t.string "account" - t.string "account_password", :default => "" - t.string "base_dn" - t.string "attr_login", :limit => 30 - t.string "attr_firstname", :limit => 30 - t.string "attr_lastname", :limit => 30 - t.string "attr_mail", :limit => 30 - t.boolean "onthefly_register", :default => false, :null => false - t.boolean "tls", :default => false, :null => false - t.string "filter" - t.integer "timeout" - end - - add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" - - create_table "biding_projects", :force => true do |t| - t.integer "project_id" - t.integer "bid_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "bids", :force => true do |t| - t.string "name" - t.string "budget", :null => false - t.integer "author_id" - t.date "deadline" - t.text "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.integer "commit" - t.integer "reward_type" - t.integer "homework_type" - t.integer "parent_id" - t.string "password" - t.integer "is_evaluation" - t.integer "proportion", :default => 60 - t.integer "comment_status", :default => 0 - t.integer "evaluation_num", :default => 3 - t.integer "open_anonymous_evaluation", :default => 1 - end - - create_table "blog_comments", :force => true do |t| - t.integer "blog_id", :null => false - t.integer "parent_id" - t.string "title", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comment_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "blogs", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.integer "position", :default => 1 - t.integer "article_count", :default => 0, :null => false - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comments_id" - t.integer "parent_id" - t.integer "author_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "homepage_id" - end - - create_table "boards", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :default => "", :null => false - t.string "description" - t.integer "position", :default => 1 - t.integer "topics_count", :default => 0, :null => false - t.integer "messages_count", :default => 0, :null => false - t.integer "last_message_id" - t.integer "parent_id" - t.integer "course_id" - t.integer "org_subfield_id" - end - - add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" - add_index "boards", ["project_id"], :name => "boards_project_id" - - create_table "bug_to_osps", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "changes", :force => true do |t| - t.integer "changeset_id", :null => false - t.string "action", :limit => 1, :default => "", :null => false - t.text "path", :null => false - t.text "from_path" - t.string "from_revision" - t.string "revision" - t.string "branch" - end - - add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" - - create_table "changeset_parents", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "parent_id", :null => false - end - - add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" - add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" - - create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false - t.string "committer" - t.datetime "committed_on", :null => false - t.text "comments" - t.date "commit_date" - t.string "scmid" - t.integer "user_id" - end - - add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" - add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true - add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" - add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" - add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" - - create_table "changesets_issues", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "issue_id", :null => false - end - - add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - - create_table "comments", :force => true do |t| - t.string "commented_type", :limit => 30, :default => "", :null => false - t.integer "commented_id", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.text "comments" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "comments", ["author_id"], :name => "index_comments_on_author_id" - add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" - - create_table "contest_notifications", :force => true do |t| - t.text "title" - t.text "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" - t.integer "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contestnotifications", :force => true do |t| - t.integer "contest_id" - t.string "title" - t.string "summary" - t.text "description" - t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contests", :force => true do |t| - t.string "name" - t.string "budget", :default => "" - t.integer "author_id" - t.date "deadline" - t.string "description" - t.integer "commit" - t.string "password" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - create_table "course_activities", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_act_id" - t.string "course_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_attachments", :force => true do |t| - t.string "filename" - t.string "disk_filename" - t.integer "filesize" - t.string "content_type" - t.string "digest" - t.integer "downloads" - t.string "author_id" - t.string "integer" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "container_id", :default => 0 - end - - create_table "course_contributor_scores", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.integer "message_num" - t.integer "message_reply_num" - t.integer "news_reply_num" - t.integer "resource_num" - t.integer "journal_num" - t.integer "journal_reply_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "total_score" - end - - create_table "course_groups", :force => true do |t| - t.string "name" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_infos", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_messages", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_message_id" - t.string "course_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "content" - t.integer "status" - end - - create_table "course_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "course_id" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "courses", :force => true do |t| - t.integer "tea_id" - t.string "name" - t.integer "state" - t.string "code" - t.integer "time" - t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "location" - t.string "term" - t.string "string" - t.string "password" - t.string "setup_time" - t.string "endup_time" - t.string "class_period" - t.integer "school_id" - t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 - t.integer "lft" - t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "is_delete", :default => 0 - t.integer "end_time" - t.string "end_term" - end - - create_table "custom_fields", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.string "field_format", :limit => 30, :default => "", :null => false - t.text "possible_values" - t.string "regexp", :default => "" - t.integer "min_length", :default => 0, :null => false - t.integer "max_length", :default => 0, :null => false - t.boolean "is_required", :default => false, :null => false - t.boolean "is_for_all", :default => false, :null => false - t.boolean "is_filter", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "searchable", :default => false - t.text "default_value" - t.boolean "editable", :default => true - t.boolean "visible", :default => true, :null => false - t.boolean "multiple", :default => false - end - - add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" - - create_table "custom_fields_projects", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "project_id", :default => 0, :null => false - end - - add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true - - create_table "custom_fields_trackers", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true - - create_table "custom_values", :force => true do |t| - t.string "customized_type", :limit => 30, :default => "", :null => false - t.integer "customized_id", :default => 0, :null => false - t.integer "custom_field_id", :default => 0, :null => false - t.text "value" - end - - add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" - add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" - - create_table "delayed_jobs", :force => true do |t| - t.integer "priority", :default => 0, :null => false - t.integer "attempts", :default => 0, :null => false - t.text "handler", :null => false - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "documents", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "category_id", :default => 0, :null => false - t.string "title", :limit => 60, :default => "", :null => false - t.text "description" - t.datetime "created_on" - t.integer "user_id", :default => 0 - t.integer "is_public", :default => 1 - end - - add_index "documents", ["category_id"], :name => "index_documents_on_category_id" - add_index "documents", ["created_on"], :name => "index_documents_on_created_on" - add_index "documents", ["project_id"], :name => "documents_project_id" - - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 - t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false - end - - create_table "editor_of_documents", :force => true do |t| - t.integer "editor_id" - t.integer "org_document_comment_id" - t.datetime "created_at" - end - - create_table "enabled_modules", :force => true do |t| - t.integer "project_id" - t.string "name", :null => false - t.integer "course_id" - end - - add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" - - create_table "enumerations", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "is_default", :default => false, :null => false - t.string "type" - t.boolean "active", :default => true, :null => false - t.integer "project_id" - t.integer "parent_id" - t.string "position_name", :limit => 30 - end - - add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" - add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" - - create_table "exercise_answers", :force => true do |t| - t.integer "user_id" - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_choices", :force => true do |t| - t.integer "exercise_question_id" - t.text "choice_text" - t.integer "choice_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_questions", :force => true do |t| - t.text "question_title" - t.integer "question_type" - t.integer "question_number" - t.integer "exercise_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_score" - end - - create_table "exercise_standard_answers", :force => true do |t| - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_users", :force => true do |t| - t.integer "user_id" - t.integer "exercise_id" - t.integer "score" - t.datetime "start_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "end_at" - t.integer "status" - end - - create_table "exercises", :force => true do |t| - t.text "exercise_name" - t.text "exercise_description" - t.integer "course_id" - t.integer "exercise_status" - t.integer "user_id" - t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "publish_time" - t.datetime "end_time" - t.integer "show_result" - end - - create_table "first_pages", :force => true do |t| - t.string "web_title" - t.string "title" - t.text "description" - t.string "page_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sort_type" - t.integer "image_width", :default => 107 - t.integer "image_height", :default => 63 - t.integer "show_course", :default => 1 - t.integer "show_contest", :default => 1 - end - - create_table "forge_activities", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_act_id" - t.string "forge_act_type" - t.integer "org_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" - - create_table "forge_messages", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_message_id" - t.string "forge_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "secret_key" - t.integer "status" - end - - create_table "forums", :force => true do |t| - t.string "name", :null => false - t.text "description" - t.integer "topic_count", :default => 0 - t.integer "memo_count", :default => 0 - t.integer "last_memo_id", :default => 0 - t.integer "creator_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sticky" - t.integer "locked" - end - - create_table "groups_users", :id => false, :force => true do |t| - t.integer "group_id", :null => false - t.integer "user_id", :null => false - end - - add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true - - create_table "homework_attaches", :force => true do |t| - t.integer "bid_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - t.string "name" - t.text "description" - t.integer "state" - t.integer "project_id", :default => 0 - t.float "score", :default => 0.0 - t.integer "is_teacher_score", :default => 0 - end - - add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" - - create_table "homework_commons", :force => true do |t| - t.string "name" - t.integer "user_id" - t.text "description" - t.date "publish_time" - t.date "end_time" - t.integer "homework_type", :default => 1 - t.string "late_penalty" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "teacher_priority", :default => 1 - t.integer "anonymous_comment", :default => 0 - end - - add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" - - create_table "homework_detail_groups", :force => true do |t| - t.integer "homework_common_id" - t.integer "min_num" - t.integer "max_num" - t.integer "base_on_project" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" - - create_table "homework_detail_manuals", :force => true do |t| - t.float "ta_proportion" - t.integer "comment_status" - t.date "evaluation_start" - t.date "evaluation_end" - t.integer "evaluation_num" - t.integer "absence_penalty", :default => 1 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_detail_programings", :force => true do |t| - t.string "language" - t.text "standard_code", :limit => 2147483647 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "ta_proportion", :default => 0.1 - t.integer "question_id" - end - - create_table "homework_evaluations", :force => true do |t| - t.string "user_id" - t.string "homework_attach_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_for_courses", :force => true do |t| - t.integer "course_id" - t.integer "bid_id" - end - - add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" - add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" - - create_table "homework_tests", :force => true do |t| - t.text "input" - t.text "output" - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "result" - t.text "error_msg" - end - - create_table "homework_users", :force => true do |t| - t.string "homework_attach_id" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "invite_lists", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "mail" - end - - create_table "issue_categories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.integer "assigned_to_id" - end - - add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" - add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" - - create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :default => "", :null => false - t.integer "delay" - end - - add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true - add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" - add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" - - create_table "issue_statuses", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_closed", :default => false, :null => false - t.boolean "is_default", :default => false, :null => false - t.integer "position", :default => 1 - t.integer "default_done_ratio" - end - - add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" - add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" - add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" - - create_table "issues", :force => true do |t| - t.integer "tracker_id", :null => false - t.integer "project_id", :null => false - t.string "subject", :default => "", :null => false - t.text "description" - t.date "due_date" - t.integer "category_id" - t.integer "status_id", :null => false - t.integer "assigned_to_id" - t.integer "priority_id", :null => false - t.integer "fixed_version_id" - t.integer "author_id", :null => false - t.integer "lock_version", :default => 0, :null => false - t.datetime "created_on" - t.datetime "updated_on" - t.date "start_date" - t.integer "done_ratio", :default => 0, :null => false - t.float "estimated_hours" - t.integer "parent_id" - t.integer "root_id" - t.integer "lft" - t.integer "rgt" - t.boolean "is_private", :default => false, :null => false - t.datetime "closed_on" - t.integer "project_issues_index" - end - - add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" - add_index "issues", ["category_id"], :name => "index_issues_on_category_id" - add_index "issues", ["created_on"], :name => "index_issues_on_created_on" - add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" - add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" - add_index "issues", ["project_id"], :name => "issues_project_id" - add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" - add_index "issues", ["status_id"], :name => "index_issues_on_status_id" - add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" - - create_table "join_in_competitions", :force => true do |t| - t.integer "user_id" - t.integer "competition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "join_in_contests", :force => true do |t| - t.integer "user_id" - t.integer "bid_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "journal_details", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - - create_table "journal_replies", :id => false, :force => true do |t| - t.integer "journal_id" - t.integer "user_id" - t.integer "reply_id" - end - - add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" - add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" - add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" - - create_table "journals", :force => true do |t| - t.integer "journalized_id", :default => 0, :null => false - t.string "journalized_type", :limit => 30, :default => "", :null => false - t.integer "user_id", :default => 0, :null => false - t.text "notes" - t.datetime "created_on", :null => false - t.boolean "private_notes", :default => false, :null => false - end - - add_index "journals", ["created_on"], :name => "index_journals_on_created_on" - add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" - add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" - add_index "journals", ["user_id"], :name => "index_journals_on_user_id" - - create_table "journals_for_messages", :force => true do |t| - t.integer "jour_id" - t.string "jour_type" - t.integer "user_id" - t.text "notes" - t.integer "status" - t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.string "m_parent_id" - t.boolean "is_readed" - t.integer "m_reply_count" - t.integer "m_reply_id" - t.integer "is_comprehensive_evaluation" - t.integer "private", :default => 0 - end - - create_table "kindeditor_assets", :force => true do |t| - t.string "asset" - t.integer "file_size" - t.string "file_type" - t.integer "owner_id" - t.string "asset_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "owner_type", :default => 0 - end - - create_table "member_roles", :force => true do |t| - t.integer "member_id", :null => false - t.integer "role_id", :null => false - t.integer "inherited_from" - end - - add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" - add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" - - create_table "members", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "project_id", :default => 0 - t.datetime "created_on" - t.boolean "mail_notification", :default => false, :null => false - t.integer "course_id", :default => -1 - t.integer "course_group_id", :default => 0 - end - - add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true - add_index "members", ["user_id"], :name => "index_members_on_user_id" - - create_table "memo_messages", :force => true do |t| - t.integer "user_id" - t.integer "forum_id" - t.integer "memo_id" - t.string "memo_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "memos", :force => true do |t| - t.integer "forum_id", :null => false - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false - t.integer "author_id", :null => false - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count", :default => 0 - end - - create_table "message_alls", :force => true do |t| - t.integer "user_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "messages", :force => true do |t| - t.integer "board_id", :null => false - t.integer "parent_id" - t.string "subject", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "replies_count", :default => 0, :null => false - t.integer "last_reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.integer "quotes" - end - - add_index "messages", ["author_id"], :name => "index_messages_on_author_id" - add_index "messages", ["board_id"], :name => "messages_board_id" - add_index "messages", ["created_on"], :name => "index_messages_on_created_on" - add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" - add_index "messages", ["parent_id"], :name => "messages_parent_id" - - create_table "news", :force => true do |t| - t.integer "project_id" - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" - t.text "description" - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false - t.integer "course_id" - t.integer "sticky", :default => 0 - end - - add_index "news", ["author_id"], :name => "index_news_on_author_id" - add_index "news", ["created_on"], :name => "index_news_on_created_on" - add_index "news", ["project_id"], :name => "news_project_id" - - create_table "no_uses", :force => true do |t| - t.integer "user_id", :null => false - t.string "no_use_type" - t.integer "no_use_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "notificationcomments", :force => true do |t| - t.string "notificationcommented_type" - t.integer "notificationcommented_id" - t.integer "author_id" - t.text "notificationcomments" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "onclick_times", :force => true do |t| - t.integer "user_id" - t.datetime "onclick_time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "open_id_authentication_associations", :force => true do |t| - t.integer "issued" - t.integer "lifetime" - t.string "handle" - t.string "assoc_type" - t.binary "server_url" - t.binary "secret" - end - - create_table "open_id_authentication_nonces", :force => true do |t| - t.integer "timestamp", :null => false - t.string "server_url" - t.string "salt", :null => false - end - - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.text "description" - t.integer "commit_count", :default => 0 - t.integer "code_line", :default => 0 - t.integer "users_count", :default => 0 - t.date "last_commit_time" - t.string "url" - t.date "date_collected" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "option_numbers", :force => true do |t| - t.integer "user_id" - t.integer "memo" - t.integer "messages_for_issues" - t.integer "issues_status" - t.integer "replay_for_message" - t.integer "replay_for_memo" - t.integer "follow" - t.integer "tread" - t.integer "praise_by_one" - t.integer "praise_by_two" - t.integer "praise_by_three" - t.integer "tread_by_one" - t.integer "tread_by_two" - t.integer "tread_by_three" - t.integer "changeset" - t.integer "document" - t.integer "attachment" - t.integer "issue_done_ratio" - t.integer "post_issue" - t.integer "score_type" - t.integer "total_score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - end - - create_table "org_activities", :force => true do |t| - t.integer "user_id" - t.integer "org_act_id" - t.string "org_act_type" - t.integer "container_id" - t.string "container_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_courses", :force => true do |t| - t.integer "organization_id" - t.integer "course_id" - t.datetime "created_at" - end - - create_table "org_document_comments", :force => true do |t| - t.text "title" - t.text "content" - t.integer "organization_id" - t.integer "creator_id" - t.integer "parent_id" - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "org_subfield_id" - end - - create_table "org_member_roles", :force => true do |t| - t.integer "org_member_id" - t.integer "role_id" - end - - create_table "org_members", :force => true do |t| - t.integer "user_id" - t.integer "organization_id" - t.string "role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_messages", :force => true do |t| - t.integer "user_id" - t.integer "sender_id" - t.integer "organization_id" - t.string "message_type" - t.integer "message_id" - t.integer "viewed" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_projects", :force => true do |t| - t.integer "organization_id" - t.integer "project_id" - t.datetime "created_at" - end - - create_table "org_subfield_messages", :force => true do |t| - t.integer "org_subfield_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_subfields", :force => true do |t| - t.integer "organization_id" - t.integer "priority" - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "field_type" - t.integer "hide", :default => 0 - end - - create_table "organizations", :force => true do |t| - t.string "name" - t.text "description" - t.integer "creator_id" - t.integer "home_id" - t.string "domain" - t.boolean "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "phone_app_versions", :force => true do |t| - t.string "version" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_answers", :force => true do |t| - t.integer "poll_question_id" - t.text "answer_text" - t.integer "answer_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_questions", :force => true do |t| - t.string "question_title" - t.integer "question_type" - t.integer "is_necessary" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_number" - end - - create_table "poll_users", :force => true do |t| - t.integer "user_id" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_votes", :force => true do |t| - t.integer "user_id" - t.integer "poll_question_id" - t.integer "poll_answer_id" - t.text "vote_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "polls", :force => true do |t| - t.string "polls_name" - t.string "polls_type" - t.integer "polls_group_id" - t.integer "polls_status" - t.integer "user_id" - t.datetime "published_at" - t.datetime "closed_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "polls_description" - t.integer "show_result", :default => 1 - end - - create_table "praise_tread_caches", :force => true do |t| - t.integer "object_id", :null => false - t.string "object_type" - t.integer "praise_num" - t.integer "tread_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "praise_treads", :force => true do |t| - t.integer "user_id", :null => false - t.integer "praise_tread_object_id" - t.string "praise_tread_object_type" - t.integer "praise_or_tread" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "principal_activities", :force => true do |t| - t.integer "user_id" - t.integer "principal_id" - t.integer "principal_act_id" - t.string "principal_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_infos", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_scores", :force => true do |t| - t.string "project_id" - t.integer "score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "issue_num", :default => 0 - t.integer "issue_journal_num", :default => 0 - t.integer "news_num", :default => 0 - t.integer "documents_num", :default => 0 - t.integer "changeset_num", :default => 0 - t.integer "board_message_num", :default => 0 - end - - create_table "project_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "project_id" - t.integer "project_type" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - end - - add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - - create_table "projecting_softapplictions", :force => true do |t| - t.integer "user_id" - t.integer "softapplication_id" - t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false - t.integer "parent_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "identifier" - t.integer "status", :default => 1, :null => false - t.integer "lft" - t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false - t.integer "project_type" - t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 - t.integer "user_id" - t.integer "dts_test", :default => 0 - t.string "enterprise_name" - t.integer "organization_id" - t.integer "project_new_type" - t.integer "gpid" - t.integer "forked_from_project_id" - t.integer "forked_count" - t.integer "commits_count", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "issues_count", :default => 0 - t.integer "attachments_count", :default => 0 - t.integer "boards_count", :default => 0 - t.integer "news_count", :default => 0 - t.integer "acts_count", :default => 0 - t.integer "journals_count", :default => 0 - t.integer "boards_reply_count", :default => 0 - end - - add_index "projects", ["lft"], :name => "index_projects_on_lft" - add_index "projects", ["rgt"], :name => "index_projects_on_rgt" - - create_table "projects_trackers", :id => false, :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true - add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" - - create_table "queries", :force => true do |t| - t.integer "project_id" - t.string "name", :default => "", :null => false - t.text "filters" - t.integer "user_id", :default => 0, :null => false - t.boolean "is_public", :default => false, :null => false - t.text "column_names" - t.text "sort_criteria" - t.string "group_by" - t.string "type" - end - - add_index "queries", ["project_id"], :name => "index_queries_on_project_id" - add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - - create_table "relative_memo_to_open_source_projects", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "relative_memos", :force => true do |t| - t.integer "osp_id" - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 16777215, :null => false - t.integer "author_id" - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 - t.string "url" - t.string "username" - t.string "userhomeurl" - t.date "date_collected" - t.string "topic_resource" - end - - create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" - t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 - t.text "extra_info" - t.string "identifier" - t.boolean "is_default", :default => false - t.boolean "hidden", :default => false - end - - add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - - create_table "roles", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "assignable", :default => true - t.integer "builtin", :default => 0, :null => false - t.text "permissions" - t.string "issues_visibility", :limit => 30, :default => "default", :null => false - end - - create_table "schools", :force => true do |t| - t.string "name" - t.string "province" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "logo_link" - t.string "pinyin" - end - - create_table "seems_rateable_cached_ratings", :force => true do |t| - t.integer "cacheable_id", :limit => 8 - t.string "cacheable_type" - t.float "avg", :null => false - t.integer "cnt", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_rates", :force => true do |t| - t.integer "rater_id", :limit => 8 - t.integer "rateable_id" - t.string "rateable_type" - t.float "stars", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "is_teacher_score", :default => 0 - end - - create_table "settings", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "value" - t.datetime "updated_on" - end - - add_index "settings", ["name"], :name => "index_settings_on_name" - - create_table "shares", :force => true do |t| - t.date "created_on" - t.string "url" - t.string "title" - t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - t.integer "user_id" - t.string "description" - end - - create_table "shield_activities", :force => true do |t| - t.string "container_type" - t.integer "container_id" - t.string "shield_type" - t.integer "shield_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "softapplications", :force => true do |t| - t.string "name" - t.text "description" - t.integer "app_type_id" - t.string "app_type_name" - t.string "android_min_version_available" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "contest_id" - t.integer "softapplication_id" - t.integer "is_public" - t.string "application_developers" - t.string "deposit_project_url" - t.string "deposit_project" - t.integer "project_id" - end - - create_table "student_work_projects", :force => true do |t| - t.integer "homework_common_id" - t.integer "student_work_id" - t.integer "project_id" - t.integer "user_id" - t.integer "is_leader" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "student_work_projects", ["homework_common_id"], :name => "index_student_work_projects_on_homework_common_id" - add_index "student_work_projects", ["project_id"], :name => "index_student_work_projects_on_project_id" - add_index "student_work_projects", ["student_work_id"], :name => "index_student_work_projects_on_student_work_id" - add_index "student_work_projects", ["user_id"], :name => "index_student_work_projects_on_user_id" - - create_table "student_work_tests", :force => true do |t| - t.integer "student_work_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "status", :default => 9 - t.text "results" - t.text "src" - end - - create_table "student_works", :force => true do |t| - t.string "name" - t.text "description", :limit => 2147483647 - t.integer "homework_common_id" - t.integer "user_id" - t.float "final_score" - t.float "teacher_score" - t.float "student_score" - t.float "teaching_asistant_score" - t.integer "project_id", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "late_penalty", :default => 0 - t.integer "absence_penalty", :default => 0 - t.float "system_score", :default => 0.0 - t.boolean "is_test", :default => false - end - - add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" - - create_table "student_works_evaluation_distributions", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "student_works_scores", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.integer "score" - t.text "comment" - t.integer "reviewer_role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "students_for_courses", :force => true do |t| - t.integer "student_id" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" - add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" - - create_table "system_messages", :force => true do |t| - t.integer "user_id" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "description" - t.string "subject" - end - - create_table "taggings", :force => true do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", :limit => 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" - - create_table "tags", :force => true do |t| - t.string "name" - end - - create_table "teachers", :force => true do |t| - t.string "tea_name" - t.string "location" - t.integer "couurse_time" - t.integer "course_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "extra" - end - - create_table "time_entries", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "issue_id" - t.float "hours", :null => false - t.string "comments" - t.integer "activity_id", :null => false - t.date "spent_on", :null => false - t.integer "tyear", :null => false - t.integer "tmonth", :null => false - t.integer "tweek", :null => false - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" - add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" - add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" - add_index "time_entries", ["project_id"], :name => "time_entries_project_id" - add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - - create_table "tokens", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40, :default => "", :null => false - t.datetime "created_on", :null => false - end - - add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" - add_index "tokens", ["value"], :name => "tokens_value", :unique => true - - create_table "trackers", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_in_chlog", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "is_in_roadmap", :default => true, :null => false - t.integer "fields_bits", :default => 0 - end - - create_table "user_activities", :force => true do |t| - t.string "act_type" - t.integer "act_id" - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "user_id" - end - - create_table "user_extensions", :force => true do |t| - t.integer "user_id", :null => false - t.date "birthday" - t.string "brief_introduction" - t.integer "gender" - t.string "location" - t.string "occupation" - t.integer "work_experience" - t.integer "zip_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "technical_title" - t.integer "identity" - t.string "student_id" - t.string "teacher_realname" - t.string "student_realname" - t.string "location_city" - t.integer "school_id" - t.string "description", :default => "" - end - - create_table "user_feedback_messages", :force => true do |t| - t.integer "user_id" - t.integer "journals_for_message_id" - t.string "journals_for_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_grades", :force => true do |t| - t.integer "user_id", :null => false - t.integer "project_id", :null => false - t.float "grade", :default => 0.0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" - add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" - add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" - - create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - end - - create_table "user_preferences", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.text "others" - t.boolean "hide_mail", :default => false - t.string "time_zone" - end - - add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" - - create_table "user_score_details", :force => true do |t| - t.integer "current_user_id" - t.integer "target_user_id" - t.string "score_type" - t.string "score_action" - t.integer "user_id" - t.integer "old_score" - t.integer "new_score" - t.integer "current_user_level" - t.integer "target_user_level" - t.integer "score_changeable_obj_id" - t.string "score_changeable_obj_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "grade", :default => 0.0 - end - - add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" - add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" - add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" - - create_table "users", :force => true do |t| - t.string "login", :default => "", :null => false - t.string "hashed_password", :limit => 40, :default => "", :null => false - t.string "firstname", :limit => 30, :default => "", :null => false - t.string "lastname", :default => "", :null => false - t.string "mail", :limit => 60, :default => "", :null => false - t.boolean "admin", :default => false, :null => false - t.integer "status", :default => 1, :null => false - t.datetime "last_login_on" - t.string "language", :limit => 5, :default => "" - t.integer "auth_source_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "type" - t.string "identity_url" - t.string "mail_notification", :default => "", :null => false - t.string "salt", :limit => 64 - t.integer "gid" - end - - add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" - add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" - add_index "users", ["type"], :name => "index_users_on_type" - - create_table "versions", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :default => "", :null => false - t.string "description", :default => "" - t.date "effective_date" - t.datetime "created_on" - t.datetime "updated_on" - t.string "wiki_page_title" - t.string "status", :default => "open" - t.string "sharing", :default => "none", :null => false - end - - add_index "versions", ["project_id"], :name => "versions_project_id" - add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - - create_table "visitors", :force => true do |t| - t.integer "user_id" - t.integer "master_id" - t.datetime "updated_on" - t.datetime "created_on" - end - - add_index "visitors", ["master_id"], :name => "index_visitors_master_id" - add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" - add_index "visitors", ["user_id"], :name => "index_visitors_user_id" - - create_table "watchers", :force => true do |t| - t.string "watchable_type", :default => "", :null => false - t.integer "watchable_id", :default => 0, :null => false - t.integer "user_id" - end - - add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" - add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" - add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" - - create_table "web_footer_companies", :force => true do |t| - t.string "name" - t.string "logo_size" - t.string "url" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "web_footer_oranizers", :force => true do |t| - t.string "name" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "wiki_content_versions", :force => true do |t| - t.integer "wiki_content_id", :null => false - t.integer "page_id", :null => false - t.integer "author_id" - t.binary "data", :limit => 2147483647 - t.string "compression", :limit => 6, :default => "" - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" - add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" - - create_table "wiki_contents", :force => true do |t| - t.integer "page_id", :null => false - t.integer "author_id" - t.text "text", :limit => 2147483647 - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" - add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" - - create_table "wiki_pages", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title", :null => false - t.datetime "created_on", :null => false - t.boolean "protected", :default => false, :null => false - t.integer "parent_id" - end - - add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" - add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" - add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" - - create_table "wiki_redirects", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title" - t.string "redirects_to" - t.datetime "created_on", :null => false - end - - add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" - add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" - - create_table "wikis", :force => true do |t| - t.integer "project_id", :null => false - t.string "start_page", :null => false - t.integer "status", :default => 1, :null => false - end - - add_index "wikis", ["project_id"], :name => "wikis_project_id" - - create_table "workflows", :force => true do |t| - t.integer "tracker_id", :default => 0, :null => false - t.integer "old_status_id", :default => 0, :null => false - t.integer "new_status_id", :default => 0, :null => false - t.integer "role_id", :default => 0, :null => false - t.boolean "assignee", :default => false, :null => false - t.boolean "author", :default => false, :null => false - t.string "type", :limit => 30 - t.string "field_name", :limit => 30 - t.string "rule", :limit => 30 - end - - add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" - add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" - add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" - add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - - create_table "works_categories", :force => true do |t| - t.string "category" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "zip_packs", :force => true do |t| - t.integer "user_id" - t.integer "homework_id" - t.string "file_digest" - t.string "file_path" - t.integer "pack_times", :default => 1 - t.integer "pack_size", :default => 0 - t.text "file_digests" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -end -======= # encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to @@ -2026,1654 +11,1660 @@ end # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160112085834) do - - create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - t.integer "activity_container_id" - t.string "activity_container_type", :default => "" - t.datetime "created_at" - end - - add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" - add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" - add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - - create_table "activity_notifies", :force => true do |t| - t.integer "activity_container_id" - t.string "activity_container_type" - t.integer "activity_id" - t.string "activity_type" - t.integer "notify_to" - t.datetime "created_on" - t.integer "is_read" - end - - add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" - add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" - add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" - - create_table "api_keys", :force => true do |t| - t.string "access_token" - t.datetime "expires_at" - t.integer "user_id" - t.boolean "active", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" - add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" - - create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - end - - create_table "apply_project_masters", :force => true do |t| - t.integer "user_id" - t.string "apply_type" - t.integer "apply_id" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "at_messages", :force => true do |t| - t.integer "user_id" - t.integer "at_message_id" - t.string "at_message_type" - t.boolean "viewed", :default => false - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sender_id" - end - - add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" - - create_table "attachment_histories", :force => true do |t| - t.integer "container_id" - t.string "container_type" - t.string "filename", :default => "" - t.string "disk_filename", :default => "" - t.integer "filesize", :default => 0 - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "" - t.integer "downloads", :default => 0 - t.integer "author_id" - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.integer "copy_from" - t.integer "quotes" - t.integer "version" - t.integer "attachment_id" - end - - create_table "attachments", :force => true do |t| - t.integer "container_id" - t.string "container_type", :limit => 30 - t.string "filename", :default => "", :null => false - t.string "disk_filename", :default => "", :null => false - t.integer "filesize", :default => 0, :null => false - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "", :null => false - t.integer "downloads", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype", :default => 1 - t.integer "is_public", :default => 1 - t.integer "copy_from" - t.integer "quotes" - end - - add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" - add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" - add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" - - create_table "attachmentstypes", :force => true do |t| - t.integer "typeId", :null => false - t.string "typeName", :limit => 50 - end - - create_table "auth_sources", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 60, :default => "", :null => false - t.string "host", :limit => 60 - t.integer "port" - t.string "account" - t.string "account_password", :default => "" - t.string "base_dn" - t.string "attr_login", :limit => 30 - t.string "attr_firstname", :limit => 30 - t.string "attr_lastname", :limit => 30 - t.string "attr_mail", :limit => 30 - t.boolean "onthefly_register", :default => false, :null => false - t.boolean "tls", :default => false, :null => false - t.string "filter" - t.integer "timeout" - end - - add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" - - create_table "biding_projects", :force => true do |t| - t.integer "project_id" - t.integer "bid_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "bids", :force => true do |t| - t.string "name" - t.string "budget", :null => false - t.integer "author_id" - t.date "deadline" - t.text "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.integer "commit" - t.integer "reward_type" - t.integer "homework_type" - t.integer "parent_id" - t.string "password" - t.integer "is_evaluation" - t.integer "proportion", :default => 60 - t.integer "comment_status", :default => 0 - t.integer "evaluation_num", :default => 3 - t.integer "open_anonymous_evaluation", :default => 1 - end - - create_table "blog_comments", :force => true do |t| - t.integer "blog_id", :null => false - t.integer "parent_id" - t.string "title", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comment_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "blogs", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.integer "position", :default => 1 - t.integer "article_count", :default => 0, :null => false - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comments_id" - t.integer "parent_id" - t.integer "author_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "homepage_id" - end - - create_table "boards", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :default => "", :null => false - t.string "description" - t.integer "position", :default => 1 - t.integer "topics_count", :default => 0, :null => false - t.integer "messages_count", :default => 0, :null => false - t.integer "last_message_id" - t.integer "parent_id" - t.integer "course_id" - t.integer "org_subfield_id" - end - - add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" - add_index "boards", ["project_id"], :name => "boards_project_id" - - create_table "bug_to_osps", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "changes", :force => true do |t| - t.integer "changeset_id", :null => false - t.string "action", :limit => 1, :default => "", :null => false - t.text "path", :null => false - t.text "from_path" - t.string "from_revision" - t.string "revision" - t.string "branch" - end - - add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" - - create_table "changeset_parents", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "parent_id", :null => false - end - - add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" - add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" - - create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false - t.string "committer" - t.datetime "committed_on", :null => false - t.text "comments" - t.date "commit_date" - t.string "scmid" - t.integer "user_id" - end - - add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" - add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true - add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" - add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" - add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" - - create_table "changesets_issues", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "issue_id", :null => false - end - - add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - - create_table "comments", :force => true do |t| - t.string "commented_type", :limit => 30, :default => "", :null => false - t.integer "commented_id", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.text "comments" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "comments", ["author_id"], :name => "index_comments_on_author_id" - add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" - - create_table "contest_notifications", :force => true do |t| - t.text "title" - t.text "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" - t.integer "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contestnotifications", :force => true do |t| - t.integer "contest_id" - t.string "title" - t.string "summary" - t.text "description" - t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contests", :force => true do |t| - t.string "name" - t.string "budget", :default => "" - t.integer "author_id" - t.date "deadline" - t.string "description" - t.integer "commit" - t.string "password" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - create_table "course_activities", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_act_id" - t.string "course_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_attachments", :force => true do |t| - t.string "filename" - t.string "disk_filename" - t.integer "filesize" - t.string "content_type" - t.string "digest" - t.integer "downloads" - t.string "author_id" - t.string "integer" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "container_id", :default => 0 - end - - create_table "course_contributor_scores", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.integer "message_num" - t.integer "message_reply_num" - t.integer "news_reply_num" - t.integer "resource_num" - t.integer "journal_num" - t.integer "journal_reply_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "total_score" - end - - create_table "course_groups", :force => true do |t| - t.string "name" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_infos", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_messages", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_message_id" - t.string "course_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "content" - t.integer "status" - end - - create_table "course_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "course_id" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "courses", :force => true do |t| - t.integer "tea_id" - t.string "name" - t.integer "state" - t.string "code" - t.integer "time" - t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "location" - t.string "term" - t.string "string" - t.string "password" - t.string "setup_time" - t.string "endup_time" - t.string "class_period" - t.integer "school_id" - t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 - t.integer "lft" - t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "is_delete", :default => 0 - t.integer "end_time" - t.string "end_term" - end - - create_table "custom_fields", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.string "field_format", :limit => 30, :default => "", :null => false - t.text "possible_values" - t.string "regexp", :default => "" - t.integer "min_length", :default => 0, :null => false - t.integer "max_length", :default => 0, :null => false - t.boolean "is_required", :default => false, :null => false - t.boolean "is_for_all", :default => false, :null => false - t.boolean "is_filter", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "searchable", :default => false - t.text "default_value" - t.boolean "editable", :default => true - t.boolean "visible", :default => true, :null => false - t.boolean "multiple", :default => false - end - - add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" - - create_table "custom_fields_projects", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "project_id", :default => 0, :null => false - end - - add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true - - create_table "custom_fields_trackers", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true - - create_table "custom_values", :force => true do |t| - t.string "customized_type", :limit => 30, :default => "", :null => false - t.integer "customized_id", :default => 0, :null => false - t.integer "custom_field_id", :default => 0, :null => false - t.text "value" - end - - add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" - add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" - - create_table "delayed_jobs", :force => true do |t| - t.integer "priority", :default => 0, :null => false - t.integer "attempts", :default => 0, :null => false - t.text "handler", :null => false - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "documents", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "category_id", :default => 0, :null => false - t.string "title", :limit => 60, :default => "", :null => false - t.text "description" - t.datetime "created_on" - t.integer "user_id", :default => 0 - t.integer "is_public", :default => 1 - end - - add_index "documents", ["category_id"], :name => "index_documents_on_category_id" - add_index "documents", ["created_on"], :name => "index_documents_on_created_on" - add_index "documents", ["project_id"], :name => "documents_project_id" - - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 - t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false - end - - create_table "editor_of_documents", :force => true do |t| - t.integer "editor_id" - t.integer "org_document_comment_id" - t.datetime "created_at" - end - - create_table "enabled_modules", :force => true do |t| - t.integer "project_id" - t.string "name", :null => false - t.integer "course_id" - end - - add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" - - create_table "enumerations", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "is_default", :default => false, :null => false - t.string "type" - t.boolean "active", :default => true, :null => false - t.integer "project_id" - t.integer "parent_id" - t.string "position_name", :limit => 30 - end - - add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" - add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" - - create_table "exercise_answers", :force => true do |t| - t.integer "user_id" - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_choices", :force => true do |t| - t.integer "exercise_question_id" - t.text "choice_text" - t.integer "choice_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_questions", :force => true do |t| - t.text "question_title" - t.integer "question_type" - t.integer "question_number" - t.integer "exercise_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_score" - end - - create_table "exercise_standard_answers", :force => true do |t| - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_users", :force => true do |t| - t.integer "user_id" - t.integer "exercise_id" - t.integer "score" - t.datetime "start_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "end_at" - t.integer "status" - end - - create_table "exercises", :force => true do |t| - t.text "exercise_name" - t.text "exercise_description" - t.integer "course_id" - t.integer "exercise_status" - t.integer "user_id" - t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "publish_time" - t.datetime "end_time" - t.integer "show_result" - end - - create_table "first_pages", :force => true do |t| - t.string "web_title" - t.string "title" - t.text "description" - t.string "page_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sort_type" - t.integer "image_width", :default => 107 - t.integer "image_height", :default => 63 - t.integer "show_course", :default => 1 - t.integer "show_contest", :default => 1 - end - - create_table "forge_activities", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_act_id" - t.string "forge_act_type" - t.integer "org_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" - - create_table "forge_messages", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_message_id" - t.string "forge_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "secret_key" - t.integer "status" - end - - create_table "forums", :force => true do |t| - t.string "name", :null => false - t.text "description" - t.integer "topic_count", :default => 0 - t.integer "memo_count", :default => 0 - t.integer "last_memo_id", :default => 0 - t.integer "creator_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sticky" - t.integer "locked" - end - - create_table "groups_users", :id => false, :force => true do |t| - t.integer "group_id", :null => false - t.integer "user_id", :null => false - end - - add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true - - create_table "homework_attaches", :force => true do |t| - t.integer "bid_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - t.string "name" - t.text "description" - t.integer "state" - t.integer "project_id", :default => 0 - t.float "score", :default => 0.0 - t.integer "is_teacher_score", :default => 0 - end - - add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" - - create_table "homework_commons", :force => true do |t| - t.string "name" - t.integer "user_id" - t.text "description" - t.date "publish_time" - t.date "end_time" - t.integer "homework_type", :default => 1 - t.string "late_penalty" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "teacher_priority", :default => 1 - t.integer "anonymous_comment", :default => 0 - end - - add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" - - create_table "homework_detail_groups", :force => true do |t| - t.integer "homework_common_id" - t.integer "min_num" - t.integer "max_num" - t.integer "base_on_project" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" - - create_table "homework_detail_manuals", :force => true do |t| - t.float "ta_proportion" - t.integer "comment_status" - t.date "evaluation_start" - t.date "evaluation_end" - t.integer "evaluation_num" - t.integer "absence_penalty", :default => 1 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_detail_programings", :force => true do |t| - t.string "language" - t.text "standard_code", :limit => 2147483647 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "ta_proportion", :default => 0.1 - t.integer "question_id" - end - - create_table "homework_evaluations", :force => true do |t| - t.string "user_id" - t.string "homework_attach_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_for_courses", :force => true do |t| - t.integer "course_id" - t.integer "bid_id" - end - - add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" - add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" - - create_table "homework_tests", :force => true do |t| - t.text "input" - t.text "output" - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "result" - t.text "error_msg" - end - - create_table "homework_users", :force => true do |t| - t.string "homework_attach_id" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "invite_lists", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "mail" - end - - create_table "issue_categories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.integer "assigned_to_id" - end - - add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" - add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" - - create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :default => "", :null => false - t.integer "delay" - end - - add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true - add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" - add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" - - create_table "issue_statuses", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_closed", :default => false, :null => false - t.boolean "is_default", :default => false, :null => false - t.integer "position", :default => 1 - t.integer "default_done_ratio" - end - - add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" - add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" - add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" - - create_table "issues", :force => true do |t| - t.integer "tracker_id", :null => false - t.integer "project_id", :null => false - t.string "subject", :default => "", :null => false - t.text "description" - t.date "due_date" - t.integer "category_id" - t.integer "status_id", :null => false - t.integer "assigned_to_id" - t.integer "priority_id", :null => false - t.integer "fixed_version_id" - t.integer "author_id", :null => false - t.integer "lock_version", :default => 0, :null => false - t.datetime "created_on" - t.datetime "updated_on" - t.date "start_date" - t.integer "done_ratio", :default => 0, :null => false - t.float "estimated_hours" - t.integer "parent_id" - t.integer "root_id" - t.integer "lft" - t.integer "rgt" - t.boolean "is_private", :default => false, :null => false - t.datetime "closed_on" - t.integer "project_issues_index" - end - - add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" - add_index "issues", ["category_id"], :name => "index_issues_on_category_id" - add_index "issues", ["created_on"], :name => "index_issues_on_created_on" - add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" - add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" - add_index "issues", ["project_id"], :name => "issues_project_id" - add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" - add_index "issues", ["status_id"], :name => "index_issues_on_status_id" - add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" - - create_table "join_in_competitions", :force => true do |t| - t.integer "user_id" - t.integer "competition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "join_in_contests", :force => true do |t| - t.integer "user_id" - t.integer "bid_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "journal_details", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - - create_table "journal_replies", :id => false, :force => true do |t| - t.integer "journal_id" - t.integer "user_id" - t.integer "reply_id" - end - - add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" - add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" - add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" - - create_table "journals", :force => true do |t| - t.integer "journalized_id", :default => 0, :null => false - t.string "journalized_type", :limit => 30, :default => "", :null => false - t.integer "user_id", :default => 0, :null => false - t.text "notes" - t.datetime "created_on", :null => false - t.boolean "private_notes", :default => false, :null => false - end - - add_index "journals", ["created_on"], :name => "index_journals_on_created_on" - add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" - add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" - add_index "journals", ["user_id"], :name => "index_journals_on_user_id" - - create_table "journals_for_messages", :force => true do |t| - t.integer "jour_id" - t.string "jour_type" - t.integer "user_id" - t.text "notes" - t.integer "status" - t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.string "m_parent_id" - t.boolean "is_readed" - t.integer "m_reply_count" - t.integer "m_reply_id" - t.integer "is_comprehensive_evaluation" - t.integer "private", :default => 0 - end - - create_table "kindeditor_assets", :force => true do |t| - t.string "asset" - t.integer "file_size" - t.string "file_type" - t.integer "owner_id" - t.string "asset_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "owner_type", :default => 0 - end - - create_table "member_roles", :force => true do |t| - t.integer "member_id", :null => false - t.integer "role_id", :null => false - t.integer "inherited_from" - end - - add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" - add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" - - create_table "members", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "project_id", :default => 0 - t.datetime "created_on" - t.boolean "mail_notification", :default => false, :null => false - t.integer "course_id", :default => -1 - t.integer "course_group_id", :default => 0 - end - - add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true - add_index "members", ["user_id"], :name => "index_members_on_user_id" - - create_table "memo_messages", :force => true do |t| - t.integer "user_id" - t.integer "forum_id" - t.integer "memo_id" - t.string "memo_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "memos", :force => true do |t| - t.integer "forum_id", :null => false - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false - t.integer "author_id", :null => false - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count", :default => 0 - end - - create_table "message_alls", :force => true do |t| - t.integer "user_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "messages", :force => true do |t| - t.integer "board_id", :null => false - t.integer "parent_id" - t.string "subject", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "replies_count", :default => 0, :null => false - t.integer "last_reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.integer "quotes" - end - - add_index "messages", ["author_id"], :name => "index_messages_on_author_id" - add_index "messages", ["board_id"], :name => "messages_board_id" - add_index "messages", ["created_on"], :name => "index_messages_on_created_on" - add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" - add_index "messages", ["parent_id"], :name => "messages_parent_id" - - create_table "news", :force => true do |t| - t.integer "project_id" - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" - t.text "description" - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false - t.integer "course_id" - t.integer "sticky", :default => 0 - end - - add_index "news", ["author_id"], :name => "index_news_on_author_id" - add_index "news", ["created_on"], :name => "index_news_on_created_on" - add_index "news", ["project_id"], :name => "news_project_id" - - create_table "no_uses", :force => true do |t| - t.integer "user_id", :null => false - t.string "no_use_type" - t.integer "no_use_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "notificationcomments", :force => true do |t| - t.string "notificationcommented_type" - t.integer "notificationcommented_id" - t.integer "author_id" - t.text "notificationcomments" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "onclick_times", :force => true do |t| - t.integer "user_id" - t.datetime "onclick_time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "open_id_authentication_associations", :force => true do |t| - t.integer "issued" - t.integer "lifetime" - t.string "handle" - t.string "assoc_type" - t.binary "server_url" - t.binary "secret" - end - - create_table "open_id_authentication_nonces", :force => true do |t| - t.integer "timestamp", :null => false - t.string "server_url" - t.string "salt", :null => false - end - - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.text "description" - t.integer "commit_count", :default => 0 - t.integer "code_line", :default => 0 - t.integer "users_count", :default => 0 - t.date "last_commit_time" - t.string "url" - t.date "date_collected" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "option_numbers", :force => true do |t| - t.integer "user_id" - t.integer "memo" - t.integer "messages_for_issues" - t.integer "issues_status" - t.integer "replay_for_message" - t.integer "replay_for_memo" - t.integer "follow" - t.integer "tread" - t.integer "praise_by_one" - t.integer "praise_by_two" - t.integer "praise_by_three" - t.integer "tread_by_one" - t.integer "tread_by_two" - t.integer "tread_by_three" - t.integer "changeset" - t.integer "document" - t.integer "attachment" - t.integer "issue_done_ratio" - t.integer "post_issue" - t.integer "score_type" - t.integer "total_score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - end - - create_table "org_activities", :force => true do |t| - t.integer "user_id" - t.integer "org_act_id" - t.string "org_act_type" - t.integer "container_id" - t.string "container_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_courses", :force => true do |t| - t.integer "organization_id" - t.integer "course_id" - t.datetime "created_at" - end - - create_table "org_document_comments", :force => true do |t| - t.text "title" - t.text "content" - t.integer "organization_id" - t.integer "creator_id" - t.integer "parent_id" - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "org_subfield_id" - end - - create_table "org_member_roles", :force => true do |t| - t.integer "org_member_id" - t.integer "role_id" - end - - create_table "org_members", :force => true do |t| - t.integer "user_id" - t.integer "organization_id" - t.string "role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_messages", :force => true do |t| - t.integer "user_id" - t.integer "sender_id" - t.integer "organization_id" - t.string "message_type" - t.integer "message_id" - t.integer "viewed" - t.string "content" +ActiveRecord::Schema.define(:version => 20160114022928) do + + create_table "activities", :force => true do |t| + t.integer "act_id", :null => false + t.string "act_type", :null => false + t.integer "user_id", :null => false + t.integer "activity_container_id" + t.string "activity_container_type", :default => "" + t.datetime "created_at" + end + + add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" + add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" + add_index "activities", ["user_id"], :name => "index_activities_on_user_id" + + create_table "activity_notifies", :force => true do |t| + t.integer "activity_container_id" + t.string "activity_container_type" + t.integer "activity_id" + t.string "activity_type" + t.integer "notify_to" + t.datetime "created_on" + t.integer "is_read" + end + + add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" + add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" + add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" + + create_table "api_keys", :force => true do |t| + t.string "access_token" + t.datetime "expires_at" + t.integer "user_id" + t.boolean "active", :default => true + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" + add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" + + create_table "applied_projects", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + end + + create_table "apply_project_masters", :force => true do |t| + t.integer "user_id" + t.string "apply_type" + t.integer "apply_id" + t.integer "status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "at_messages", :force => true do |t| + t.integer "user_id" + t.integer "at_message_id" + t.string "at_message_type" + t.boolean "viewed", :default => false + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sender_id" + end + + add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" + + create_table "attachment_histories", :force => true do |t| + t.integer "container_id" + t.string "container_type" + t.string "filename", :default => "" + t.string "disk_filename", :default => "" + t.integer "filesize", :default => 0 + t.string "content_type", :default => "" + t.string "digest", :limit => 40, :default => "" + t.integer "downloads", :default => 0 + t.integer "author_id" + t.datetime "created_on" + t.string "description" + t.string "disk_directory" + t.integer "attachtype" + t.integer "is_public" + t.integer "copy_from" + t.integer "quotes" + t.integer "version" + t.integer "attachment_id" + end + + create_table "attachments", :force => true do |t| + t.integer "container_id" + t.string "container_type", :limit => 30 + t.string "filename", :default => "", :null => false + t.string "disk_filename", :default => "", :null => false + t.integer "filesize", :default => 0, :null => false + t.string "content_type", :default => "" + t.string "digest", :limit => 40, :default => "", :null => false + t.integer "downloads", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.string "description" + t.string "disk_directory" + t.integer "attachtype", :default => 1 + t.integer "is_public", :default => 1 + t.integer "copy_from" + t.integer "quotes" + end + + add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" + add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" + add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" + + create_table "attachmentstypes", :force => true do |t| + t.integer "typeId", :null => false + t.string "typeName", :limit => 50 + end + + create_table "auth_sources", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 60, :default => "", :null => false + t.string "host", :limit => 60 + t.integer "port" + t.string "account" + t.string "account_password", :default => "" + t.string "base_dn" + t.string "attr_login", :limit => 30 + t.string "attr_firstname", :limit => 30 + t.string "attr_lastname", :limit => 30 + t.string "attr_mail", :limit => 30 + t.boolean "onthefly_register", :default => false, :null => false + t.boolean "tls", :default => false, :null => false + t.string "filter" + t.integer "timeout" + end + + add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" + + create_table "biding_projects", :force => true do |t| + t.integer "project_id" + t.integer "bid_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "bids", :force => true do |t| + t.string "name" + t.string "budget", :null => false + t.integer "author_id" + t.date "deadline" + t.text "description" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.integer "commit" + t.integer "reward_type" + t.integer "homework_type" + t.integer "parent_id" + t.string "password" + t.integer "is_evaluation" + t.integer "proportion", :default => 60 + t.integer "comment_status", :default => 0 + t.integer "evaluation_num", :default => 3 + t.integer "open_anonymous_evaluation", :default => 1 + end + + create_table "blog_comments", :force => true do |t| + t.integer "blog_id", :null => false + t.integer "parent_id" + t.string "title", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comment_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "blogs", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.integer "position", :default => 1 + t.integer "article_count", :default => 0, :null => false + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comments_id" + t.integer "parent_id" + t.integer "author_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "homepage_id" + end + + create_table "boards", :force => true do |t| + t.integer "project_id", :null => false + t.string "name", :default => "", :null => false + t.string "description" + t.integer "position", :default => 1 + t.integer "topics_count", :default => 0, :null => false + t.integer "messages_count", :default => 0, :null => false + t.integer "last_message_id" + t.integer "parent_id" + t.integer "course_id" + t.integer "org_subfield_id" + end + + add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" + add_index "boards", ["project_id"], :name => "boards_project_id" + + create_table "bug_to_osps", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "changes", :force => true do |t| + t.integer "changeset_id", :null => false + t.string "action", :limit => 1, :default => "", :null => false + t.text "path", :null => false + t.text "from_path" + t.string "from_revision" + t.string "revision" + t.string "branch" + end + + add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" + + create_table "changeset_parents", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "parent_id", :null => false + end + + add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" + add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" + + create_table "changesets", :force => true do |t| + t.integer "repository_id", :null => false + t.string "revision", :null => false + t.string "committer" + t.datetime "committed_on", :null => false + t.text "comments" + t.date "commit_date" + t.string "scmid" + t.integer "user_id" + end + + add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" + add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true + add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" + add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" + add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" + + create_table "changesets_issues", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "issue_id", :null => false + end + + add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true + + create_table "code_review_assignments", :force => true do |t| + t.integer "issue_id" + t.integer "change_id" + t.integer "attachment_id" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.string "action_type" + t.integer "changeset_id" + end + + create_table "code_review_project_settings", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "updated_by" + t.boolean "hide_code_review_tab", :default => false + t.integer "auto_relation", :default => 1 + t.integer "assignment_tracker_id" + t.text "auto_assign" + t.integer "lock_version", :default => 0, :null => false + t.boolean "tracker_in_review_dialog", :default => false + end + + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "code_reviews", :force => true do |t| + t.integer "project_id" + t.integer "change_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line" + t.integer "updated_by_id" + t.integer "lock_version", :default => 0, :null => false + t.integer "status_changed_from" + t.integer "status_changed_to" + t.integer "issue_id" + t.string "action_type" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.integer "attachment_id" + t.integer "file_count", :default => 0, :null => false + t.boolean "diff_all" + end + + create_table "comments", :force => true do |t| + t.string "commented_type", :limit => 30, :default => "", :null => false + t.integer "commented_id", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.text "comments" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + add_index "comments", ["author_id"], :name => "index_comments_on_author_id" + add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + + create_table "contest_notifications", :force => true do |t| + t.text "title" + t.text "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contesting_projects", :force => true do |t| + t.integer "project_id" + t.string "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contesting_softapplications", :force => true do |t| + t.integer "softapplication_id" + t.integer "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.text "description" + t.integer "author_id" + t.integer "notificationcomments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contests", :force => true do |t| + t.string "name" + t.string "budget", :default => "" + t.integer "author_id" + t.date "deadline" + t.string "description" + t.integer "commit" + t.string "password" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + create_table "course_activities", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_act_id" + t.string "course_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_attachments", :force => true do |t| + t.string "filename" + t.string "disk_filename" + t.integer "filesize" + t.string "content_type" + t.string "digest" + t.integer "downloads" + t.string "author_id" + t.string "integer" + t.string "description" + t.string "disk_directory" + t.integer "attachtype" + t.integer "is_public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "container_id", :default => 0 + end + + create_table "course_contributor_scores", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.integer "message_num" + t.integer "message_reply_num" + t.integer "news_reply_num" + t.integer "resource_num" + t.integer "journal_num" + t.integer "journal_reply_num" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "total_score" + end + + create_table "course_groups", :force => true do |t| + t.string "name" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_infos", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_messages", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_message_id" + t.string "course_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "content" + t.integer "status" + end + + create_table "course_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "course_id" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "courses", :force => true do |t| + t.integer "tea_id" + t.string "name" + t.integer "state" + t.string "code" + t.integer "time" + t.string "extra" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "location" + t.string "term" + t.string "string" + t.string "password" + t.string "setup_time" + t.string "endup_time" + t.string "class_period" + t.integer "school_id" + t.text "description" + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 + t.integer "lft" + t.integer "rgt" + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 + t.integer "open_student", :default => 0 + t.integer "outline", :default => 0 + t.integer "publish_resource", :default => 0 + t.integer "is_delete", :default => 0 + t.integer "end_time" + t.string "end_term" + end + + create_table "custom_fields", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.string "field_format", :limit => 30, :default => "", :null => false + t.text "possible_values" + t.string "regexp", :default => "" + t.integer "min_length", :default => 0, :null => false + t.integer "max_length", :default => 0, :null => false + t.boolean "is_required", :default => false, :null => false + t.boolean "is_for_all", :default => false, :null => false + t.boolean "is_filter", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "searchable", :default => false + t.text "default_value" + t.boolean "editable", :default => true + t.boolean "visible", :default => true, :null => false + t.boolean "multiple", :default => false + end + + add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" + + create_table "custom_fields_projects", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "project_id", :default => 0, :null => false + end + + add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true + + create_table "custom_fields_trackers", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true + + create_table "custom_values", :force => true do |t| + t.string "customized_type", :limit => 30, :default => "", :null => false + t.integer "customized_id", :default => 0, :null => false + t.integer "custom_field_id", :default => 0, :null => false + t.text "value" + end + + add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" + add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" + + create_table "delayed_jobs", :force => true do |t| + t.integer "priority", :default => 0, :null => false + t.integer "attempts", :default => 0, :null => false + t.text "handler", :null => false + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "documents", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "category_id", :default => 0, :null => false + t.string "title", :limit => 60, :default => "", :null => false + t.text "description" + t.datetime "created_on" + t.integer "user_id", :default => 0 + t.integer "is_public", :default => 1 + end + + add_index "documents", ["category_id"], :name => "index_documents_on_category_id" + add_index "documents", ["created_on"], :name => "index_documents_on_created_on" + add_index "documents", ["project_id"], :name => "documents_project_id" + + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 + t.string "File" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false + end + + create_table "editor_of_documents", :force => true do |t| + t.integer "editor_id" + t.integer "org_document_comment_id" + t.datetime "created_at" + end + + create_table "enabled_modules", :force => true do |t| + t.integer "project_id" + t.string "name", :null => false + t.integer "course_id" + end + + add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" + + create_table "enumerations", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "is_default", :default => false, :null => false + t.string "type" + t.boolean "active", :default => true, :null => false + t.integer "project_id" + t.integer "parent_id" + t.string "position_name", :limit => 30 + end + + add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" + add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" + + create_table "exercise_answers", :force => true do |t| + t.integer "user_id" + t.integer "exercise_question_id" + t.integer "exercise_choice_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_choices", :force => true do |t| + t.integer "exercise_question_id" + t.text "choice_text" + t.integer "choice_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_questions", :force => true do |t| + t.text "question_title" + t.integer "question_type" + t.integer "question_number" + t.integer "exercise_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_score" + end + + create_table "exercise_standard_answers", :force => true do |t| + t.integer "exercise_question_id" + t.integer "exercise_choice_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_users", :force => true do |t| + t.integer "user_id" + t.integer "exercise_id" + t.integer "score" + t.datetime "start_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.datetime "end_at" + t.integer "status" + end + + create_table "exercises", :force => true do |t| + t.text "exercise_name" + t.text "exercise_description" + t.integer "course_id" + t.integer "exercise_status" + t.integer "user_id" + t.integer "time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.datetime "publish_time" + t.datetime "end_time" + t.integer "show_result" + end + + create_table "first_pages", :force => true do |t| + t.string "web_title" + t.string "title" + t.text "description" + t.string "page_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sort_type" + t.integer "image_width", :default => 107 + t.integer "image_height", :default => 63 + t.integer "show_course", :default => 1 + t.integer "show_contest", :default => 1 + end + + create_table "forge_activities", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_act_id" + t.string "forge_act_type" + t.integer "org_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" + + create_table "forge_messages", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_message_id" + t.string "forge_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "secret_key" + t.integer "status" + end + + create_table "forums", :force => true do |t| + t.string "name", :null => false + t.text "description" + t.integer "topic_count", :default => 0 + t.integer "memo_count", :default => 0 + t.integer "last_memo_id", :default => 0 + t.integer "creator_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sticky" + t.integer "locked" + end + + create_table "groups_users", :id => false, :force => true do |t| + t.integer "group_id", :null => false + t.integer "user_id", :null => false + end + + add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true + + create_table "homework_attaches", :force => true do |t| + t.integer "bid_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + t.string "name" + t.text "description" + t.integer "state" + t.integer "project_id", :default => 0 + t.float "score", :default => 0.0 + t.integer "is_teacher_score", :default => 0 + end + + add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" + + create_table "homework_commons", :force => true do |t| + t.string "name" + t.integer "user_id" + t.text "description" + t.date "publish_time" + t.date "end_time" + t.integer "homework_type", :default => 1 + t.string "late_penalty" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "teacher_priority", :default => 1 + t.integer "anonymous_comment", :default => 0 + end + + add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" + + create_table "homework_detail_groups", :force => true do |t| + t.integer "homework_common_id" + t.integer "min_num" + t.integer "max_num" + t.integer "base_on_project" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" + + create_table "homework_detail_manuals", :force => true do |t| + t.float "ta_proportion" + t.integer "comment_status" + t.date "evaluation_start" + t.date "evaluation_end" + t.integer "evaluation_num" + t.integer "absence_penalty", :default => 1 + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_detail_programings", :force => true do |t| + t.string "language" + t.text "standard_code", :limit => 2147483647 + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "ta_proportion", :default => 0.1 + t.integer "question_id" + end + + create_table "homework_evaluations", :force => true do |t| + t.string "user_id" + t.string "homework_attach_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_for_courses", :force => true do |t| + t.integer "course_id" + t.integer "bid_id" + end + + add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" + add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" + + create_table "homework_tests", :force => true do |t| + t.text "input" + t.text "output" + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "result" + t.text "error_msg" + end + + create_table "homework_users", :force => true do |t| + t.string "homework_attach_id" + t.string "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "invite_lists", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "mail" + end + + create_table "issue_categories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.integer "assigned_to_id" + end + + add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" + add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" + + create_table "issue_relations", :force => true do |t| + t.integer "issue_from_id", :null => false + t.integer "issue_to_id", :null => false + t.string "relation_type", :default => "", :null => false + t.integer "delay" + end + + add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true + add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" + add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" + + create_table "issue_statuses", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_closed", :default => false, :null => false + t.boolean "is_default", :default => false, :null => false + t.integer "position", :default => 1 + t.integer "default_done_ratio" + end + + add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" + add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" + add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" + + create_table "issues", :force => true do |t| + t.integer "tracker_id", :null => false + t.integer "project_id", :null => false + t.string "subject", :default => "", :null => false + t.text "description" + t.date "due_date" + t.integer "category_id" + t.integer "status_id", :null => false + t.integer "assigned_to_id" + t.integer "priority_id", :null => false + t.integer "fixed_version_id" + t.integer "author_id", :null => false + t.integer "lock_version", :default => 0, :null => false + t.datetime "created_on" + t.datetime "updated_on" + t.date "start_date" + t.integer "done_ratio", :default => 0, :null => false + t.float "estimated_hours" + t.integer "parent_id" + t.integer "root_id" + t.integer "lft" + t.integer "rgt" + t.boolean "is_private", :default => false, :null => false + t.datetime "closed_on" + t.integer "project_issues_index" + end + + add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" + add_index "issues", ["author_id"], :name => "index_issues_on_author_id" + add_index "issues", ["category_id"], :name => "index_issues_on_category_id" + add_index "issues", ["created_on"], :name => "index_issues_on_created_on" + add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" + add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" + add_index "issues", ["project_id"], :name => "issues_project_id" + add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" + add_index "issues", ["status_id"], :name => "index_issues_on_status_id" + add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" + + create_table "join_in_competitions", :force => true do |t| + t.integer "user_id" + t.integer "competition_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "join_in_contests", :force => true do |t| + t.integer "user_id" + t.integer "bid_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "journal_details", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + + create_table "journal_replies", :id => false, :force => true do |t| + t.integer "journal_id" + t.integer "user_id" + t.integer "reply_id" + end + + add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" + add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" + add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" + + create_table "journals", :force => true do |t| + t.integer "journalized_id", :default => 0, :null => false + t.string "journalized_type", :limit => 30, :default => "", :null => false + t.integer "user_id", :default => 0, :null => false + t.text "notes" + t.datetime "created_on", :null => false + t.boolean "private_notes", :default => false, :null => false + end + + add_index "journals", ["created_on"], :name => "index_journals_on_created_on" + add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" + add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" + add_index "journals", ["user_id"], :name => "index_journals_on_user_id" + + create_table "journals_for_messages", :force => true do |t| + t.integer "jour_id" + t.string "jour_type" + t.integer "user_id" + t.text "notes" + t.integer "status" + t.integer "reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.string "m_parent_id" + t.boolean "is_readed" + t.integer "m_reply_count" + t.integer "m_reply_id" + t.integer "is_comprehensive_evaluation" + t.integer "private", :default => 0 + end + + create_table "kindeditor_assets", :force => true do |t| + t.string "asset" + t.integer "file_size" + t.string "file_type" + t.integer "owner_id" + t.string "asset_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "owner_type", :default => 0 + end + + create_table "member_roles", :force => true do |t| + t.integer "member_id", :null => false + t.integer "role_id", :null => false + t.integer "inherited_from" + end + + add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" + add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" + + create_table "members", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "project_id", :default => 0 + t.datetime "created_on" + t.boolean "mail_notification", :default => false, :null => false + t.integer "course_id", :default => -1 + t.integer "course_group_id", :default => 0 + end + + add_index "members", ["project_id"], :name => "index_members_on_project_id" + add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true + add_index "members", ["user_id"], :name => "index_members_on_user_id" + + create_table "memo_messages", :force => true do |t| + t.integer "user_id" + t.integer "forum_id" + t.integer "memo_id" + t.string "memo_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "memos", :force => true do |t| + t.integer "forum_id", :null => false + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :null => false + t.integer "author_id", :null => false + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count", :default => 0 + end + + create_table "message_alls", :force => true do |t| + t.integer "user_id" + t.integer "message_id" + t.string "message_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "messages", :force => true do |t| + t.integer "board_id", :null => false + t.integer "parent_id" + t.string "subject", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "replies_count", :default => 0, :null => false + t.integer "last_reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + t.integer "quotes" + end + + add_index "messages", ["author_id"], :name => "index_messages_on_author_id" + add_index "messages", ["board_id"], :name => "messages_board_id" + add_index "messages", ["created_on"], :name => "index_messages_on_created_on" + add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" + add_index "messages", ["parent_id"], :name => "messages_parent_id" + + create_table "news", :force => true do |t| + t.integer "project_id" + t.string "title", :limit => 60, :default => "", :null => false + t.string "summary", :default => "" + t.text "description" + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.integer "comments_count", :default => 0, :null => false + t.integer "course_id" + t.integer "sticky", :default => 0 + end + + add_index "news", ["author_id"], :name => "index_news_on_author_id" + add_index "news", ["created_on"], :name => "index_news_on_created_on" + add_index "news", ["project_id"], :name => "news_project_id" + + create_table "no_uses", :force => true do |t| + t.integer "user_id", :null => false + t.string "no_use_type" + t.integer "no_use_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "notificationcomments", :force => true do |t| + t.string "notificationcommented_type" + t.integer "notificationcommented_id" + t.integer "author_id" + t.text "notificationcomments" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "onclick_times", :force => true do |t| + t.integer "user_id" + t.datetime "onclick_time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "open_id_authentication_associations", :force => true do |t| + t.integer "issued" + t.integer "lifetime" + t.string "handle" + t.string "assoc_type" + t.binary "server_url" + t.binary "secret" + end + + create_table "open_id_authentication_nonces", :force => true do |t| + t.integer "timestamp", :null => false + t.string "server_url" + t.string "salt", :null => false + end + + create_table "open_source_projects", :force => true do |t| + t.string "name" + t.text "description" + t.integer "commit_count", :default => 0 + t.integer "code_line", :default => 0 + t.integer "users_count", :default => 0 + t.date "last_commit_time" + t.string "url" + t.date "date_collected" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "option_numbers", :force => true do |t| + t.integer "user_id" + t.integer "memo" + t.integer "messages_for_issues" + t.integer "issues_status" + t.integer "replay_for_message" + t.integer "replay_for_memo" + t.integer "follow" + t.integer "tread" + t.integer "praise_by_one" + t.integer "praise_by_two" + t.integer "praise_by_three" + t.integer "tread_by_one" + t.integer "tread_by_two" + t.integer "tread_by_three" + t.integer "changeset" + t.integer "document" + t.integer "attachment" + t.integer "issue_done_ratio" + t.integer "post_issue" + t.integer "score_type" + t.integer "total_score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + end + + create_table "org_activities", :force => true do |t| + t.integer "user_id" + t.integer "org_act_id" + t.string "org_act_type" + t.integer "container_id" + t.string "container_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_courses", :force => true do |t| + t.integer "organization_id" + t.integer "course_id" + t.datetime "created_at" + end + + create_table "org_document_comments", :force => true do |t| + t.text "title" + t.text "content" + t.integer "organization_id" + t.integer "creator_id" + t.integer "parent_id" + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "org_subfield_id" + end + + create_table "org_member_roles", :force => true do |t| + t.integer "org_member_id" + t.integer "role_id" + end + + create_table "org_members", :force => true do |t| + t.integer "user_id" + t.integer "organization_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_messages", :force => true do |t| + t.integer "user_id" + t.integer "sender_id" + t.integer "organization_id" + t.string "message_type" + t.integer "message_id" + t.integer "viewed" + t.string "content" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "status", :default => 0 - end - - create_table "org_projects", :force => true do |t| - t.integer "organization_id" - t.integer "project_id" - t.datetime "created_at" - end - - create_table "org_subfield_messages", :force => true do |t| - t.integer "org_subfield_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_subfields", :force => true do |t| - t.integer "organization_id" - t.integer "priority" - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "field_type" - t.integer "hide", :default => 0 - end - - create_table "organizations", :force => true do |t| - t.string "name" - t.text "description" - t.integer "creator_id" - t.integer "home_id" - t.string "domain" - t.boolean "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "phone_app_versions", :force => true do |t| - t.string "version" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_answers", :force => true do |t| - t.integer "poll_question_id" - t.text "answer_text" - t.integer "answer_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_questions", :force => true do |t| - t.string "question_title" - t.integer "question_type" - t.integer "is_necessary" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_number" - end - - create_table "poll_users", :force => true do |t| - t.integer "user_id" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_votes", :force => true do |t| - t.integer "user_id" - t.integer "poll_question_id" - t.integer "poll_answer_id" - t.text "vote_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "polls", :force => true do |t| - t.string "polls_name" - t.string "polls_type" - t.integer "polls_group_id" - t.integer "polls_status" - t.integer "user_id" - t.datetime "published_at" - t.datetime "closed_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "polls_description" - t.integer "show_result", :default => 1 - end - - create_table "praise_tread_caches", :force => true do |t| - t.integer "object_id", :null => false - t.string "object_type" - t.integer "praise_num" - t.integer "tread_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "praise_treads", :force => true do |t| - t.integer "user_id", :null => false - t.integer "praise_tread_object_id" - t.string "praise_tread_object_type" - t.integer "praise_or_tread" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "principal_activities", :force => true do |t| - t.integer "user_id" - t.integer "principal_id" - t.integer "principal_act_id" - t.string "principal_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_infos", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_scores", :force => true do |t| - t.string "project_id" - t.integer "score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "issue_num", :default => 0 - t.integer "issue_journal_num", :default => 0 - t.integer "news_num", :default => 0 - t.integer "documents_num", :default => 0 - t.integer "changeset_num", :default => 0 - t.integer "board_message_num", :default => 0 + end + + create_table "org_projects", :force => true do |t| + t.integer "organization_id" + t.integer "project_id" + t.datetime "created_at" + end + + create_table "org_subfield_messages", :force => true do |t| + t.integer "org_subfield_id" + t.integer "message_id" + t.string "message_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_subfields", :force => true do |t| + t.integer "organization_id" + t.integer "priority" + t.string "name" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "field_type" + t.integer "hide", :default => 0 + end + + create_table "organizations", :force => true do |t| + t.string "name" + t.text "description" + t.integer "creator_id" + t.integer "home_id" + t.string "domain" + t.boolean "is_public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "phone_app_versions", :force => true do |t| + t.string "version" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_answers", :force => true do |t| + t.integer "poll_question_id" + t.text "answer_text" + t.integer "answer_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_questions", :force => true do |t| + t.string "question_title" + t.integer "question_type" + t.integer "is_necessary" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_number" + end + + create_table "poll_users", :force => true do |t| + t.integer "user_id" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_votes", :force => true do |t| + t.integer "user_id" + t.integer "poll_question_id" + t.integer "poll_answer_id" + t.text "vote_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "polls", :force => true do |t| + t.string "polls_name" + t.string "polls_type" + t.integer "polls_group_id" + t.integer "polls_status" + t.integer "user_id" + t.datetime "published_at" + t.datetime "closed_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "polls_description" + t.integer "show_result", :default => 1 + end + + create_table "praise_tread_caches", :force => true do |t| + t.integer "object_id", :null => false + t.string "object_type" + t.integer "praise_num" + t.integer "tread_num" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "praise_treads", :force => true do |t| + t.integer "user_id", :null => false + t.integer "praise_tread_object_id" + t.string "praise_tread_object_type" + t.integer "praise_or_tread" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "principal_activities", :force => true do |t| + t.integer "user_id" + t.integer "principal_id" + t.integer "principal_act_id" + t.string "principal_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_infos", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_scores", :force => true do |t| + t.string "project_id" + t.integer "score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "issue_num", :default => 0 + t.integer "issue_journal_num", :default => 0 + t.integer "news_num", :default => 0 + t.integer "documents_num", :default => 0 + t.integer "changeset_num", :default => 0 + t.integer "board_message_num", :default => 0 t.integer "board_num", :default => 0 t.integer "attach_num", :default => 0 - end - - create_table "project_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "project_id" - t.integer "project_type" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - end - - add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - - create_table "projecting_softapplictions", :force => true do |t| - t.integer "user_id" - t.integer "softapplication_id" - t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false - t.integer "parent_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "identifier" - t.integer "status", :default => 1, :null => false - t.integer "lft" - t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false - t.integer "project_type" - t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 - t.integer "user_id" - t.integer "dts_test", :default => 0 - t.string "enterprise_name" - t.integer "organization_id" - t.integer "project_new_type" - t.integer "gpid" - t.integer "forked_from_project_id" - t.integer "forked_count" - t.integer "commits_count", :default => 0 - t.integer "publish_resource", :default => 0 - end - - add_index "projects", ["lft"], :name => "index_projects_on_lft" - add_index "projects", ["rgt"], :name => "index_projects_on_rgt" - - create_table "projects_trackers", :id => false, :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true - add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" - - create_table "queries", :force => true do |t| - t.integer "project_id" - t.string "name", :default => "", :null => false - t.text "filters" - t.integer "user_id", :default => 0, :null => false - t.boolean "is_public", :default => false, :null => false - t.text "column_names" - t.text "sort_criteria" - t.string "group_by" - t.string "type" - end - - add_index "queries", ["project_id"], :name => "index_queries_on_project_id" - add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - - create_table "relative_memo_to_open_source_projects", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "relative_memos", :force => true do |t| - t.integer "osp_id" - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 16777215, :null => false - t.integer "author_id" - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 - t.string "url" - t.string "username" - t.string "userhomeurl" - t.date "date_collected" - t.string "topic_resource" - end - - create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" - t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 - t.text "extra_info" - t.string "identifier" - t.boolean "is_default", :default => false - t.boolean "hidden", :default => false - end - - add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - - create_table "roles", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "assignable", :default => true - t.integer "builtin", :default => 0, :null => false - t.text "permissions" - t.string "issues_visibility", :limit => 30, :default => "default", :null => false - end - - create_table "schools", :force => true do |t| - t.string "name" - t.string "province" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "logo_link" - t.string "pinyin" - end - - create_table "seems_rateable_cached_ratings", :force => true do |t| - t.integer "cacheable_id", :limit => 8 - t.string "cacheable_type" - t.float "avg", :null => false - t.integer "cnt", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_rates", :force => true do |t| - t.integer "rater_id", :limit => 8 - t.integer "rateable_id" - t.string "rateable_type" - t.float "stars", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "is_teacher_score", :default => 0 - end - - create_table "settings", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "value" - t.datetime "updated_on" - end - - add_index "settings", ["name"], :name => "index_settings_on_name" - - create_table "shares", :force => true do |t| - t.date "created_on" - t.string "url" - t.string "title" - t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - t.integer "user_id" - t.string "description" - end - - create_table "shield_activities", :force => true do |t| - t.string "container_type" - t.integer "container_id" - t.string "shield_type" - t.integer "shield_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "softapplications", :force => true do |t| - t.string "name" - t.text "description" - t.integer "app_type_id" - t.string "app_type_name" - t.string "android_min_version_available" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "contest_id" - t.integer "softapplication_id" - t.integer "is_public" - t.string "application_developers" - t.string "deposit_project_url" - t.string "deposit_project" - t.integer "project_id" - end - - create_table "student_work_projects", :force => true do |t| - t.integer "homework_common_id" - t.integer "student_work_id" - t.integer "project_id" - t.integer "user_id" - t.integer "is_leader" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "student_work_projects", ["homework_common_id"], :name => "index_student_work_projects_on_homework_common_id" - add_index "student_work_projects", ["project_id"], :name => "index_student_work_projects_on_project_id" - add_index "student_work_projects", ["student_work_id"], :name => "index_student_work_projects_on_student_work_id" - add_index "student_work_projects", ["user_id"], :name => "index_student_work_projects_on_user_id" - - create_table "student_work_tests", :force => true do |t| - t.integer "student_work_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "status", :default => 9 - t.text "results" - t.text "src" - end - - create_table "student_works", :force => true do |t| - t.string "name" - t.text "description", :limit => 2147483647 - t.integer "homework_common_id" - t.integer "user_id" - t.float "final_score" - t.float "teacher_score" - t.float "student_score" - t.float "teaching_asistant_score" - t.integer "project_id", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "late_penalty", :default => 0 - t.integer "absence_penalty", :default => 0 - t.float "system_score", :default => 0.0 - t.boolean "is_test", :default => false - end - - add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" - - create_table "student_works_evaluation_distributions", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "student_works_scores", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.integer "score" - t.text "comment" - t.integer "reviewer_role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "students_for_courses", :force => true do |t| - t.integer "student_id" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" - add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" - + end + + create_table "project_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "project_id" + t.integer "project_type" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + end + + add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" + + create_table "projecting_softapplictions", :force => true do |t| + t.integer "user_id" + t.integer "softapplication_id" + t.integer "project_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "projects", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.string "homepage", :default => "" + t.boolean "is_public", :default => true, :null => false + t.integer "parent_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "identifier" + t.integer "status", :default => 1, :null => false + t.integer "lft" + t.integer "rgt" + t.boolean "inherit_members", :default => false, :null => false + t.integer "project_type" + t.boolean "hidden_repo", :default => false, :null => false + t.integer "attachmenttype", :default => 1 + t.integer "user_id" + t.integer "dts_test", :default => 0 + t.string "enterprise_name" + t.integer "organization_id" + t.integer "project_new_type" + t.integer "gpid" + t.integer "forked_from_project_id" + t.integer "forked_count" + t.integer "commits_count", :default => 0 + t.integer "publish_resource", :default => 0 + t.integer "issues_count", :default => 0 + t.integer "attachments_count", :default => 0 + t.integer "boards_count", :default => 0 + t.integer "news_count", :default => 0 + t.integer "acts_count", :default => 0 + t.integer "journals_count", :default => 0 + t.integer "boards_reply_count", :default => 0 + end + + add_index "projects", ["lft"], :name => "index_projects_on_lft" + add_index "projects", ["rgt"], :name => "index_projects_on_rgt" + + create_table "projects_trackers", :id => false, :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true + add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" + + create_table "queries", :force => true do |t| + t.integer "project_id" + t.string "name", :default => "", :null => false + t.text "filters" + t.integer "user_id", :default => 0, :null => false + t.boolean "is_public", :default => false, :null => false + t.text "column_names" + t.text "sort_criteria" + t.string "group_by" + t.string "type" + end + + add_index "queries", ["project_id"], :name => "index_queries_on_project_id" + add_index "queries", ["user_id"], :name => "index_queries_on_user_id" + + create_table "relative_memo_to_open_source_projects", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "relative_memos", :force => true do |t| + t.integer "osp_id" + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :limit => 16777215, :null => false + t.integer "author_id" + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 + t.string "url" + t.string "username" + t.string "userhomeurl" + t.date "date_collected" + t.string "topic_resource" + end + + create_table "repositories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "url", :default => "", :null => false + t.string "login", :limit => 60, :default => "" + t.string "password", :default => "" + t.string "root_url", :default => "" + t.string "type" + t.string "path_encoding", :limit => 64 + t.string "log_encoding", :limit => 64 + t.text "extra_info" + t.string "identifier" + t.boolean "is_default", :default => false + t.boolean "hidden", :default => false + end + + add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" + + create_table "rich_rich_files", :force => true do |t| + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "rich_file_file_name" + t.string "rich_file_content_type" + t.integer "rich_file_file_size" + t.datetime "rich_file_updated_at" + t.string "owner_type" + t.integer "owner_id" + t.text "uri_cache" + t.string "simplified_type", :default => "file" + end + + create_table "roles", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "assignable", :default => true + t.integer "builtin", :default => 0, :null => false + t.text "permissions" + t.string "issues_visibility", :limit => 30, :default => "default", :null => false + end + + create_table "schools", :force => true do |t| + t.string "name" + t.string "province" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "logo_link" + t.string "pinyin" + end + + create_table "seems_rateable_cached_ratings", :force => true do |t| + t.integer "cacheable_id", :limit => 8 + t.string "cacheable_type" + t.float "avg", :null => false + t.integer "cnt", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "seems_rateable_rates", :force => true do |t| + t.integer "rater_id", :limit => 8 + t.integer "rateable_id" + t.string "rateable_type" + t.float "stars", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "is_teacher_score", :default => 0 + end + + create_table "settings", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "value" + t.datetime "updated_on" + end + + add_index "settings", ["name"], :name => "index_settings_on_name" + + create_table "shares", :force => true do |t| + t.date "created_on" + t.string "url" + t.string "title" + t.integer "share_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + t.integer "user_id" + t.string "description" + end + + create_table "shield_activities", :force => true do |t| + t.string "container_type" + t.integer "container_id" + t.string "shield_type" + t.integer "shield_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "softapplications", :force => true do |t| + t.string "name" + t.text "description" + t.integer "app_type_id" + t.string "app_type_name" + t.string "android_min_version_available" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "contest_id" + t.integer "softapplication_id" + t.integer "is_public" + t.string "application_developers" + t.string "deposit_project_url" + t.string "deposit_project" + t.integer "project_id" + end + + create_table "student_work_projects", :force => true do |t| + t.integer "homework_common_id" + t.integer "student_work_id" + t.integer "project_id" + t.integer "user_id" + t.integer "is_leader" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "student_work_projects", ["homework_common_id"], :name => "index_student_work_projects_on_homework_common_id" + add_index "student_work_projects", ["project_id"], :name => "index_student_work_projects_on_project_id" + add_index "student_work_projects", ["student_work_id"], :name => "index_student_work_projects_on_student_work_id" + add_index "student_work_projects", ["user_id"], :name => "index_student_work_projects_on_user_id" + + create_table "student_work_tests", :force => true do |t| + t.integer "student_work_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "status", :default => 9 + t.text "results" + t.text "src" + end + + create_table "student_works", :force => true do |t| + t.string "name" + t.text "description", :limit => 2147483647 + t.integer "homework_common_id" + t.integer "user_id" + t.float "final_score" + t.float "teacher_score" + t.float "student_score" + t.float "teaching_asistant_score" + t.integer "project_id", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "late_penalty", :default => 0 + t.integer "absence_penalty", :default => 0 + t.float "system_score", :default => 0.0 + t.boolean "is_test", :default => false + end + + add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" + + create_table "student_works_evaluation_distributions", :force => true do |t| + t.integer "student_work_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "student_works_scores", :force => true do |t| + t.integer "student_work_id" + t.integer "user_id" + t.integer "score" + t.text "comment" + t.integer "reviewer_role" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "students_for_courses", :force => true do |t| + t.integer "student_id" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" + add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" + create_table "subfield_subdomain_dirs", :force => true do |t| t.integer "org_subfield_id" t.string "name" @@ -3681,356 +1672,351 @@ ActiveRecord::Schema.define(:version => 20160112085834) do t.datetime "updated_at", :null => false end - create_table "system_messages", :force => true do |t| - t.integer "user_id" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "description" - t.string "subject" - end - - create_table "taggings", :force => true do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", :limit => 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" - - create_table "tags", :force => true do |t| - t.string "name" - end - - create_table "teachers", :force => true do |t| - t.string "tea_name" - t.string "location" - t.integer "couurse_time" - t.integer "course_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "extra" - end - - create_table "temp", :id => false, :force => true do |t| - t.integer "id", :default => 0, :null => false + create_table "system_messages", :force => true do |t| + t.integer "user_id" + t.string "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "description" + t.string "subject" end - create_table "time_entries", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "issue_id" - t.float "hours", :null => false - t.string "comments" - t.integer "activity_id", :null => false - t.date "spent_on", :null => false - t.integer "tyear", :null => false - t.integer "tmonth", :null => false - t.integer "tweek", :null => false - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" - add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" - add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" - add_index "time_entries", ["project_id"], :name => "time_entries_project_id" - add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - - create_table "tokens", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40, :default => "", :null => false - t.datetime "created_on", :null => false - end - - add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" - add_index "tokens", ["value"], :name => "tokens_value", :unique => true - - create_table "trackers", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_in_chlog", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "is_in_roadmap", :default => true, :null => false - t.integer "fields_bits", :default => 0 - end - - create_table "user_activities", :force => true do |t| - t.string "act_type" - t.integer "act_id" - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "user_id" - end - - create_table "user_extensions", :force => true do |t| - t.integer "user_id", :null => false - t.date "birthday" - t.string "brief_introduction" - t.integer "gender" - t.string "location" - t.string "occupation" - t.integer "work_experience" - t.integer "zip_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "technical_title" - t.integer "identity" - t.string "student_id" - t.string "teacher_realname" - t.string "student_realname" - t.string "location_city" - t.integer "school_id" - t.string "description", :default => "" - end - - create_table "user_feedback_messages", :force => true do |t| - t.integer "user_id" - t.integer "journals_for_message_id" - t.string "journals_for_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_grades", :force => true do |t| - t.integer "user_id", :null => false - t.integer "project_id", :null => false - t.float "grade", :default => 0.0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" - add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" - add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" - - create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - end - - create_table "user_preferences", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.text "others" - t.boolean "hide_mail", :default => false - t.string "time_zone" - end - - add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" - - create_table "user_score_details", :force => true do |t| - t.integer "current_user_id" - t.integer "target_user_id" - t.string "score_type" - t.string "score_action" - t.integer "user_id" - t.integer "old_score" - t.integer "new_score" - t.integer "current_user_level" - t.integer "target_user_level" - t.integer "score_changeable_obj_id" - t.string "score_changeable_obj_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "grade", :default => 0.0 - end - - add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" - add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" - add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" - - create_table "users", :force => true do |t| - t.string "login", :default => "", :null => false - t.string "hashed_password", :limit => 40, :default => "", :null => false - t.string "firstname", :limit => 30, :default => "", :null => false - t.string "lastname", :default => "", :null => false - t.string "mail", :limit => 60, :default => "", :null => false - t.boolean "admin", :default => false, :null => false - t.integer "status", :default => 1, :null => false - t.datetime "last_login_on" - t.string "language", :limit => 5, :default => "" - t.integer "auth_source_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "type" - t.string "identity_url" - t.string "mail_notification", :default => "", :null => false - t.string "salt", :limit => 64 - t.integer "gid" - end - - add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" - add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" - add_index "users", ["type"], :name => "index_users_on_type" - - create_table "versions", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :default => "", :null => false - t.string "description", :default => "" - t.date "effective_date" - t.datetime "created_on" - t.datetime "updated_on" - t.string "wiki_page_title" - t.string "status", :default => "open" - t.string "sharing", :default => "none", :null => false - end - - add_index "versions", ["project_id"], :name => "versions_project_id" - add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - - create_table "visitors", :force => true do |t| - t.integer "user_id" - t.integer "master_id" - t.datetime "updated_on" - t.datetime "created_on" - end - - add_index "visitors", ["master_id"], :name => "index_visitors_master_id" - add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" - add_index "visitors", ["user_id"], :name => "index_visitors_user_id" - - create_table "watchers", :force => true do |t| - t.string "watchable_type", :default => "", :null => false - t.integer "watchable_id", :default => 0, :null => false - t.integer "user_id" - end - - add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" - add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" - add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" - - create_table "web_footer_companies", :force => true do |t| - t.string "name" - t.string "logo_size" - t.string "url" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "web_footer_oranizers", :force => true do |t| - t.string "name" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "wiki_content_versions", :force => true do |t| - t.integer "wiki_content_id", :null => false - t.integer "page_id", :null => false - t.integer "author_id" - t.binary "data", :limit => 2147483647 - t.string "compression", :limit => 6, :default => "" - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" - add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" - - create_table "wiki_contents", :force => true do |t| - t.integer "page_id", :null => false - t.integer "author_id" - t.text "text", :limit => 2147483647 - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" - add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" - - create_table "wiki_pages", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title", :null => false - t.datetime "created_on", :null => false - t.boolean "protected", :default => false, :null => false - t.integer "parent_id" - end - - add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" - add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" - add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" - - create_table "wiki_redirects", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title" - t.string "redirects_to" - t.datetime "created_on", :null => false - end - - add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" - add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" - - create_table "wikis", :force => true do |t| - t.integer "project_id", :null => false - t.string "start_page", :null => false - t.integer "status", :default => 1, :null => false - end - - add_index "wikis", ["project_id"], :name => "wikis_project_id" - - create_table "workflows", :force => true do |t| - t.integer "tracker_id", :default => 0, :null => false - t.integer "old_status_id", :default => 0, :null => false - t.integer "new_status_id", :default => 0, :null => false - t.integer "role_id", :default => 0, :null => false - t.boolean "assignee", :default => false, :null => false - t.boolean "author", :default => false, :null => false - t.string "type", :limit => 30 - t.string "field_name", :limit => 30 - t.string "rule", :limit => 30 - end - - add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" - add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" - add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" - add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - - create_table "works_categories", :force => true do |t| - t.string "category" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "zip_packs", :force => true do |t| - t.integer "user_id" - t.integer "homework_id" - t.string "file_digest" - t.string "file_path" - t.integer "pack_times", :default => 1 - t.integer "pack_size", :default => 0 - t.text "file_digests" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -end ->>>>>>> 26631e21991a327974a811851282b7535ab10b1d + create_table "taggings", :force => true do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context", :limit => 128 + t.datetime "created_at" + end + + add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" + add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" + + create_table "tags", :force => true do |t| + t.string "name" + end + + create_table "teachers", :force => true do |t| + t.string "tea_name" + t.string "location" + t.integer "couurse_time" + t.integer "course_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "extra" + end + + create_table "time_entries", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.integer "issue_id" + t.float "hours", :null => false + t.string "comments" + t.integer "activity_id", :null => false + t.date "spent_on", :null => false + t.integer "tyear", :null => false + t.integer "tmonth", :null => false + t.integer "tweek", :null => false + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" + add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" + add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" + add_index "time_entries", ["project_id"], :name => "time_entries_project_id" + add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" + + create_table "tokens", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.string "action", :limit => 30, :default => "", :null => false + t.string "value", :limit => 40, :default => "", :null => false + t.datetime "created_on", :null => false + end + + add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" + add_index "tokens", ["value"], :name => "tokens_value", :unique => true + + create_table "trackers", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_in_chlog", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "is_in_roadmap", :default => true, :null => false + t.integer "fields_bits", :default => 0 + end + + create_table "user_activities", :force => true do |t| + t.string "act_type" + t.integer "act_id" + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "user_id" + end + + create_table "user_extensions", :force => true do |t| + t.integer "user_id", :null => false + t.date "birthday" + t.string "brief_introduction" + t.integer "gender" + t.string "location" + t.string "occupation" + t.integer "work_experience" + t.integer "zip_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "technical_title" + t.integer "identity" + t.string "student_id" + t.string "teacher_realname" + t.string "student_realname" + t.string "location_city" + t.integer "school_id" + t.string "description", :default => "" + end + + create_table "user_feedback_messages", :force => true do |t| + t.integer "user_id" + t.integer "journals_for_message_id" + t.string "journals_for_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_grades", :force => true do |t| + t.integer "user_id", :null => false + t.integer "project_id", :null => false + t.float "grade", :default => 0.0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" + add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" + add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" + + create_table "user_levels", :force => true do |t| + t.integer "user_id" + t.integer "level" + end + + create_table "user_preferences", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.text "others" + t.boolean "hide_mail", :default => false + t.string "time_zone" + end + + add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" + + create_table "user_score_details", :force => true do |t| + t.integer "current_user_id" + t.integer "target_user_id" + t.string "score_type" + t.string "score_action" + t.integer "user_id" + t.integer "old_score" + t.integer "new_score" + t.integer "current_user_level" + t.integer "target_user_level" + t.integer "score_changeable_obj_id" + t.string "score_changeable_obj_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_scores", :force => true do |t| + t.integer "user_id", :null => false + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "active" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "grade", :default => 0.0 + end + + add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" + add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" + add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" + + create_table "users", :force => true do |t| + t.string "login", :default => "", :null => false + t.string "hashed_password", :limit => 40, :default => "", :null => false + t.string "firstname", :limit => 30, :default => "", :null => false + t.string "lastname", :default => "", :null => false + t.string "mail", :limit => 60, :default => "", :null => false + t.boolean "admin", :default => false, :null => false + t.integer "status", :default => 1, :null => false + t.datetime "last_login_on" + t.string "language", :limit => 5, :default => "" + t.integer "auth_source_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "type" + t.string "identity_url" + t.string "mail_notification", :default => "", :null => false + t.string "salt", :limit => 64 + t.integer "gid" + end + + add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" + add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" + add_index "users", ["type"], :name => "index_users_on_type" + + create_table "versions", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :default => "", :null => false + t.string "description", :default => "" + t.date "effective_date" + t.datetime "created_on" + t.datetime "updated_on" + t.string "wiki_page_title" + t.string "status", :default => "open" + t.string "sharing", :default => "none", :null => false + end + + add_index "versions", ["project_id"], :name => "versions_project_id" + add_index "versions", ["sharing"], :name => "index_versions_on_sharing" + + create_table "visitors", :force => true do |t| + t.integer "user_id" + t.integer "master_id" + t.datetime "updated_on" + t.datetime "created_on" + end + + add_index "visitors", ["master_id"], :name => "index_visitors_master_id" + add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" + add_index "visitors", ["user_id"], :name => "index_visitors_user_id" + + create_table "watchers", :force => true do |t| + t.string "watchable_type", :default => "", :null => false + t.integer "watchable_id", :default => 0, :null => false + t.integer "user_id" + end + + add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" + add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" + add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" + + create_table "web_footer_companies", :force => true do |t| + t.string "name" + t.string "logo_size" + t.string "url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "web_footer_oranizers", :force => true do |t| + t.string "name" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "wiki_content_versions", :force => true do |t| + t.integer "wiki_content_id", :null => false + t.integer "page_id", :null => false + t.integer "author_id" + t.binary "data", :limit => 2147483647 + t.string "compression", :limit => 6, :default => "" + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" + add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" + + create_table "wiki_contents", :force => true do |t| + t.integer "page_id", :null => false + t.integer "author_id" + t.text "text", :limit => 2147483647 + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" + add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" + + create_table "wiki_pages", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title", :null => false + t.datetime "created_on", :null => false + t.boolean "protected", :default => false, :null => false + t.integer "parent_id" + end + + add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" + add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" + add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" + + create_table "wiki_redirects", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title" + t.string "redirects_to" + t.datetime "created_on", :null => false + end + + add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" + add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" + + create_table "wikis", :force => true do |t| + t.integer "project_id", :null => false + t.string "start_page", :null => false + t.integer "status", :default => 1, :null => false + end + + add_index "wikis", ["project_id"], :name => "wikis_project_id" + + create_table "workflows", :force => true do |t| + t.integer "tracker_id", :default => 0, :null => false + t.integer "old_status_id", :default => 0, :null => false + t.integer "new_status_id", :default => 0, :null => false + t.integer "role_id", :default => 0, :null => false + t.boolean "assignee", :default => false, :null => false + t.boolean "author", :default => false, :null => false + t.string "type", :limit => 30 + t.string "field_name", :limit => 30 + t.string "rule", :limit => 30 + end + + add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" + add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" + add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" + add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" + + create_table "works_categories", :force => true do |t| + t.string "category" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "zip_packs", :force => true do |t| + t.integer "user_id" + t.integer "homework_id" + t.string "file_digest" + t.string "file_path" + t.integer "pack_times", :default => 1 + t.integer "pack_size", :default => 0 + t.text "file_digests" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + +end From 62c2085d61df6c7f5c6f5e26c106ad1b462b2487 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 15 Jan 2016 22:45:16 +0800 Subject: [PATCH 002/507] merge --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 2e0e4d238..5d1d51c13 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160114022928) do +ActiveRecord::Schema.define(:version => 20160115023749) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 744b2469307d912915edac88c953547cd479da2d Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 15 Jan 2016 23:15:06 +0800 Subject: [PATCH 003/507] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/wechat.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/wechat.yml b/config/wechat.yml index af795654f..20b6382c3 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -1,14 +1,14 @@ default: &default - corpid: "corpid" - corpsecret: "corpsecret" - agentid: 1 +# corpid: "corpid" +# corpsecret: "corpsecret" +# agentid: 1 # Or if using public account, only need above two line -# appid: "my_appid" -# secret: "my_secret" - token: "my_token" + appid: "wxc09454f171153c2d" + secret: "dff5b606e34dcafe24163ec82c2715f8" + token: "123456" access_token: "1234567" encrypt_mode: true # if true must fill encoding_aes_key - encoding_aes_key: "TJP8IMYwdcW1EkBIKIcQ193bCe7uB0RVqZDC2eAmkjz" + encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" production: From 932b0923b19da204daf743b5b569299abfe11453 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 15 Jan 2016 23:49:03 +0800 Subject: [PATCH 004/507] change wechat to guange2015 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 0e4e456ca..d8d148ec3 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end -gem 'wechat' +gem 'wechat',git: 'https://github.com/guange2015/wechat.git' gem 'grack', path:'lib/grack' gem 'gitlab', path: 'lib/gitlab-cli' gem 'rest-client' From 5f6a3cac04c05c1180b002350c441be98590dbad Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 16 Jan 2016 11:54:59 +0800 Subject: [PATCH 005/507] wechat init --- app/views/wechats/create.html.erb | 0 config/routes.rb | 2 ++ db/migrate/20160116034925_create_wechat_logs.rb | 11 +++++++++++ db/schema.rb | 10 +++++++++- 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app/views/wechats/create.html.erb create mode 100644 db/migrate/20160116034925_create_wechat_logs.rb diff --git a/app/views/wechats/create.html.erb b/app/views/wechats/create.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/routes.rb b/config/routes.rb index 5bccb915c..02f611677 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,6 +27,8 @@ RedmineApp::Application.routes.draw do + resource :wechat, only: [:show, :create] + mount Mobile::API => '/api' # Enable Grack support diff --git a/db/migrate/20160116034925_create_wechat_logs.rb b/db/migrate/20160116034925_create_wechat_logs.rb new file mode 100644 index 000000000..a60c68f9f --- /dev/null +++ b/db/migrate/20160116034925_create_wechat_logs.rb @@ -0,0 +1,11 @@ +class CreateWechatLogs < ActiveRecord::Migration + def change + create_table :wechat_logs do |t| + t.string :openid, null: false, index: true + t.text :request_raw + t.text :response_raw + t.text :session_raw + t.datetime :created_at, null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5d1d51c13..6de03ed54 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160115023749) do +ActiveRecord::Schema.define(:version => 20160116034925) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1928,6 +1928,14 @@ ActiveRecord::Schema.define(:version => 20160115023749) do t.datetime "updated_at", :null => false end + create_table "wechat_logs", :force => true do |t| + t.string "openid", :null => false + t.text "request_raw" + t.text "response_raw" + t.text "session_raw" + t.datetime "created_at", :null => false + end + create_table "wiki_content_versions", :force => true do |t| t.integer "wiki_content_id", :null => false t.integer "page_id", :null => false From 080cc71912889598bc653abac45c4e44295cac98 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 16 Jan 2016 11:59:09 +0800 Subject: [PATCH 006/507] =?UTF-8?q?wechat=20=E8=B7=AF=E7=94=B1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 02f611677..aa97e84e5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,9 +26,6 @@ # Example: :via => :get ====> :via => :get RedmineApp::Application.routes.draw do - - resource :wechat, only: [:show, :create] - mount Mobile::API => '/api' # Enable Grack support From 9f667588c45b61481d6a1d1eb47878ece4cacb5d Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 11:50:59 +0800 Subject: [PATCH 007/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 config/menu.yml diff --git a/config/menu.yml b/config/menu.yml new file mode 100644 index 000000000..1a4927fbd --- /dev/null +++ b/config/menu.yml @@ -0,0 +1,9 @@ +button: + - + type: "click" + name: "最新动态" + key: "MY_NEWS" + - + type: "view" + name: "进入网站" + url: "http://www.trustie.net/" \ No newline at end of file From 40047ff81866b042c086f36da71ef3666d90fc9c Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 11:51:26 +0800 Subject: [PATCH 008/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index fd3050e05..880b5d6de 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -54,6 +54,14 @@ class WechatsController < ActionController::Base end end + on :click, with: 'MY_NEWS' do |request, key| + + news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } + request.reply.news(news) do |article, n, index| # article is return object + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' + end + end + # When user click the menu button on :click, with: 'BOOK_LUNCH' do |request, key| request.reply.text "User: #{request[:FromUserName]} click #{key}" From 08e193ea3cbca918e4cd0bea3eb9909a67d5216e Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 11:51:37 +0800 Subject: [PATCH 009/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_wechat.rb | 3 +++ .../20160119034447_create_user_wechats.rb | 21 +++++++++++++++++++ db/schema.rb | 21 ++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 app/models/user_wechat.rb create mode 100644 db/migrate/20160119034447_create_user_wechats.rb diff --git a/app/models/user_wechat.rb b/app/models/user_wechat.rb new file mode 100644 index 000000000..f77e3273d --- /dev/null +++ b/app/models/user_wechat.rb @@ -0,0 +1,3 @@ +class UserWechat < ActiveRecord::Base + # attr_accessible :title, :body +end diff --git a/db/migrate/20160119034447_create_user_wechats.rb b/db/migrate/20160119034447_create_user_wechats.rb new file mode 100644 index 000000000..e2170f0c1 --- /dev/null +++ b/db/migrate/20160119034447_create_user_wechats.rb @@ -0,0 +1,21 @@ +class CreateUserWechats < ActiveRecord::Migration + def change + create_table :user_wechats do |t| + t.integer :subscribe + t.string :openid + t.string :nickname + t.integer :sex + t.string :language + t.string :city + t.string :province + t.string :country + t.string :headimgurl + t.string :subscribe_time + t.string :unionid + t.string :remark + t.integer :groupid + t.references :user + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 6de03ed54..a7b2af8b2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160116034925) do +ActiveRecord::Schema.define(:version => 20160119034447) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1853,6 +1853,25 @@ ActiveRecord::Schema.define(:version => 20160116034925) do add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" + create_table "user_wechats", :force => true do |t| + t.integer "subscribe" + t.string "openid" + t.string "nickname" + t.integer "sex" + t.string "language" + t.string "city" + t.string "province" + t.string "country" + t.string "headimgurl" + t.string "subscribe_time" + t.string "unionid" + t.string "remark" + t.integer "groupid" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "users", :force => true do |t| t.string "login", :default => "", :null => false t.string "hashed_password", :limit => 40, :default => "", :null => false From 571196ad2d198f2c97f9b9a14c622c7958883dd3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 12:00:13 +0800 Subject: [PATCH 010/507] =?UTF-8?q?wechat=20model=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 1 + app/models/user_wechat.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index f3367db59..4a30fcaf0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -179,6 +179,7 @@ class User < Principal ##### has_many :shares ,:dependent => :destroy + has_one :user_wechat # add by zjc has_one :level, :class_name => 'UserLevels', :dependent => :destroy diff --git a/app/models/user_wechat.rb b/app/models/user_wechat.rb index f77e3273d..446655afd 100644 --- a/app/models/user_wechat.rb +++ b/app/models/user_wechat.rb @@ -1,3 +1,6 @@ class UserWechat < ActiveRecord::Base - # attr_accessible :title, :body + attr_accessible :subscribe, :openid, :nickname, :sex, :language, :city, :province, :country, + :headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user + + belongs_to :user end From 96d0b2e717fb345aaff60f88b29f31bdef172699 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 14:07:59 +0800 Subject: [PATCH 011/507] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 38 +++++++++++++++++++++------ config/routes.rb | 8 ++++-- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 880b5d6de..24de889a8 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -1,6 +1,8 @@ class WechatsController < ActionController::Base wechat_responder + + # default text responder when no other match on :text do |request, content| request.reply.text "echo: #{content}" # Just echo @@ -54,14 +56,6 @@ class WechatsController < ActionController::Base end end - on :click, with: 'MY_NEWS' do |request, key| - - news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } - request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' - end - end - # When user click the menu button on :click, with: 'BOOK_LUNCH' do |request, key| request.reply.text "User: #{request[:FromUserName]} click #{key}" @@ -124,4 +118,32 @@ class WechatsController < ActionController::Base # Any not match above will fail to below on :fallback, respond: 'fallback message' + + on :click, with: 'MY_NEWS' do |request, key| + if user_binded? + news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } + request.reply.news(news) do |article, n, index| # article is return object + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' + end + else + news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } + request.reply.news(news) do |article, n, index| # article is return object + article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_path + end + end + end + + def bind + + end + + def login + + end + + private + def user_binded? + openid = request[:FromUserName] + uw = UserWechat.where(:openid, open).first + end end diff --git a/config/routes.rb b/config/routes.rb index aa97e84e5..3ed832368 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1122,8 +1122,12 @@ RedmineApp::Application.routes.draw do end resources :at - - resource :wechat, only:[:show, :create] + resource :wechat, only:[:show, :create] do + collection do + get :login + post :bind + end + end Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| file = File.join(plugin_dir, "config/routes.rb") From 8e66ab6a41c1a97cadf88403bf00abb3eab4bbf3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 14:28:13 +0800 Subject: [PATCH 012/507] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20bind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 17 ++++++++++---- app/views/wechats/login.html.erb | 32 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 app/views/wechats/login.html.erb diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 24de889a8..40c7d5ff5 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -1,8 +1,6 @@ class WechatsController < ActionController::Base wechat_responder - - # default text responder when no other match on :text do |request, content| request.reply.text "echo: #{content}" # Just echo @@ -134,11 +132,22 @@ class WechatsController < ActionController::Base end def bind - + begin + raise "非法操作, 微信ID不存在" unless params[:openid] + user, last_login_on = User.try_to_login(params[:username], params[:password]) + raise "用户名或密码错误,请重新登录" unless user + #补全用户信息 + puts wechat.user(request[:openid]) + user.user_wechat = UserWechat.new(openid: params[:openid]) + user.save! + rescue Exception=>e + @wechat_bind_errors = e.message + render :login + end end def login - + @openid = request[:FromUserName] #TODO 安全性 end private diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb new file mode 100644 index 000000000..44fc1da32 --- /dev/null +++ b/app/views/wechats/login.html.erb @@ -0,0 +1,32 @@ +
+
+

+ <%= @wechat_bind_errors %> +

+
+ <%= form_tag(bind_wechat_path,:id=>'main_login_form',:method=>'post') do %> + +
+ <%= text_field_tag 'username', params[:username], :tabindex => '1' , + :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称', :onkeypress => "user_name_keypress(event);"%> + +
+ <% if Setting.openid? %> +
+ <%= text_field_tag "openid_url", nil, :tabindex => '3',:placeholder=>'请输入OpenId URL' %> +
+ <% end %> +
+ + <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码', :onkeypress => "user_name_keypress(event);"%> +
+ + + +
+ <%= submit_tag '绑定' %> +
+ + <% end %> + +
\ No newline at end of file From 80feca0c8c7628df2541505214c7c48c25f8dfe8 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 14:32:22 +0800 Subject: [PATCH 013/507] . --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 40c7d5ff5..9231bb77c 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -153,6 +153,6 @@ class WechatsController < ActionController::Base private def user_binded? openid = request[:FromUserName] - uw = UserWechat.where(:openid, open).first + uw = UserWechat.where(:openid => open).first end end From 2681cc97ddca4da513360dd5c069938ce6b24645 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 14:39:31 +0800 Subject: [PATCH 014/507] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=89=8D=E5=85=88=E5=BD=95=E5=85=A5=E7=94=A8=E6=88=B7=E8=B5=84?= =?UTF-8?q?=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 9231bb77c..75fba6082 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -124,9 +124,11 @@ class WechatsController < ActionController::Base article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' end else + openid = request[:FromUserName] + puts wechat.user(request[:openid]) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_path + article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_url end end end @@ -137,7 +139,7 @@ class WechatsController < ActionController::Base user, last_login_on = User.try_to_login(params[:username], params[:password]) raise "用户名或密码错误,请重新登录" unless user #补全用户信息 - puts wechat.user(request[:openid]) + user.user_wechat = UserWechat.new(openid: params[:openid]) user.save! rescue Exception=>e From 0b1b8a4fcd8030d276eba4b9fb126f326f5559be Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 14:40:39 +0800 Subject: [PATCH 015/507] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20bind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 75fba6082..dc3804bf8 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -155,6 +155,6 @@ class WechatsController < ActionController::Base private def user_binded? openid = request[:FromUserName] - uw = UserWechat.where(:openid => open).first + uw = UserWechat.where(openid: openid).first end end From 527b695fabd89abe5cee5215eca85ddd26c87186 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 14:46:16 +0800 Subject: [PATCH 016/507] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20bind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index dc3804bf8..017886194 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -125,10 +125,12 @@ class WechatsController < ActionController::Base end else openid = request[:FromUserName] - puts wechat.user(request[:openid]) + attrs = wechat.user(openid) + UserWechat.delete_all(openid: openid) + uw = UserWechat.create!(attrs) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_url + article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_url(openid: uw.id) end end end @@ -140,7 +142,7 @@ class WechatsController < ActionController::Base raise "用户名或密码错误,请重新登录" unless user #补全用户信息 - user.user_wechat = UserWechat.new(openid: params[:openid]) + user.user_wechat = UserWechat.find_by_id(params[:openid]) user.save! rescue Exception=>e @wechat_bind_errors = e.message From 349f511c1210fbc56a759f3a7a2ea0b9d371184d Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 14:56:52 +0800 Subject: [PATCH 017/507] =?UTF-8?q?=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E5=BC=849200=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 4a30fcaf0..502f521d1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1163,17 +1163,17 @@ class User < Principal def create_user_ealasticsearch_index if self.id != 2 && self.id != 4 - self.__elasticsearch__.index_document + self.__elasticsearch__.index_document if Rails.env.production? end end def update_user_ealasticsearch_index if self.id != 2 && self.id != 4 - self.__elasticsearch__.update_document + self.__elasticsearch__.update_document if Rails.env.production? end end def delete_user_ealasticsearch_index if self.id != 2 && self.id != 4 - self.__elasticsearch__.delete_document + self.__elasticsearch__.delete_document if Rails.env.production? end end From babf30af0ae7fbb3cc63c6093bf1bacc8a4cbf00 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 15:06:40 +0800 Subject: [PATCH 018/507] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 5 +++-- app/views/wechats/bind.html.erb | 14 ++++++++++++++ app/views/wechats/login.html.erb | 15 ++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 app/views/wechats/bind.html.erb diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 017886194..a83969d39 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -142,8 +142,9 @@ class WechatsController < ActionController::Base raise "用户名或密码错误,请重新登录" unless user #补全用户信息 - user.user_wechat = UserWechat.find_by_id(params[:openid]) - user.save! + uw = UserWechat.find_by_id(params[:openid]) + uw.user = user + uw.save! rescue Exception=>e @wechat_bind_errors = e.message render :login diff --git a/app/views/wechats/bind.html.erb b/app/views/wechats/bind.html.erb new file mode 100644 index 000000000..e569162b2 --- /dev/null +++ b/app/views/wechats/bind.html.erb @@ -0,0 +1,14 @@ + + + + Ruby China + + + + + + +

恭喜! 绑定成功.

+ + + \ No newline at end of file diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index 44fc1da32..cbc476f26 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -1,3 +1,13 @@ + + + + Ruby China + + + + + +

@@ -29,4 +39,7 @@ <% end %> -

\ No newline at end of file +
+ + + \ No newline at end of file From f098e5358da34be6f0df2106d2c8b4b3d6830fc9 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 15:12:00 +0800 Subject: [PATCH 019/507] =?UTF-8?q?openid=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index a83969d39..7f589124d 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -152,7 +152,7 @@ class WechatsController < ActionController::Base end def login - @openid = request[:FromUserName] #TODO 安全性 + @openid = params[:openid] #TODO 安全性 end private From 3a0f98ebea5f316c86b9f487b8a5f640c0b65f64 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 15:17:56 +0800 Subject: [PATCH 020/507] =?UTF-8?q?openid=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 7f589124d..3cf0664e4 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -118,7 +118,7 @@ class WechatsController < ActionController::Base on :fallback, respond: 'fallback message' on :click, with: 'MY_NEWS' do |request, key| - if user_binded? + if user_binded?(request[:FromUserName]) news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } request.reply.news(news) do |article, n, index| # article is return object article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' @@ -156,8 +156,7 @@ class WechatsController < ActionController::Base end private - def user_binded? - openid = request[:FromUserName] + def user_binded?(openid) uw = UserWechat.where(openid: openid).first end end From 7f5bb11a5f28cb448995bda653f1c5fa4e87faa3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 15:25:36 +0800 Subject: [PATCH 021/507] =?UTF-8?q?=E8=AE=A4=E8=AF=81=E5=90=8E=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 3cf0664e4..993007308 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -118,10 +118,15 @@ class WechatsController < ActionController::Base on :fallback, respond: 'fallback message' on :click, with: 'MY_NEWS' do |request, key| - if user_binded?(request[:FromUserName]) - news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } + uw = user_binded?(request[:FromUserName]) + if uw + ua = UserActivity.where(user_id: uw.user.id).order("id desc").limit(5) + news = ua.map do |ua| + {title: "act_type: #{ua.act_type}, act_id: #{ua.act_id}", content: "container_id: #{ua.container_id}, container_type: #{ua.container_type}"} + end + request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: 'http://www.baidu.com/' end else openid = request[:FromUserName] From f39631169d9cd1e0e29f5fc52cc1abd07ec0caee Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 19 Jan 2016 15:29:03 +0800 Subject: [PATCH 022/507] =?UTF-8?q?=E8=AE=A4=E8=AF=81=E5=90=8E=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- app/models/user_wechat.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 993007308..34dd2e79a 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -148,7 +148,7 @@ class WechatsController < ActionController::Base #补全用户信息 uw = UserWechat.find_by_id(params[:openid]) - uw.user = user + uw.user_id = user.id uw.save! rescue Exception=>e @wechat_bind_errors = e.message diff --git a/app/models/user_wechat.rb b/app/models/user_wechat.rb index 446655afd..49053dbf0 100644 --- a/app/models/user_wechat.rb +++ b/app/models/user_wechat.rb @@ -1,6 +1,6 @@ class UserWechat < ActiveRecord::Base attr_accessible :subscribe, :openid, :nickname, :sex, :language, :city, :province, :country, - :headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user + :headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user, :user_id belongs_to :user end From 3f867a7f83a71d4d9fc5506adac71a1884c02c2e Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 21:40:56 +0800 Subject: [PATCH 023/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0weui=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/weui/weui.min.css | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 public/stylesheets/weui/weui.min.css diff --git a/public/stylesheets/weui/weui.min.css b/public/stylesheets/weui/weui.min.css new file mode 100644 index 000000000..7b75fa7dd --- /dev/null +++ b/public/stylesheets/weui/weui.min.css @@ -0,0 +1,5 @@ +/*! + * WeUI v0.2.2 (https://github.com/weui/weui) + * Copyright 2016 Tencent, Inc. + * Licensed under the MIT license + */.weui_input,.weui_select,.weui_switch{-webkit-appearance:none}.weui_btn,.weui_btn:after,.weui_grid,.weui_switch{box-sizing:border-box}html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{line-height:1.6;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}*{margin:0;padding:0}a img{border:0}a{text-decoration:none}@font-face{font-weight:400;font-style:normal;font-family:weui;src:url(data:application/octet-stream;base64,d09GRgABAAAAAA8oAA4AAAAAGewAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABRAAAAEQAAABWQClLhWNtYXAAAAGIAAAAOgAAAUrUIBe2Y3Z0IAAAAcQAAAAKAAAACgAAAABmcGdtAAAB0AAABZQAAAtwiJCQWWdhc3AAAAdkAAAACAAAAAgAAAAQZ2x5ZgAAB2wAAASuAAAHEkoVOHVoZWFkAAAMHAAAADUAAAA2CDTIZ2hoZWEAAAxUAAAAHQAAACQHlgNiaG10eAAADHQAAAAPAAAAPDqYAABsb2NhAAAMhAAAACAAAAAgDBYN2W1heHAAAAykAAAAIAAAACAApQu0bmFtZQAADMQAAAF6AAACnb2DL0hwb3N0AAAOQAAAAH0AAADNNS4jc3ByZXAAAA7AAAAAZQAAAHvdawOFeJxjYGR+wTiBgZWBg6mKaQ8DA0MPhGZ8wGDIyMTAwMTAysyAFQSkuaYwOLxifMXHHPQ/iyGKOYhhGlCYESQHAA5IDDB4nGNgYGBmgGAZBkYGEHAB8hjBfBYGDSDNBqQZGZgYGF7x/f8PUvCKEUSLMUDVAwEjG8OIBwB1qwa+AAAAAAAAAAAAAAAAAAB4nK1WaXMTRxCd1WHLNj6CDxI2gVnGcox2VpjLCBDG7EoW4BzylexCjl1Ldu6LT/wG/ZpekVSRb/y0vB4d2GAnVVQoSv2m9+1M9+ueXpPQksReWI+k3HwpprY2aWTnSUg3bFqO4kPZ2QspU0z+LoiCaLXUvu04JCISgap1hSWC2PfI0iTjQ48yWrYlvWpSbulJd9kaD+qt+vbT0FGO3QklNZuhQ+uRLanCqBJFMu2RkjYtw9VfSVrh5yvMfNUMJYLoJJLGm2EMj+Rn44xWGa3GdhxFkU2WG0WKRDM8iCKPslpin1wxQUD5oBlSXvk0onyEH5EVe5TTCnHJdprf9yU/6R3OvyTieouyJQf+QHZkB3unK/ki0toK46adbEehivB0fSfEI5uT6p/sUV7TaOB2RaYnzQiWyleQWPkJZfYPyWrhfMqXPBrVkoOcCFovc2Jf8g60HkdMiWsmyILujk6IoO6XnKHYY/q4+OO9XSwXIQTIOJb1jkq4EEYpYbOaJG0EOYiSskWV1HpHTJzyOi3iLWG/Tu3oS2e0Sag7MZ6th46tnKjkeDSp00ymTu2k5tGUBlFKOhM85tcBlB/RJK+2sZrEyqNpbDNjJJFQoIVzaSqIZSeWNAXRPJrRm7thmmvXokWaPFDPPXpPb26Fmzs9p+3AP2v8Z3UqpoO9MJ2eDshKfJp2uUnRun56hn8m8UPWAiqRLTbDlMVDtn4H5eVjS47CawNs957zK+h99kTIpIH4G/AeL9UpBUyFmFVQC9201rUsy9RqVotUZOq7IU0rX9ZpAk05Dn1jX8Y4/q+ZGUtMCd/vxOnZEZeeufYlyDSH3GZdj+Z1arFdgM5sz+k0y/Z9nebYfqDTPNvzOh1ha+t0lO2HOi2w/UinY2wvaEGT7jsEchGBXMAGEoGwdRAI20sIhK1CIGwXEQjbIgJhu4RA2H6MQNguIxC2l7Wsmn4qaRw7E8sARYgDoznuyGVuKldTyaUSrotGpzbkKXKrpKJ4Vv0rA/3ikTesgbVAukTW/IpJrnxUleOPrmh508S5Ao5Vf3tzXJ8TD2W/WPhT8L/amqqkV6x5ZHIVeSPQk+NE1yYVj67p8rmqR9f/i4oOa4F+A6UQC0VZlg2+mZDwUafTUA1c5RAzGzMP1/W6Zc3P4fybGCEL6H78NxQaC9yDTllJWe1gr9XXj2W5twflsCdYkmK+zOtb4YuMzEr7RWYpez7yecAVMCqVYasNXK3gzXsS85DpTfJMELcVZYOkjceZILGBYx4wb76TICRMXbWB2imcsIG8YMwp2O+EQ1RvlOVwe6F9Ho2Uf2tX7MgZFU0Q+G32Rtjrs1DyW6yBhCe/1NdAVSFNxbipgEsj5YZq8GFcrdtGMk6gr6jYDcuyig8fR9x3So5lIPlIEatHRz+tvUKd1Ln9yihu3zv9CIJBaWL+9r6Z4qCUd7WSZVZtA1O3GpVT15rDxasO3c2j7nvH2Sdy1jTddE/c9L6mVbeDg7lZEO3bHJSlTC6o68MOG6jLzaXQ6mVckt52DzAsMKDfoRUb/1f3cfg8V6oKo+NIvZ2oH6PPYgzyDzh/R/UF6OcxTLmGlOd7lxOfbtzD2TJdxV2sn+LfwKy15mbpGnBD0w2Yh6xaHbrKDXynBjo90tyO9BDwse4K8QBgE8Bi8InuWsbzKYDxfMYcH+Bz5jBoMofBFnMYbDNnDWCHOQx2mcNgjzkMvmDOOsCXzGEQModBxBwGT5gTADxlDoOvmMPga+Yw+IY59wG+ZQ6DmDkMEuYw2Nd0ayhzixd0F6htUBXowPQTFvewONRUGbK/44Vhf28Qs38wiKk/aro9pP7EC0P92SCm/mIQU3/VdGdI/Y0Xhvq7QUz9wyCmPtMvxnKZwV9GvkuFA8ouNp/z98T7B8IaQLYAAQAB//8AD3icdZVfbFN1FMd/557f73dv713b3d723rVrV9aut7qtlXWj5U8GPmJMTCC8khgffZfEEBPxiQQVEX1wPpgYDIRNE4I4B3Vk/JkQQjQREzABFv4EfRCJYbDKeue5t5QMTZPbb257TnLO93PO71emMLZyCL9BhxnMYdqJWJdkSmkIIqD2gbMZamXAMhTphb5GABbrDSEa9foS6ampO5zfmZr0FR369RTFlur1xvK3/PbU1G0eKGN+jS/wOGaoRj/V6In8v4Yqcy+BW90E5hhJxU6YoxUb/jr5RIgnJ880hWgWdkXd6K5I2Nmpa66m7+zpwoxonmlnNBcnYrEJKwmOZhia90eSMaS6X+HXmKC6SZZj+nRfyqba+J/acTkEOXedWa2N2k6xDGPVih2X8GD6sRCPp0/7hj/X1bSqgzasQTaWTBaSSUyIxul2RvMtVddVSGkA2gbww26y5fsjPIDDLMyy5DvdrbZ9mzZ3qgM1swwWSDK+BapZsGsFX+Hhngs7QoAHDgCGdlzY7c0i/wSVhCLe5ghFjnEFh/vG097ZKw8GBh5cgfH0uHfdO4f4GYpejjsBHiFaGPj/Et/DFNVv+7ciatu/2QJAPaijdhTiBGFdsWrl3Kf+F3fPbQs19u37R9s293FZB13khA7ZiGWlLQtTmU0p76dL9/L5e5dgJLXpMWhXhbiqecf8cNpiLf+f4g9YpM3Kk//+3kTY91+GLbAZyGmFDFecoh1XQbrFgsuKkqk2c6oM1gjgKKPqG2pMQlyaUpHS+1l2SyUtvOX52RUmBLDZeeAwImOSq4p4VYi7gvK6pferBDlFMbEqlzH+3K6X2AgLv6yPlIddf+l556W3RARoRjIK0g66pu7dnFNJOB2Pw5D3iLp6XUYFchDvyKiEggAjGgfofFKU3HUB4hWhkB1TvisF9IuowcHv3f8wPKUcos7lcbsbSkPWKo5QtVscI1AcN4Qq1WTXpXC2S8l09Rlhw2jOGGkDMkZ/xIjI0EFNh9kQUCBjNI/RZFuzmsDvMUdsTJpV5Ok9IBUfCa2qy6x+c9Qchft1/zTWzwNRXWEbvd9KDczR2/lnvzdvwGvezdW8kUVZL5194t2Xtrt1jgFvIogdmGM+Mbour9wF+LsD4msDzWvwJwAMd+RZag4E2KiP/XgWS+QtRZuoT2d7ra7WPdBeOPKn0o2TCC4Dt4juqoNwf84ja4BzF0GljWrcqGp6RPJBTQmDnrdSKTeVwhIFLq5KvKdr3i9cQgiGNcN7wc9xUy0mB/E0vsg0FmN9bNBnUsgmrWiIB0w2w5ibk3HbIQBmAAH9HrmPyFWeu4sfJrPZSja7ff+GDRc3Dl32ljgH7fLMCs3lx0mfwWSgig5rRtbQszHjnUunlWPcW2plzVwGbflwO4+0xWoSD6MZnBGfVV9P7Ckrtag6qlNzasVap7EpH05MpNvPdzOLQizOtPTITc5vHjmywPmCEl+VBMlnKTOLy/N8oZVDGuzkm/g7bqeNzPj/GzEzRDtZiED+Wcm4VEGFoI9i0JPywdierUdvcX7rKOnaQcitby7sPYF4Ym+g7w+ubYVIt+4Z866vh552jJT9C4YpwdAAAHicY2BkYGAA4udtFj/j+W2+MnAzvwCKMFyadr0aQq/1ZmD4n8X8gjkIyOVgYAKJAgB9Iw0DAAAAeJxjYGRgYA76n8UQxfyCAQiAJCMDKuAHAGaBBAAAAAB4nGN+wcDATCYGAKtTDcYAAAAAAAAyAG4ArgDuAS4BdgHUAgQCLgJyArgDCANOA4kAAQAAAA8AMgAEAAAAAAACAAAAEABzAAAAHgtwAAAAAHicdZDNSgMxFIVPbKu1BReK7oS7USzC9AdcqJtCRV0r1PXYpjNTppOSyVi69R1c+HK+ip6ZRhHBCZn73ZObk5sA2McHFDbfBeeGFerMNryFHVx6rlEfeq5z3HhuoI17z9vUHz23cI4nz20c4JUOqr7LbI43zwpNfHrewp7a8VxDUx16rpOPPTdwpE48b1O/9tzCWI08t3Gq3kdmubZJFDs5G3Vk0OtfyPNaDKUkC1MJCxcbm8tQZiZzOk1NMDGLlS6SBx0VaWhLLOdY2zwxmfSDXpne6Uzb0Olp6Za/RAPnZjKzZiG33keW1sz1xAWxc8urbve3P0YwWGINiwQRYjgIzqh2GAfooc+HFzyzQli5qUqQIURKJUTBHXG1kjMfcs6YZVQ1K1JygAn/C6yoFNz7wBiRUu62P+p3HDOWXknlIjw/YBffq3eMWVURVidMf3rL8ULXAVXHDsoubHWq4PZPP8L7lmtzKhPqQXVrR/UKXY5/+v8CE7x2bAAAeJxtjd0KwyAUg086p/2bZU9Y5NRugijohq8/up7dLTchHyShjk6N9F8LETpcoHCFhkGPASMmzLjBYtEcCkffb7mlmN2mQtrzXN3u1/pm9rUO39BcSUaIFV/P7v0XUxZimguvkB5WXLA6RqbjQIBml9hHXb0r/CT6AAFSNNIAAAB4nGPw3sFwIihiIyNjX+QGxp0cDBwMyQUbGVidNjIwaEFoDhR6JwMDAycyi5nBZaMKY0dgxAaHjoiNzCkuG9VAvF0cDQyMLA4dySERICWRQLCRgUdrB+P/1g0svRuZGFwAB9MiuAAAAA==) format('truetype'),url(data:application/octet-stream;base64,AAEAAAAOAIAAAwBgT1MvMkApS4UAAADsAAAAVmNtYXDUIBe2AAABRAAAAUpjdnQgAAAAAAAADfQAAAAKZnBnbYiQkFkAAA4AAAALcGdhc3AAAAAQAAAN7AAAAAhnbHlmShU4dQAAApAAAAcSaGVhZAg0yGcAAAmkAAAANmhoZWEHlgNiAAAJ3AAAACRobXR4OpgAAAAACgAAAAA8bG9jYQwWDdkAAAo8AAAAIG1heHAApQu0AAAKXAAAACBuYW1lvYMvSAAACnwAAAKdcG9zdDUuI3MAAA0cAAAAzXByZXDdawOFAAAZcAAAAHsAAQPoAZAABQAIAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA6gHqDgNS/2oAWgNSAJYAAAABAAAAAAAAAAAAAwAAAAMAAAAcAAEAAAAAAEQAAwABAAAAHAAEACgAAAAGAAQAAQACAADqDv//AAAAAOoB//8AABYAAAEAAAAAAAAAAAEGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAA/6QDrgMXAAsAFwAItRIMBgACLSsBDgEHHgEXPgE3LgEDLgEnPgE3HgEXDgEB9bz5BQX5vLz4BQX5u6zkBATkrKvkBATkAxcF+by7+QUF+Ly8+fy0BOOsrOMEBOOsrOMAAAIAAP+fA7MDHQALACEACLUYDgYAAi0rAQ4BBx4BFz4BNy4BAwcGIi8BJjY7ARE0NjsBMhYVETMyFgHvuvsFBfu6wv0FBf0ldg8mD3YODRddCggmCApdGAwDHQX9wrr7BQX7usL9/fWaEhKaExkBFwgLCwj+6RkAAAMAAP+lA60DFQALABkAIgAKtx4aFg4GAAMtKwEOAQceARc+ATcuAQMUBisBIiY1ETY3MxYXJy4BNDYyFhQGAfC39wUF97e/+QUF+ZsKBxwHCgEILAgBHxIZGSUZGQMVBfm/t/cFBfe3v/n9dQcKCgcBGggBAQg5ARklGRkmGQAAAgAA/5ADkQMsAA0AHwAItRwQBwACLSsBDgEHERYEFzYkNxEuARMBBi8BJj8BNh8BFjclNh8BFgH0gchUCQEDkZEBAwlUyHv+vgMElAMCFQIFeQQDAScEAxQCAywePRz+w9TwJCTw1AE9HD3+3f7EAwOZAwUbBANdAQH2AwMTAwADAAD/ogOCAxoADQAZACIACrceGhMOBwADLSsBDgEHER4BFz4BNxEuAQczFg8BFCsBIjUnNhMiJjQ2MhYUBgH1e8FRCfmLi/oIUcGSLgoBCgUiBQoBHw4TExwTEwMaHTsa/s/L5yMj58sBMRo79wEI2AUF2Aj+sRMcExMcEwAAAAIAAP+VA70DJwAXACMACLUhGxUNAi0rAS4BPwE+AR8BFjI3JTYyFycWFAcBBiYnJSYAJwYABxYAFzYAASAFAQQDBg8HYgcSBgEUBhEGAgYG/tAGEAYCHAX+/Ma+/wAFBQEAvsYBBAExBhIGBAcCBUsFBeUFBgIGEAb+1QYBBqzGAQQFBf78xr7/AAUFAQAAAAQAAP+kA64DFwALABcALQAxAA1ACjEuLCYSDAYABC0rAQ4BBx4BFz4BNy4BAy4BJz4BNx4BFw4BEwUOAS8BJgYPAQYWHwEWMjcBPgEmIhcyFRcB9bz5BQX5vLz4BQX5u6zkBATkrKvkBATkK/72BhIGYAYPBQMEAQV9Bg8GASUFAQsPFAEBAxcF+by7+QUF+Ly8+fy0BOOsrOMEBOOsrOMCIt0FAQVJBQIGBAcRBoAGBQEhBQ8LBAEBAAAAAQAAAAADuwKkABcABrMWEAEtKxMuAT8BPgEfARYyNwE2FhcnFhQHAQ4BJz0LBQcGBxkMyw0fDAIdDB4LDQsL/bkLHAsBHQshDgsOBgmTCAoBvgkBCw0LHQv9sQoBCgAAAgAA/5oDuAMiAAsAEQAItQ4MBgACLSsBBgIHHgEXNiQ3JgATIREzETMB7rz9BQX9vMUBAAUF/wA6/tot+QMiBf8Axbz9BQX9vMUBAP3eAU7+3wAABAAA/6QDrgMXAAMADwAbACEADUAKHhwWEAoEAwAELSsBMhUXAw4BBx4BFz4BNy4BAy4BJz4BNx4BFw4BAyMVMzUjAuUBAfK8+QUF+by8+AUF+bus5AQE5Kyr5AQE5Nkk/dkB7QEBASwF+by7+QUF+Ly8+fy0BOOsrOMEBOOsrOMCLf0kAAAAAAMAAP+PA8MDLQALABoAIwAKtx8bEwwGAAMtKwEGAAcWABc2ADcmAAczMhYVAxQGKwEmJwMmNhMiJjQ2MhYUBgHuwf79BQUBA8HJAQcFBf753jYICg4GBCoIAg0BCiMTGhomGhoDLQX++cnB/v0FBQEDwckBB+cKCP7TBAYBCQEsCAv+KBomGhomGgAABAAA/5MDvwMpAAgAEgAeACoADUAKJR8ZEw8JBAAELSsBPgE0JiIGFBYXIxUzESMVMzUjAwYABxYEFz4BNyYCAy4BJz4BNx4BFw4BAfQZHx8yHx9Sjzk5yTorzf74BAQBCM25/wUF/8er4wQE46ur4wQE4wIKASAxICAxIDod/sQcHAKxBP74zbn/BQX/uc0BCPynBOOrq+MEBOOrq+MAAAMAAP+rA6cDEQALABcAIwAKtx4YEgwGAAMtKwEHJwcXBxc3FzcnNwMOAQceARc+ATcuAQMuASc+ATceARcOAQKOmpocmpocmpocmpq2ufUFBfW5ufUFBfW5qN8EBN+oqOAEBOACFJqaHJqaHJqaHJqaARkF9bm59QUF9bm59fzGBOCoqOAEBOCoqOAAAgAA/2oD6ANSABEAHQAItRgSEQkCLSslDgEjLgEnPgE3HgEXFAYHAQcBPgE3LgEnDgEHHgECjTSBSKriBATiqqriBDAqASI4/eCItQMDtYiItQMDtYwqMATiqqriBATiqkiBNP7dOAEYA7WIiLUDA7WIiLUAAAAAAQAAAAEAAOeGfnFfDzz1AAsD6AAAAADSltd7AAAAANKWrUsAAP9qA+gDUgAAAAgAAgAAAAAAAAABAAADUv9qAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAADwPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAAAAAAAMgBuAK4A7gEuAXYB1AIEAi4CcgK4AwgDTgOJAAEAAAAPADIABAAAAAAAAgAAABAAcwAAAB4LcAAAAAAAAAASAN4AAQAAAAAAAAA1AAAAAQAAAAAAAQAEADUAAQAAAAAAAgAHADkAAQAAAAAAAwAEAEAAAQAAAAAABAAEAEQAAQAAAAAABQALAEgAAQAAAAAABgAEAFMAAQAAAAAACgArAFcAAQAAAAAACwATAIIAAwABBAkAAABqAJUAAwABBAkAAQAIAP8AAwABBAkAAgAOAQcAAwABBAkAAwAIARUAAwABBAkABAAIAR0AAwABBAkABQAWASUAAwABBAkABgAIATsAAwABBAkACgBWAUMAAwABBAkACwAmAZlDb3B5cmlnaHQgKEMpIDIwMTUgYnkgb3JpZ2luYWwgYXV0aG9ycyBAIGZvbnRlbGxvLmNvbXdldWlSZWd1bGFyd2V1aXdldWlWZXJzaW9uIDEuMHdldWlHZW5lcmF0ZWQgYnkgc3ZnMnR0ZiBmcm9tIEZvbnRlbGxvIHByb2plY3QuaHR0cDovL2ZvbnRlbGxvLmNvbQBDAG8AcAB5AHIAaQBnAGgAdAAgACgAQwApACAAMgAwADEANQAgAGIAeQAgAG8AcgBpAGcAaQBuAGEAbAAgAGEAdQB0AGgAbwByAHMAIABAACAAZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AdwBlAHUAaQBSAGUAZwB1AGwAYQByAHcAZQB1AGkAdwBlAHUAaQBWAGUAcgBzAGkAbwBuACAAMQAuADAAdwBlAHUAaQBHAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAHMAdgBnADIAdAB0AGYAIABmAHIAbwBtACAARgBvAG4AdABlAGwAbABvACAAcAByAG8AagBlAGMAdAAuAGgAdAB0AHAAOgAvAC8AZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AAAAAAgAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPAAABAgEDAQQBBQEGAQcBCAEJAQoBCwEMAQ0BDgEPBmNpcmNsZQhkb3dubG9hZARpbmZvDHNhZmVfc3VjY2VzcwlzYWZlX3dhcm4Hc3VjY2Vzcw5zdWNjZXNzX2NpcmNsZRFzdWNjZXNzX25vX2NpcmNsZQd3YWl0aW5nDndhaXRpbmdfY2lyY2xlBHdhcm4LaW5mb19jaXJjbGUGY2FuY2VsBnNlYXJjaAAAAAAAAAEAAf//AA8AAAAAAAAAAAAAAACwACwgsABVWEVZICBLuAAOUUuwBlNaWLA0G7AoWWBmIIpVWLACJWG5CAAIAGNjI2IbISGwAFmwAEMjRLIAAQBDYEItsAEssCBgZi2wAiwgZCCwwFCwBCZasigBCkNFY0VSW1ghIyEbilggsFBQWCGwQFkbILA4UFghsDhZWSCxAQpDRWNFYWSwKFBYIbEBCkNFY0UgsDBQWCGwMFkbILDAUFggZiCKimEgsApQWGAbILAgUFghsApgGyCwNlBYIbA2YBtgWVlZG7ABK1lZI7AAUFhlWVktsAMsIEUgsAQlYWQgsAVDUFiwBSNCsAYjQhshIVmwAWAtsAQsIyEjISBksQViQiCwBiNCsQEKQ0VjsQEKQ7AAYEVjsAMqISCwBkMgiiCKsAErsTAFJbAEJlFYYFAbYVJZWCNZISCwQFNYsAErGyGwQFkjsABQWGVZLbAFLLAHQyuyAAIAQ2BCLbAGLLAHI0IjILAAI0JhsAJiZrABY7ABYLAFKi2wBywgIEUgsAtDY7gEAGIgsABQWLBAYFlmsAFjYESwAWAtsAgssgcLAENFQiohsgABAENgQi2wCSywAEMjRLIAAQBDYEItsAosICBFILABKyOwAEOwBCVgIEWKI2EgZCCwIFBYIbAAG7AwUFiwIBuwQFlZI7AAUFhlWbADJSNhRESwAWAtsAssICBFILABKyOwAEOwBCVgIEWKI2EgZLAkUFiwABuwQFkjsABQWGVZsAMlI2FERLABYC2wDCwgsAAjQrILCgNFWCEbIyFZKiEtsA0ssQICRbBkYUQtsA4ssAFgICCwDENKsABQWCCwDCNCWbANQ0qwAFJYILANI0JZLbAPLCCwEGJmsAFjILgEAGOKI2GwDkNgIIpgILAOI0IjLbAQLEtUWLEEZERZJLANZSN4LbARLEtRWEtTWLEEZERZGyFZJLATZSN4LbASLLEAD0NVWLEPD0OwAWFCsA8rWbAAQ7ACJUKxDAIlQrENAiVCsAEWIyCwAyVQWLEBAENgsAQlQoqKIIojYbAOKiEjsAFhIIojYbAOKiEbsQEAQ2CwAiVCsAIlYbAOKiFZsAxDR7ANQ0dgsAJiILAAUFiwQGBZZrABYyCwC0NjuAQAYiCwAFBYsEBgWWawAWNgsQAAEyNEsAFDsAA+sgEBAUNgQi2wEywAsQACRVRYsA8jQiBFsAsjQrAKI7AAYEIgYLABYbUQEAEADgBCQopgsRIGK7ByKxsiWS2wFCyxABMrLbAVLLEBEystsBYssQITKy2wFyyxAxMrLbAYLLEEEystsBkssQUTKy2wGiyxBhMrLbAbLLEHEystsBwssQgTKy2wHSyxCRMrLbAeLACwDSuxAAJFVFiwDyNCIEWwCyNCsAojsABgQiBgsAFhtRAQAQAOAEJCimCxEgYrsHIrGyJZLbAfLLEAHistsCAssQEeKy2wISyxAh4rLbAiLLEDHistsCMssQQeKy2wJCyxBR4rLbAlLLEGHistsCYssQceKy2wJyyxCB4rLbAoLLEJHistsCksIDywAWAtsCosIGCwEGAgQyOwAWBDsAIlYbABYLApKiEtsCsssCorsCoqLbAsLCAgRyAgsAtDY7gEAGIgsABQWLBAYFlmsAFjYCNhOCMgilVYIEcgILALQ2O4BABiILAAUFiwQGBZZrABY2AjYTgbIVktsC0sALEAAkVUWLABFrAsKrABFTAbIlktsC4sALANK7EAAkVUWLABFrAsKrABFTAbIlktsC8sIDWwAWAtsDAsALABRWO4BABiILAAUFiwQGBZZrABY7ABK7ALQ2O4BABiILAAUFiwQGBZZrABY7ABK7AAFrQAAAAAAEQ+IzixLwEVKi2wMSwgPCBHILALQ2O4BABiILAAUFiwQGBZZrABY2CwAENhOC2wMiwuFzwtsDMsIDwgRyCwC0NjuAQAYiCwAFBYsEBgWWawAWNgsABDYbABQ2M4LbA0LLECABYlIC4gR7AAI0KwAiVJiopHI0cjYSBYYhshWbABI0KyMwEBFRQqLbA1LLAAFrAEJbAEJUcjRyNhsAlDK2WKLiMgIDyKOC2wNiywABawBCWwBCUgLkcjRyNhILAEI0KwCUMrILBgUFggsEBRWLMCIAMgG7MCJgMaWUJCIyCwCEMgiiNHI0cjYSNGYLAEQ7ACYiCwAFBYsEBgWWawAWNgILABKyCKimEgsAJDYGQjsANDYWRQWLACQ2EbsANDYFmwAyWwAmIgsABQWLBAYFlmsAFjYSMgILAEJiNGYTgbI7AIQ0awAiWwCENHI0cjYWAgsARDsAJiILAAUFiwQGBZZrABY2AjILABKyOwBENgsAErsAUlYbAFJbACYiCwAFBYsEBgWWawAWOwBCZhILAEJWBkI7ADJWBkUFghGyMhWSMgILAEJiNGYThZLbA3LLAAFiAgILAFJiAuRyNHI2EjPDgtsDgssAAWILAII0IgICBGI0ewASsjYTgtsDkssAAWsAMlsAIlRyNHI2GwAFRYLiA8IyEbsAIlsAIlRyNHI2EgsAUlsAQlRyNHI2GwBiWwBSVJsAIlYbkIAAgAY2MjIFhiGyFZY7gEAGIgsABQWLBAYFlmsAFjYCMuIyAgPIo4IyFZLbA6LLAAFiCwCEMgLkcjRyNhIGCwIGBmsAJiILAAUFiwQGBZZrABYyMgIDyKOC2wOywjIC5GsAIlRlJYIDxZLrErARQrLbA8LCMgLkawAiVGUFggPFkusSsBFCstsD0sIyAuRrACJUZSWCA8WSMgLkawAiVGUFggPFkusSsBFCstsD4ssDUrIyAuRrACJUZSWCA8WS6xKwEUKy2wPyywNiuKICA8sAQjQoo4IyAuRrACJUZSWCA8WS6xKwEUK7AEQy6wKystsEAssAAWsAQlsAQmIC5HI0cjYbAJQysjIDwgLiM4sSsBFCstsEEssQgEJUKwABawBCWwBCUgLkcjRyNhILAEI0KwCUMrILBgUFggsEBRWLMCIAMgG7MCJgMaWUJCIyBHsARDsAJiILAAUFiwQGBZZrABY2AgsAErIIqKYSCwAkNgZCOwA0NhZFBYsAJDYRuwA0NgWbADJbACYiCwAFBYsEBgWWawAWNhsAIlRmE4IyA8IzgbISAgRiNHsAErI2E4IVmxKwEUKy2wQiywNSsusSsBFCstsEMssDYrISMgIDywBCNCIzixKwEUK7AEQy6wKystsEQssAAVIEewACNCsgABARUUEy6wMSotsEUssAAVIEewACNCsgABARUUEy6wMSotsEYssQABFBOwMiotsEcssDQqLbBILLAAFkUjIC4gRoojYTixKwEUKy2wSSywCCNCsEgrLbBKLLIAAEErLbBLLLIAAUErLbBMLLIBAEErLbBNLLIBAUErLbBOLLIAAEIrLbBPLLIAAUIrLbBQLLIBAEIrLbBRLLIBAUIrLbBSLLIAAD4rLbBTLLIAAT4rLbBULLIBAD4rLbBVLLIBAT4rLbBWLLIAAEArLbBXLLIAAUArLbBYLLIBAEArLbBZLLIBAUArLbBaLLIAAEMrLbBbLLIAAUMrLbBcLLIBAEMrLbBdLLIBAUMrLbBeLLIAAD8rLbBfLLIAAT8rLbBgLLIBAD8rLbBhLLIBAT8rLbBiLLA3Ky6xKwEUKy2wYyywNyuwOystsGQssDcrsDwrLbBlLLAAFrA3K7A9Ky2wZiywOCsusSsBFCstsGcssDgrsDsrLbBoLLA4K7A8Ky2waSywOCuwPSstsGossDkrLrErARQrLbBrLLA5K7A7Ky2wbCywOSuwPCstsG0ssDkrsD0rLbBuLLA6Ky6xKwEUKy2wbyywOiuwOystsHAssDorsDwrLbBxLLA6K7A9Ky2wciyzCQQCA0VYIRsjIVlCK7AIZbADJFB4sAEVMC0AS7gAyFJYsQEBjlmwAbkIAAgAY3CxAAVCsQAAKrEABUKxAAgqsQAFQrEACCqxAAVCuQAAAAkqsQAFQrkAAAAJKrEDAESxJAGIUViwQIhYsQNkRLEmAYhRWLoIgAABBECIY1RYsQMARFlZWVmxAAwquAH/hbAEjbECAEQA) format('woff'),url(data:application/octet-stream;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxtZXRhZGF0YT5Db3B5cmlnaHQgKEMpIDIwMTUgYnkgb3JpZ2luYWwgYXV0aG9ycyBAIGZvbnRlbGxvLmNvbTwvbWV0YWRhdGE+CjxkZWZzPgo8Zm9udCBpZD0id2V1aSIgaG9yaXotYWR2LXg9IjEwMDAiID4KPGZvbnQtZmFjZSBmb250LWZhbWlseT0id2V1aSIgZm9udC13ZWlnaHQ9IjQwMCIgZm9udC1zdHJldGNoPSJub3JtYWwiIHVuaXRzLXBlci1lbT0iMTAwMCIgYXNjZW50PSI4NTAiIGRlc2NlbnQ9Ii0xNTAiIC8+CjxtaXNzaW5nLWdseXBoIGhvcml6LWFkdi14PSIxMDAwIiAvPgo8Z2x5cGggZ2x5cGgtbmFtZT0iY2lyY2xlIiB1bmljb2RlPSImI3hlYTAxOyIgZD0ibTUwMSA3OTFjLTI0NCAwLTQ0Mi0xOTgtNDQyLTQ0MiAwLTI0MyAxOTgtNDQxIDQ0Mi00NDFzNDQxIDE5NyA0NDEgNDQxYzAgMjQ0LTE5OCA0NDItNDQxIDQ0MnogbTAtODQ5Yy0yMjMgMC00MDQgMTgwLTQwNCA0MDMgMCAyMjMgMTgxIDQwMyA0MDQgNDAzIDIyMiAwIDQwMy0xODAgNDAzLTQwMyAwLTIyMy0xODEtNDAzLTQwMy00MDN6IiBob3Jpei1hZHYteD0iMTAwMCIgLz4KPGdseXBoIGdseXBoLW5hbWU9ImRvd25sb2FkIiB1bmljb2RlPSImI3hlYTAyOyIgZD0ibTQ5NSA3OTdjLTI0MiAwLTQ0Mi0yMDAtNDQyLTQ1MiAwLTI0MiAyMDAtNDQyIDQ0Mi00NDIgMjUyIDAgNDUyIDIwMCA0NTIgNDQyIDAgMjUyLTIwMCA0NTItNDUyIDQ1MnogbTE1Ny01MjhsLTExOC0xNTRjLTE5LTI0LTQ5LTI0LTY4IDBsLTExOCAxNTRjLTE5IDI0LTkgNDQgMjIgNDRoOTN2Mjc5YzAgMTAgOCAxOSAxOCAxOWgzOGMxMCAwIDE4LTkgMTgtMTl2LTI3OWg5M2MzMSAwIDQxLTIwIDIyLTQ0eiIgaG9yaXotYWR2LXg9IjEwMDAiIC8+CjxnbHlwaCBnbHlwaC1uYW1lPSJpbmZvIiB1bmljb2RlPSImI3hlYTAzOyIgZD0ibTQ5NiA3ODljLTIzOCAwLTQzNS0xOTctNDM1LTQ0NSAwLTIzOCAxOTctNDM1IDQzNS00MzUgMjQ4IDAgNDQ1IDE5NyA0NDUgNDM1IDAgMjQ4LTE5NyA0NDUtNDQ1IDQ0NXogbTM2LTY1NmMwLTktOC0xNy0xNy0xN2gtMjhjLTkgMC0xNyA4LTE3IDE3djI4MmMwIDUgNCA5IDkgOWg0NGM1IDAgOS00IDktOXYtMjgyeiBtLTMxIDMzOWMtMjQgMC00NCAyMC00NCA0NHMyMCA0NCA0NCA0NGMyNCAwIDQ0LTE5IDQ0LTQ0cy0yMC00NC00NC00NHoiIGhvcml6LWFkdi14PSIxMDAwIiAvPgo8Z2x5cGggZ2x5cGgtbmFtZT0ic2FmZV9zdWNjZXNzIiB1bmljb2RlPSImI3hlYTA0OyIgZD0ibTUwMCA4MTJjLTE3My0zOS0yOTktODItNDEzLTExOSAwLTEyMCAwLTIxNiAwLTMxNyAwLTI4MyAyMzEtNDM5IDQxMy00ODggMTgyIDQ5IDQxMyAyMDUgNDEzIDQ4OCAwIDEwMSAwIDE5NyAwIDMxNy0xMTQgMzctMjQwIDgwLTQxMyAxMTl6IG0yNTItMzIxbC0zMjItMzE2Yy0yLTItNS0yLTcgMGwtMTQ4IDE1M2MtMiAyLTIgNS0xIDhsMjEgMjdjMSAyIDQgMyA3IDFsMTIxLTkzYzItMSA1LTEgNyAwbDI5NSAyNDZjMiAyIDUgMiA3IDBsMjAtMTljMS0yIDEtNSAwLTd6IiBob3Jpei1hZHYteD0iMTAwMCIgLz4KPGdseXBoIGdseXBoLW5hbWU9InNhZmVfd2FybiIgdW5pY29kZT0iJiN4ZWEwNTsiIGQ9Im01MDEgNzk0Yy0xNjYtMzgtMjg3LTgwLTM5Ny0xMTQgMC0xMTYgMC0yMDggMC0zMDUgMC0yNzIgMjIzLTQyMiAzOTctNDY5IDE3NCA0NyAzOTcgMTk3IDM5NyA0NjkgMCA5NyAwIDE4OSAwIDMwNS0xMTAgMzQtMjMxIDc2LTM5NyAxMTR6IG0tMjMtMjc2aDQ2YzYgMCAxMC00IDktOWwtMTAtMjE2YzAtMy0yLTUtNS01aC0zNGMtMyAwLTUgMi01IDVsLTEwIDIxNmMwIDUgNCA5IDkgOXogbTIzLTMzNmMtMTggMC0zMyAxNS0zMyAzM3MxNSAzMyAzMyAzMyAzMy0xNSAzMy0zMy0xNS0zMy0zMy0zM3oiIGhvcml6LWFkdi14PSIxMDAwIiAvPgo8Z2x5cGggZ2x5cGgtbmFtZT0ic3VjY2VzcyIgdW5pY29kZT0iJiN4ZWEwNjsiIGQ9Im0yODggMzA1Yy03IDgtOCAyMi0yIDMwbDMgNGM3IDkgMTkgMTEgMjggNGw5OC03NWM5LTcgMjMtNyAzMSAwbDI3NiAyMjljOCA3IDIxIDcgMjktMWwtMiAyYzgtOCA4LTIwIDAtMjhsLTMwNC0yOTljLTctOC0yMC03LTI4IDFsLTEyOSAxMzN6IG02NjkgMzljMCAyNTgtMjA1IDQ2My00NjMgNDYzLTI0NiAwLTQ1MS0yMDUtNDUxLTQ2MyAwLTI0NiAyMDUtNDUxIDQ1MS00NTEgMjU4IDAgNDYzIDIwNSA0NjMgNDUxeiIgaG9yaXotYWR2LXg9IjEwMDAiIC8+CjxnbHlwaCBnbHlwaC1uYW1lPSJzdWNjZXNzX2NpcmNsZSIgdW5pY29kZT0iJiN4ZWEwNzsiIGQ9Im01MDEgNzkxYy0yNDQgMC00NDItMTk4LTQ0Mi00NDIgMC0yNDMgMTk4LTQ0MSA0NDItNDQxczQ0MSAxOTcgNDQxIDQ0MWMwIDI0NC0xOTggNDQyLTQ0MSA0NDJ6IG0wLTg0OWMtMjIzIDAtNDA0IDE4MC00MDQgNDAzIDAgMjIzIDE4MSA0MDMgNDA0IDQwMyAyMjIgMCA0MDMtMTgwIDQwMy00MDMgMC0yMjMtMTgxLTQwMy00MDMtNDAzeiBtMjE0IDU1MGwtMjY2LTIyMWMtOC03LTIyLTctMzAtMWwtOTYgNzNjLTggNy0yMCA1LTI2LTNsLTMtNGMtNi05LTUtMjIgMi0zMGwxMjUtMTI4YzctOCAxOS04IDI3LTFsMjkzIDI4OWM3IDcgOCAxOCAxIDI2LTggNy0yMCA3LTI3IDB6IG0yNiAxYzAgMCAxLTEgMS0xIDAgMCAxLTEgMS0xbC0yIDJ6IiBob3Jpei1hZHYteD0iMTAwMCIgLz4KPGdseXBoIGdseXBoLW5hbWU9InN1Y2Nlc3Nfbm9fY2lyY2xlIiB1bmljb2RlPSImI3hlYTA4OyIgZD0ibTYxIDI4NWMtMTQgMTQtMTggNDAtOSA1OGw2IDExYzggMTggMjggMjMgNDQgMTFsMjAzLTE0N2MxNi0xMSA0MS0xMSA1NiAybDU0MSA0NDZjMTUgMTIgMzkgMTEgNTMtM2wtMTMgMTNjMTQtMTQgMTQtMzcgMC01MWwtNTgzLTU5MWMtMTQtMTQtMzYtMTQtNTAtMWwtMjQ4IDI1MnoiIGhvcml6LWFkdi14PSIxMDAwIiAvPgo8Z2x5cGggZ2x5cGgtbmFtZT0id2FpdGluZyIgdW5pY29kZT0iJiN4ZWEwOTsiIGQ9Im00OTQgODAyYy0yNDQgMC00NDYtMjAyLTQ0Ni00NTggMC0yNDQgMjAyLTQ0NiA0NDYtNDQ2IDI1NiAwIDQ1OCAyMDIgNDU4IDQ0NiAwIDI1Ni0yMDIgNDU4LTQ1OCA0NTh6IG0yNTUtNTUxaC0yOTR2MzM0aDQ1di0yODloMjQ5di00NXoiIGhvcml6LWFkdi14PSIxMDAwIiAvPgo8Z2x5cGggZ2x5cGgtbmFtZT0id2FpdGluZ19jaXJjbGUiIHVuaWNvZGU9IiYjeGVhMGE7IiBkPSJtNzQxIDQ5M2MwIDAgMS0xIDEtMSAwIDAgMS0xIDEtMWwtMiAyeiBtLTI0MCAyOThjLTI0NCAwLTQ0Mi0xOTgtNDQyLTQ0MiAwLTI0MyAxOTgtNDQxIDQ0Mi00NDFzNDQxIDE5NyA0NDEgNDQxYzAgMjQ0LTE5OCA0NDItNDQxIDQ0MnogbTAtODQ5Yy0yMjMgMC00MDQgMTgwLTQwNCA0MDMgMCAyMjMgMTgxIDQwMyA0MDQgNDAzIDIyMiAwIDQwMy0xODAgNDAzLTQwMyAwLTIyMy0xODEtNDAzLTQwMy00MDN6IG0tNDYgNTYxaC0zNnYtMjUzaDI1M3YzNmgtMjE3eiIgaG9yaXotYWR2LXg9IjEwMDAiIC8+CjxnbHlwaCBnbHlwaC1uYW1lPSJ3YXJuIiB1bmljb2RlPSImI3hlYTBiOyIgZD0ibTQ5NCA4MTNjLTI1MCAwLTQ1Ny0yMDctNDU3LTQ2OSAwLTI1MCAyMDctNDU3IDQ1Ny00NTcgMjYyIDAgNDY5IDIwNyA0NjkgNDU3IDAgMjYyLTIwNyA0NjktNDY5IDQ2OXogbS0yMS0yMzZoNTRjMTAgMCAxOC04IDE4LTE4bC0xNC0zMDFjMC01LTUtMTAtMTAtMTBoLTQyYy01IDAtOSA1LTEwIDEwbC0xMyAzMDBjLTEgMTAgNyAxOSAxNyAxOXogbTI3LTQ3MmMtMjUgMC00NSAyMC00NSA0NSAwIDI1IDIwIDQ2IDQ1IDQ2IDI1IDAgNDUtMjEgNDUtNDYgMC0yNS0yMC00NS00NS00NXoiIGhvcml6LWFkdi14PSIxMDAwIiAvPgo8Z2x5cGggZ2x5cGgtbmFtZT0iaW5mb19jaXJjbGUiIHVuaWNvZGU9IiYjeGVhMGM7IiBkPSJtNTAwIDUyMmMzMiAwIDU3IDI2IDU3IDU4IDAgMzEtMjUgNTctNTcgNTctMzIgMC01Ny0yNi01Ny01NyAwLTMyIDI1LTU4IDU3LTU4eiBtNTctNTdoLTE0M3YtMjloNTd2LTMxNmgtNTd2LTI4aDIwMXYyOGgtNTh2MzQ1eiBtLTQzIDM0NGMtMjY4IDAtNDczLTIwNS00NzMtNDczIDAtMjQwIDIwNS00NDUgNDczLTQ0NSAyNDAgMCA0NDUgMjA1IDQ0NSA0NDUgMCAyNjgtMjA1IDQ3My00NDUgNDczeiBtLTE0LTg2MWMtMjIyIDAtNDAyIDE4MC00MDIgNDAyIDAgMjIyIDE4MCA0MDIgNDAyIDQwMiAyMjIgMCA0MDItMTgwIDQwMi00MDIgMC0yMjItMTgwLTQwMi00MDItNDAyeiIgaG9yaXotYWR2LXg9IjEwMDAiIC8+CjxnbHlwaCBnbHlwaC1uYW1lPSJjYW5jZWwiIHVuaWNvZGU9IiYjeGVhMGQ7IiBkPSJtNjU0IDUzMmwtMTU0LTE1NC0xNTQgMTU0LTI4LTI4IDE1NC0xNTQtMTU0LTE1NCAyOC0yOCAxNTQgMTU0IDE1NC0xNTQgMjggMjgtMTU0IDE1NCAxNTQgMTU0eiBtLTE1NCAyNTNjLTI0MCAwLTQzNS0xOTUtNDM1LTQzNSAwLTI0MCAxOTUtNDM1IDQzNS00MzUgMjQwIDAgNDM1IDE5NSA0MzUgNDM1IDAgMjQwLTE5NSA0MzUtNDM1IDQzNXogbTAtODMxYy0yMTggMC0zOTUgMTc4LTM5NSAzOTYgMCAyMTggMTc3IDM5NiAzOTUgMzk2IDIxOCAwIDM5Ni0xNzggMzk2LTM5NiAwLTIxOC0xNzgtMzk2LTM5Ni0zOTZ6IiBob3Jpei1hZHYteD0iMTAwMCIgLz4KPGdseXBoIGdseXBoLW5hbWU9InNlYXJjaCIgdW5pY29kZT0iJiN4ZWEwZTsiIGQ9Im02NTMgMTQwYy02OS01Ni0xNTctOTAtMjUzLTkwLTIyMSAwLTQwMCAxNzktNDAwIDQwMHMxNzkgNDAwIDQwMCA0MDAgNDAwLTE3OSA0MDAtNDAwYzAtOTYtMzQtMTg0LTkwLTI1M2wyOTAtMjkxLTU2LTU2LTI5MSAyOTB6IG0tMjUzLTEwYzE3NyAwIDMyMCAxNDMgMzIwIDMyMHMtMTQzIDMyMC0zMjAgMzIwLTMyMC0xNDMtMzIwLTMyMCAxNDMtMzIwIDMyMC0zMjB6IiBob3Jpei1hZHYteD0iMTAwMCIgLz4KPC9mb250Pgo8L2RlZnM+Cjwvc3ZnPg==) format('svg')}[class*=" weui_icon_"]:before,[class^=weui_icon_]:before{font-family:weui;font-style:normal;font-weight:400;speak:none;display:inline-block;vertical-align:middle;text-decoration:inherit;width:1em;text-align:center;font-variant:normal;text-transform:none;line-height:1em;margin:0}.weui_btn,.weui_dialog_ft a{text-decoration:none;-webkit-tap-highlight-color:transparent}.weui_icon_circle:before{content:"\EA01"}.weui_icon_download:before{content:"\EA02"}.weui_icon_info:before{content:"\EA03"}.weui_icon_safe_success:before{content:"\EA04"}.weui_icon_safe_warn:before{content:"\EA05"}.weui_icon_success:before{content:"\EA06";font-size:23px;color:#09BB07}.weui_icon_success_circle:before{content:"\EA07"}.weui_icon_success_no_circle:before{content:"\EA08"}.weui_icon_waiting:before{content:"\EA09";font-size:23px;color:#10AEFF}.weui_icon_waiting_circle:before{content:"\EA0A"}.weui_icon_warn:before{content:"\EA0B";font-size:23px;color:#F43530}.weui_icon_info_circle:before{content:"\EA0C"}.weui_icon_cancel:before{content:"\EA0D"}.weui_icon_info:before{font-size:23px;color:#10AEFF}.weui_icon_success_circle:before,.weui_icon_success_no_circle:before{font-size:23px;color:#09BB07}.weui_icon_waiting_circle:before{font-size:23px;color:#10AEFF}.weui_icon_circle:before{font-size:23px;color:#C9C9C9}.weui_icon_download:before,.weui_icon_info_circle:before{font-size:23px;color:#09BB07}.weui_icon_safe_success:before{color:#09BB07}.weui_icon_safe_warn:before{color:#FFBE00}.weui_icon_cancel:before{color:#F43530;font-size:22px}.weui_icon_search:before{content:"\EA0E";color:#B2B2B2;font-size:14px}.weui_icon_msg:before,.weui_icon_safe:before{font-size:104px}.weui_icon_warn.weui_icon_msg:before{color:#F76260}.weui_btn.weui_btn_mini{line-height:1.9;font-size:14px;padding:0 .75em;display:inline-block}button.weui_btn,input.weui_btn{width:100%;border-width:0;outline:0;-webkit-appearance:none}button.weui_btn:focus,input.weui_btn:focus{outline:0}button.weui_btn_inline,button.weui_btn_mini,input.weui_btn_inline,input.weui_btn_mini{width:auto}.weui_btn+.weui_btn{margin-top:15px}.weui_btn.weui_btn_inline+.weui_btn.weui_btn_inline{margin-top:auto;margin-left:15px}.weui_btn_area{margin:1.17647059em 15px .3em}.weui_btn_area.weui_btn_area_inline{-webkit-display:-webkit-box;-webkit-display:-webkit-flex;display:-webkit-box;display:-ms-flexbox;display:flex}.weui_btn_area.weui_btn_area_inline .weui_btn{margin-top:auto;margin-right:15px;width:100%;-webkit-flex:1;-webkit-box-flex:1;-ms-flex:1;flex:1}.weui_btn_area.weui_btn_area_inline .weui_btn:last-child{margin-right:0}.weui_btn{position:relative;display:block;margin-left:auto;margin-right:auto;padding-left:14px;padding-right:14px;font-size:18px;text-align:center;color:#FFF;line-height:2.33333333;border-radius:5px;overflow:hidden}.weui_btn:after,.weui_cell:before{content:" ";position:absolute}.weui_btn:after{width:200%;height:200%;top:0;left:0;border:1px solid rgba(0,0,0,.2);-webkit-transform:scale(.5);-ms-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;border-radius:10px}.weui_btn.weui_btn_inline{display:inline-block}.weui_btn_default{background-color:#F7F7F7;color:#454545}.weui_btn_default:not(.weui_btn_disabled):visited{color:#454545}.weui_btn_default:not(.weui_btn_disabled):active{color:#A1A1A1;background-color:#DEDEDE}.weui_btn_primary{background-color:#04BE02}.weui_btn_primary:not(.weui_btn_disabled):visited{color:#FFF}.weui_btn_primary:not(.weui_btn_disabled):active{color:rgba(255,255,255,.4);background-color:#039702}.weui_btn_warn{background-color:#EF4F4F}.weui_btn_warn:not(.weui_btn_disabled):visited{color:#FFF}.weui_btn_warn:not(.weui_btn_disabled):active{color:rgba(255,255,255,.4);background-color:#C13E3E}.weui_btn_disabled{color:rgba(255,255,255,.6)}.weui_btn_disabled.weui_btn_default{color:#C9C9C9}.weui_btn_plain_primary{color:#04BE02;border:1px solid #04BE02}button.weui_btn_plain_primary,input.weui_btn_plain_primary{border-width:1px;background-color:transparent}.weui_btn_plain_primary:active{border-color:#039702}.weui_btn_plain_primary:after{border-width:0}.weui_btn_plain_default{color:#5A5A5A;border:1px solid #5A5A5A}button.weui_btn_plain_default,input.weui_btn_plain_default{border-width:1px;background-color:transparent}.weui_btn_plain_default:after{border-width:0}.weui_cell:before,.weui_cells:before{top:0;border-top:1px solid #D9D9D9;-webkit-transform:scaleY(.5);-ms-transform:scaleY(.5)}.weui_cell:before{width:100%;height:1px;color:#D9D9D9;-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;transform:scaleY(.5);left:15px}.weui_cells:before,.weui_grids:before{-webkit-transform-origin:0 0;-ms-transform-origin:0 0}.weui_cell:first-child:before{display:none}.weui_cells{margin-top:1.17647059em;background-color:#FFF;line-height:1.41176471;font-size:17px;overflow:hidden;position:relative}.weui_cells_access .weui_cell:not(.no_access):active,.weui_cells_checkbox .weui_cell:active,.weui_cells_radio .weui_cell:active{background-color:#ECECEC}.weui_cells_tips,.weui_cells_title{padding-left:15px;padding-right:15px;font-size:14px}.weui_cells:after,.weui_cells:before{position:absolute;left:0;width:100%;height:1px;color:#D9D9D9;content:" "}.weui_cells:before{transform-origin:0 0;transform:scaleY(.5)}.weui_cells:after{bottom:0;border-bottom:1px solid #D9D9D9;-webkit-transform-origin:0 100%;-ms-transform-origin:0 100%;transform-origin:0 100%;-webkit-transform:scaleY(.5);-ms-transform:scaleY(.5);transform:scaleY(.5)}.weui_cells_title{margin-top:.77em;margin-bottom:.3em;color:#888}.weui_cells_title+.weui_cells{margin-top:0}.weui_cells_tips{margin-top:.3em;color:#888}.weui_cell{padding:10px 15px;position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.weui_cell_ft{text-align:right;color:#888}.weui_cell_primary{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.weui_cells_access .weui_cell:not(.no_access){-webkit-tap-highlight-color:transparent}.weui_cells_access a.weui_cell{color:inherit}.weui_cells_access .weui_cell_ft:after{content:" ";display:inline-block;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);height:6px;width:6px;border-width:2px 2px 0 0;border-color:#C8C8CD;border-style:solid;position:relative;top:-2px;top:-1px;margin-left:.3em}.weui_check_label{-webkit-tap-highlight-color:transparent}.weui_check{position:absolute;left:-9999em}.weui_cells_radio .weui_cell_ft{padding-left:.35em}.weui_cells_radio .weui_check:checked+.weui_icon_checked:before{content:'\EA08';color:#09BB07;font-size:16px}.weui_cells_checkbox .weui_cell_hd{padding-right:.35em}.weui_cells_checkbox .weui_icon_checked:before{content:'\EA01';color:#C9C9C9;font-size:23px;display:block}.weui_cells_checkbox .weui_check:checked+.weui_icon_checked:before{content:'\EA06';color:#09BB07}.weui_input,.weui_textarea{border:0;color:inherit;outline:0}.weui_label{display:block;width:3em}.weui_input{width:100%;background-color:transparent;font-size:inherit;height:1.41176471em;line-height:1.41176471}.weui_input::-webkit-inner-spin-button,.weui_input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.weui_textarea{display:block;resize:none;width:100%;font-size:1em;line-height:inherit}.weui_textarea_counter{color:#B2B2B2;text-align:right}.weui_dialog,.weui_grid_label,.weui_msg,.weui_toptips{text-align:center}.weui_cell_warn .weui_textarea_counter{color:#E64340}.weui_toptips{display:none;position:fixed;-webkit-transform:translateZ(0);width:100%;top:0;line-height:2.3;font-size:14px;color:#FFF;z-index:2}.weui_toptips.weui_warn{background-color:#E64340}.weui_cells_form .weui_cell_warn{color:#E64340}.weui_cells_form .weui_cell_warn .weui_icon_warn{display:inline-block}.weui_cells_form .weui_cell_hd{padding-right:.3em}.weui_cells_form .weui_cell_ft{font-size:0}.weui_cells_form .weui_icon_warn{display:none}.weui_cell_select .weui_cell_bd:after,.weui_select_before .weui_cell_hd:before{content:" ";display:inline-block;margin-top:-3px}.weui_cell_select{padding:0}.weui_select,.weui_select_after,.weui_select_before .weui_cell_bd{padding-left:15px}.weui_cell_select .weui_select{padding-right:30px}.weui_cell_select .weui_cell_bd:after{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);height:6px;width:6px;border-width:2px 2px 0 0;border-color:#C8C8CD;border-style:solid;position:absolute;top:50%;right:15px}.weui_grid:before,.weui_select_before .weui_cell_hd:after{-webkit-transform-origin:0 100%;-ms-transform-origin:0 100%}.weui_select,.weui_select_before .weui_cell_hd{position:relative}.weui_select{border:0;outline:0;background-color:transparent;width:100%;font-size:inherit;height:44px;z-index:1}.weui_select_before{padding-right:15px}.weui_select_before .weui_select{width:auto}.weui_select_before .weui_cell_hd:after{content:" ";position:absolute;right:0;top:0;width:1px;height:100%;border-right:1px solid #D9D9D9;color:#D9D9D9;transform-origin:0 100%;-webkit-transform:scaleX(.5);-ms-transform:scaleX(.5);transform:scaleX(.5)}.weui_select_before .weui_cell_hd:before{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);height:6px;width:6px;border-width:2px 2px 0 0;border-color:#C8C8CD;border-style:solid;position:absolute;top:50%;right:15px}.weui_select_before .weui_cell_bd:after{display:none}.weui_vcode{padding-top:0;padding-right:0;padding-bottom:0}.weui_vcode .weui_cell_ft img{margin-left:5px;height:44px;vertical-align:middle}.weui_cell_switch{padding-top:6px;padding-bottom:6px}.weui_switch{-moz-appearance:none;appearance:none;position:relative;width:52px;height:32px;border:1px solid #DFDFDF;outline:0;border-radius:16px;background:#DFDFDF}.weui_switch:after,.weui_switch:before{position:absolute;height:30px;border-radius:15px;top:0;left:0;content:" "}.weui_switch:before{width:50px;background-color:#FDFDFD;-webkit-transition:-webkit-transform .3s;transition:transform .3s}.weui_switch:after{width:30px;background-color:#FFF;box-shadow:0 1px 3px rgba(0,0,0,.4);-webkit-transition:-webkit-transform .3s;transition:transform .3s}.weui_switch:checked{border-color:#04BE02;background-color:#04BE02}.weui_switch:checked:before{-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}.weui_switch:checked:after{-webkit-transform:translateX(20px);-ms-transform:translateX(20px);transform:translateX(20px)}.weui_uploader_hd{padding-top:0;padding-right:0;padding-left:0}.weui_uploader_hd .weui_cell_ft{font-size:1em}.weui_uploader_bd{margin-bottom:-4px;margin-right:-9px;overflow:hidden}.weui_uploader_file,.weui_uploader_input_wrp{margin-right:9px;margin-bottom:9px;float:left}.weui_uploader_files{list-style:none}.weui_uploader_file{width:79px;height:79px;background:center center no-repeat;background-size:cover}.weui_uploader_status{position:relative}.weui_uploader_status:before{content:" ";position:absolute;top:0;right:0;bottom:0;left:0;background-color:rgba(0,0,0,.5)}.weui_uploader_status .weui_uploader_status_content{position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);color:#FFF}.weui_uploader_status .weui_icon_warn{display:block}.weui_uploader_input_wrp{position:relative;width:77px;height:77px;border:1px solid #D9D9D9}.weui_uploader_input_wrp:after,.weui_uploader_input_wrp:before{content:" ";position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background-color:#D9D9D9}.weui_uploader_input_wrp:before{width:2px;height:39.5px}.weui_uploader_input_wrp:after{width:39.5px;height:2px}.weui_uploader_input_wrp:active{border-color:#999}.weui_uploader_input_wrp:active:after,.weui_uploader_input_wrp:active:before{background-color:#999}.weui_uploader_input{position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;opacity:0;-webkit-tap-highlight-color:transparent}.weui_msg{padding-top:36px}.weui_msg .weui_icon_area{margin-bottom:30px}.weui_msg .weui_text_area{margin-bottom:25px;padding:0 20px}.weui_msg .weui_msg_title{margin-bottom:5px;font-weight:400;font-size:20px}.weui_msg .weui_msg_desc{font-size:14px;color:#888}.weui_msg .weui_opr_area{margin-bottom:25px}.weui_msg .weui_extra_area{margin-bottom:15px;font-size:14px;color:#888}.weui_msg .weui_extra_area a{color:#61749B}@media screen and (min-height:438px){.weui_extra_area{position:fixed;left:0;bottom:0;width:100%;text-align:center}}.weui_article{padding:20px 15px;font-size:15px}.weui_article section{margin-bottom:1.5em}.weui_article h1{font-size:17px;font-weight:400;margin-bottom:.75em}.weui_article h2{font-size:16px;font-weight:400;margin-bottom:.3em}.weui_article h3{font-weight:400;font-size:15px}.weui_progress{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.weui_progress_bar{background-color:#EBEBEB;height:3px;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.weui_progress_inner_bar{width:0;height:100%;background-color:#09BB07}.weui_progress_opr{display:block;margin-left:15px;font-size:0}.weui_grids{position:relative;overflow:hidden}.weui_grids:after,.weui_grids:before{content:" ";position:absolute;color:#D9D9D9;top:0;left:0}.weui_grids:before{width:100%;height:1px;border-top:1px solid #D9D9D9;transform-origin:0 0;-webkit-transform:scaleY(.5);-ms-transform:scaleY(.5);transform:scaleY(.5)}.weui_dialog_ft:after,.weui_grids:after{-webkit-transform-origin:0 0;-ms-transform-origin:0 0}.weui_grids:after{width:1px;height:100%;border-left:1px solid #D9D9D9;transform-origin:0 0;-webkit-transform:scaleX(.5);-ms-transform:scaleX(.5);transform:scaleX(.5)}.weui_grid{position:relative;float:left;padding:20px 10px;width:33.33333333%}.weui_grid:after,.weui_grid:before{content:" ";position:absolute;color:#D9D9D9}.weui_grid:before{top:0;width:1px;height:100%;border-right:1px solid #D9D9D9;transform-origin:0 100%;-webkit-transform:scaleX(.5);-ms-transform:scaleX(.5);transform:scaleX(.5);right:-1px}.weui_grid:after{left:0;bottom:0;width:100%;height:1px;border-bottom:1px solid #D9D9D9;-webkit-transform-origin:0 100%;-ms-transform-origin:0 100%;transform-origin:0 100%;-webkit-transform:scaleY(.5);-ms-transform:scaleY(.5);transform:scaleY(.5)}.weui_grid:active{background-color:#E4E4E4}.weui_grid_icon{width:28px;height:28px;margin:0 auto}.weui_grid_icon img{display:block;width:100%;height:100%}.weui_grid_icon+.weui_grid_label{margin-top:5px}.weui_grid_label{display:block;color:#000;font-size:14px}.weui_dialog{position:fixed;z-index:13;width:85%;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background-color:#FAFAFC;border-radius:3px}.weui_dialog_confirm .weui_dialog .weui_dialog_hd{padding:1.2em 20px .5em}.weui_dialog_confirm .weui_dialog .weui_dialog_bd{text-align:left}.weui_dialog_hd{padding:1.2em 0 .5em}.weui_dialog_title{font-weight:400;font-size:17px}.weui_dialog_bd{padding:0 20px;font-size:15px;color:#888}.weui_dialog_ft{position:relative;line-height:42px;margin-top:20px;font-size:17px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.weui_dialog_ft a{display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;color:#3CC51F}.weui_dialog_confirm .weui_dialog_ft a:after,.weui_dialog_ft:after{content:" ";left:0;top:0;color:#D5D5D6}.weui_dialog_ft a:active{background-color:#EEE}.weui_dialog_ft:after{position:absolute;width:100%;height:1px;border-top:1px solid #D5D5D6;transform-origin:0 0;-webkit-transform:scaleY(.5);-ms-transform:scaleY(.5);transform:scaleY(.5)}.weui_dialog_confirm .weui_dialog_ft a{position:relative}.weui_dialog_confirm .weui_dialog_ft a:after{position:absolute;width:1px;height:100%;border-left:1px solid #D5D5D6;-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleX(.5);-ms-transform:scaleX(.5);transform:scaleX(.5)}.weui_dialog_confirm .weui_dialog_ft a:first-child:after{display:none}.weui_btn_dialog.default{color:#353535}.weui_btn_dialog.primary{color:#0BB20C}@media screen and (min-width:1024px){.weui_dialog{width:35%}}.weui_toast{position:fixed;z-index:3;width:7.6em;min-height:7.6em;top:180px;left:50%;margin-left:-3.8em;background:rgba(40,40,40,.75);text-align:center;border-radius:5px;color:#FFF}.weui_icon_toast{margin:22px 0 0;display:block}.weui_icon_toast:before{content:'\EA08';color:#FFF;font-size:55px}.weui_toast_content{margin:0 0 15px}.weui_loading_toast .weui_toast_content{margin-top:64%;font-size:14px}.weui_loading{position:absolute;width:0;z-index:2000000000;left:50%;top:38%}.weui_loading_leaf{position:absolute;top:-1px;opacity:.25}.weui_loading_leaf:before{content:" ";position:absolute;width:8.14px;height:3.08px;background:#d1d1d5;box-shadow:rgba(0,0,0,.0980392) 0 0 1px;border-radius:1px;-webkit-transform-origin:left 50% 0;-ms-transform-origin:left 50% 0;transform-origin:left 50% 0}.weui_mask,.weui_mask_transition,.weui_mask_transparent{z-index:1;height:100%;position:fixed;left:0;top:0;width:100%}.weui_loading_leaf_0{-webkit-animation:opacity-60-25-0-12 1.25s linear infinite;animation:opacity-60-25-0-12 1.25s linear infinite}.weui_loading_leaf_0:before{-webkit-transform:rotate(0) translate(7.92px,0);-ms-transform:rotate(0) translate(7.92px,0);transform:rotate(0) translate(7.92px,0)}.weui_loading_leaf_1{-webkit-animation:opacity-60-25-1-12 1.25s linear infinite;animation:opacity-60-25-1-12 1.25s linear infinite}.weui_loading_leaf_1:before{-webkit-transform:rotate(30deg) translate(7.92px,0);-ms-transform:rotate(30deg) translate(7.92px,0);transform:rotate(30deg) translate(7.92px,0)}.weui_loading_leaf_2{-webkit-animation:opacity-60-25-2-12 1.25s linear infinite;animation:opacity-60-25-2-12 1.25s linear infinite}.weui_loading_leaf_2:before{-webkit-transform:rotate(60deg) translate(7.92px,0);-ms-transform:rotate(60deg) translate(7.92px,0);transform:rotate(60deg) translate(7.92px,0)}.weui_loading_leaf_3{-webkit-animation:opacity-60-25-3-12 1.25s linear infinite;animation:opacity-60-25-3-12 1.25s linear infinite}.weui_loading_leaf_3:before{-webkit-transform:rotate(90deg) translate(7.92px,0);-ms-transform:rotate(90deg) translate(7.92px,0);transform:rotate(90deg) translate(7.92px,0)}.weui_loading_leaf_4{-webkit-animation:opacity-60-25-4-12 1.25s linear infinite;animation:opacity-60-25-4-12 1.25s linear infinite}.weui_loading_leaf_4:before{-webkit-transform:rotate(120deg) translate(7.92px,0);-ms-transform:rotate(120deg) translate(7.92px,0);transform:rotate(120deg) translate(7.92px,0)}.weui_loading_leaf_5{-webkit-animation:opacity-60-25-5-12 1.25s linear infinite;animation:opacity-60-25-5-12 1.25s linear infinite}.weui_loading_leaf_5:before{-webkit-transform:rotate(150deg) translate(7.92px,0);-ms-transform:rotate(150deg) translate(7.92px,0);transform:rotate(150deg) translate(7.92px,0)}.weui_loading_leaf_6{-webkit-animation:opacity-60-25-6-12 1.25s linear infinite;animation:opacity-60-25-6-12 1.25s linear infinite}.weui_loading_leaf_6:before{-webkit-transform:rotate(180deg) translate(7.92px,0);-ms-transform:rotate(180deg) translate(7.92px,0);transform:rotate(180deg) translate(7.92px,0)}.weui_loading_leaf_7{-webkit-animation:opacity-60-25-7-12 1.25s linear infinite;animation:opacity-60-25-7-12 1.25s linear infinite}.weui_loading_leaf_7:before{-webkit-transform:rotate(210deg) translate(7.92px,0);-ms-transform:rotate(210deg) translate(7.92px,0);transform:rotate(210deg) translate(7.92px,0)}.weui_loading_leaf_8{-webkit-animation:opacity-60-25-8-12 1.25s linear infinite;animation:opacity-60-25-8-12 1.25s linear infinite}.weui_loading_leaf_8:before{-webkit-transform:rotate(240deg) translate(7.92px,0);-ms-transform:rotate(240deg) translate(7.92px,0);transform:rotate(240deg) translate(7.92px,0)}.weui_loading_leaf_9{-webkit-animation:opacity-60-25-9-12 1.25s linear infinite;animation:opacity-60-25-9-12 1.25s linear infinite}.weui_loading_leaf_9:before{-webkit-transform:rotate(270deg) translate(7.92px,0);-ms-transform:rotate(270deg) translate(7.92px,0);transform:rotate(270deg) translate(7.92px,0)}.weui_loading_leaf_10{-webkit-animation:opacity-60-25-10-12 1.25s linear infinite;animation:opacity-60-25-10-12 1.25s linear infinite}.weui_loading_leaf_10:before{-webkit-transform:rotate(300deg) translate(7.92px,0);-ms-transform:rotate(300deg) translate(7.92px,0);transform:rotate(300deg) translate(7.92px,0)}.weui_loading_leaf_11{-webkit-animation:opacity-60-25-11-12 1.25s linear infinite;animation:opacity-60-25-11-12 1.25s linear infinite}.weui_loading_leaf_11:before{-webkit-transform:rotate(330deg) translate(7.92px,0);-ms-transform:rotate(330deg) translate(7.92px,0);transform:rotate(330deg) translate(7.92px,0)}@-webkit-keyframes opacity-60-25-0-12{0%,0.01%{opacity:.25}0.02%{opacity:1}100%,60.01%{opacity:.25}}@-webkit-keyframes opacity-60-25-1-12{0%,8.34333%{opacity:.25}8.35333%{opacity:1}100%,68.3433%{opacity:.25}}@-webkit-keyframes opacity-60-25-2-12{0%,16.6767%{opacity:.25}16.6867%{opacity:1}100%,76.6767%{opacity:.25}}@-webkit-keyframes opacity-60-25-3-12{0%,25.01%{opacity:.25}25.02%{opacity:1}100%,85.01%{opacity:.25}}@-webkit-keyframes opacity-60-25-4-12{0%,33.3433%{opacity:.25}33.3533%{opacity:1}100%,93.3433%{opacity:.25}}@-webkit-keyframes opacity-60-25-5-12{0%{opacity:.270958333333333}41.6767%{opacity:.25}41.6867%{opacity:1}1.67667%{opacity:.25}100%{opacity:.270958333333333}}@-webkit-keyframes opacity-60-25-6-12{0%{opacity:.375125}50.01%{opacity:.25}50.02%{opacity:1}10.01%{opacity:.25}100%{opacity:.375125}}@-webkit-keyframes opacity-60-25-7-12{0%{opacity:.479291666666667}58.3433%{opacity:.25}58.3533%{opacity:1}18.3433%{opacity:.25}100%{opacity:.479291666666667}}@-webkit-keyframes opacity-60-25-8-12{0%{opacity:.583458333333333}66.6767%{opacity:.25}66.6867%{opacity:1}26.6767%{opacity:.25}100%{opacity:.583458333333333}}@-webkit-keyframes opacity-60-25-9-12{0%{opacity:.687625}75.01%{opacity:.25}75.02%{opacity:1}35.01%{opacity:.25}100%{opacity:.687625}}@-webkit-keyframes opacity-60-25-10-12{0%{opacity:.791791666666667}83.3433%{opacity:.25}83.3533%{opacity:1}43.3433%{opacity:.25}100%{opacity:.791791666666667}}@-webkit-keyframes opacity-60-25-11-12{0%{opacity:.895958333333333}91.6767%{opacity:.25}91.6867%{opacity:1}51.6767%{opacity:.25}100%{opacity:.895958333333333}}.weui_mask{background:rgba(0,0,0,.6)}.weui_mask_transition{display:none;background:0 0;-webkit-transition:background .3s;transition:background .3s}.weui_fade_toggle{background:rgba(0,0,0,.6)}.weui_actionsheet{position:fixed;left:0;bottom:0;-webkit-transform:translate(0,100%);-ms-transform:translate(0,100%);transform:translate(0,100%);-webkit-backface-visibility:hidden;backface-visibility:hidden;z-index:2;width:100%;background-color:#EFEFF4;-webkit-transition:-webkit-transform .3s;transition:transform .3s}.weui_actionsheet_menu{background-color:#FFF}.weui_actionsheet_action{margin-top:6px;background-color:#FFF}.weui_actionsheet_cell{position:relative;padding:10px 0;text-align:center;font-size:18px}.weui_actionsheet_cell:before{content:" ";position:absolute;left:0;top:0;width:100%;height:1px;border-top:1px solid #D9D9D9;color:#D9D9D9;-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(.5);-ms-transform:scaleY(.5);transform:scaleY(.5)}.weui_actionsheet_cell:active{background-color:#ECECEC}.weui_actionsheet_cell:first-child:before{display:none}.weui_actionsheet_toggle{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)} \ No newline at end of file From a585d618f174e2bac23f12e624d29fa8e23ada13 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 21:49:22 +0800 Subject: [PATCH 024/507] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/bind.html.erb | 29 +++++++++++++++---- app/views/wechats/login.html.erb | 48 +++++++++++++++++--------------- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/app/views/wechats/bind.html.erb b/app/views/wechats/bind.html.erb index e569162b2..755a2df4d 100644 --- a/app/views/wechats/bind.html.erb +++ b/app/views/wechats/bind.html.erb @@ -1,14 +1,31 @@ - + - Ruby China - - - + + + 绑定用户 + -

恭喜! 绑定成功.

+
+
+
+
+

操作成功

+

内容详情,可根据实际需要安排

+
+
+

+ 确定 + 取消 +

+
+ +
+
\ No newline at end of file diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index cbc476f26..f323b0a1d 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -1,12 +1,11 @@ - + - Ruby China - - - - - + + + 绑定用户 + +
@@ -14,27 +13,30 @@ <%= @wechat_bind_errors %>

- <%= form_tag(bind_wechat_path,:id=>'main_login_form',:method=>'post') do %> -
- <%= text_field_tag 'username', params[:username], :tabindex => '1' , - :class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称', :onkeypress => "user_name_keypress(event);"%> - -
- <% if Setting.openid? %> -
- <%= text_field_tag "openid_url", nil, :tabindex => '3',:placeholder=>'请输入OpenId URL' %> + + <%= form_tag(bind_wechat_path,:id=>'main_login_form',:method=>'post') do %> +
+
+
+
+
- <% end %> -
- - <%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码', :onkeypress => "user_name_keypress(event);"%> -
+
+ +
+
+
+ +
+
-
- <%= submit_tag '绑定' %> +
+ 确定 +
+
<% end %> From a5cc5d376142384518830d373b8f3afce17ae05f Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 21:52:36 +0800 Subject: [PATCH 025/507] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/bind.html.erb | 2 +- app/views/wechats/login.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/wechats/bind.html.erb b/app/views/wechats/bind.html.erb index 755a2df4d..ab35351c4 100644 --- a/app/views/wechats/bind.html.erb +++ b/app/views/wechats/bind.html.erb @@ -4,7 +4,7 @@ 绑定用户 - + diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index f323b0a1d..a079ca6a0 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -4,7 +4,7 @@ 绑定用户 - +
From 9f49a20a698a8153480e1ac3b868b005fde29fca Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 21:55:50 +0800 Subject: [PATCH 026/507] =?UTF-8?q?=E5=81=9C=E7=94=A8miniprofiler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d8d148ec3..95484139d 100644 --- a/Gemfile +++ b/Gemfile @@ -44,7 +44,7 @@ gem 'elasticsearch-rails' group :development do gem 'grape-swagger' gem 'better_errors', '~> 1.1.0' - gem 'rack-mini-profiler', '~> 0.9.3' + # gem 'rack-mini-profiler', '~> 0.9.3' if RUBY_PLATFORM =~ /w32/ gem 'win32console' end From e576b5a800f75fb8147bce7225efff4d8f855540 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 21:57:48 +0800 Subject: [PATCH 027/507] =?UTF-8?q?=E5=85=B3=E9=97=ADiphone=E9=A6=96?= =?UTF-8?q?=E5=AD=97=E5=A4=A7=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/login.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index a079ca6a0..c305cd9d5 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -20,7 +20,7 @@
- +
From 7e18fe19be8f0db7d0655dc54a5f8d74e3ca425a Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 22:01:45 +0800 Subject: [PATCH 028/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=82=E5=90=88?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=9B=BE=E6=96=87=E7=9A=84=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/images/trustie_logo2.png | Bin 0 -> 106513 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 public/stylesheets/images/trustie_logo2.png diff --git a/public/stylesheets/images/trustie_logo2.png b/public/stylesheets/images/trustie_logo2.png new file mode 100644 index 0000000000000000000000000000000000000000..bee75165ee5486e8f02070ebe283d7bc6b5bb4e6 GIT binary patch literal 106513 zcmaI7Wk6ibl0Q7SOYq?C?(XjH4ub@DcXtTx4uRkr+}$C#I|PRygT6d>_ukzP@BYuH zK7Go%TBf?{H&M!pQb_Q)@Bjb+Nk&>+6#xJa1OUKF?TQp63f_`SOQgnCgxsFV?cfY0K&;yUE5V#L7vyl!H&`79~wqaJI7CM0Dxb} z)6vAt2Ixv`3beGg7a+ar=piMxHWwh(;!t2#a1;YtSxb961J%40)y=$Z%y`U6g#?ND zJ$XL`*a2Nlh&}CW?Ok|11xWuTm-n;%Pd5`O@xMr1Z3IaF%P4IHWnwW0XCN^LBL{;S zGYdO07Y`!~2Maql3q3I_GYcCNGaC~N8v_d~FEbA>3kUIkKct`9oXstGRmCO$Ti55C z0I8L$t0ONHlZS@~qX!$KgR>&CqHN{h>fmDK;7BYcMog_>VrFgs&pXY( z7!(wEW$ayCP3+BpGU5WHpQ0J9t<8D4Sy@C_SS5KxxkOl5SR^>OS=iVl#Mro5*(5|* zS(&;2%`5I;=4J=9cl|f7`Ty{W{GYu4tSmdnPtD>$XKQz$xumm$9r3?>!E610+rssK z%KL9#^Z(lx?*EgQ>C+gdf7Z$WS~vgh`dp0vH2<>;K41Q`kAU`{Zg>9NB>_6($N;b$ zP8o3#bJym^jh}%=JL|&Bz?NhQ9CC9H#Jh! z!$>bR)oa>g!(-)Ueihu7*g6E*w6e4M`b=IEcca|kv zoM9GCY79yc(Por5_^Tzq+<(Z(2yIXyc|-QQD$Hq9zoYOf4H7f|FClhFLfvdRFh~QD zmQ?@Ky-$xLN#Tm~spUTkIgkPS|ET?U2So4xv=cn5>XTy2i3u%_9V-j9Q;$^+-TpB^ zF-D;3Ri;~Da?h`GPzO0F{lJGjZw&`9{ArX_{h%rX;SIMROyfhPalJC3DW(Ve&GEi~ zK@Y#VV0H$nu_u2k3m{gCf7){h?Njl7Qv{`Xh_DlN4K>VxSEuEk*Gqk%$H#dRr26q$ zCR=(*Pr9~aJat;me=+$c;l$K`a>X()X1D@qVMA$1>>b-&iZw=}LVGeyqE1zZmVi~emr5EF>;N}|jc+%P0$rM&qYo8E z3)WVG7j8&L;wCbfcdMOQj^Y5BXn5nS*6iV)i@EW`ZxSV;AaUxJN&y*At*E8RhzB*0 z(dtbJ}xgY9N?M^zTVwP11!}qR;uRj4$H^GWhC1Nx<`{`~fNm#|dscQD`Cc?HnH`tF~iar;6eD`^J(70{TxN5i0va3Au{4a=# z8;?}-{O{aHD1@RF`p&YVxQ2LD{oSPtMkNd{-5&lP$YLPE8@7dos2UW5_`YnRgrJ#? z&=!N^j+v~74jp|TKkpiBdlvcI{LLHn!F}61GH&qcAo8PEev60mzOe|x;g#Y9lcPne)8udv5P?MAH0%$Bu9%0{nw^Tc|4@36CbSq+_1{RKHdlx0&(psDuA_NB6 zQQMB@NA!ln%haasjl!Xn`07bzKGGB9TgQHB&|T(UY7vW?Oc!lE3^0<5LBIj+`*B|v z2aKGs&5SowG|Z~fn`i;DZ|geos=hUG+1AeEW+-TiAZsKmt=+RZXr|bHwK-0P8Xvj> zcIzNGUj|M0i6Dc2Ahc|~L$F_LoQ~=9d81za*C|ns0caPEL@2$HA{q$#ctSz^I3&Tq z#x50=`SvdGVxXV>gT% zC@G>;$*h&1a2Cgpt2Pn_6JRz0Med%1q|JB;%dr5I?-$$e7XimT>?1B;5*lT=dH1aL>ZP2nM}&rF#ZZbe zCP>J-;KJo`TNlHRqhBaN8edpr-@97)2=7mxO6qW!`|G4C*~Y*6>{KtsALu(WPoQoFD1H zusXf`d2Q2?7hza9g8@)=jO29{>ZFyE6`DCiwy+$s9naTZ0_XG~Z<+ainh(ck&&l@f{c-kVb%uCu&BBjJCt47( zVb~05M@Z681?$urt27L1@_aKU^YM`+KUc%~UE9hxS)!v^_(pv>cxW@p@4|GKg6<#4cHw~$N+mhiBo}+UwdMfV?lZ@|5 z#nVfNb<6#JEtbLe3uPVIKX7XM9XV^sq0RxhvBGLE^tPG1vj{~%ra4DX+{6ML)J9_s z&K*XWW@6EHlfg8Mx419GzyQy-wL~kdKkmi@YLy4`Jy3#FX<#!q+}R_QZER!)DcvI{ zQX-f-zu^G#4rgU*Jr)`(`VtT)&<}8N(qQ-y^!xo1u5QPjd#5BPtrNeC|mGCTL z=Zm|2ts+Kq5t?xA&r`&S0vQvB8ByuAEIJ<18wkKEl04G#bK94qc=_p!Q3lrcD?rbK zL*8y%ZV3g72|ar#7e+E{zcFTU+C7MlcVERUj_4*uP7VZ&D{!a=JO6+D6 z^)4{x>*c845$1x`4yzN#Dzmw?_PU1bog5X6dRD0J(@_$LRxxI^rwr{FeJp)bSat&fBmtUasHpD29H9nfQ@%qHd{RG26ed^nZ z-WG(Ifp`8d5F1yTGfD#3S1yo`d8eA8-{Ap&Wsq{8019%fU}VW@LW@O^nJ(maiy3HO zrLsf>-T_J;Kl4bJ&HwICw4;oEv>j-?vN8!d9*wHtV=k^fZiMtdW$bY=pSPk;SDwFf zAdCHuRdS1qtUXlY0TnM>3N?0`SjwOUzWyi=;&n5BPHQ?W#agYcx)x&=#457sF@xybA)P z2(2tIi4j=3-jd{`zRMQ7Enqbv+KZDelmrT+q=a-vYka^xg;`dEyK#V-QlM(deED5O zTv=^_Ec{SPUyx`zqW2N+9+XBqHDS)Ij+wA>Nb6*$sy{jn0S$dd2b0J!$c4C4o%VVk|{(1+(f0bgOLv zqJ}N@+wt#8A7tJ&UC>cS7WuCN2(rFcMN! zDMl*&8x^Z?s~bYxy?!rLtrfq6D^eK5E*>nK>cTGVg_|W^{%a^-MHv{2dM|$&`|`-vz$+%N(KI znCnIofs7x6t)nU>`P)Pn_7pH`kI7&@P^igg&x3_SQ;pm)1JWb3I6|)p$XxJNBqr zFJ0x^Fd1~9Wtp@Z+98dyYAw~=vlY9jhh2zy7C3iS*?GdLO55GYIPlC#gIbd1$9Kkz zLc`o=|2ZGECIpw~LtYKPy_?WNt)wM@kT&stzJyO#Bsgb{Zo>|2lei7SQowFZLl@p* zo2b_t2hAX&^#CQkQK(DLYk!OeSbZ}oziyUx6@@|LpW{ZyS_1_lR8j6F=3f*JBg~Sz z=}EUI+|Dl#CO6k4T>}8MD=YqKU+%q4xrpG=C~??EdDpbnrwfN7uRBTnH_!~rYkEXd zZZ6bzpY*z92&zGuZ{w~X8V#X{W&%+j6u*&NLzO1cVpycBQkjO0+p*{2W)rbQOIDHd zHgo`mwuI}M`_*vE$E|_w^O4Y)qR@0}qBrs+3Ju*s*T|=XZ2J10TZJP>;unu1lY58h zF;u3Hh1>93gRxZ%Cv~8ZhDc>!S+a~E_alranHVRF+4Gx?Mn3X##hkq310>_+)X0X%Uy5B9a+@5O8P63rltw$@G=-VuJSiDTwbvpr^t^K@3f_=oJ@J2?|5?zQZW_&67a2u&52y&-)6y}i`zCWK&QY}k zuf!5Mzt3J&F0G+5X{aXJhjBMLB~KHn%*t?%#_O#{0^6*$*&&(g2lbvh-ZmGGpd7 z@ggOl=k<`7v_?-qG{C-){6OL|-Eqkm8v&+=l-gQ}lr4=(ki|Gm%Eyj4U$*>0AFbG~ z9_-Wd3JPIHo`-ZqSC~dXM;}dyClg|c+QZQD-WX??nJ!@F2m{v&Ep6jT;rT@eJf^s& zOP71y0k74DMmLswHKgsQPyJPDp}BE>&#q(%JET&Wf9&WMrt#k1gP=?usQ(=y7V;xg zx?eh)EGRT-2gL6 z$PSrFb40Z$2+CzCE9OTHw)Ld;D$xa?OOLNwD^ zf?NE>q?o`{b%hTx4Sxs$#Z(Dc6y>C9J6CX630%tMn{#@HIyu;>wOjU*b^)E0EdSb> zNo&BMh$wV_idz1lO=xV!)EC%9b+c^i4~J|%)uPxX?f>~5-P!_r$QpTvyKXcgN7&yA zw#{s$o|!#%sGbFbr;d(kQja(hLKF;sB8-2$wBh9~T#3IZIBZ0e(9#VSMj(~<2^s5# zcj_=f)^4aj$c!P4#~Kh#G6oiOO$ z&Ks?Up5fy_RA%V=Wr3+Dw2CDOZ z#FyjO&SE(dcxeO#@kkq1VN5X!Ra0S5jB>}y7?P|of%AJT+Qh8A)6;r7%Q5;_`PQ3M zA$a>^OPb_-e5GLaC2Za6d+KhBf*p!nUp76Ft~%m*b1?rP$mn>nO!J?C8DD7ru)wrl z6VTQs!SFP325&RY87;ClTVL?Q&PAmp;^^?0R1U^NK>P zD{na@>0vg23X)7htyAgIc-zK%==fl1cGiLshI;0t;5#?@-n0CkmLX_oaC7v;xX?-5ZltM^K3(pEroIem@(x-C{q3hc+2Z`#7Xz% zzI2IdeSxlBlr+2t83L>453hEACNuu79AZ!oYvoPu&CWHSaX`3zjipq4zE9TfY5v^TbjEFdAGzS2BH0)v9wms5_jR zz!t5>Jc95E2R}!>UOA;eG%@U6#HClqseScQpD{AYibxZISp@$zb-o@UDNjs+`RQu#BcPQrr%V!tvR=0SciuGiXZ z`+-3VK7ReX=_oLN2A$UJ1Bt3w#{Bk&kXt}F`MMoiIhR`5hRBvGgD>J2N=1uiiLRdO zHFok?O$~s!8D8DU5o66pLFvH~qYBT|4Lsbt2 zSp0v9FKg~#4WIwq5cW-W8VN|S*4)5{X*D~6;q zRX0Yexz(WG!y+Zn&!!cAm5KSqhB_Fmzc(4}y9xRIr%J~QR(xD2t5S!zhD1*WXrV4P zQ*gP`XY)HoH}Z9NWjaGm0i&Wjp|Z;7M-DXlt3@ZK4^vz$53N!x&nLwhUS|r(lot93 zr82=tlsuF439wq>v29DS?bHw?2=IliW~s(or$Yjc-w0SrHiS?_dBpn}d+moT zqGLNMAYfQtw%_p-1wj}sevdvYPtCQ&Yy|*v$=#cW*=(F%^LA#{Idp7YHixdTsPw#% z*P8)vmltSkHnsj%WP*5?=*(%xCi_iF7qYXiWEIOM&nIe&El>12se~~PI1|&ACADI9 z8^(*!29zP>$-fT;z;$Hy>g^J}7kX%@pA;+{A(W`W#?eI*(koLvlfPKfX5`$#lX!(+ zJ(5JpT&6_7zpt>4m1}?04y#5nK1H%K;lm&X)Kar2g#{>Z?n4M={C$?n7@?=9i4L2% z_8bJvI*@q!ni{sGwfo-=4B!Mj)5LBB^dR0@NGbl>ttqK&${Ytexcy*Of3JZ3$jz@% z+?R)M9#HCHHY>m8@9&WJjEosQBkjjf`o6{?91IWZz(6t+kmq@iIT^DtWhPa3;qwu@ zbm!p}op72dRW%&*Al0wl_RI5tc{tx2F_}p)!c_3MhN1<-im2Cq2}0C0I!!+J!x0Lm zHAJLPU+!sYIfp}tGkgr&uy-<#iySHG_{MM^(^EL4bCdLlf{mNnYbZADXkqr12SL2F zVI;#$gC&0+Y2n4!4r5p{2~UvmuE@n~pE_2l$npCJKTmZ3U&!b?&H8X1dJz-9iW5+= zGFkUHVXPE{GcSK`hy)GA?lm)F%v|5i^cZ;kiJ%WMAVtC&96*T(2ar(7KcS+x8elzp zE;Y&fb0t+-i<0^7W`&EN=(QoK#wIGqvdL~y`i4IQ-K&EFpaFo>{NCq$y!7F|>4m_5 zdV^E*c_8ljb>jU^Rk+}#1cvReugDqKz_K3IAS1;uyR{-`Y;A&N&-Pn&hV`z67Jg7x zO0ufCv>;PBcAo4toI`^i&J+sL?hb*+==g%2(39ZW%z9~OJDL~0MqO|SAqQ9nWuBKN zmXdh_iWdbbk}1{gaW$(mUBD0tT~Tcp^hLS>){i_SUXJ46*=MpIw4hMrdP7UIlAi6ymJ+aF*S zTfXQnSDjRRzYchwCKBR_g*d{Bb{II^h>)tIb0S4diuuYkpUV!Prhl{~U3$Rk)}>*Y zx3|yEFUKq)h3GTdN=$@d7hQapn{&SejXDO7B65UJqGp3zLIJ9#s16xnMjDG%y&dIT zpPQGNT|eG%{I5kOyC3tamK0V9$%^|QS;E}K?&-g6rQx<9=`F5m8<+$G(S#SL!~14f zYpKvX^q)9|l~$jeOk6Rjhyw8Kj%}sX9GFzQ`~*?8U*wrj#vrFN{7)%j`5k)@^Rrr5 z`ZB(3IhFjm|6_>LJW_+6cCpcn-lgRWTfP3bMSc*sqdY8`3PiXXlG(Z~(XFm3oX@(i z9-td2Mj+-6^c~xBxae>%e8fdI_PC6scxbqwsZ98u?scZ^r{HA*c1MK2WAhA@?|MZm z+xCUHi{L)l7gnCt0%5l8&n<$;Xdae^$cW+8Tcg*j4QG|6rj3(`5Tp`}&pGs_DUd$X z=5y`9j#zisfCF7u10Rkx_sh?FcC4|gNe)I`IDlB9O=80yGm9&>lT$3d(3p|l^bZKz z@qAjy_^A*kNx)xUkTJzYcMP&b*06xNmS9nrMh+>v+(fP|Yf8+`VQgW+JFcC`gb@1Z zX9-DIK3<$hhUkJC)j4XL3GWQ;K%oQ`U&AAWCVJVxB&VN2d40=HaxQg{$SI3 z>SZleS0ek_w_{8;9)k7i8JczQMz;ZgcWtLA>pk9>dav<~)^>%!C3R@b1U(irXdVH_ z@78IOkbft5GSn}QGRy~7JI-STq_w9-9HYg{H#g1j^00{=QktD&6R-FqQi|avk0!@% zSHe2pa@7p{cG3v!c9_Tqu{Z#PV1&YC=5G#3(MJQ9utOHd~ z9iG8V$jqKZl-)}zBx&Ra6=n1W&XCPnbo}Qhv*SSA$=e{+toO9yFZgY&*^-nNrY>)9d>(DHr_Ub%R+yil8?in!CIX%D-Pdd3eX0C`fzZaH{D~P7cZphD)4Af{6%w*$dyN%(#|CttzTf) zQp$QY3l1#eD4BUtmpEp0$(pFCF7n1Qf2e-@1DWcVs3AUX3!T?R5wZmXx#V12K3UnM6a?yB@ItBJr1V}PprTLb^Nv)SJ`7X z6Ol`$|J#PuJye$4RovJ|>cxm&Yi@{J{ws!eO`GO}O3iE3WOId^Qu!n9oSgS-<}vg0 z@9lbSL6RAvip~WFMB`|+hRf7HHy<324@Hl~MEjbr9PmoT$BpKZaDjMG0lce>G&$w+ zUc-iqVc-^qUYWI<9n7!2`7Ay=fqIbXN!QzTk3rUQYtQ70Ifa-BlH^d0cO75N?7?GE zwZ6-x((}^JiTzaPWO<(E%h(zD96TYO{X0J=JnQSv+J?g-HHN)X=nDM@8=dZ|dek~o zzjj5Wa<_D}?k8iR@b_yN{P&A1ma%GWmO)l&)}x#Ixy;n;ep<2J*)VyHJTuEljtC!& zBJ`P$ zi?lB;RVnLwGC5Lz?wk0Gq2SL&&MCMz&gQ0qs{tYr6c}Zij(r(zKJs#$@TOYJKF$8J zs3@xZ!O=|*v&*>U!!vZ{TTAQH$N8~0^kw4y2!V9{;P(VS{A#|LdxIW`ES+=6DxbVm zNP*-pRghdefk;}JkzaMmYsTgUdmPI`Cf-yPwSp8k5&%pP>`J3tv5WqttG zNWeXUyx;>h4vgyj#AIiDo4H;-{eizqD#aCOppzWdi9jITF#ev)57~g|SvgDzfyFW7 zvuc+=cCP2JcK{L4|C?=Q^ud z^hIWHUr8`1nefGmif z+TttpeBp*-F(I?c9Tqioi4C|%RU}Hn07RINmyh0S2$TY4S`uJ34yB8;Rt~u+)>l@u z_U(z|vA?}lzX-qd+aDco2TV-ibl%gA+OFbrdz9s{frMMv6ju8}fQ;lL`M&T}gx)wV zBk|T>P2XKOQa#xbz{0`Sz8rnkq4a8E%H?w}`e;9!bpruOI0HC@RQbO>f|K^{>gQzk zUmJKhT|ee$cphScnzS|w2Q^bJ;pqptOEfyg=!U3pYReA8tmN7vs^))+JwvOdh&Oiy zYrZ$6KCnG++)-O#n}<3MEIWu*wrZ)A*!YlC6_TP#^?h9I?wY-%Fk}@ z!lo~&3t$X+EU5{Vk`ge9+n_Kj4jG_TXf;WZwjovIO0+r0hi1j3ICjxbEud53y6@F>r=cskd2Ypqm)pr zx>7=LSdKGlhh?N}l&IiL#VhH{I6-l-{_tmcez1_}4YoMI2eJ(B;oc%`w3tPigg55z ziYM`eQPr9H8zl(hOz`H5?bAH=od2!_?yrTjP5JEzmbW}QDwd(J{U{-UK$8@;>TZH{BGzf5hJ*hYya zv4uVi*T+qE#kj1BX>3%bWxxaF1?3FxCiLcu%Ebl(+Tujt9&_F}bvcB2yK3pCmOd-{ zBi-y6rw}7A(jalQ&+-alY|3E*S{E1aL*c!XWNX4GAEOH!9WLKPeX66;c?U6*ePX6m zJ#ANEZoW#NdUS>j5kVg{Al}(41tfC#{cw&h)tK?9O0ZxE|3@MW`pjMNU_M>Of%l2N zvK7&^8+y{iFC*=YYwulNsmf-kkPZ*C>tQ^W>&)y~uT`M*O7#%xH8(Cvw*oxXFSXeC zTYRmefOeD!|5x-_p}VU4u4}5H4X(5DCl(QV35#tGEwlYs4DqYJ_DX1%j`sw|CbIBv;kF)~tGf0!Oe1YX8=c5z>r zMSuLicC+-&ao~@JH(flRNfz$+7e1D;zI?Svvz19Wbr=M21W-2Uk@^l%8|%wt?E}({ zpV3cc70YMDhxbwnAbAovC();L(c=P8Bx^UGY5398?6z;ji`{eiBo@E_4kZ;%)M zvl7B9rp0j;b2x#ntLJbfgIJ6HM0QEz6vBEqW^>L@o(im{Sw)=mL^l6=23CHam^Z}?cMuymGZ83PSIVOhsX5e6F=Ad^@f5$j6q#y00gE}4x8MRR- z178_VnPO!-Wa1 z0>QR3cEvhe-v@25IirIziZVKt8_F5GI`%N(b;tsIVMqMmZ1B7Hk2AJfXD++}>68O^ zs{IwFz}|)g~i%KTLH$bdC7^ z@yUFz5QY9)(#tE1o=L9~vrJ~kqR!MeBWKL8orHB&XR=eQU>Be5#nivwDq46tBCdWRr?7kjckZ;A+i^%vvXnLuu8K4htH=D zK5s~J9^8rs&9AyP5%ZUO<%Pd;U4d9KeT#e{?B#FS*YEIGJ%_@?4!LsgS~WeChJKhA zN`g^oE-iOvmWY6v6pEjWKTnVIMuI+WK6Y399>=zlzpmfGnCe=kq{)!03yHwDW9Wn_ zP{>4OUTix35TO6Ev9TI;xrtr)I6x%v*i0n3eu=Du0OtW{3@`ypG5VMJiu>LHuJ_cXoy275Yn2s-GKUV5G9E*qxLO z8uSt?Q=GmJb3h&`-Jk+6j;D8$S6Zhv?Rdp%2l>f|ClT#NdQGMIwcael_xY=7`=(tj$uub zElLmR4#Kk+{)po$2w|FbH6p59e*WVX7aOd@9t&#qcl-WsW!2Y?(v@FO=&5*1rD*&#&FAzKZ)E(vR-n9n!_lB%+A`S! zMZC73I%X9?jL(ow=Vo0fkiqDK%C`L?KT&77Hn54hHOImJ0$+yem5#rGitrba6o@d( zYac1>JW~U)btx@!rYS3vwW@Q{RSx}G$cuo}_tM2`wO!+pnD#fX3M~cUy$rdecj03H zTyci~nVrso8u*5KW~s7>*D6%Y%|K_1-n1Xn`Ym^oEXm?Vu({mN*RgpSIAVn&c$>4| zxL`Jz0LI5=HHIt8_}rPe;Lk#~APU-CVVFb;JQUZs$x2dbs8Qge6Oy7$e;u`CKc}Rn zQ2<2pj9@}dz%OtHz9sjM8;(>6?Hrtuu@S2@of6c$c8=~oSWWw(Du*xS*;GWwkAne6Sjv$09*ReNG-dc4a&;F%Gu2P z*&$w<>0~Pq5)f4uBK_>_BmE-z29vv9D~Rdr<5PcQTp{QRC9!hEY15cNk3IXNGXe31 zLPCK#RM$)Pwl8hnE80E!pW@Y0?&E zmLcZ0&oKWyUmH@5<|Vw{rZ>pNtNk@$&VCIkl4U7c?$-Pe*{XDb%^&i;H*#ZW@x9=5 zHS)1TC1(@=@v(xw@NC5w@Em9L#~|Vp;{q9|Dbel820P4fs z+Jq3QrpIM~ishpZY_j_e%VOILFJ?fjpdm^ZHbR?2qW`r9foYLah%W?07E#CTO8*HU zm}Hjw%#?Y_3*JLIOU1YQX(AoD2(qQ}nWwIllj31{&d1s+@gPr%H}d)_=CMW7m%k6! zuoUyvnpOoW_goX7O~BLqE6>u&0l;`ay(h9;$#4YQU-Z$qQigB3-K>7xh;xW;X{p6Brp6(m(WwE8WdJwue860Nv{j%=w$mcEi zJ}11D5@VxXs!SJV4~cc_QN0$7n*)}b9Mw-L*o0z_VWp}ld1qKZPE5Bm^4Gx&YQDj7 z<~wZM^re@^(Gb$d=}g9Ik5M-pTm)Ghk7K!Mja-uwn`d4)boUs-i#^U@nS&p~I`@;! zdYjy%C+*H>>S`gW%j7`&Anjo^*F&cN&+BrAf7y zVI=L3QoY%LyD4c`x8*t#v%0#R9i>=RcVtk~7mVRyU)e@vGNxO5uQq>ES0itlmXGCt zzHkR$f{N)&Hh;pO+~hX)U0#9#!-t!F#>5f z*ve5lY0HuH^5k@@Gj$FWV~Yj@h5^^|%xDcd2P0+58JVrOM=2eIJAVwC8{rZ9lG1{V zDCwvqUl*Ib*joIL`Bvyfy^nMD_1a3jBEYwWcL5X417kLP!#gg5VL3IjECbY&J{XwD zHBI*gE`6Z>!a?7D<-#qqS*ASc3S#|lPPnUI(oz4Z?a2a1gFk z4qA|LmfLjW>SAV+F=&|$$3}@I_Ya3aN zD`z}4yDT%>?)N&}arHz^4#({Vm(BCAZRVHi-O-=i|D3%YI17??FZP&mQLlJQdweS_ zA&XuFcFq0;m1v(p(voJg(06eW(Nrr}&#>t;3h9BR$z}+70@RfF!{%Tdu?!1{kP~A7)#cVt8ZKUrXe!wnG7^}RbQurb!ju9zee>En!pq5o<`QuRh(ns!rz}Hb*s=G z5j?Me+eV|QmH<%^q3==6M6MAv_G&;a%iSljVnmp*d)gQlRefP-r?1y;Xh{;P&@nz> z`CnQfv{pbBGW3cH1sO)M^w#B-)g_us-E%`h%MmSh1Cq9{w_5ePHm#suBS)Cf`rQa` zJii*eN{hcw+^xcuuy=hk@Lt+|!RUvZ^x9z6%dUUY+V0>oBe=*uQAJ+BDR_Ml*i zO9E{*5sN}*%L4fQ7`6qRwqrtk&=AunAh>5jk2*A8=FiVFL@*nh@pj4u!zfexRAXf;wFa5ugO36`qw~ zf{mO2rYntF9{@RMYvYFeB^)^JM7_(_I+`0lukAi$OD;oO4SqI}kwv&Vzoa1`C)0l& zYnNW@l$qpFbwy{;7~(JW0=3Fwkirt=Bh-q11fR;Aj`JG3G2n4=DO8*raC<_M1-z1l zU$!Br`51~hInCXN0?!Tm6@}7-v1meu%e8VdS{j&54>U%j?~|-;28L(+6oY%Vl>Axy z3ucK(y2$m#!tHN`dWMrxJ}{;H-}GX8Zo*#`bvR}anedf(n-w=-77Sg?vHeD0hc>Z| zcYYd4&Xfy5Ev4KB*80({uEqb#iO0nZm&uA)>FIu(sAySN5`+czuFIHww@E$i(nyp% zxI2XsIQ-*NbiVz~ILI2mfP_uhPIPyQlvg*^#mf^i7gt&3>yW7bsjZ#|Og(yvzHYki?#Uf^2 zN;+YQF~8-~^aATUiwoZzW`z0zpP0oCTXhrDtWWGU9RBNAfay~oj7rAL_y$)x_l6Et zjl5~0wP?vC^UvvM96x(bW!jYlw<}&Ey&jN)?ek}nxWPpV(<}@ML*X~7ftKPsXomYX zIp6s8w5P*H#ryq9fKwE=g|$))gO(>d_`TTJhm~*1Ven{XD;6pLoj&XNc>vS${8ZcE zm5TR1GNjWK2|%cB(+hRN6;iUSuiBn52Y-)oqJwn=)j$4HsFRY3uO+^Is~IH><=S-# zukEF@utsPT0;}7^Wn&jUH&5@P8)}-+Kx3`pz;J4!kuO#2RzP%C(~fJ9ZU9|eG4_D0 zTRUqDj8I;w*Um7UkpuHkS5C|*(z@Efk5*H|ca1Z>Ir&2G>j(hd$dIqE&H2AGB8xJm zF*u@K5I8=2KZ!Lc>lX81sb>%~D9#w~tsXnw2Ej1jY%FNw^D_1oj5d>jy_3)3Xz_T> z!PgjT{BCJ3yxT)y@!UshDAhSGO%H*ibT5q*9=frGW1*!zaJ=n%ak~DDagq~+qMXOX z+0Hivk2rkPss{lajApoT2n;3~Nm*!hHTgy#3Mh7Q&w_XqoKW z9t_g#TpGuUHh>fE7m4#XRnC~(e&1`ia?&mO#zyMfo-ukI0uIni^xa0rVZ;++%bqhk(PxGn18}=Y z?6ZT67h=W4DZSZ+CeYj|4>3H-*evX%EhjDS2gf|^)u-C#yo6Y{y499yfJouXVy%FgVuEr+t|Y3FmkYdnYsg@x>lnQLE?!X+JfRt9A?rV$PM%rq^s_dn?ejgy9Kb;B;472Aan|W-;)Q{w)ApUK! zYN?VV4Q=fqCBRrF#;?53aW5!No}1rV4|$*2i0oqu(9sM=*wN3*K7_9@-UKF9U6KE$ zQhjwOU(A6S&lLSdPxk}lgO*7-`$|gr@s1e(cEt4wERq3je(zD%=V^R_w^6NY$yu$_ z%7AQL)Kas-Yj-z_Y;o~$EHLQJ8LiIAgF?4qqIg!iJCiOmchF6mp^L?If-R-*=w&ZW z+JXL_Bs+1Y*yIQtiwhHXfo^smP*LbBh~PX=m8;?8B@3V1ntb#l%KBXUx_I+z^>b(k zd9u|c%VHIi!1%>Y5ddXOv3yR}cp3we5NZA+{ zYKChwcg2=rwmV+}tQa&vv=~kWby{yUmNfg264-4HBNk^Wb{N2T;Nb`FE@nmYQx^8w z+DsLmDR??wX`2^_Pp?w(LCgPV7_mMf#r#*CDDtISZ8oj+KPSSH+G=*yqb`6S z8hs4~H5OlJASZNe4}U1B>XEL37e?uY5_GsbCAtZs5fBsxhP@`T7bO(l5rX}JwE4s{ zB^dv$A7Q>b()+}?e6w@l4}xSmHG*Yk{CyNpFhVXA{{a$lHF5;w+;T?X-0-Gb3yYYa zGOD+E5$FD0Mz5TlcbtGfJSX&u91-w{H|bPI^V1?o_#uIeyIGU}l@czM5%To6k5Bz| zz}t4lW-H3N{Rhdj;DZzPd3tIl3u+Jh1;Y zSiOnfT6)G`HLx4;BXd`%qdie~2B}*CZrnWAOT)um6_r!veG`pKykyimx#dQ4VUvA*Yy6gdVzGhAK8=)JcaM?kE$ z5S)v>w`-TsB1)Fpu`Q%g$)|%dL;11eM*{AAFh)S($GyOvvKd);z?U+PG24}_DI%Wm zu&x(nd;%9J59a3Y*5lEd;yb60YMf;GQ=}s(SVb9ue?T(oCIl~VO1b`ZzXM?!pR-zD zD^$T47)fUm!j!Kpud|v);1l!6`b#cVf~Ck(4s6EB+Cpv@l2xrf-i(=-wdC1 z1(#2u53Vs~$t10tbqm(xV%3M*;Wft_K&q1=n!rpw>R zlh)%#A?g@Wk6qHTbB0NU$_xWygq+j=%EA?w-`!5kKHel0K9UioGTbA=L8r169J-iS zMU$w;Kw~{-uI5xv6vQmn!gI^8S__sl7%OD{YhLH(;xB*J_8-VG8M|*A9vn5aFq`R) zvf|vrZR1Zgn()8#9hr@>iBC&;V542wMYB|K=`}9#dlAwOgJXT$9fU*N^uk7dJGad6 z+;^M6`{SLGA$rjFcbs3fOZVV;Fju*n8glgRiqQM$D`OyKVt(Fm+UK>tBF_+EcFeF9 z*N?E(;#irVGn5o&hmsbZJlXjReXoTA>$2GSeX!1Oloa7E9S2khLXR7lz5|@n7se)~ z%~L!5pB&T!XY{-9hF)EYKz_eJ z6m($)cpyoo;Z-aG7V@gbRz6w%Tjvu41 zylka3w6&pwE5>!#eF6iYz5(4=T!}v!uyx#XoJz#YP;ph z->I=7OTcfih`$RHlgOPMm7bim6V7C8N&Z!>*R;Kloss=uACCU|*Rs-m=D3$d!%$pwDy`7svsjPS8|^eB$~_P03v%U@#pz4xS|OxvK>gc4n0!LX=7x-!-R zsAMVKCYz{w{@wR5eAhk5^sd9;7r!XO>>3k`>fsdCgk)-)iTOQj6r6Z}MXk(&6y89= zA66=2^pU?J)82}7M=Lt7xz@cdiV$g)c)l`Qx1jZcT}b!$gN_}wb27=EC(k3g(xQ_2 z*0HA#3=Jr&V3fk<%?;1PH}C#hcuR?d1Lbh*dnsfK%vPYLVQ3*1*H;th1?{_s%u~dM zavi1ujuXrRmnnFATy{>$W;qyqMYe}L^y8nP_o}P0{+3(N|C!I&71hl1_Slw$zmdvX z^#1uTNfdvi*7e9kcspn@XXD?cNks;KBS?PV_-B{1^D+-_`M`)G8&&YPe?JcY5M@kd9*8y>;TU3cU7pB_Np6<1;7t+!&}3pb;A`!>J_luqyE>_fX0G`@_gRKKKxZe)oIK+Tbr~qaxE*YF;`!RqRXYf0QY` zXj3+Doq6#EoZP$#tvh#0Ppd05l}|1&F7Qn{BY*lgs4D=;2P}LYDo9Uslmc7i9TvIL zIQiJ4NDU5POM5#ycV84K&?o|cI|4-%9<*I@5jwB9472;*LqSybkpP=|7ld#h!)mUS zaBqr!enHTsd%66AKZI)@jP)u%Sg!FOfn25-GDU= z{-anIBv=A?T^b9i?W({j)TpP z%Py1j5&qCvnS;O5)Ht{Fvw_6vn&@{(g9mOMv={=&&yS8{`tA47_rXDQ>^fi4|L7 zVW{=5wonf1M~d2&U2UE~A7~2*c!tm-9t!T!U|*QGlc-<7Nf1b-ef0&zbhY@aJ9#Oi1t%2b_1 zy3s;a3~&_~vVgyeDLsbue)1y1C8(Ur{Lfseh@rnfjj1=^k~Cb~_!{r|@Q3XpD+8x9 zx1F}iLO2n{Lqc69m@jX;A>$;-6k(;{SX5w%RC>*O|JIlX(Az#O=kLPyfBj!zbhP8} zuYM&xfnw8SL@p9z(LjMH)J0sYl}a^QI3gLkFg+=~WrFI$Nr=`;_bY5x!AUiB@F1p+ z9Ydi|&AZpZDhQ)O zDkQ_%_B{~c{BjXY&`6kOh+~67WQQZg?fF!^AHCOoil1v5skROb-G4uF6B9CgXgEDR z5k?mf4)E(=4^hHD_=K80>h~VF9tNtclmeca8lB)vQx~izU`e4qzi1^%HJvGGH1J~I zi~TPOj0$}J9KZW6%67FHh$waG;P>uos*$-y&+or`9+<5>9MAd15yI{0JcvvMg?cvTJWC=~~e5EtBn^LzJUVc&i< zZ{8~NB-A0QrjlJ9@+VdBfL7c0df1k^rTK;}+(i#tQ5l-FEj02YO^T`xwgHK)*u`Jn zANwdWTQ*6m1(`2&@Q~#-AacD1YAC%iYqLH*!0HoW%XSVcvMU>G{6ICop1k}oig=e| zS&4g^wn?`q-hK=D|M&kvZhQ>ezW2{)J?~skDL9p%YmfoPZyz=F_n>)Q50cFp6#4#I zj&(!Iy>Y_IB7|2OpRhUtg#wLwzd3w;nPkx<5le))^eA9PsL=|u(u9R&PB70+NEEzw zRdzG~vaIs?sA43!;Ek-bAJZ;e5|N;0)9UOp`s}mFjauE7wtV~B$PBL6f~_GO{|edv z>Xkr|-`b^MH!DG7CGtoGjTbG$x+kCG$62c)C4!8EMzt0Lz|&lyk(;G!!v=oyQe9ox z^!3}&bIsMV@9FTL{)p+9UP5kiQYru;p?{{CvjwTHweL5bEEyQ|CN9Op0`NAArOf=l6HZ zH^0R};GkBXl5V87ND_8$sR+47Op#US98!mcr&+dDl%ecGI)VmHFzw#9rqBR}#UiD$v_jEFX zWUD^ABg>NIMo3<=^N8p$lxS~}omyf5c!qcY;k3O{D>>~v2}hZyy1UW)v5(8cdV$F; ziZM(){WOmK`ZqZFx4+2>BS|#D?0y-vJpB>;Av-O;ecXRR*g-*_NwJo6Mae<3rR3r8u)X%Fo?&BGgC7Es4Q|5+u8yv zF*MX-KPZ(Kvp|ti4RkCSTzkO5%oSnI&4cC_LNAm;stc&jZzI28RldKxxQN2U7)sNV z4WK4Hn{(==mofgx-!T9F`$|t@L#db!5@#=mC|u5VgO$J$TSgE_4FFz7^?}!_lTxGm zu$J@&wJS=(HZHRJ-pBYu52JI(F7(}WQz+Nvn(+7`7*%jcN;M8ig%+jJipxMHI@hei zaIGN08#EY6&s%P7#o)KUh2-XqX!_|-G4jwuSe(tG1S<#J2y5}kyz|hKaL8+)>F?d` z%0;M@MtZBtqylTSwr^@NqA%P+Ro6CCyT5y#_Lu`iy;nL$j#(&RZqKWjeDOK7pT7&u z>o57hz0jLr@OxVAX1NpqV@dq(7a>k zDOH9m>0{CU7HzMZ`H@U4so*W@y9_uTTgoUbETTBSXt`L7#!5dz0fS=jOUceGMuPt9 zZ$RgT7i0ZD-hg9&xD(?qJck^YyO7ngw$Vp=5eWHqp}+5V**?O01{)eEw2qSUyP6N~ zbjV3)hBk{_+pNMQyMR&Qymg?vRX}GIJ{5;fAp7P!nBRXu0zl2XMx;9cPvy#2y0bV# z=wm|^Wm4merBvZ}3V3ScB9JrCwpDJT9Y(FCZ)5BBt?0S(LzsR2RZPG2mfc5~d=1>F zuFxM83oYzS3z8OL9Qo-PC7h`y#Hwx1oRWV7$);8$GA;b~1Q#l$NUqBItfA_!wYWt2 zHx}|J78YTai;_mglObfc(6TIDqrv;f0-%)HWUiKAUfBCSW?p;+9hX}DUMsDGsF36Q z`yXKXwbzm5^Y8E|GFIOi*BYrcZOdQnU+X9UznrfK+9*g69o6gC;j>zf{?;twdx)&A z8)e^hQG;_x5#BqgG|5ufR{kanRJvFDZicX2VWkzItst}GM~~upXO#@O=z? z{$|X)_9`Zye;(7Xzk!7Vhmb#U62;kRluAXHOkD6nrqda2+a@JJHd-<;+J(&JKUqQ+ zxv}PEu$C6to-*0of~KBsq(volXFFIbEfXG14tUGOysTOklr)0AtHh0GQN&jmAH(9v z2=ZM16m189VXt$)p~vd1q-R>+H?JZ@_8QOUu`oO$yGRvhXOZgY@C;9;-}O_n;wyAp zA%2heq`G;$wG=th5@mM`0M97XmW78*YZ&RiKJ;9D6{enl4%xl$p=2kTE8< zl$kj*Bl7@rqob0#z$s23GD7T7rOK_Z7tNbC%ACghNvH2FSv_t+6|3|b-PEp95CTaw z>P@g9!Xw+NRr?nsx{9{C0mw9ptb}b%3;LYNH};_W;DHbT7&d46x8%57 zQvz-W_zRDT3R1;+nv%cBwB|iwND2e9P?VHCC7Wl``eeiIBoIv)Seu8A*?`uP&(ratL6Z*LP%a%-%3 zazq~Hd=`ci&Qyp+9T%2r6sEd5kXhf4WKSnx1Hi;;SuSK%`v&5?jE`~`5>yCy(|i@XDiN$RJxv{* zSoiTyV8bn6MAx-fTY!QqL6MJR7K;`rVorL3J!_@~mPiOZ2LOtGy2+%Z>u?H%+*tUq9qwiCt!$9FJ=B+6H}OZ`4x=Z{{Tk+ z{uFYv(~|5q0oGWUCWIzQ4OJFLPh#=l2gvhz^Z+1Rt76ZdMbEQJeuKJ^3SiQgjlPaf zad3^VuViPZJOp3tsyZk#8QB9q$&IF_OSls7;sq}w}{ycIhH zTj3g)vYuH$JOq`m3<)|FRLcQGl}cQ{ATwv@Q9Ln*(&QA98=9lhFAG}X`H2ZEa^LK8ehX*_JI*Hz*Mmoho&ALy03OoMwU(x%iPp;asP7SQX%v*0D(b5v| zl2r-`M^=NoIY#=kLLjGmd(py`Xv^*kSMGu~b47XaZX^fSp~zL^$wwYRDPNFqB~hn= z7H0iBd8URP&dx1lksTkC9CB@IQ0#?l2^ZLh6SCJYL#P5op%4IisziTXe3?{*b2KVc zt9agZo9^=ZikwYrU9L9 z5Kw?;Zs3ZL{7Q6ZC#-(Q_tOGbpVa^`q*Hy%&K>Bu{1TZr;w138rTq;qEjLw(F)goE z^4f_)kf~rHh<{OPy@cD_km&D2qN~%rfvdG}30_ZH<^u%6b0eEI8b*Ue$xK&0_OE2; z6{^IgB|cyIlVh^yvo36zdwBUTzHc$)DY`l6qzG2BJ3?9{s39O1P+sZta4@|HMgV%z zU7}^zc>#?pDT-`o7}4^IA5kb%7UAVWK{;pUQS>x$b3zGxi$(rDS(N6opi;TICahz} zkR4`rKZy(e=Iz_iw(}e`b#*C9fExZbwW5w5^}LgGVcJm^ zSC!NSZu~%&`RJ6Hn}Twh!UFrEX%&#^N)r9Y0PwVtg28RxvVJ`}x9>npPmj_OqOq2s zq$#POYh41F`32-Br%;@otMXyqxh9&Lk?QJ^0D~Du05GoXreKkqBPH^|db-in-mZnD zmtu!$k0?S_m|3o=pJWg-*>}_hrrtebilr?Y ziYHrI`Tc6D3_;lP-Zv`@A2NSVW0i=7!fNpw5$OWb$CF8@Rw`A`O4H9Nm1#kyxeX~1 z>R$4Cx0Bu(1#Av$zf%Pso3-TvlzP>OGH}^4ejN+;wOmc>)jbRH2fJ(9`;|d~ZWL;d zk;OmBs(hMgb5@$qq9}^&U~%^e@@$hCAO)CJ`V^`~>&MVMB`Q+c*{1J7ar z=w;(+dFkm4nl^1l^Oh}0+u+Jcwr|uHcKt{$w-9s7|3ya&k&9NGn64s#eBrm|R(`Z_ zYcUyU6PEZtcXDK|ous1fiG>1?yQo zRYk`N=6b}|y6MZbHK;4sWx{~kx}X{>w@;l`SPm%Ud8kn7W-bY?&WVtQ7?J{BX{*&z!FlWlDw@*PU*&02>*!Ml7mbpSfc0iZ(m>$CKm zwr@rIC6}Oi^JXo_t|90bVy-b2s1-#Y+BuZx=VYRM^h(svKvYSJ3a(^RlTv(8oA7T` zX~+d5l5sOhu%?u(`qV5~4w%bEf?KUd-R1YB*wC_(yA8|y)93b7=3qb&Xw$-i9)2V* zz!E~UCp(y!vssw)3%(G$c30d`4}~gCmyO%EbeP-gS$eEG_&w?r)vQVF{Pgc*%fL5E zH9cfSrdW_WE%ZJh&}Y?|(=g>ok>1k!uZ7t$DvOj>sd_fJ;lWI|L8DQ}_pp$4#zGXT z6TK7d4A(3I3>ZZ@lxF5+8j2?Cg4q~#gG|z7hatV<32tPwL~@yAc&#xNro(>h>|IB2z8;O{P<5>ghsLUyoIhs(y>0NMMNo|6Dx^ zI!Gn$wW;!-y#USSg{(_;5+>V2J4_f>h%Ypm*w>>o{A4|@L+cRvQ=S$I?7nEO34-5*<;)1gZgVIYO?lA-E8HF9T~xJXP}Gu&TZ(ZHWY1maQ3)r+cD` z*?BBXP9e{K!uC8FTBnKn)wKUFF`ubq3eD{u$Z*3|lO1g7GTh&RhyrjS3JfkMSfPOb zw9=t(S(05+!tyh#`C0eFW22sF2U6U+` zT%$H~g`RUsN<1hAfNOT>#4KL0Dbd=7*7Y0E(m%ifPg;AfUJoOw!if}069?*ukm}q# z%Cj8E6pOx-V@gqj{@H?mE#1+MbW4jBN=9v@m(;MJvqx(y65YK>w08y<6Bp{qR7&!S zG1hnqh(9E&cD8WZ0EwB(jZPqUV$4Tppl0|`P>`gOAP!>9gke{H+JH@Q1d|V?lYUDS za^fmNNO*JwI8{RBEFig5U*M^-tZTIfeCo(Z*whS$cE4Aw^T;x!)+ zNLdpIwrLBA*ZRMMY=F8rHYGu-@bX3rtCbM5s{=C zq@1HH3Q#trc8iw1LAqIeJ74<>w`as&cN)PsPoW~3txnWnz)b>MH=mS_47kny(=B_TZ_V&uEWfj;v-dTUk-M~y%XkM%3 zDK6$@(TQ0sRfRQY<`y!o3T)F{iLDs~7;fZ?ExCTN8dy1-lEE2MK}PLslxlpAd9Fs; zZG+4@Kdi3vV4mSehO6XH?Y^T5hcb$MFO{r>BQ+$+G!Fu+*}#cPgAioOi6lP^Bl1)o z0Coyga^$@dU5=8X^GYJ6YVc*TEmgT)p5r=YdPXu$!~k&3V?Z?^ z%^Wl&8#aal3dPPXS7l(ikVA2CUUpH4-oeb*zA24FQ;YOyi4E;V>1f6FrSR&ddb(u` zx-bu)tPn1g`1O>mip>V?X+6Y2u0e15M5pMrSz1`&$71+dGp&T!TlAuzr#uYJ+H?wZ z!bA)6`|QZ);dLAj>iLNW1m_}>jR2UcdLMzP8p`6b}V^lvWtH`_J))1vL5@?_fe;+ln zIbrb+X8H!?VT80_6V`S{Y|`#d{@Qc{R+?5S?bS=zhv5s$$;WJh1pQO|HNE=9hzer2 zBbocS;hP|eRB)<-B<7?Uh6HpY-BPDV&&~SRGHK}$BuKv#RtT6a8&!yB$S@zOEEkF> zi57aIwOq*DQH^We-R}zBg+J#>f_7u=`vC=b&rM7tKQRR}mk(8>tcpMhgEeZ3i&Gh& z=x9Y|un+0pPW`>KBsNE@Dx6GNgRe3GsK=Qwl3nfm=-|e+#T)7XK`&33P*t?laF0qN z2XJHrg{jHlY!V@ycx-hf3{#pV1R?;U-!j)b(uhEPxv2hpR4t{M)ZB9$h$ie5mo+}( zUcfGx2-f_h`na{RX_L%(%g@d%$y4Lxzo@)^WhY(v|7Y*Lza&ep^T6-E^jY3^SNk6C zfiWNkP5?=P5I}+;KoBA&iXbIQwG~p6QoN z6~?lN;=j4mO^uBr%>kE4$2PnMlKmXv5F513xRrkYQt^Pp;9} z+~F*;V0Led0c^-Z=ElxWS59988I0n;v5lZsw`0Rw%_S7*cy+q!K?_oJ6A0{m&rqZR zWNWqwk}BSBeMUskQ5ZwO_5Gwz`VSm8+;OEpt0j;DKL5vX3H#D6=N}WGJbN zf0Sn}qEK?Apno!*MCHN-)X!f4dA8gK&Jq(b7tz6!y#?3g`J0;P`d(f^bz>{C$F3Jv zrpPXgUYl%~boKI}UQ{hq!oL;#+XHbqrHT6%w_d;L_y0Q*0J6waXI3{XigNR(P9Qro zgVLo-9k-gzk^8R9F&IHW7wBzn7r4P%i{Bg;3rPv5)luhlv<8h5U062O$Ndr%eEycx z$e%eG|6U=|%N$S3uTKy{QTBmRXeI*olpFc#$_gsi7SSy3a9}zbm^x^)mzmmu6P^5k zFuOt#{TPb0;e>{w6FQ8FNi#Ju#wb{S%vc+HTHnNMm)h3Iv#uYEat}oM*Xtg&t@(D> z!#b=sBFpbqYiL$#Xb2&4FA$)<>$^yQ@XC`BwV~OGDGmTfZ(7?IGz2so{GL`gV5)E< zx1eiV}UEkP7WqJJo@4^rOUWaI-y}3zFOd@ye zI5Kl{(%CdT+vW6NEaVnbly}wWO>I690-%j@N!9^6>2z1dkSTmNb)u<)e_}n3>S785 zm}%7@aX3>R;vP$FSTL}-scNeEDR)OWECC?gMk{4&W$>6%#{gK= zRjkj+Iy#X;%)GZgPE)dmf|B5D5~BFTaGvKl?K*KK2;4UwRoeFDP-) zzFyQiuXvvz5ViRkGr*aHI9Vk&kn@PIPGP}bqXU9Jnm;ylbJabV7#l-sW`_HhF|8DZ z_V5f;W-x(J#9suPROUfZjr*7M%?p#>u_<7?)6o}6f;)ndv!{_gwjd=}1mncIGz`q* zW}rA@Q+Srtu&~R;>*RBMQ;Z;yPDMv}8;uEj*~b27R~MJD_@zI?&daYM!6Px@{H3U< z>qY8Vt0=tqlGK_S#8`2S8}qDzOa=I#E$YFV900n_?u;(kpB1BcrlTLWlvMP` zEbfQY+9&F}`_#G~T`!Hn^x8J+(lACok6<`ur9M*3R%WgiR*?1Fm?F~={pfK0hrprb z>GfTdP@Fn5)<$3TlZ6&-p z511(~LK=|2^S@fO8kRV?sR@Mw9zY8X!YEs-Bq$CnFd@S$>I+VE0TZQU10P`!w<)w* z#B_UKEAOJZy(Jq#lIigw0DLEaK(d&)hX_(HNBEFGpjADbBZcRUc(D{_ysV zLo5~?^nMSccO{S%euqqhcXxNuSX)DLb4z2)z|d!&z;~uhE4UZsD$d9V9HFb43MHZ( zX2eLH#)~K?Rp<8T%K!IAc=JF1XRN>Yiu@=y;y zr)s3#5Qdn88Meze<*a?xnh{w`$|PwqH;M&egV~sV#fal^mo~;I0zCWpep}j+$e&-! zf_vvXDp%Bm?Uv9~By?ISEM`Z}o<1ydO_Ik`+i#PP?N)Y#+Wf!-e*1BVW}QSXD@zHq zPB?YSQV$M=n9+^y8{c%62S?LLjZO~ynyk-(F)vlyV(MBzzO$6J4ciB_Lz1ZW-R=2%)Rw*GNH95&&6H+fUcsArBQk2W= z%~@(%Q~=l2uY3(xzxX8-Ir#HgKcCBTS=cvAOuZ6g_ePOxdvx2?+GSk^RhIWy%=Z3R z3y(k7>aAI1fapOJGSPbz?%srx;I?KAl*`F!9j?ec^1t_dx7ag{TRZawbxPjTxF- zg9CqB1S@AIIzj(Dg^Hn2Jt-UD6h&JNlKR&~l1Kb0epZPtBS3MQ8GfI0>DE}P@&F?K znBNmAaxvh&S+fXy*Q=qKK73K3n4^4}7UZtGOCEXA)W zkwSHO6@@3CK>g}fq+r%G^@q&;+EKp-P;xjtO5S|pasE*ajC}7~a<9mm88OVBD4d+) zX>pKeahW%sPjsNlZo5XEJ8W*uIcUusna9YPTQG9VtwfX+bPa-oi4#!Dy+gJgli?A=j_ZVKz$z_ln9YHdi(KNRlm^C~0 zwwK<4m_CeE7qv0^)L4H&qkRU5v|-)yssu<9wV6iCKE+TL0)%9zCoy_t4jF#$YK21Z zbDQH)%9zk8o6aKa3I}=Xn;f|C?>N@_S^3IktbglUSpC~?V(a-AP~sr1RxC)3yME?x z+PXCzZ(}DU=t?LMo*B&=-Pecuzsn>KlaK(A_+Hp~;RS5+S2JK~LKdlA7r0|#dgaek zDWu27FmmDqX5RZ=EPU!0F#FMug2eo0)|AiMX}FPEz+SL9vj7TJVo1!`&dg0CF+O_J z+dnZ%u~8^WyGEw%AO#{b*3){C9lzdh$o0tgT4H(%G&&m3F*3U?R><1mC|zB|?v<;W z1eDtfPlKke;1i7IA(itWsI>*oow5Q(HK=B<#Ga_Ftja%!0Pv=Ve|os6)}D(rngD-E4g#5=p1GlP zx>#hYn@V<_s4<6(u6@Y4cTWVU>w+s3mqxdEq*~y&A1vPR$^Fc8* z26eN1EE&rL2j-cnDWo`{5lt~yANvzr`tN^$jVGQ&!&^sc2O4!SV%-uIu`)F=zu!ww zaOl>V-i>X3cN;JpS3UqQ5UOl!pu}Hm99UlY>%YeQM}Hb~AN){@`4i7>BoDV%>AM?P zXSP`6T#}-p$!SfBx!KKMWo1LwACn(6_~4BYW)@g?K-)~+xgMJ$Yx71%keiuC$^g}* zW-G`Co0gTSS8+(`A!;iPP-nzK)}9?;645)O| z=19nOlS5-;1=qgxN7#JnRb2b}H?X_BC^uckceX^vx%SQyFxJiyyRksB|GmOAMm5y| z7{pm%sQ&SpLdaMSg=}J3*@Hn1g>pwp}Zs} zLTsX;0E7e$V2^rCj=%F#qoc@9&qTBp{l+dv?Ufmn7+Ah9%Y*XN+%(@vt*lIod3F%4 zAYTtvHyYIMb?w2gup7vR`q=?@X9uN~RaCY@0BCCEu>-_4)Fn(7@?u$0lh1>R%JOQ^ z2;wk*m;?3H!xA@BT#_<{0%{wZa#UhsWF+Ry4!2g+um&*lM58V?IXQ{+#01hDXw}uX z`Vo_LVJQ+HYUGNjNUt=ysU(t_6r7Y%14y2rF;R4}HF;!GtHTkIu!SM=lPkmqW7K*D zNd2_xcU>&)-#0nfJPF5$(5MS*IEW7AsGSlC(w2a0bA1bokNpJ)GELNXN;1ux^Bk2n zY+Yd{78YrXf^sI^Hm(YWIj)%xx4FP0SBZ&Cg3Mx5&GgJ-CS25ak52$B$#|zWb5+ z!Q-f&Ki{eYRG2GyzT}S+B&fLqb^ws9?XX9MqGvIlg8~@K2D+aEpX0hnh!UhWHB8rM z3+U28jP%VY#^j}E=8&GA9R8tPb(HfL;~;1ot3jOp)?K_~~w^_3MgHn*Yxkm07# z2^|7J>%=3!)3s$51^CO%%)rTy7*4gyu+OsgJ_{=Q-(4R4#_VDi|{{aow(|L_k{ zUR{yRNlE70I+7`9BBP&}F<3rsu=HQV9KwmsM_(>Mjitl2!rJd)Rd_t+);0McxQlwJ60xfXD`IN@7fs;RNJ+B} z?Z>p|?>~rZ+{f=@M$mLn#aZu=Ljb?sD@!PEYz3qBn039j4?t{ss!W-#f>aiXiD_A@ zti7j0nvo*qGAuYh@fyARZrt|UzlAingBQQ}MHDYx;`W(?K(FzHx}<`-ooBokd&S~7 zL5uT=QKnRr3_b4wv%XM^G75YBn|+hGmco7-(!l`w}NrU z8#K_|DWbM`4K)q`#h?M9#Bj46?`Qz13r`vgK{-UnktkkHi%vF!EnrJMHIie-yRPD>+J zufr{sWSxdu`*_f7SUfgSn|Rc~lc0;Mgd>=`sbOIq99Ji&wpZZ2Z$ObzWaWhAth(G0 z4Y0nIaO2f&?d!U&H&9((k}olX)=_O1>+=~aGgkcu5NW4IN0FJCMQUs!e5+6QDqp5` zWfLN5qqgRu{2h1Tj{ooK~i`Em= zZ5i?2fKMDqU~PE3aKsZcaut3Cf@vbndvQbqmNeVb{p#zUlU}363|0vi(@Xns6?8q* zUp??}Dxgj(d(A=yj=I<*YIB?T?Cg;_WEbY8IJx?qH3@I6R&hfiSV!ds{o3$kw8w-s@Fx7~VC*> z{kCaS9>&_;WXH#9$Fwg! zwVp%O(ju(}Fc@r2_Ea)s@eo6FECx-BT>zl2$JY&D(?-wO9*wmJRHo}Uz->%*StgmIQrjmwGQnW+HuTfxnKy5klc{VXZz0r0c<6 z>a=SyLUZ9$pT^No{48qM7P0&0no$v5G?$6V zC4Q5cs5KUy=wkMG$2pL#?-0RxAS2Rj%9`bt92m*Z7D0R>otK|mz4A78UVaIsi*Lz{ zj-%9~_mk0KmOr&x+YY~X(Az-&UKSbuDIZBbFXhj290Vp`d{GiIF6{DI-DoOCRVKm= zQ$vhsU0p}5xP$bOdF|ZjCg>I$>Hu2poGv>ohGnNk>-oY_B*w?kEEKI{lcM}os8^!a z{Hddf)Y!vCw1&ad-(wVwj9W}3b?5ZS=y;+IivJXvYPD`Q8ke(J(O>dePcR)yus9>6 z+y%XZCK5RdK~uLRi|Dohmo>!YT$0c^_D7(4Oc$6Fh|aw#pu~HQb^wn4#S|kH|E$%! zo56lE_ga)a+GEHSW0#q-*Bw#rBkIg~6u1uVjE)gWY;J)+9(564UuB5 zUb=wF)weNn+bz)?1PfDu)U`z&0>B%H17y)fV%fy0kr8CLF-vmeQaAi;9Fz<|0kOc) zF^i)N44Ie)QLRal(}b- zNvX{z=}1vyX9Dop`tQ1+>6g~gD3*|%N_R(9W1{aOomZfnwUDsJxElAbxhG7Lki_CBEO4( zoeB2|dACW?Rf=g=pw5`ZIx$fO7lNT_xGf>V!)VpW!fGiurM|n1($#AyFD{|U!JrP! z$quzx=gA7TzYF=7+?g}T9y=C=7eP?lpQ0L>K}Dy70|&ng`G!0kl3>u`!3PP6FAO## zqo#n{#rp?c2G~stoLL-@o}ESh#3`g_W>Mw<5XN;eGWNFu_MHwl%D+caFuPVm`O;+$ z0x!#2^8~l)z72C33zP}~bF$Eo0X!7EA89-Swb`4=mikys(FDbG%*8S-#I#6EI-W`u z_2Lei5>EH1`ciu=9PLs1NHbB)~}G$eQ)IFJyCiQLRYVM}zB!3u3ygd=SG zoZ|TVW3?{tNk&dE zaI}b&^|Ek{H9?jXaxm>2i0$m`e$$X;^c{mqGg6!4h{!-fMdOQU6M0)l)0cp85;FKo z@jW2~(`$uo+5Js1EPN++)21uO)Lt1!;;C*Qsjm>Qd03&u^*)WF<1im8ypq4%eM!`^Y+?nzuMd~*pl;`=Mj63ll;s_Wi zBPn62=Oa()S6v{k8J&q=bvvR~sRB(EF-Nr9Kfv6|Oc@0i^tl1>lnVK^`@a za3h{Qc>>P(xCB~~t!zf?U_`o{vKcg8CTA&DE?-7{eN~x3OOeE9TZ_)@Kr?|b4eTZy zFw0I8!=HA~$(8bW)KYB{D(j4GO$!TjewhlOALRm?o{C%F8@FJj}l=TH)|0uW-X z&}OjqVmwTSSL;V(Ew+qEF`o?Rr?}B?4qz5A?s!ks^&FKdMZ^#<%b-dksm9n3GJF49WJ1D7db zh%p<}DhLfdbLBTM2|Hd{Tf@$U^QbN_B6EDf0OLR$ze465UM%#EO#w%h=S^)k{kbMa z^Tr|xzGM0PXF_Nfw6n;kp<9Vh`h@IAY*#Fh9kz)@p~k|;l>Yth_`CO24W19!nwERWjB7F3A;&PfQka$lg)|Q`^2bkL=HZ8M^yfZ- z*`N6+oOA|DfB9Efd-4g%jxe;BZRtK;NqRjM2Q3L6P>E6xCvo_6znB?t8i!l0V)v~J z*u8K8O}>Yd2z5;vdMt^su&E*~*6@Cw;lOYFw%ajs;$%>x>?(Zk{&a7v*KpWmIrtej zTMZ_RxskN3xwrPjsEN;Svewwco>|rXU%z2Zuu>GwN2HkTYLQcG}fmzhaMEy{fgBA{68XMavzVs5do_`+I&2`Bt zw~S&~lS;jeXj1{XufHg+FO|aRt!FXz?gx=OdkYeY6j-GK)~E$Fdwu}!uvWUs^&X;R zqMNO{Qc<*@m%C_dw^~oKjav zKQ;E1DPDIUe5PJ%aERbvxr)Z>CTi=OsEfJq0Ym3R>{Gw1AQ1%W9K__ZU+QOrSJR^a6WxcdU{G2 z$!c*2m5ohVKbh&`Q8dbBIXy%SkvEMFbx~17dS8yNRi}=?%4TE{yqF~&1;{Dnj-8ON zK_5+iAKv~Se~8lR3U&nml#brzMlf3b-SzTS-spNpQH)|5fA~E(`!9bJ(;xoG{yIki zAVukc8)aPkGr261A`F^}!~_7rC~zlym;fM)duWO=s4lOdeEDrOwzdKXr%zpB%62AO ztYK@a51giN8--&LjyZSg6yF0A#(6S(Fhhf|<<}p?^u2GnJ*x1%E9{voC1CvVd}zC0 zsmp&?Nd^&c*V#;HzVr2#N=-ZS|LCkmSawcA#i7ha<=8T!rZXA6> za(q-yDanqGXlW*$bD@r2je`@JSif+|<0KNP&mSiN% ztwPXhiT(N1VMc&Oq+*y7m<7W2BYf{4KZz_4aGX@e4pFGbBHWw&U>@S5ggND!h2ww~ z9}w5G-OjrDWj$X0N5tl&~B7Sv1VE+w!OyYWUP~*nSn$@ z12?1&i*D#%yNir<$U2@KSru^G1BLcyloZlAq6?5mYAOQ=Z%Di9P};#kov4i7OPS4e zNTxwMo~CeS%{rWBP2}}8!4m7d*)AS!h<^>28&q9Kg=S6XJV+=gQphZ*&+Nbw?O`2< ztek88u6=O`2@z;uFf}-$e1n7v%UvyN9Ghx#osPHzw9akbcsPVnjSI zDpadBB9JN22er_b#dKzM3%S}OH`W1U*(M;gbpU>_6+W59iZ=$BYJLv`wv-?Vj$p>FAPQ z-P>n-01yWN{({XDEVvu_4jml(ryBC`xhN}AiD*g}E}+N(V0CFpS$lfxuBs`jGkhXI zZPg00$evNOAZ0*CvRg8H`Xo|Qlg2v`6)7DaEh0e3fNd4fDDDJ6I-xxTCFw%_>x~3j zq@pr7(j6BScE6F=eeTprj6e7;jNE#Q1kXOn;M#=IST~A;b}J!VfBD)q?7a3W-#^!4 zc*=fqD?IF|_nu(^#|p?KieM+5s1g}qFr zk>ZhA^2ofDh6%TbYk{Ns=IP{~{Y@u6saC6^x>H1BcgOxTOdu?gt`kmCiP^d=&Sn@? zA;nw?F~p7wqWz4y56u4Tm$B3hLU{6)0?R@YE?{#oo?cms9j8f%bs2FA?D zMo@@GC+&7O`!&@GI}#+9d~1GNUHy~ zm|5{GN^f1{An-NrYl^`gay9w-Ap>|*9->wvIWfkK+lVd?p;0*0*_9a)wz?Qa6GM4v z1=Y39L*sa4?PMD}k(!=Cdj2S!vGE|)&3a^Is10D1G9=9=n&m2wpli`|tA$A-0py*8 z##-oK5?5Ij^JIN?iVRcjGn1}4XegL#amazpK|2UG;Lkd&X4`)ERkn`#AkAn0E?>mP zlTTph-0SjpQV45bSsTU1FgrosxIv{W*h>MBvRA}sW{)ml;(o!(+}8eXD-CQzDA*cn z>487J8HKx*wzW z+>K-+Va+4?8Mrui);Z_UdQWw03tP`UhwT@hN26FUf~5G2&kz9K42R2F^=7Va9Mz%n zoi?8_=`(()o|LR$`Is#le^F-5D5suE?KuRkl_R?Z6=q@Dq|tBM-?QYXLppre>O zTd!2$*6MaUqcjcn8l(87M-nhiO(1{lC^9osmLQY`1mj>MA=c+J?)*DWI)$-&?!wre zw;{>>OjGkS)RkYR*c}ySYZBhy%5R)U@!985xq4N%>BAtFog%ddrs2A!@q%xhPHsV@qNU&%C_B?V7{U-&OUpQ`nw-$@gTPlNMNIm&? zCY0MLqUCKqj%KBd>iPz%n_JrC3@hLSG==y82(qYLHw$>ku+~OQw8)H&YceqVp|lVI z^h&*HuTPP>cz0yo8aZ@kfQRl4J+q3TtJX@z4eI^w6(*3f>6y`GNvu_@a9H>$YU3-L z98eTqei`e}K8y0|s;3Ew)?Tp&T$WTY3xltqcQNE=nwH+O-srqIccNNv(YZlsNu z*@t@T4XV*9HJ|hXC-#j;cLCmCR<5%H`#lD8B*0H-ffD-$|2c5EwwzC1&P@KH-Qa8ftUG zogwNzEM8Ab%+y;O)OHDe-zNZ_4wRO!Yi1#NSesj6WmQ=eWomPt1vA2QITi^jyq0pm zS8Xp6D$E{^XafKl%&JD}3E&5vhe6wn2fj#5_Tbk?F6^q8tji~;00rfxb-8j7of(@% zW?~wY&W5S`K37k0#-7HVx)vHcWi&R5Xzr8`ft_MO>4TJ3GPFXg*RG=Q?2l1;{dH|l zbDT|xdupw~G}Jd>0Sg#5#ijFkIVx-Hp$8=sqmg|S&ZaiWKUH{_snSr|Nils=10!Xk zlDVo6XNR|#Xw=-^0xOrp8fWtF3F*}>LHSH~4G3C_{^$ZmZ@V4Yg`<&o5h!?GgT05* zhwsmu4_*;l6~45!Lb|f4v=8|lCLVYfrhnqS$j;0JfS1K6>-HRA69vNDvKH`-H?Z~0 zGbq1(*^Isq)w&x_0*O3oQUvsM{h;*J6tc6kNR5u7TH1}wIn}ot>yCklhcsOssnHSS z=4O%S5nUP9iFDU@KuzF}s25(dCx|XI@5Efw`p%A=sq2qkBlucn`Xph8$cwDw&&8fj z*T?)ZOuR2GpBo*l&0jI%ZhhtxjO z4&)T2pKwD&FT|P0$3gssbQ;bsjDV+iR@-)+vYWM3L3LBeaqJ$7Ks5l|29+u1y^5xf z;tS8Cy0jQX{M2W`0W;UQO#Qm>E0#x&9>vr>_h9tQ>AqGO!4x4eH<&(Mn%UMr|DhNQ zS-G}|%E}7rg>A43w~V5>LjIcL1u=UA1wwaJ*3pSkg#v^LIV5g}+(uK$2E|=R@F8*} z8}aqrEEKW*GnKEsOA^~9cYhGNru$6@uUX*q+H966;Q~YI}Y45Y- zU5MAW>_p4P$hqE$6r5ZZiOF$fIM~cAEO37{ju=;oAWZ~YeW+dl9F);0HzR%e6!Lf9 zCC5ot*4G2T7SsT;=vwaPp7}!OuJ9V7hFq|1=>i!DBspi$&wUx9h*RMWQ;qCq|N|BMNWeS zfAYICIXKxo7k>Wqm&n7I~~K7G10XU#=vZ%VF%HhcNcQ14vFx?lG)` zy;edMS|=6)*?Jv2ubsoz6FlW8fsT!MZ{8 z=m!KQh-T3>;VsO}>>S2;05WphZBnYG>9Rmyw_gXS>eMg9@bTuB8WspW{&_AXMyB&h&Vykz(D+?-^MNu3@;j&=1r*rq6p)jJP zjAJx`Enny2nq>W%cMgLR($V&_+mx@v6U;LOsE5FaQW-cSvGH-3T)e6?X{{vk8<3GXD-~0`B zE?o@jdJ{(A;|FbSvwHcU>b!u54~Ut7P|)PhDo+39w;OYxy~{P#K@^C?PG;O$X$ zUD(QosEhkyE$a~_E^ZZ#dKFA)=B=z?>($qA?dyLdXQWR)a379+@{>6B^Pj@leGf>6 zU;UNj2!dx@ESpPU*f79>z2^3y@3EOYICGT!Z4p?x!6gunC4pR7gYN?lCeluAf zY-cs_ci3iv3<02;9yBL57=KUjwO z61TL;mcdtKjHtsm$-sr*4~IX$^yml&&GX2fy#*up+>87jcWA@v$+6Wv^}e%gLPM_l zcMhJJ=n${g4v+m(8EfyN68RiPZ@&{`x7~rlGe1VDSZH0RF~O!C>!&?OhCs$ef+?@F zG{yJb#9en{`k@E4=8wL4OhyqqB>@3BLCU}M%FDR?KmHJx{^$S1=EaNhXCnN`qSZK| zW#l?asMveusbAaH*Shriu5gET)xqDh9Tg=oVUQ5ktWl&&TU9^k3fL0GuA)}F--2}_ zOSAUmGuV9kIV^tdZ*k@~K96Ic`3%z2GcX~V98bu+@&<}or^>C)9$UcV!w+NZ$tR^| zU!4c0Nj30h{iq1|wliocL2_am>62%Wm|w5}^kEI)O?e1s<$7tTexk;Kp(pG5Buf_; zSvCtpduio^bzOt110)s?;1M5yWhd~xz|zK-qNIT_HrK`gNcxJdS(iz&zexC+#_ES!R7aG=ki5vXfH+v zsH^AIEt3+SH_3F)`2F|e=*K^Xg-?AFqj%he+{sfIIeiA%i3tvJH@p6hPHaWMYI%1` zIH<~I0oB3|MsIklL}5LuWlxRXbvtH%@*^m|_A1KX{~qezyAnhi32#kRl8r@b?SLi= zYyZYLP(SihKZ%J4-yH!D-9stTQixIW7B-t~eeVaj@E`vpE`RwkRO>Z4*&=Cl%lh9R z-WL`CSBgMf+Or+&*Pd$UidOHrDvuSBsp_B!$Pi!pqYg)7+FfTFfFq_u((c(U(m7)Z z+B{IJ0P?g)qEy@_79alsD%=LvcS|_+PydPB_mQ|4!eyzk%v&!g|h=&iS^2;sW=(;)!d^VX%dJ4rx>hGpZ1nu2v^xQHbJVOyk!{-@IgVlhlC&WF5lPeRyhSy<;~(pt`z&-KAwY zI?k_;bBO|GfmnyLCm%$`Px6o{sIf7mkDoy1KCX?cLPT8+d^0g0bGq8K%fV{qFRMu9o`>nsj3V&Vs(jVj0 zul`d^KJp;a^W*$A4d>FuuAVt{SU+S5CPezmZPeuJu-Gqs8i4{L@_EdC;vb_lP6B%#OHnqM?U@YNX^Y@j8CKpuB(Nn zG~ppSU}@{e&*H5=_yb(|+E*p`6Rck{DBEFy9;Z3Ok$RB*9fbAj=GzF-X0u2JhwZ(& zDf06ebpv9oD>gX3Oi4$k!6X_M)*PshChO^@R$hJ?SHAGykQ&M3_^ynqoU z74nf%LgWS4g4y$e1d&Bp_{7hmc5Mmli(f=>X;H5Egse>rWxt5U4TV!0jl9|*QGZAI4!NRbZEq?uz;V7FI?qt?Cb#i`k(L)2*w8X%_rw0)V! zERtv3n_k4d_RQ0Al-c;{lb}=*)#a5|1Bxib?jxd)`=KgP#vIm;2EJiK*r+2Wq$a0u z^7Frj%+Vvb{QFN~I!4W%)q}X<>t2@b1qp7vQ|^J(DDNw#VQ1ew_LB&tu`! zzku}Y?A{EC**WgVEJ|jhy1b0F?|ug>KYCoIvmNE!^$Y;@()mM~W zLoe1;@ue5B_N{MY;@uBo>XAnx!GKzZ64ZwV!MM-7wbUrZ(;vC(F5LF-{+-MiT>8Qn zu=?yX(r1e@u2cYgOkOm!ykf134tH0v3Axb`Ed1;zaQZiY6SE)w$zYDMO8p!*Dd=Ge zIO4)Xu9_JRS&TEwOi#n{)W*dT&eSA@O;f_RLqdd-7Q>iql$~qQq>zc?`n2{mm7+W5 zlr(vZxWjEW(I^zq+}`G1tgeh(Vpg$L*1>8s=(U$V02Bqn2_Y49`3f%o?(bved*8*z zb5A3|!Cy{pI!Cf*B1`OsEw*i0#X*HPG{Dc*R|oCcvjr-J-X;HS1Hg`*EVfK#9Tto*#(-FF!GQgMX+ zbc2%)0@ZaT_HJ!;8SeIG09<9W2ZLP_<`8UpNt|BHFzLYDt1Y z`}8UOZ(?8MxzC^b(1&pBbDzWXKm2KA=365UU4Neu4(S|_ApmT@4UG(jbT|%oOXL`} zM_zHdwxpx=7B@P3pmsF-ql3aG3rFeHvi)9s1Vjo%VEc3(-Hb9v0;?J32qo@?MBJZguO#w!WdS<@nA-QSmyB0J(g3rBP`7dZG^7oxn}Rot)u z&=QClYr4hMhBaR4W5;m(w|@(>zwjv(o_`6OPd0}hP^{UF zX1nRY*H*v3$in(#uddToJ%OchPBdOM3)^tZCBO%OepF+45EhYkQGQNJJ!rzg#KR9_ z;-Por%)j{O*na96Z2ss8Y`^j{N>{I-zPSOnQUVj5|NOm9I*nv*gs=H2qSxDwK;5Msp-Fl>U&}8*kJJt_MJteW=UinJ|x~Jpu4jkbydAodtlO^%-?5OfT~thWWht zXN&Z5vnDi_4xiCtF-d>XaqVf>WsV-joOpfgA4*-!DhGenm1Q)xwmImnwmu+}mP|}$ zW(L{0Sy|WW14~yG7WW)3=>vxMur6c7M>r6tOolt^WXwoSLOY2UI^f4J^quh@k(3}9 z-u_Nca?mBjq9>>Hb<5PrBv2$INCSunEUO_Y{&B zN$9fWj~$n<=|HJB$1swFQas0Ej9A@hqGqFMU6;8}JDZ0pQ>^HMwvd*JE*%F;r$90E;xCb-5%CW`-qsC&+x{ zV~o6Wz0DRhwb$!t?Ci={#1TX;&Xk|=W`@#!UXwZ`w9VUu{0j%OZlxOOx??fY3al;b z<<(p%>3@fVzvTFsoY5@O3XRPz)C)VxtV=IGWh@YsQNMqXsoz1lV;aEE7P%seJrQi=+(&*AmCILAySj+&^KVMfvZu zFCRgJYuFqDz{9YnVHa9%hZI;ZF_cduv;OQ&uX4C?jzPV^R!tNKy;}uYJ0~2YGm`7g zoGTlzb8M-`^DGuH=)E>x0kBJL8#hI2%iSu1?Uc0bZq9S=+!5@X7t(6hn!;o?>PRIV zj2u6K#P~RN-+mj7bLS-JbRvbuq|Lmf2usx+D78(_>;$~peO|w5)wucB)Pbq8Uz8tY zwLqZIo$~_{wfj?@9lJ-L8wNo9)hO+v=GPevN;j8wz9`H zVAlbpXmz@EcDG-C!6HF!FZny^wgS`$M6cvBu>9Rjswhk$4$3K_f@BVS&D>0=OM(~rzB z#JwAa$mg~#mSNhJHnz7=TVIuqG3^1sFvyD&NP(=isI07^wp9qU?;PFgbTo9jFf9d! z-LFDQBoj#HN0A&I)zSy%Ax5M%cD>o4T>=6-XfhJso}17$WNaq5EPK zc9r_;SH>ZSeKGdswVfS3kE_DbbDM#7uTq zpLy9@E(zpLoW$9G^RJP=<5pbxgFnFfx4(l5e@?P%Q%c(~EkFpz1|G~620Rf9$0nL$ z?Y^{52rYE6zb1#D{?=xoa zxd*2{_e(hOxzAzb?t5atiMp`JgMni)L`XM#XvhE_a(0igF4L6MHqK^1M>fVL@afkX zFp3s|wG~xu!$RAbEY^-+qUcrm*H+zJM|oul^_>FJbF;yDF~#Um_#fdpRBLc|1n4Ro zN=rI;WR{DGFs%$)okdWKCpx#LC-`eh{&(CVI?S3|TM_^&)f?9OzHaAUswWwABfE^> zqdCm})K6mUfp?*~TgH{g{#1%ji)Wnj4YPj_ji|em-M2PlkVZSJT!^A(&-!wNadQ*& zC_n6oc9istja^lPq@asBB7oES?}j&VB9+f!;=X$^dgc~1wu;z(`DK)^zU|F@?Jr?Q z%;vZ}XIZVH$=9u0t`3dkf!W}2wJ|kF2>#}JUBOAD$0l&{v;P<~@B0AOzWY6_e*GKR zeDX=`i1A;g9l2%_3Ztv8d+M~O2L!=YDUpQt--7vSdjBncmZT7XMLwZd2GDW>uGTe6 zAs|yMZd3I?h|h9$n?dlnWqHq=UO?r8jqLasX79fr^B?~?9R0*6FwXb1(Dv-eFfxi^ zorlK|0Nw!6cAS&5)uz~HkhZNR=rrnp`eOjQy;4cpFE62d@hvH9g0r_Eye!3NSPCCS zs;1H8Akb}ge=Zhch($4uF8|_?oVpgPJ?7Qp)z;TJAS-E|rQJr@F+^!_zCP=a5Z#Kb zRkJj5#~rfRI60cd+kf&WD6Xz?C%};LfM7xy)ke(H)9Nex<$G-to)`-D zJqO8t)|;(@av>#j;uyy6zDtgG9KHQ^q-JK?UMuYfLLVMO0JwMHM{PGAwTW(Zq2DOI zEqg?%r8C&icl2U7x)B}`8&qs$*$FJ>qh7g+`r3L=R;j+bgX;FS?52z`u0eGQ#n)3B zx18BJtHpV8kRXgaoEY}6UPrxHK%=+~Pky=UN)Bs;%_zdS`4E@J$Ki~Rg1N2a{@DHZ z;m&{mA29jIdvNV9zKr!B{sJd59oM+H|=lw?%?6Th14GZJ@ zP!EyGC_n7KvB|tfCxe(lkgG5dJ|iKF)8yH+Soq}6;p9L2HGcmdktGQ0$?wbWbz|7> zUKmYgJX~V_*mp4#xQu#v2mlW>r1kiIJgF+M0H6PaYIhhP7nUqZ|*Z$;B@zxi?cC{+9uy zGS-unU`EbuZq$)Jc@oF?UYh^t$B@Y8z-l}=7tL{`)Oa$sCnpogV)>{(l?0_zEiG9a zM;bKjkU^Gs&wfbx4FTYdZoF75v!OUein1bFbA+sKN^np>@dm{jYqpDOyKh1vW_PH5 zcVz9_HI#W|-PkE2IXZ@L+p1@wBn90jn(OOu*SLWzm9%prrTfwrT{7cD$e^P9wtT_5 zr4uP+Mn9A)Yky?jeK%^0_mw4ZeX*)dol|PIQ1L9 zf#bjQS?s+05;ng718hF^G>Ydh@N-&6b7u!GKSx%t1%{8vv2o@HL-SYhW#A&B8 zDI{_^B=Vz3&&*={&O0&t!4F{SLmxo?_B)VBwNm@;?ry8jE1A%kbEn5^(aQ>youUX@ zH;YBoR#s3i6p-Sees~-N70B9$*j}TYHf2KjJ>SL(DW*gsal>9_od=@jYnM@7TME*_ zjwchPXalqf;BAbfEkGqN70!4NUcu5=zlPezCaTv~b8?BG#?@*(CWafEH7gF#pf~k z=A#&Y_e1(;nm|oB>*5X?OG{|1t^}#tXxz$_+71fEd5x1+#hDpG#TQ{PQ&OyUR(9RS z8lG~QJMwMRIDiP#hSU*YTLF`zQ)kx22&a?bKr}Nkt^q**NO0gh@!t2z*BKspSJyXC zSzJPm-=juhi-W*QIM`ePfYy^?EYPJC?|0G}3B)QKsBeDvJJ|T{cTwS=JD5J%@XP(W zo>V4_$@}h?(j4RWKfu9T7R_22u3%lr(Z({he3D)?N&=h;mNelYDc1h<6w-4?33b5q7=Q`?A{$!P`6$O)-R1nr7?I~Dpm-ltc#3MjsI4!duj$LQVnz{zC2_qhlP z&YbWQYJ~zy9Nbja)&tPxsO($B*0+gx8KPZs{vw{6M*7%MB-;T%4o2PWB3P~7QSPNX zFweBf1OB|!v;=@79F&d+_ebM6nKE9F8{X`~QTZC=(I^x-5Ouhdc?G)?02&e=dosF; zcxx_)vHR}D(NBF6Qy=``zPiz%a6*h}n&a^`AjuIP+z{amDj%je(3=2K7bK>h)Y-*s;kL{jI#xLaUKvCm^a zro#`9UJhq?3l5f5WJ*6K)B3R>Q@;sOgv*>x9F+b~E{9GoS$k-iWx#bOwks+g(t5uz z9ECUD#P;(q$WdqEI~>WzFe73Vj&pZq1(ls*AdwQzDD}jUnO_IjuGWQuQV_FlOaj1( zNu;M|uj(*oRGh@E%iC-&k4lOyXlmnDmB&Q~?o6%!US2m#N;@dQ^wHkb?0DwX+MHJgJHn`nD z5k5jYQesBu+zgz2ZV&a0(NKq^zzBJw!a%)LlJ%L5?SgD7u-=2=F+4i%me4LYi`ytX z_Z+sLeg-wZt`cb9#l9cF+7ISSZ=A>Oxi@8vYhWvbv1>y}HUxmfW1yR^vs0orqq70q zkPymck(ix8a%LP(IvFx#q9C7G& z>pyrLThBe)N{zy+b79e@fL8X{>tLf$5`}^p#Z2uW(9SnGK7#bZJO^A;+IhIj1qddm zy0XY4?j^YOnx+8=%k?rVJczkpim{XpDHG$!&CPKjIN2Ujd*ksAE=kotY%%XeI7699 zc^y9x*!y15yO5a5Y$yOTk;@}7HV(4XSoQ+mgXc(4CPyeWfc&qerDc?)oJcixy$p}x zVY3co6kdpg$<{FIqMDHPzeC8= zP9v@TSyxA-WP$_iF=QquBwH7^j#&@i>I>U6_#ZX?O#PAtcViQcr4`wwJv@d-Zx)+0 zc-JhIvGx3O*na6H)QiP{`8(KPBHX`q9t?}~+2VG(wzO!mox?EaWHopbg*P$t{tqC3>XZbcZoP?( z?>~-fU;IN9pMF{cj(R~p>#6QJoCVODxhwvj$z(8j&;6Ks=n*-2!@RHlQC(d_@#004 zR+d}ct7u;y-tE2eVTlj^M5kS9Y!XQh#>vvbda$di-AWq_i!iuPZ2x7ZzButfCp9;Z z)WQM}dR~$#Xxj>-u5J@4#4?jTOny3FPBJJIrE{!rY#=k>W}V@2GlM^~eF>;sxrD+G zzmJ{go|T!DBy7`q_8a`QV5#_SF_mQJ(p%Vk?rBWD|9!{=K{UlS+zpQ*0303zH5A ziuCvdlF1}kVH@?eH7PrgQod9ddyQVTDv|B${0SDY^-d=ci1isf(Frtc@asz~FN+k%!(Qzj#`Hklgd^A`u;G(81KJwh9N?KDM`_IafZ{?}P=OSQYNA-~I- zDHEWSb>cY4aKN8mI3^{4njD<5UhbedkwlSa^4FKI$JVG+P`pV8!R~A4u>HbIsPOgb2gZ(&dSVAzR~kz13+L~aswlkpDz;vH5u^9shxEi` zcmaWo#PGOTk6{WpV56w(P2G)K)l#g~&9+2D7}*XJEx((|VD!HGF!9JwAUiguZS@vt zVY+%g)6>!2q=UovFwc0A1b0axH@fG-_3pSC&y(T0~=a$NIc_xyQrf9dgKS|8R{I&z-~S_kX~H=2wC#H~yH-W?=CK zPb%nt_sfVvT>xQAcP?FO%~5{+buAbtWk%2N7y`hXoPX=`HxyqU&0ty_eHTJ=n${g- zFlyl=ZdVnL_K&f9?!nCa9>wUHGl5}|W4b7m&>&`ScCbN^=$)Yel(|X`oB)Dp{>t&! z2!CbK`WdORFkO1c$hm0p223V@TLu%z-Fg=DKl9U=dGyh?GbQVro2V>aL(Kqyz2GhF z^jRpXY(D?=)D-dy3&>1O-4GtgrdY{(1bVh3oWJbIi3{W;2EHd*WIyTaJv}#z%*o>* z4!V5}M%!a$-Rm7icCkN3tGu>~-NmbNl%VY%>t{NIfD&DN^y7$0pJ0FKT9;nac6z4oG5;VQ>K;fTa+JmT>@hiQ?Mn-Vt10Tlp`#%V0d@L|-%+qjF zzgCR$D!p|H^|cNCNwZ$hMwN6hCS3T>;OJ3gIRFC+fJb5@RIyZ-#2eqDo2FsbDYWK3rm zaF)Cbq08CH$R1po*&$~J4MvjSJ5mKjJJn!K0~JD zX7>wYXMf@+aPpUa3A6v;1E8c6M&}+v zSL?ULq>bA42C8cu{4u44l+L#@acsYiBh4x^{eATu);lm-N&Okob->h1dcu6NlDTq>h>DR2-@Kc^v=8 zpTn8Y{~D%ly`@#-0eI3WLGM{lpoBU=8XKhSx5xt^ev@;n-(B z4QC`D-j{GhNJRfnh(9;CH?=G8+j9qL_*M!cws2-)$>@$OgXS`~{R6ZtrN8O4xYvNvwVEd#J3g%Ek|0f{I9|3J+$r__~CS z96L(hNjqM!Q>|98&cW*Xx4(_r(o)11GG?f=504=Lyjc%224c&fiRiyn0jt)GIw2MV ze3&O*!VFF;Or)9hMyw61M(sjS7DklWlc#XYZ~qSN`nUfUvk$&oIxvwwZ8Fyzqvkbe z(B2qLY7<}fXVet+Y9^+Rw7{!aq(>foKW_V-e}f~R`3z_z7hE?ny|Y<8s#mU{{N{Po z*VZ*=&_!?Et`RUrx@3(o>iOfxkrldhxm=eK_+j1~y^gN$|MRs8fyS35h4c`==jkK! zQW~b4y}~+7TQp-YKY-fVSeF9mwe8KAUl=;ZceKASf_`yqzVIBDzxyq0zi}??{8d3; zr?t4BfYqB6C0}4(T_O*3-oAphZ+{OPKX?MH*6^;4f>ICAFt`~4z;^}$j5v}?p@3Z; z$yK(ugIbPYSeX(W5i^0F#ld+F&4DV#(jOF~fOQNx$>huoPW|S;#J&Ib|AmvE{WOyK ztOS8|@$c&BE`tVP*Y}o((?s~02*;bwWN`A6pTgb${@>%oul^Gx$3}vvH0%(jh+S&d zYS`fbaQo6_l(q}1Xmz|r1lTItOxh!~0=H#2W=grK$?>TedKsI-FQN6m1`qHZLdu)$oA;aU)FIKb~ z)%51GHEe$CJJ|g0576LiCt=uqKXpMd!e9HlvvlIYQO-k98yn9&h1G9<6T5G|v4>!O zcpQdfC0DllHk<5vpn686%@d9V ze=ID~ASFr`6LzYX-VZfO@ze#H7*De}of*Ljm*JfNNZA{MMQaTK2UG1kBJUF=-E zC~aD66sEtxLV`f|1Y}u1fLSwcTGe>FLJ^DIvgu0mA!ETB_q7S@+nd<>;rFre&;!UE zKPEfwgYRbM_rmDj8y-Udc!;-nTX@BRnRrFEDfvToylr5rKl_M-g*r?@Jf_J03BZ=f z%1LX0B~lO1Mic_9GOLVbHf{hXmTrLapN7X)cZ9*H6}i{bnz|ho6)jyn0q%$g)vYXG7Mmp5L24cTvg6ZzY3$LvQw61>MHH*^KQ-w7^^MeOkK z7y`gU^q?aECU;jno`Forr&+#$Rra29ZF3W=-~Kk%L?Zv!{cQAJAZ5TOw z7P-@>0P#Q$zZLm1gTEX~#0&x8%?AR>?wJHQBVGNUYz|DpVl9R$$_n@fAt70$F=S?D zkyJ*xb?=oaobX5i|E9=kuwZkGBY*l7PW{HOpeE}DO+!KL=bl8mF#RsdhL_&;wR}b6M0R=-`7>uR@$PqH_5&Zn^!pw~{?=P1 z6B+_qSE~mjPZ&64{-RT0o0Squm(FANtvBWPF49;bvLr@20|e55KMV8(Gt<);z3q17 zPoC0r>eOz)n@K~f8yTQMd_%YMswtI3?&wiD7dSaGg39i0FzlYZV1<$DTn)OU69iOJ z$94YMl}m4s?V!h%t0E`e%3??zPVlS~h8nS`g1|Hn9G^?_v3?UqjIoR1N}9 zvLtJn#rCi;@1l=$3_IQ8nB`vgrj6V5o7zOcQ(j)i^51%tZ|sHU)JRR?(+X&&3-MD zsV%5PYQfxE1qSl}OXl(zzxO`*I`OOj4E481ryASaz}*$>gOcCy|+-N9NcuWch1^13xjoZtSkRky$tzNqaM9 z0y~Nr%qTC|I;!hyD86+OrNt$gg3$&V5z}f}dSF)0e-3+ z1l7G_bEnU?>l3CR;W+_*n{aGf=!)2g3(i_<#p{J zEA~zd#=Pg<1$&y~0maze_h97YNmQ;~Rb+lF<@>CgC!|*o`hlLD3(NuF_H)l+>d{9P z0BF2f3A%>(@8;qEn939cp?%8>h>?@4U;i3b{_gLjT7+MAqRx4b7-1G=^O)HEAj(U>Sk*k$gY3q+Za828rh>qF>>c!E$-7{(Pp|~GsqAC9`;S% z?x<{SVRvm^rkVWCE>*IE;y#lsFpafpE&QVO)YLe#$L5fl9`76eQM<5^RL;x}3R&cH z_&KIBa5!*F@z;Jv)#`nsNV7qknAZdd)f&p@&ZESm@%s8YwCT+Zv2&2SSrY2~k!kyE z4!Pqek>LPPZB&Ug0bQq+Om?V$ICf$WY4hax7{>3pTTZ_b;7kbGx@b4|nXJYA;ddKF z^Awgr)Og^t`__3>mKQAnAHz@t`ex+*qO$kWicrgaHhCbt{I##(?Z^HUTNloUntz%l zWjYYF2JTGLGbQqW+FGx2-j2wsB$G&plyb9yW}^`VJPt+s4Le#QX8UUk1p2IZnFrEK zU->Gs$B*HJ$mAS3+DZje)B6RducwX9gr5{X)5`&#*UqtEEb5SQc9F=vG9Z`vI71$JC zd=ZO(`p4M#`@e_V^y~h*vvHkj^3=f7Uw@fY3Nw#9g0uhIzrij4=l_AZkNpf%W1~S? zN~(aK_o#jo+WkeVsEqJ(Gj)}MG1*B<+GY(4dqN{d9A>xS{q5C9&|t=^%i)n%?6 zr^XZwID#_I$DrNG8$rOBnHWBXpenK$#^@_m24KkiyH>&;rT*1hk| zy|w`Z#$W?Bm|**2z$Ry75CY}Ul3Jm2KDqYny({fqRi~3$p}VVCMXOJrQ>SW&@B4k} z_boXCB`a2lyi?s)Pn!6T6v)RLuY-q8ePMP55nGJ87&#|d`{ zCQ~e&Ndz2|_i18W+Ulut&XHBSFa}LT^u15K?m8iSu zVpOkPE4+>dF@4_7m!`zKvaO!=L?VNB?*VEqWd0r=YPO15QppsKz3~Q)y!t9e_U%>o zhfHc45MTxXaMpptY!>?9DDp$>%;Y>|DAbpJ)7(x{WQaOl!$BoaMK}>hw7e7{_A@x9 z2H2Aw9q9Y~a|~|ZZWn2U#;~zPgLBE+_4N%&;E}^Rs|QSRQzOb(orR*s3)N2rdjFIi zoV2!N`I(4RR@v3{IwbB$I#sJl?7%<+&K^MnPZmmMa0o~K z@JAec?m6`B+AY@FSgj@}@+Fq1Pcs**r7H5~T8`D%qx$NrP=3*cW*8c%zVJdc+;o#* zRIsBHRCn^8U9Av>%(KpdE8Y2rm0xHX(?gw|IP~K0g(on5?3f}h>4g31!4Uw!)6v!& zW8>0H7Wq+5f0CA}44qs*qVOWAh5xb(p1`|DgksS-4GcMs5b)dqeb(tdIH%#zH(w*k zgj8Ny;>11JQ|iF(XaT-y;%)O#vU)XQ&8^Bi2=U9V433j=#A@qMHh&RH>l$D)Nz%NL zK2N>;m4!}U#c!^ph&lh93vlS0ZAczCP{3m(}?^df$H!hkpA!dOrQc zHa0o!6+Nyww{reCfYXJH%A2`=5q90`4d%!QGGVmvIM5kn2TC$3WHkrB*TAJM=lYe#9`RAkM+jpXB!$!~NxYxV!#+y-d>1Coq zm_xFR0D?q7Nou+PH9AJ~g0Zl#`IGbCM$DIb-}?Xu9(fdd9JK}AvC|k|0y^Dw`{@4 z{{1dPf!JLgf@5|a!`rsu&@;~nT9iyWV|f0EW_Xx&YW4{yQ(j<}ddRaCW`&h2mM%rp z?YE=$>dnxKihMs>x#@f~-E<48SFaHuO%#Ptvn+(DiheTL$yD-y@FGS2Y*vv~?_2NU z(38)g=k52TJr+>H%%mfrftjGSt|v3l2Zo`KB-M>XsPD&#&%fP2WzT~?4!jHw3uHT- ze%5g5sU(JX?!dr~ZAka`JDwb3RaaYmJI6Ei3%?;}TGi2L45hqv-KGsFYHU!fch7eO z(|OX5Xmtfjmn=llycUrTz&$ipmab#*j!%E&mJF0QW*{-UgXDU9k=(u=$vwMKw(?A9 z(U^HXwE<&r%rG@jV9G{!?`DAKNpw8>oZ!YYyuns6g{$YZPooSnkuN3&Q5E;8aR69S zSC5A4uSdgGS0P$iQ9xf2Xo)y#uDF~TCGE&|bz@&)t$WkysS5L;~S(EReo(=$y(e;V7t#m?deNI(8I;+qPnK-(H)bTSMV)5biLD z9Uv@_3}$)%__bs8b*Nai0;Ojx^1b&-*c8DrEvrQxW-Sy!>EgvGU%pKAX|@yNiIH|e zC+!2V!obu9e%6^~*BIKq14CQ3B73aUF&540%^(wWW=I>m)Pc(KM~&j7Iy!LZ`R8%q zcfZ5Xv10=KMd7ppCDi$cU>k5#uUOeZ?%Z#&UZ~Mo&1y4AjRpZ+C)8hk6`F6q9mPwR zN}tn3L7HxoLtA&sTWmJoaXV^ny;;yAWrg8tT+2yeB$M+1y7Zfo&u*kI@iRF(jE>j- z0|$Te8w`E5)um2#>7;5;W8X740sweQF(4VE5QJ}R-P%rLDk0cF!w+m&8yB{VpXV#Z zE2~7a?YR!ZsSih=@^4puabC}3_?vAQ`ui57JC4|Sdc>5tRvRU85{a)@A^9be0iaGQ zHQV*^ckue`lBNa}FIkLmZLKf%qZ6ZJ436nB*&t`!T1ULO73Hhepk(19A>ecq#4D3O zg~_q<0Yh+l1CMkbMc+4DF|=oox=u-80i5pO&rgOs9Ci+TPai&lLr*`0_Q#*Z;O^b_ z{1YpmTk0?57XToDmsQI8gXUDv5)<5Uy%5nf)LwE4ns2)eWoy?ecS|6r8mP{Pk~5Yv z!1!&{Z@vc6Vv`PuR|QjDX<;|fo#5ob61(R;2e@2M#!L`A+SQ4J&pnGnPd$aCv=5Bv zi+3C7bc%I&!4Uw!=@$fri9pmh<`~+@ip`|xe5*jrXG>9e6G&DVAuimYg+W664Dh%O z)@;IT*xoz-Bq#+YS69tNEz8;ye>9DQ!Vdwr;mZM_LYLqNnE=7BH1MBfJ= z3ZNh_(LleQzJ5P9$EWHCa3n>Bfty3Wdmj6rehP!Tb{H)n#r$f9VPVUE*j_Qq0I>c} zeUO%|A*kdkphnRLzooLZYtVA%U8ud{3TP3jJCs=% zW??XsPDVZz0*J&cV6=*&_*g`QA#@Dw&-@zu9{B}^ckVL51rhm?#MOga-Wya=q`?sY zz>^L*l(g-FM|NNsnPc6^_YD>-A|O(sh_}m!>b+7n7O(t`GkYo=3Ra{KNTaT-N%xo(~srf{q3zp)>6jt%MTs%U zC{2n0)sZ3jisDEYN(vCIKNQ@2_;h zLbTp?2O6%t0-<6|`E&}o(NXA`v}=b@ zZ~G@#KQZFd_0c-Ha*EehAyHq8aB*=k(6*HeiL*}@B$9yc@5jIwf5YGxpF>ZM+JZ>2 zEUDxFn}`W4TkEp83u_vR7yv9@v;I3x3YbrI1$#!+);4=*T{ru+` z_!33QMEcxpr$afQO-tqYJ?vJ8>hI(tSOl8Q;pkF3n4m#i=_|M%$r{pfk` z9rXY0Gf-U*reg*enR1#3m8ep9LC?Wo{R(>?c?5miz7enUe7BI@=g-s`RF?6EXU<6l z886Gud2h~4GbyU6LCaltq4}PB5T7?s)lqWf!Z(S})JhW1Rj8sI^*7y&mb>po#bUz{ z%A3AIs^mcz_WaqvjTk98MEaau;z7)CFxOy1M-F4}FQ3Bx#~;V22?B`=EK?bE2k0*V zfTs>zNGqDS?S1FS_V*#v*$I7k$ms)Ymc`qff~Zy!mDB~XEkCMIg@}Lh5HLHb7C2;W z4DHIDard>%u=(iu;6wC(`Wf;gBX;Gl&0bGoHz(Jv0v;lPed3efLcO6rqpFyoc;P~n zoq48c$K;C+2m;UFDfH(U?hiE#U)0))+D+%9YSn7dNkKN$CN)!*=5<)1#cB0^6}f=v z3U7y~Fo&L@)dB&-cdl;EYax-GAg{Wo3#9Eme!#m+hI z0d!QOu6R!^m!LJy`Mv@4fA}#5xwnOZbEoQ(Olk!XQ}P(}KCC+lao&0C z=aK>tkE-6}ApCpsy*cK|JsWwcA~@dAfQr?tQMzccLkT18Pu-_5g!l*wnIeRk^g`lS zNr`3BDfIvSbM$@i0n$f~xSWVo_0M>4U$AD5M{@Y*-ddqk-RzC);-izn-@$h5|M?@> z$31_0_ldP4a*9pwpfK|+ubz9=Q56-5v>*aSimChtyxQ0F{1FX}mtKlR_kS047hfVT z7!=AIA8QZTT((rzQYFimqxJ5)(Rkgph?JIyqL8c_~Pn0Is(&o$OkxQnLWhaG0 zG;CeV1|Y=QyXvM=m5Z{OLTszVH~@_CZsK!Zl~WIi1~rqjo%tBpx)oh-zm372yX;2n zRQePtcx_c&T2WiwR`Nvh{uzQVQeKAARjW{P<_ZSXBR@NDdF7{pnvJ zKRSYiKl%~dix-+{i^K$fG_ZjJ0C=)}23}8}o$TsXGP;gjI*oiLYkP%4zODl55lfbh zWx2bJhS`n_J`#%|UR{Y;RYjl>3P3j5r5oID03l^Z_oOS4V?|qDz0FX{nR>03$ zXX@#Yy%LyW&*#wl#TO|5=pzO^S0UEg>LVV=7(~&*3Oa7NZn>j;3VsZat+R87zW6)# z{q$!z`0TS7?e8~x`&u}W`lg>yKSzT5-xM|^Gjf?VldsZ{EgWRlUUoU=Km4%Z`g5+G zH&?Rek}rPDlIES6edmbe!Bd?LPJiO6jpu`An5mM!E^8GVuB5|pnvOVEjg6A9@aWsxdb?H7-o3+}$Aq^o#MYKZ#;2xGa=nP^V6vo!CWNW63etxUqxYS6P_|+P8g9A? zn$6|rc!XqbwE*@_kL>W0u@gxS8*`%(6XfU=eQ&)bLcWJyeu)8;q*1_Nt_P}19yUnp zYQpA-(|JaN0sivrqL$~c?vhKf;2-`0^*7uA5(&fpQn}DXiZM_h_k!~;39J!U?_TO1 zp=xH(iYNyIf=Af1XY)p=I7D=lRNC@ZQm;-NL&kbLdr%Wx8c&eny@OwRNfhnn2L@2L zd9$Fa3D$l908ax&LM7LZx+Js5x{y407@2`VGkm1J&Dnm`w_TY7X4K6ieuhE}0LGw4 z0s!c?afu71r4AlM_g~&Z??;~q%k_9^v#m56gWaB*T|cN@R8qQTHOe<_Kx|%%_nwFY z`rO_?8u)Wg>Z-9I6eUi^l6&nG&7X(L^EaXIt1mJ7=9@z4Y4W zo9n0V(@#-+#uAjST8Yv#S6Uib3Z(@re* zY+M|)v_MWNb@BhzTyn8^v!)RoVW2FN%L$+yk^!U?0-uPl+5^0a6FQCvAk07@`;Ly+ zUq`C53!@!}(Q?Nfh&I#*i8KKKJf&_xMR2$xNJx(iBQrb%n#m~ne`C3Oh}(-`TKl@x z){I}PsH6lXl~srZB+y==qD+mBzR&)KuD|>RBklWbDjsWmwW)rOodZbhsyq(zOBxzc zb^iINT7MqGiDKUmlQ}p$a=QI#zlP-f8Hu3e?6s&^zaE3%e2x5}4yiJCa-n?U@&H;Y zT9@G9Xflbe4?jZry7vTuc&N10%!s1O{SgwF3ey1riHy@+uuzU5WIB(c|}V(#v127g{e?v53|8J!{JQx{EHrf*=1Q8gIS{S~%hlX9+Oj=90wc zJ=6yw6XLnonoBQ%77as-#c=qA7m-aR4T5SoM($L|n~BFjGLDd-i81mYdpK$O|MNeP z>^O+F`@f5lGtUf`aR2~MjiT^x2Il-Nn;b!ooxB&Y<`x2!j;}cEvUej)tV{i6dG&8N z7Dp%`fgbZ1-nARuAH0wL?b{6M1hIIXf)P3af?w+KG*YF-k#%xGU3$hDs5)mIird;I zh*0N_*UwKOo(}#WBC8*zlZ)|}L~AR`*RMm##~)&p0l+-ulzFN6$W)j_LVDg}6Ll>3 zcZH>I1DRJ1y^HZZg4yBYa+Z^iEUVIS)fB(ry3kZjO z^u|=?os5eIB^BiPSk?I#n1xCdM}GG^q|+HQ8<0RVnHMOb{*A6sC@ay~e@0rAlb0wQ zC}z*&p+kqT=chkM`dAkh{O|{;+^|8tu2fJ%JU+}|mjnQCI>ZO{HJ6;Hw#=t9#W4$AkfpRMkh6 z+I(ju2S581dmnui2cG+_peC`}MiL?!gOvIJ9G_}!DPPz&D5+HNVS4^x0v-N6wO4!# z3x4z?)L(a<4gToK<`E$NYqx6SCTO9EV52zr{BuYRkFfF4p(zwxL?!F<*#I)5hVi>! z7~1IF9fmG9vGOv60syG^=VYNcylp#r-hCItCZl`^4n+YZ;5K=f zpe9m_-pmXnaN3v3jT@1e*A`624B5dBG^GTEu(W2T;*Q4V-CvmbBX%=rs3uvd5WRifad z?#ine&{=y>)wNHL>Zm%Q3k3Wpb}O{RqS05!RQ zMrPpD%ycRS0@)rs%;qT7(ScNZJDR`!ZP5qWN%7HDK=01c3XT8(PFZvi;#a=p;JdKm!ZR6Jo= zU0;bBI>XqxTM7@LfeIYnK}v1P)S{*a)SSOT2t+L&J;~yE`u$*-GqA!m1S}3RQrI{v zT6q>~F1s85AWvo^<(2q+%xB90v}z z%Ga*Ol7IRqL~Ckr;Hf7u(s5Y4Cv5c&hSTDJ5UI@_bqYS*jzQuKqO_CD4-tbzDM~qq zW**&JwqW%C{=YD^cMs-2_yEdQuQkCu(~;CDp)n|)g8dNy!07@TQdOt4Ruu}E-0%>x z!^3vY&_q3o>K};NsX({EMmP~iys8S(ib`maNMOgi#*k*R===CX9DC!>7--)wUW*Em zp_!gkePUw|pQLT7+3lTjW}Z$=(@?QyEh^WaCwgdl{R@HMnK`RR{k!Z146%JzdC~b8 z-2M$lj~vGEv7-jJry17MT} z^G*yols7}Z{4A=h5$)IJKm2`^tvFLMA|y|*U7SHr+1L@&h^FS+D_Xn=3;y%}j&M~a z_C4}*4D8x1^i`NTxso=Flc<-7%lftqbkXrc$&Yjtt<0Wa7+yM(M~`9e&wh^4-TScc z;fGPT`D!NgBka4wMw*VReP3_{0Py%!2JzUVxEnGV>$1eY0R>$;y?ez4m&PpSNK`pfWg49}qwa zWvLffAtj5K2(Qf0mamX{?KNQpSY95xBaD=KJ{29UnY1u`eGPVWpyQ?ABi`JEraSIH zsI<%oFA}-ffS9E5!HiByj!QB;H_(qGY@FL4dko$0zAst>#?86#%ivUa`#j|sL~#^2 zK+rNGjkyw`O4G3Cb6ws#4{hJQA8ijjAV|motFw@<^ctOoFjJP|Tn5_y;5E!qo z$Aa&DAJO6x?EU%A(EH_=0@Ow*wfiE=@m-HJc2&sx=~gF#V-!S%h+!;opqWmmaqy3? zV)*NCF#q%Kp!xp$kXX3T?A+s|Pz4DS0RTKc@1LLlz=a}cItzVZ2>GEApK2|CYEHkD zZbH3_mc*jaii>Tc*trM%T;nHczVy)}=>F>)=zjYzNDmB1-B(N^4XHOUo#1?{IXhJG z)Wl0lP`z=Jpni#zm%GquU~S;4)Iu)uoJ)eZ(LZ2a*{+b!lk7M&H74HcOOkU zrf{Ws9etnv4aZ*pD~5LLG6a%k#Z!m&Wx}8yfU6))%!h8~{&9g)ao&2-o~Y!EB?|a+ zdl-UahFEnTjqO>Ah&42#=F&?sxNRF!3^4HCsKUEIrAkAhdP>Gy34Y|bA#?ZVbR9i! z{sr;cT7)aAP;vHJM>foPKER2LuWyDK^mGQtUV9DgkNpDOum2g@bh--d8`g=6GW*!`&qnd~#4ge{}V zh14c=;>6jB1e(8nClXcF*i-fI==kHG1Ob24GL&q&>MAOsem+*`SL&k+A$WzD#yfy$+AJMuKai$wcxPiulnsCT9EX4R0=nOOSEA|Apos9X zYj^zTSh_FXC*3amXlq3c1AmnlTp&nMW>I#(EbVlSY9q2M<+v+R9h2M#I&cF|unn zy54z5tT&^Dl_nK%(J6hSUE52HLIb|blOw}8_NPA~!IW66x(121R>?q|yZxk{A{v)` z@Ev2B+ixEZ{^mDmf9fd=Zr>&pnj$YK6gQMi;;qUCS}3riP%>LJA$eiM8##ZGNCfrY z`j+VHTX*%F!k8x*Gx9>CF;U&hft{Rh&cBf^poy99^DwML~(Ew6-ig_o&14_2~vJYIyF zO&6m6qDzoyXpjs>-3c(wK&|XYX&b;-8EV;97%DHh1oa(@yU2 z7uLM}7WO~-C=UPO4@eCUONAZ|F?1nuE!BGX&LMHlBjAvR^S@_I@K;nG#rDm-~;&f6lsbM&9=-u)K zqQCzw;!L5|U3)G2vasY~^7gDDWG?iVaYj)l-62+`g?S|RAHb2{y@2*#J%w(Q#z%xD ziRKguP+%;EP`eh_2P6{7nABy~JoB1a^L>>|mt(<0525A0djxNtjA01DtP45DTUs&y zAAXE@^E~W-2uS%0e(Begw}2byV?c0d%KcAm zt~pbdThtJu)lN7D5@F}8ZUZOrX?U2_Bz39l=woT>LOS9OZ+FUyvq@y6>h zdgu_6ue^*@HY=(}BSe#_f*nc=Ohh0MoAZq;q_FKxG(be>yYC`WQHfAl8LBV6R53-p zN$#_MP5F7xWCM}2F?7HACJsFQ1djgs&qyXmg>#Rupu|T& z_I&U@4n6y8(eF2FElgr@!5dToy3Ei|ecGi{;z1~C>t2GqDad1q1nRH63QafMh@$!P zm8o*usg%g7dFG7!i6DY@L-!e(Wy3)np{{me1eND)K-1p+NbcT+o-JDpPY=zDVgmTB zxAE3Jfu~!95W41znREsnfA}K^j|3DKqhkGf2lP;xZ*4AUFydOX>V6yeYAX&t^D7*B z{y7Zq*=Km91WeGBPZGHou+(?LPbew8f3AH)C{;R*TXH*IQif&*`gpNN)kPP&Wc+Ld ze^jB}(o8~~iVM%j8MW1jw=|*snWr&m_EwGnQha8tux}yYXVBEx9Iw(wvM7@{U#C$i z%+|%$udw}}{~7%set>!3`3`EYyb@ssQk}%anJT0L0C*C-e?H6+(hB7kXQsa&+0mp} zj-fFeTz;TORv3grDPkbuum}N1ii&4-c*jk@;`gK@yZ7Me%P-;BU*1GIWp(?I+p|-t zH9L{8BvE99*XVbLm2{g4r1G3~XukOtru5JAS_K|t6PS=Q819YvJP!E;1PH6S^b(A= z?_>MEPbf8!D!{=2A(I*cyH;IFJ+S>6#0W175SSdrkylTU3a1NzWY$TY^n2hJ#RuyqIfK4j|4YH+R$OTFwFU@#mkmq;s5cUk(fUZ`=59c zJs*8+QpGrZmfd1?yu;{BqPsQ{k><>(nCAvk%-g{Ag z?s^}ua*ziY06@P5UO*D)!z0M{^dirIpz3L&6W%tSYno>$97D9Y6p`ZMIWWTRrbo`` zWcvEi{q{TPe&>Cpk98ZlS1_63sW&{Y$sB%e>zz_h;e$N#IdkmGnc!-;?G|RiUnB{L zyn45GtEidB%tq`x_p7s`({z1Puv5%TTu5cVk;BQBShNTY%rF=|d>H9xpJmEr)Yz}o z;qss^w;m|~kO_5C*E~c>gxGn-DYgf?*d8cZb|w*a*1qKCfx0{b6( z3Cj;c}p8>_3w{O>=E(q+rB@8^%;@JlZtH8LWKLn2h| zrR=92)o{N{+ETAQFV7#}L;U(tlYemN&>`&nU;iHlw{FFvA3ThD9-faENna;ZNC(H9 z27m+#C8yonP+lC|1DG2eKt7dH72gDXB98EJ5{PXe!>s*KWd*ddG9UYQ7A;V_)sR0l zPVL`^q0c`wSU} z6%2Sl+@yVHg!`$m^CW+<(N5I`B9Fm-t*>6xUW` z-fg#G{(}#(c{$f-1sQ27WESTAdGH>Mt2XY_*IC9CWa`vvG%Tz3cVxd`pD=yj{fDZqPm|XN>G2zW{^-w zZuVC|!p%)kI7a~>9T&yvnKZHk1IP>vLC@xn17xaP1C~cX3r9fWG12ExR?>8qjx~|M zpwnobB6*A{z60$@_VwB@Oe4e&q1nXGuF#6ym4!fU~fG@Z?s4wjIQnDCE6PFcf(^pixb}bfs_kOh8 zemi1~O}?vr*5W>otAx0)Ahiv3>y`NY`B?OS{#TT*UW@&YK7x+_cnzcJlmLM-6U15Y zjha+mgic1nDR<+#M@<-0yds&;;oxU~!_k*sMy#$5mFKOu%rTc#3Os>x6adP+{!TRr zmGa2+bXtTba|{IX3RP{2%Z0dBu5K=1UbY@BEpvr{>Fl%biH|I?jdOxXQ7Iy26>K~b z!sAL!q3sXEq=`~4S%`4j>AWKH{?@HS)2(-)a?^#XhlR}i5Ss#y?S|=NuO>1s@N>pj zhLTnqgHheC6$p8qzN1McU_c7M)=*I~>Nj753mN>ua4ODjSZ zfZ}K_D*H|xILTy;VXsVP#%8AiOSbRB&^KQrb@Yg0G*g)=ctVEDSSx_o?KzDyGb7w9 zxIxRx(0t>KXnW`(R9$$H@H*Nv;IVDy0!h3>n?$M8CtIdqu*sJbanxRSEsB>fMfurl z(f-u0(7$^(l9YopB4C=)Z`;b=B*zt$mAd*Vp6;yRBl+0vXv_lDlQ7@K>`5i zCrafoqD(n3Bs>5)W`P1z&m6D?jL9CKv#!HEfU&6XHq0!4(^N+QzG1SW`E96JxdH>9 zeTwYPoi@18+?G0}1w^gG%|;dCUgOA{!l|UK6%AKig_=t)v6=dHCw1Fr24+rpz|C=` z>ujava{^Q-&p@ZL~XC1X-rb{ z9tcs^&1}!lq>u=fiF>U}+<#KWbkU;4Sn^N*4Haw8#=b`%!Qt0mN0QBFjA_6KHEXwd zwJ(uBMLk|dIwpj7j8i);MeJOo*e{<>AwN0-n&Z&EDDe3O0I;x1aHpzfdwN7(PL2tp zscdlSBb=-P2f2~Nc`7x;hjuuu+L#a)&$`R2Edzdxk-5asyA(N{Emf&oX#DRP`T)f z0v_^x57;)V=1DAuy6dk;$%+-IeC|1s&pEJls{q_0XOCK8Vd|0eV*x)%u$(Bm*148= zALrL)drNJ#8uUa80N?}!MYgvesm^X>xdk!BB|}~EB5!V>NF<6#X*nXrWzZxN=-DY# ztilZ`Y(~|R{0gT0nmfBh-(^7sqZ`020>7dg>e1U)=*_Yib(3gUv}&rVM&qrwqxFFY znIKxJD0+g~1GuT=$qW}4BV1htT3TjzJPF$r#NMX&WP;b1SGDjhvUMD-s6wo&79DLisS_G%av zrYSLmQ8ZqC4Hi7`5UMtw@2{qO!qv0+;9k(8GnOFSP$$M*q|BJ}qPvXhaqSM`hvTT= z1Lg7|#Dr4)dFNr?{og_T&9@+0UoQa}2b4}6V9s{U=#rV9#>#3oHh*i;!i6~FCqF^; z`t{iV*e`JC53eFQFd%XRBcMv9u-wY6P-d~WFbZa2Adg5GfL;p`B-&a~G_RG(!;%2p z1OU)q1vqsHQt&UALwaZk$>AYnb6Ho?`^0-4Djq61895q*#w=W|IH6i6lqv#eHd*zG z-_GU9;9>Bl8*da|(c;EN9D4Ot4EOa35Er$<3tVL${1@FGVk>maKa+vsWvyPk1Z_-l zH{WwNO4z@ZS)Vo7k9ztQYl%3@mM;^b^^qOhkscW~$j2$2FdK}!Ig^vm=7cTdP0c7@ za}G+DEq4LM(?6G$NWKflAx)&t4~8Kj+PAS+$~SJnG6t$k7S6|kXMT;o-Mb6`A@TyL zi^7B`Yn~otwkNG7bNdG`D;b>HE6khGnW12zheGF z52DCyVMQhIXMN|~VJ(yD`k5?qKei%jb7rI;mR2uh*%)s2})S`?Cu}LrxIDQe${u{JWMaaGKKecRo4V%}YMAtt5# z_&F`-I0#J5VGp3{2B8w$zn)4#@9hT}7zELECGTM@aWIxsMQLglje>HwbUfj?r@3KE z7JkBLT^*Y4ybE=kuMw4iJs*FFzQ2EtkzEYL9P2`UXc#n`F$x^GWfzY#p;FG2Y6Hrc zby>OLJd`tFU9@Md_?z?!)lI@*1|E22X!*Kx z(Z-&?|KpF)|Jmml-nAR4BS(=R=oiW7dfq6E2}dI$*Ed#E#|)hLC_j4*YA(7E8OF(WRt9cdRGK8=DN+Re>`#a#sZ}DY12I`P#Ku#teQQ zLEyZB-S57GY&t3OGObQfHl2aZv#90=8XTK>F~1q%L(ovSX(QUc`&~5MbQ9v$HHvKV z%6&5DJ%DVl&|dbla;^@5QsHDSj^u#@IPk>dXn*oa4Da1%&_bYa4-qfgq6f&!8{HAo|Gb!YFPiCHz*+0MldQvE45( zQ~~wsG!*JII@49AN-`(1*Q_XcE|30CKS9T{&*JbaFJq9c=e)U|t%4-kI04}4reb-n zA`EO-Z`>d%W9zTG4)KNt$KOTA0)I1mtc_)46W5iO~2x`y+SRO}Pz);%*ILCys^AG9SGd;cN`O9B%_}S-} zA@f&^ba&a6+J5w0?m`8gXIZ*pg&+lPWb3wK%^Ef@mhr7ia+fH)t+Suw?_|uUEBn%w z=gx>+{~~%m{18dDhh(^B$tYctMRHnJI2IM;?Hu$q-h4BPm!ALxLHoX` zY+gB}FW*4W7!G}N8URvBamvDWw=;k#Gb>tu3hBumN?OuSU(q7b7vR&2tY#_OO!K(NDz- zvZ>^i@cfvh*+;a$7foHKaB=2z!L>0EY)q6kN0h%sY7v2X#(&OTdI&{wQoBXUQrd_Uz| z75zRJcpC!%I0@_CYi;+w^A7g@>%ZXe?_WYXpSNAo+N2b+Do41ux45PnzI6qb{P@Rc zy!KjVzJxprHn2?Gw!A?=3PKc+qRB;Nj!aAj|L8o|$|HB411 z7(yLIr%NK1%a}+_4J!D#>3pLDMJ5BCoz%>8)0o2Kp>z%gF-DbT;U+I+_Dc+6RrX5M z#B!Q}{i6UuAdy0iL5i6_6d(=(vu(@}qoOoa&I}ZOE?P7NWlP3nilzY|pC;k$lQiYm z6HzkH#cl~}48T{3bApqrT+OCiP(!)X0T7;S5IC&>a3;zz_ju<=N0DUUZ@9Nl z@N`+;zgz+Pg`zN_t_(q}MAaAreW9WRw4%7@Mgn2urwoW%=r<|BOq8Ew){c^Yw!cwDq5oV2Orniw(%R^wQ*Lm35MBhCdZf(<|B_}cl<(=bk6P%xoig5x*^Q$ejp zCj8>Wl{gu%&+q9qx2HoY(&PakrAl9D;%Uq^evpkLU7c6TF|fsdQl1D+G#p1#&7_~f zzE87^-SB#Zkvw`tw2!H1Y(yfL6JamjN6_XH;?FPocCs_C8%f+Y(J>Je1_&{wYPzMx zv+6nI`158mNYvG#desVq<1ys=`i*ut>9pZ}fsad=NTisQI-w)0{9fYNGh7nX<653| za>X?+)O_waBUhz)hqNxn`%J;lQR?NzB9h0&tTd*SBIu?W9KPNcuLg$O8%oAd-lx~9 zqEpzD+MJe2Q!!d4E*ZxoF3BW&N%{60R~bA|XuK_5VTXySp=(dr+|UBQs_lV@77~#_ z-a9!Iiy6@tpKG1y#IQ-{08$^{mm2x-mR9Em2a)1@Kl}D$q`e)Z2M!>0xC7aqZs;Q; zX6Q*1Cp}33(5f`!3xj`uKAQnypsZxc8K}MRB2=BT4$-<=3G@;(>|<8$=?3@{K+p{U z`6(r28BGO3f`l}Aspqjz~5^xT>iTKUBpr3 z{2JE#W}^TyLqOJZi;)pvJU=%CE`NT$UNqBS66-N=LOlLCN#*Bgt-`E&t-WP&nD>@Q1J&n1~OmBS^I z9017mmo8+Q!TV^+dM#8K1nRmi18s0eWE~n3P8oqQ_jr6XaIQIH$=9$-+s@2 zx|JM|6EtRSiVHHqdGq%0^sX66t^0CcPUO3er^fDt+kL0mS|~I}6Wy=mG`MGS633fP z^K;M>FmIFHm#1PMoQ!!GPY(FWBlyT86nGyQ=QCr?%XnSACaVL+}wy*Q@wD_`YrgW03`V{sje=hjvfUa9!4Bc zI0nfy2r4=Wp>nzcz}e?53C3)u13)^-c|8#sNc1$Bi$X>Oo#1;<)$@~a3`xKDP1Gqt zrtw~90|1=pv(RZCqv@EZ=>mY`0YAeLMub;S070Fi|IlIdva|iAS5Ud?EVSP7Z8YD0 zJ4((t!{#6rg!_|%pwkKfA*y>E!b~a{xW&J+8Fan&8umQ$C^}w$9qD9Jc(;mRdAJNB zND40}kJGI|ft4pz#5shLMyt0-Q9`sJinTNr{Bnwk_XH-eqiV+c^SsCKAVvoVkj~tBHWS z6YJJI{z`&jtk zgQ&aqS`da&h)vyp{Ku34pwZfeIE4r>s%HA5B3UNrGhZ3do}< zEGXw1O9VZ^LL^|_7<(-Iyj>IZTH3h|=kc@&|x1IL22>h1MIL1c0Wq zbRCgdxh}_6qoknG>~xJ8D>qA%ejhKrg`DPlpNs=k=p^1p$C!cHMx8z#hCDgWbu!jm zkdrwIgg6Ah^2^r$iQS0M=*iBVYt+CcoIum@>^$a4V6==Nuc7%(IrseL!QyWON z+G}+G9`t?u0fu(&5UxuR)+BOE7OH?eyHbRz!0%*RKbj5yfDmslvv4tD^A|uXF7_^) zDczhpPPu#*snjqssS&#nMtLs{;7kB`Pp>g2vvA(%Bn_;o<~)(p^x2JkZK4qM`T;p2 z5sByFaG~ASREca7)6Skk4=7D~s z@G>Q_Iu35|>jri1x!0sqZfK$w29qhSv{M7-$OHh^RE@*wOqH03SCL|Tk0UwmJMmta z_^dW}Pj{kH$cz0qynP$`Kl%Vw=bnS`ij~uHhvBIVs@!paADN?FNF6*ZdNn#to(ngD zIbBNQ2_tCCC6mYu4Iwj{6yIxC{t~mchgg#z9H&~a1;^Z62f*#s1fcP|5mBZ{ZX{(ee)Qf*E=2=*#zY8NwFDM?&T zXU(6Mvw%~Jgkv#8OG*$gD@U}fRJ5Dp3>Rr8-?M{*$gyYT{H|GDH+y9p$~J5QXd@rq zfR=Oy8~$W0KxKo0i3e@{_aSkmON|Y;=s1A#50qhpix5} zI&JK9!B=WgQCz=A zn%{<4Lj&S<^-O0}i$((3(Gg_(dy(nwMw)}*j>8zmU+nW?|>w!d$zs0DR>AvO2yczEMf=>S3t z-3zs8YdHOICYweklY*YhGNUVcasi+li`(-R(u|W3`({rSr{6?Zw6*;#4`7H{vC-y6 zLCUBKOKQ}+OvBgeOz`R5y`agI8aklFRa#OwEHe?s7XZJh0f9LQf$8j@L;vt*VeU3d zBFjRV(%G_ph@v2MN+b`Q;rHX}Q(+P>T`Iz_J zhtPP<4LJJBD`@}aFVX$}dr0T=2s5y$37;4}DN9kIf7ThTs|Df_VI8MFS%WqdxuUCMM_1W1n7F5=bq60$?Mwqj70RwFJ-G{dO z?-!w78_QTKi5e$Yz?SEbK+Wrx6_^$DjMUYl^`Qq*dge0h``J&?@xt$s92#QsSGV&6 zPpV8J#B=~qyFI8?npd@A1zK;t70v7{J!_@es?;AyI-re8tIK>EEre)Y18Vqr>E&4X zgCC&t&#&R&^UtI6z4wqA91_nS_Ke|a>pmGb$8J2WPsUPCF6WE)b(uPD{5zo(YOAst zp`XUO8#1lMLgDFI5X6JkPj{hd-7DYL(P$irrY6Me8`yr0oRIJ1`5+k{0_g2yCT7MF zc*M!6BtF80j=xt5(sl$@#M9wVnwv#AvkkDjyPi;Z%MYl_t3{+;IGcc=hZ3K#_* z{48y4McaM%qV0k2qGznhQKn=Z4f=&sqp5!lf8b6y))vLny?Oep1p0+_{|8 z;bL?PBn>l@qQTFADAY#JJx655JfRn;lW~kuIrYOY(4?+M>KT_p)HyQ&AnKBmwBQN{ zKOBG*m6V`)^EGI>?G6e2S&*18a3V1k5a;PN8xWc@l{%HPa-FRRWtsb~bk$jCyy*tf z6aLtnZy=Y?+m*s62mG2IOiJwv=c3vgwB2(r7Jl!0C|R+>V;HDwfcO?0P#b9w$MIz6 zv{}zjn7)~ZMgRDZNYpoA@4x*!x*Y32mpaw_w!WUubT9E<6@fR?WX>Ez#Vm)=1AOBb-5=8a~g|O z!_#%cGfhFt05Dorg?M8FqLmejs5Gj=rbiv>sWh^K!=gJ%#$51Ws8$KJJ%V0ug{)<3OYX}>&J~1g4`$C$@LJzfJz2; zp^fXXVj`_rs*7>q>ExAbR-@*Ui&1>W zQuUkUBxqX(5g$Kk0dZ+N0G&JHRkKy+Z^X#HJs3K$AN|{R*n59s-i`4qhvk$SZ+M^B z`E2|sibc_M#T971^G*r;QIpNWU+EHG`-2uRNz9<86nPJomZI_2TanM}4BX_=`}yBY z5J;t75B@pfWE$m1p>^mfj*@!7Kr*5V@j{Bd5se~IQi@1iX(3p`CE-DgdD4t+v z91-?fw6Y43igJMc&O`IO;(-^+h%RG<6C$UO9_UA|kDUWU$nk3Hp+WX@5P2S1>*+zN zzh4k1QM0yK?J60l<7qza0HEKJI$f<|ncGSzKDO|p)zyO6 z%E1)J0c)w`cD7z(N`)_6eKhHDO?yy>-#Vm@tJ}Fh&EAT}f2QK&#W^=Q6=- z#&b5gmqMJ!*f=p^!xOl9Wq8B_@kG4`Qa~Y0&)OxP4JHNV*qYXvfnj)b_@AR}jEmVC zDB=~1%`J$spIq^1?Ah}C**cG4^ypEHvS&;6^onqtAsDEUpiU)k2LYrCD!A#)sEN$U zq|_Dl=w*2l9WX;oVeV8;S~MkjH&|yA!q;3;WhIL18ER*4 zd#CdXe^dGB(!FRN!+|(*+y}_0;K~o!xjkz{dEE^>h$MxHOS4n6+LzyNytW3VYgVCn z`58=hM8`0$3RlDt4?tJ2mK{R2{t#vIpoD?Vl6kEdVF1vQ8S;Me?4?2pWYlUi>U~c8 zwy9(U5JLv!P0(4ndJP(`xfbQCS4)p>Ay*$W#{Ey?)q2!byFl!80_VoUWu>UQ{1S}r z+llni4h$bYD)JCRy!z7yEB;)GQ_*{_nUVAq@mSWH=_Qq~kTb_j)?p%ziUGGGCfkb_ zEI?wxLL`_RjW^aad0&SZn`iE136+%zLyK2TbKXd91Q1@(z)nn{s6pI`&SsG5E}CWg zl=DooJ(n9AX8Vx=z|Ny=44EuD*p8tcJ29|h2SyGa5;`r*z0Vw2QzM#=`xHe2M`;rYyKp zAwC`h?}R#eG;S{;m0*^k1dTUvz*n|>8LBS00F@gyqIAg;K~cat4haJ}8dGp$!!Z!W zsUCPY65hX=W^xRKC6PIH48vbtgbg4>BCW?*5 zV<>BBLD{OaP=4+@l&)Hh;&}@M7!4H{v3rS%+8|4NyqUwy&(s6KB4 zN|!D}thN?faRP*`2@*E8h5*V;$mAI?N_Tc)U@NcYdkfufzm1_?yO7G~g~cAWl&w|4 z=c+zCA>mHySg=O*rU7arOc+-$UxAuSFG2N%=cDwDGer9!&K^(L-$*EIa0+lC%I2RF z_NE!I8QQuPz3ka~-g!$1&rCWat{xT&Ni+JonjS%msou}@yht>L1Os}B#s(BGT!^xzOHs_$JqPm9`UXU}VaEY4Ta!ZR9B24MD4w*jR`bbG zVW_10dNF$FAVzlX!syN&NbcJ&6j7QPSDg1Vm&@6JJY>^4_}A_WFBz4?tBx|FaH<;} zAV{RqqpDHqo(tJ{qg3%=M$0OYXlNFNaO(U>p-eJS9pw|&aQS(yS2#E?VX|R>?Z*^T z)S4~ti1%|u^0`wV$VpuhJ#XrnsnDry0P@#jZ2eSj+=Pnt>)ASqD=X5|t!hH+huG{9 z)^B6Mn?!3XYA(1CgI{k$@{fN)hOIF>Cz6h_|BowXAbA$3Ohsc5kJym}DK*A&n(!*< zM0q8fw>FfVxg4dd&l0kH2Z~%iv(qZrj5e_UEm@3mCE}J6 zUcu4!{TO08t@qPU(f7B{F|>Ox(t`uyS;B&jN4K*Xh^j7?kI*eIw98gITCm76vp#=z`&2lwiMKX1$cy^$&itF3(9IcUEBex#Tc)%EAs zao{)4;@G?IF(8;i3=WZL-n?Hcd79rx>Ad-bqGUWZN<@7U&WDEUP0eiUm?k!I>PA_m=FpPMKeks12bu#65%7v zit0WC{FT(!q4CNq(Q?Nf0vtsutHxdvTx2`~JUQ6K{;0rJuLMRb8 z`d~97sC4NWXu9mg$*PCzP&~t3=8PH9OO2xd<;fKl+MgAp5CdIAdu5q?ozc%!sAUCAZOB5d77ne5frKGYci1RQDwWL3D4xl2TQc3NNyh(Zc7Tgc(R>Yu5A2zKZME1(q(6&V$B-# zGLVuzbjY0l6XiM~N_bS>&0?I1EvrIbt=n zJb7>Y$fYzVg>nI9-6!_G+o?pUuNT%g^vr;KjIAqvR&F{U^S<|eWV*XCxMeH4-}`J$)#xf?gOa5_G&~bDqNe6+Sm5$-|Qc4Hr^0# zZA0rr-(ws79JD|F7!LgQc?=)vw8OG_zzkIY<%=0`xZwsg-*y|y&t9vBkX$CX?g~)( zsbK55Iq0g|xKW%Om>hWgaU6Q~d5m^-BCo46<5VB2Dam;=G|s_m?fIL~_TYnPU_jXe z{HQyPS@mHPSFERa@e(Zg$$vx5g%@N0V~^p`i!UO@=9q)P@HErwdC3l(Agcwy%bFT7 z@18p`?|}zUy8Ntyp#x7BDk^zo%z=+JHlXF+d)c#H$N=uI(f+Gnp>ONg;E4fIK%(q$ z{05YIUz3%Xa{t5?x>EonF)H26b#8=d#$JI8pz>bg{ERb&S#{wB#yc|^B##_sO6N=TzV|-**g5$1HzIF| zKc$g_Nlbbb;vZ(DsMpntwO4*i81|;`^04oDirCH|9#EE<>3}L^`feKk>`Mq%x?aJ_T>YtPUn( zy+xVvUvv3o;#}~*{TO}kzKf$Tyo}Db-o|hTGt77a4wa&FWb$2srWZ82t8E;*q5uFM z=djv6Dr=bq+R|(!peo@8>hb4J)V)ikmO=vPrFn?0TjUPq&HOrIDMxvwSprVZ`=hYi z#8JsAOE5vvdi$MN_`@HdeBD}Qkx-MP3$8pPq8jwR=`{B8GD*El*RI8a;vb8g!uDVO z3Im;;cHT@`b0b=Aya_FL-@~lJ^9=X28&J98gqo61CZ{ww0!}x_P=k{*#DQqMsTuKk ztqgGe0s}jC+V`PJ0tCbfUF4}TR&fTD8?WAs1wZ}=)LeO`WaYUwnJfQHMx=6vm7Ek` z$-rr(v=ot|1P(m&YmD~v7#BbzEgj zTBd!oyB|oQLkmcl$~oTF#;*G##2Xv2|EG_j`@{EbPnvd@1pJi*v*K&kor}hsZbr@3SEG385@^1mC8|2?$ygp4_x-xzqU%CZ^`oPMsoTUd zt3L?}@tyIIRS^TR{A{}JMr8X3F!1^3IL5u(uf2x;9ovyLD`6vMo|2L8N?azLM0KI0 z7ig}Kk&z>5$qVZ8{8=r|(&i^iQW@x@DUlX1#z0Mc-6|e=Qm|YopG_h=)Qj}+fVdZH z?}R`-4r|S(t2RTCrm{9#teH8YR6@Vj`l3)Ef>Id8gT>y zg6irYc^f^Rjv-P`pt3l)f$Z@iK()TsT2pzpKr-fEqeVq%I+yLc8?Hwklb1X_hI_t! zu$N;TE6E0sq#uz$x|*k{HdvspP%0_J9O&#+qFC-8#b)0Zby9<@-5jf}N5d_*q2an) zF!<#cIP}}+aOj2KVqo_kv1h`ND~rbldVW-GWE!!GeZ6c>UtD_Nkc%9Se<~@@7wYLlzPI0%s7+i-hx+CQ8DS4pZSf_ncWk797o9!FSGO%*~WnBlf+)rRxXbkE(W zy7W>-p~>}&cBL^zx&J$&AmHG0zeQ$b#I9&O5r>t(#Fb!CRTUbq zzn+~p*x(OVUW)}vNCEGb0xzw&p_)k_E-7aK>?T9_Fa_1~*{60`$R%n0^5Dl1XX=Oe zGg&=X@e^M_(Xod%RXu6TWpx<;g?qw^pe6KPtI{ zj4DJT49*(1hk4a4=iEE;@+;_g=_T}h`6ZH>v{7KhjUb{)-g{kmM^$QV3U-D|N+zO;CgrzQ>Y>cGbJkUO zu}=BwRcN_xGphC;5M#zczNQ)8d}CZ+bo}3dd4?eMs|Soc=+ibcaU9D*Uqh zQV}n~Q^>@q+{-+)Zx@F4?nLF_Mrf6lK9YDUYTW|Cg)9?QxA2Nq?j+zTLW&GjhLZYx zo=)bDjQ+z!>N;ZP{|V4jQjF>gE)eN44Od)=qLvn~2g+9>Qg{V{mn()6x7;lpi5d%f zkJ%fA6xjJxb?(^oZcz8C}y(QrqH>4~1a96w>9W4>p35sa=+ zTZn1a0YHlJTc%mBMHz76JWR2wsseTznVjnnj*wRrHWRYEIe3o!lq&*ti7(0u-{_LZ zL^EC37F~m-cq>+{6dtWAW~F(+BJpl6LcI2;BA}I+GqrO=?5i-P5vgQ~q@fOVJQTNa z6BhpPN2t2!0%=gCs}s3;%)g~~A%!d}H%e5X%>N&+Z$!hD*C5s2fy{Hi!6*}&ny6TH znyM2kbjUrJXP$|M+ipe86_+c$6RA7Dh7ymn!>_uJDi)@*Fv?f0VfS@4hPUrT*M}bp zfvO#6<(>+coH4L^l!mkr$~Rqr8nzaS7A;giN1%q#s5f_p_|1*a4TsChQGMmN(7$H~ zh7RmSva`pr@d<@e_U;-$N7Pa&Cr!@vF>+bC_aRbTgyt)+!~zELYcIQ8R1G?g2A47= zGQiOMn)!O?kxWcv`@W6PF%@{hY)E2-@u;G3?cvrml$>=ImN4+uc;k)ec;N*c{O$81 z-!(1L334JgiAYocn(a~5MDW-u2eS-BPODMAW({h25zvMWC|R%o;mRr_zmF%;GX+9) zUC0#Ps!T{45sHnopAnZYluRHczR>!0!Wc53p^{k`tE@xQjklrUs_TS-A>OHJb_Bw~ z66`rOb5V0ISu%-ie?LYK|Nrd0_nREYl_h#2%eMF3@ZInr0g)g9I?+hV~rG`suD?!Nbbyl-}AhZ1E-N%Rs)iQa*p1W1B#1W14|?Y*n&E?*TdBGN@uGI zhbBs231FkTsxmU--gD2r_uN55jvvSPd+%ZVz<$j3^avu4mtq8noW`~pTTMz#@O>8@ z9K%PM=Ne^P~NWtI&D>53uUqd-QqFaz;t%{wF9nTZ*{9AI+zTpfJP4vpk6^*$?l! zO0&b70Qu`;HOF71hBXnCv7m!DPu8<@(|-Hy=y~WN48Qgo3+iWt-wn9#tXqC+E_W&P0PT9G3NJ4miHiELWGv>nnIN4nJ8hxrnVS*` zA+}L#wr@k-&WkMv2?HQ{9Yo?8b9q2wl0VYrh3(q9Ds~W=v%9FA z;JJi7L_I&BxNd0m#XHb+!}XXv{3(*}k6DQ!xf4>PhZ%6K{n{=xU3C>gEv@QW6H?-K zrY@r@%YE<^Ndt4_EmvNN*y%Hv9T~P#)N_^XkOJpio>m~wuNM2aqaBTxULrvEAHdKHFNzLg zP0Y)+Q_KSJ5gSZqjrqNSPzY_ziLL*^572(+9in7najv(}F(QTES>uvbVeu^W5n8uS zuOn!I(Sq5y)CYYQDh;z@}fY)LsU+h$vqp55nKR%#?V&Y*EA89A+MC#1-{-Br7e zLr-4_S&~ptNSjo3b^;%MfJ`oDumw~B_|+{fXk@RcaRPi&{thbyqr&UgvIz1Lg!g}l z83zEQMSq6WMnT;ZUCcsx{=Rjc>ruaL6GF{RE@q0%vti+#is7z}sNQiA0>_RcF+OR{ zv({@Osl(WMtHR}^WSm)R(|q+c*!YWo5=}(@x&}}F$*Tc_EScF{Ksy!)qT|lH;j66^ zBDn+4JcD#9E%vtGU`%o*J5F+f?Gp8pHOz7Smv3X^zy7Oen(~g0>AW)t%jLmql$)-) zTGR@+U3UY{Jn$Vq)$9=Lr(iuhG0O$RndCGUF1f5Omqyt{Ah_UJ4 ze#w08CY=5CuQ2q|D@d|nOxJ$3i6K?Llz6V#QUbiM3;^^BxT$lyNs}M^nkJ@y)OK!! zFBp>c8Z~N&jf1bK*cX`$khBANolSa@0l?`gp&_PD4Iue-pn3X&s?i%aVl^Aqqju9K z1RWia-i%gZ0bc4X&&&7QJO$e=;{_n@R)=S&=ID79rVs2Ppx{}OCzMD@DW2s7{# z9~-yQCi3)$U~3yftJjDWCZr>-!lY87G<5(JaTq5dFx<8ZT0@f~dN0;^QdhmEbA*yL zy{5hvwOco#dSfSi)zyo_#)sFeL%4Gje2vY>F#u>vkt?;>Bv0kEREJ<`TZopLCtiz+)+M82UA|UVA;#Y>ks6V;FgJpP{jtQ;b{A z0MTIv8rR%;CpP}P0Q8Q1hej~<3R~wcA)rNg#D$zkvSOP+yqcwC5m_<)W8HfAJKA0D zmk>4bC>h2OIl|-O#$!lNjSDFV6#!D#5Ov2Hup?aKeF+zJuB{PFL1nZSDTxRm)cF^9 z%@|M|PZ|2z(qAMns3q`m^H# zr1&K++MHxmzh^hv?z#i@mtE?9KjIWrURj)}Tx(~wt+8uvzV7RYo;-n>Gp8{9kcin9Tk9?22%7zWFN93k4s_sUTXLf61Xc&V} zKaK8(9>V1Q4|PcznEHpr?UVAHWf#zpBxk7goox~Ih7B9A;m1G3hM)cvHCwk^VFjfb zgZnbPlacx+MU_(!Ppe3&cP}p`b4!7FeWXhhQ|Ze0$h1h)SMnF;Iab!JwG!zULxE!N zUTpp!{{y5djJ`)6L1Jp!U}~jtlu{}YN`+j28HBLMf5*WN6RT4rg}rD zo$p=@4va0N6r>ZXRim|$ak8rIx#CpQ1L|Blw%ZdDlw;ux0Y%v#dLxX`7s zRnBS?-u=vLks9_NKgaB2q$W`{8cZgo2@ zLc>KDBiYl3G@mr&2)->HJl=4^{u1QUO1T_{U*Cu57pE}x_Pbd3{qLj6m=HpUT7f5z zCzL@KDG*%q=@eu8_F>@3r!e})8;FmMTHU7h$VKV`CWW@W%rIJ6EMs~Om1LFbH+G@x zAO8`ZKmA7`@nnP6oFPVT2MaQ*Sdt^8YRG4qM^d?eARZvmoOy0$?Fc3CWNnCB7cyUp zhDx$jL{yM6;Jj-WHvQrkqJgUS(Z|Hp8W`g;iClI=s0ZV@d><9>ROeWrfv>Ji8M;2k9bjUdUT8({0UF}G*2SjDlt&S3y8#pEUHZ>UgJ1P z;U3otzn_>!#&(~7~Q#=K|@1W`0YvoYM zF#?Qw+^D(w`_Fg#-3Lq@L8S>Eh^|taWq>H!*N55v`+qU~-1F$T^;UFz z>sx5N@(KpZSBdvlJd6aEyjD0JiD35BDU84K4o0}S9^O<2#u6@cW+ArdrqTD8r;$u0#Txsh#uG1% zM=}o~jS~!Z=W^YK4QRjhHZ)&%t(XgKzll?$FpoQ(i@{xXgqK%+RPhOGEyJu9d-BOQ zX3E#BFBJf=y#;}e7Lclt`xB)xeELyX&gJN32BwnAxf5&%Jwbm^OlOfxDAe*EJLf|U z2ks|6QRvT`+@ifbi2U|9=ziic)NR^~#!Ggi?rWEzn)!~<>J9-$_{1VUqKn-mJ>X}6 zCeFb6Y;QNB$4?-7=rE!uK1Y0XMDSIrcs(&Pj?^9w;M&Y`OCEJ;*Snfkq?$jzXX@Hk zq3iyipz~)xcgRIid!D+dE%7Qqq{u%B7m7@l@``K*$)RD)u=SYy=o3tT`YC3=Jc;;F zKT^>MvWYZ%O-_*@vp$*uZhkL))inrm<&I68guGY7rI(`ql3l`=o6Tdk)KCs~Eum(0 z9aGu9cy=^oe95i0a6m<8E=Ypjv7S(WpPm>Wc0ZnmD?vB*oQc=o8mZq5pacoe@ zM@g;qmfV?}#f^RWB?ejK)%)1vnEdphkP-1qhgQ+{Gr~|OP@Z>j5JE~i)cIDB6yQEx zpa6w>^cK>r5Kk_UI2$lz=E)E+7cwP2KN@#mhSuwDU`Bkix*I&S2`h^T=c=Bn;LVlp zsX|FQ_Y7R*oj~Hn0RxE<1|)_Ck(!CZ$&Z>-TZraofBN$8GJ@ruhpOOS5EBG?klmbR z$|mE?NoTAkIyu0n4sK1El0o$3pN~uIP+cl!;>Zz})LaRDNLmmf!yx}hs zi6AvHri(f=FqotEE)-K<9A3%N*>l_@C;d>U8Rw-*!p_ha;peVF**Lm|(TmiDq%jJ3(Jdyquy6g1-EcsPhiJ#nL%YDcDVr}v75|%J~7@g)^iT= zz8*~SER=Xf_Pne^UJ(G$S#M<0x_0rL&ByRsv04^IRIgc!Ktp3*u%jjkT>M<2AYXYs zPyGst+lb(Ovg4-tksrz9NS4%&6E`TPG|#fZq0i*hDxk;@VI1!>d-^nnpMM_xk3WIQ z10Nxs(VJ<4W^R;Hr4ZN&|L2nwB6Bf_#Gdw0D&u#495y0F*%sDv-8*8i;bx~Q|FgEM z3k_FZg}NO(94v&H+A4EJ98(*qG=0Of+nbLFjK_qKFi+2A6LIkx-c8LXbnyByXQPYD z8c^z0{^|keY=VBIS?*K>Q4;uD4@nM2L66%P80 z&&&ZbmqMM3bbc~{G*8yU>zs2imKYg9tiK=WXw*d>Q>V;2b*E0vw6K|y)eP&;rFXb! zbz*o3arQLpj%83|-YcI)NI1@n#d?=()!kAmR+hv#bNsWLuel0q{{CC2zx2`)?0bP= zUHJw%WjY9v{6p;I2@L-2IrKjH7mOeL6sdGd8rx?Fu{6IMb?r`{1Kjd@&DcOcX4rG^ zg%?q~ZXG)AxD#u?|9!OZ3_~d7U<3h|tU!@ug&Ab<-wZIo-+trGh@bjWXEn!04G>7Z z0p4V>Kf~wB-g7FdZA`TGjW(Og4-%{@dk=Y*NU0yQ##Yv2_{XcW$uw|?@$KFcK z%plI3P=W=TRo1!^PY`#0%#(2nx`1(9)9*&oO|dYjC}9`QVgW=?&c~-bzDxa$D`gef#=GW z@Ge}x@!hz8=XIOW2Y-#BmtV%Z?|v5>e)?lHTym-LJ6b_sJ-5Z9$^e0yi!MUTt+!(G z^W%uU{Hih(;Cv$6R|o)fj~tL|k>mp#Y;6%#cxdgKIp57Yq9?AXiO9f6LN!@tgi7`4)n@|I+_E8rig7Vi0)1Y_EHyrkSr$=EGY38S@yD3_QO#!+i<;|qY(*^tfwF{= zMo2}?33eKaNc+ovzc>pd2A}^MdLMffll%9xvlvtMitMCiJ0bp!@UHGKLd`9xUEhUz zX7uYX-Hp1-ccW&n0ni5RQMzh_llEjn(v9v!#bjF2)BrabnSNMrr%eXJ?(68-37ocqmh(EZd? zm>nMzd$z^|Uy|-0r81BtQuQJ&`TETX9^5|!#JE%{>NZdP`@bV{@(XPK*MAYLpcS~4 zQ9EzmGiRowVb5h~{`%Ju{p>hq`uc?$g+@zn{JQ`E=h;0gB9N3?(+BvC;p4NaHg<_( z(z#fiQd~0e*j$-t1nKcn`xg%YCAX42H}q$IqR^*#~}wv%mj6B13~>9|gsJ(u}}O zo@4B0^EkfF#uAu~^$P<(^uc@LoCn#p)Nb91<~@7R!W=-;-o2>q>JlQvDjt+zo6dLDilGrhf5+Dx8`;xpchpOuOC-bVG>4pgmfXHIFa@fr=zh5<^P zcJh303XvNaY(d`9*Iq~WZ+?g2H{L{=1xS7as!-1fy*B%*nGIvq9alQc*!1M2=mtwhqmCkEZ^26^qeTjB0J;=JGj*XF=l3Le z92-xy@q*yUk)xP8@DVeLpCHNrU}AX0ij>XtZpbj$8quWrw?-95zG(&?%^uEz`FY2^ z1;AdZ8Cp__F<4ammycg1o7{}Oh+*A?6V+# zA3A9k4STQh1jHyFYn+Eb5Tg5b_=OkH^U&`x`qtaXq>?)8Mx4waaRFn^2qZKkaN)CG zIhf*8Gge)H9oBy9TWI~pH&NBuCD^`V9y}q>K_Sm>M2;TC(2Fl&@cHM3-P0$K@XyqY zNSPYKp2dSd=Wa5$7}p@JyLcCBcJ6{!C6zf*;tEVkvH5E8lR;%L+dcaFYdHPu2hjiW zi()KiSiHh#h)+w(x>RQF?0Pvu%e95}8^~=ae1cYxXO-A`j=!}J{!jpc+A6HN`))-O zwzM5aRazaCKA~3kAca>7dX|SqXL{5y$iwUto$od!PEVt}w7}E$X&! zLEYDOp`HQ5nyuRq?pOsspW@^93#NiI_}N4PDfaz%>BH2=A2C4rKBf*IW@ltbd}6>b z30BF2DHcs7M$h>B%*YtdKJaTy@BbKU?!6CfcmEw~F5cnU%(8sC6)Qg-Sq7Tp-QAdc z|2+&ba5ehwyVhvPfOOBz`cNmF5vg=)GuBDNUj(Xau*1yelmVlB!{&N%;^%v4XI* z(5DVfe|iujZ@eZ-zv>wVD9ebaxjOuW-e>Q!2Nvs z{uQMINT|Fi^oKRsg;Tcd5Z7(qEN1)72OmS{07tyTkVk(R26%EV!{cNRi7ORF^BfDh zWUDN>MnXNSm$*Zl{N!U16;8bK4k9PMKzw@IVnF={;B!wqQTxHDm)?~_D?K-I5KWWju; z>6OxQ%k%~tno!LGz0jI9$elbXCXjGPRNQU^i@&H?h3=0Z*fD|9-M|@-isc2LH5TDFc zn&*Og?0>*wtjq=kt`#_Z@F2#H96{}Ge~ZS;FGu55SD|j_PVxCXT?xNlAIQEeXqti0 zWJ*YM`|7I2?Cc=>ewtQ5Ql{L5fwb`z?K(ayePTig0_PG*u~+z*N3O1GkCW7O+_)|u z*8%03l^6qkkz>aZWq^6+#BotGnNFu+4ieOiq%SCi=UpVuj0+Wk0%xtN+1}akz3-y) z7e7bC-Yb;XSR%pd7+MdlR>K|{Xor6vE$BzfwO6BV$2K(VyclPG{VPm-`l&u0M+gd& zyvCgr*#6?)8xuc*fgoyl;Bn<%1lw9XG9=}8+7nm3Hy3RlfA<}Xz4;ar%+D!fPAOch zygLN(RyQrx780cbz-?6%qs%8A`~*!$4x@VGCittWi}VFl2@<^qOz;4_W@DE~xkq^L zX2`vfIUwzF8Emwox`17PiQ0fb)RQp-7h26C@%q||fshwrCx3P}lR|Pfid1aYQtv0O zJ5Qv}BwCPVw5I7SVGSUqvi_XDao_+F(Wo`z$Sh#joH}wvbib7f zlFaF7enUJ|^ZORHW17oDQ09n;QRlO=hj4lDz6Kss8Y|dd&9F7eW-@uWsLImViZlz1 z0qx8%x8Hdu3j{Oj+>xD%bgHR8{1sE}h2qSykV8%L?a%4A|O zM0p1?dpc&EDCGiv14zpDtQb~QQv_{w)|F3Dm_Bz_JbVB0XZZX<1Z!##sILYI1@xv6 zc1W@*2EN$$BLSbNZCii;{i0xAYi=sQt(I;p70X7{b>$LS15Z7LzQ-Oz^z+a4dD@{6 z1A>|)`e~%aOLi^7LFmd##0BM*YP*FnM4dl57u~{@zy+z2vcKyv8(@5<$~^ z(LgIk2hhoy5y?c0bUCmGtZ#!nP)L^?3i#qHp{2k`X-Uu4PSgFo~6Q0b3iBO4XqpkX2V<&3*Tx z@zP7t|MXwb`@|DMKs=ewSbZ3pkdly6g;IgL+FeRrV+B18wFy{Y0|08Q8_8qXowFEd zUM|D=yTkz|iQa80HB5;=SumQIP6=kxsTG$t998&iH_}7HLOglCEwh@c)c>a$Ap+%6 zStH{NM06v<>?L4#%Tj9%-RcQMa$fqs8LuKb0I-_?-2j$Kc8o|`mHZu=uDKc=-}*b$ zU2;jDV5Jm)B;8F@kCy1)G}zRPRrlN@WK($7Bsw@K@z&rf0IOgA#|ggRq6PuL)fZ4(cuM@slMUdC0vLYW!o>l&Y##q98i zV47>NIgbY}G+iivRky#j72&O05nQ(pgaN?ZJf9$Ig_!LW#1FTj^OOc$F)}c6JHJ&O zM(tX_5YN@Kn-q4;%&hzd*_~Xn!Oo40A=5j6%;dBKm{6rV!K*efuY;kwr&{b9Ko5l* zX0(Se_~f5)?%{_q_VFjo$!Dzw4xdZZm*yq;=Y2AV=`h$K;ptcoNGZ)Zxts-CD=ioj z^`(TYK<j6(fIpK?sV^j*kd=51|iA9hz-~DAiADeTLI%Ipl~aagQdn zWQ5J7qzYiAj(mn!8Hn3eQ6)H2TssFER@b6rAEoc+gUvV*KS3_QzN4fUr?Ru9?`K&6 znNaGom-?4r-!1HiuPSUYpgx(|^vV)A#yi?NZBmMs!t3r?7pB23?=%^knvT_I*?Tn_ zzIK^7$M&}NFo30y1=OxplV{6Tty_=g>#t{f@qjoRX03YhEFdwOR`driH>lmQUDUd1 z)pD~Hb&Vk{56IfTm*^kF^s&z{eeN9M66n&$V0sHYd(XWoOp0g)UPl}b%B%jGr`KmW z;Lc`{V4#)8<9R>JbEXqa7K32{Trmn8VJEI2q&y9&YF7IzL~S9 z(EZRu=zjQ*h@9;f2D{1vezJ2WE+e$i^@|G77Lih}WX`oR1ZXmVD-Qq)P{i5uU@&hD zqYB8V#Wrz0zR8acqH*t)%;{Y#?S4|h9U&I(q^<)=?R{YE%i7IbQTxlSSbzVI5Iu4f z6K}nP@%P@vaL8hDJT?M%Z z()+GhKP74dgC?IBu}<2892Y9p%MgbOq9#pJwE{R0H@1}kxHOAM0n8{6P!oB2k+GmT zg8}3=tbX%GH1D|#)f+pNcT#|C8P1|mP*byU6Poty#mr~N5$WkEu?EgQUm}QUY(#iN zCxRWTy!}#H5-9dm9mT_?lF(St9|{Fg9n|wZy!)8n$(%V0UDJIPOu{0s&!Tyqk6^sm zxum(QXXe4YH=3lUDB=K72EcX|Z#YaR5e|n@T~h-s6fT>|F7#c4HFXHrH3+#Nu6Qxu z6Q~yIv7!K=O+j<9U}_b{hFCOL-Pws6_Vfh<^Y9sv$Zq$)=Gdl7PU?ltG%3^L^8|tD z;tYlJ0)MfdZuC6#C!G7;A27oVR={BWMBNSGZg!#0)WgCD0aP(~b4!*iR4B6I9=xuS zccBG?-d9SU@Iy0txgnzO$pasv@zP7g@OEB{t5|VT>7jIp!4t>#lYSOxs23oVKf5B+ znEmog(S6JH+9F)D?TgP58y~ea)dD(ErSE0pAs|iMHGR~@eN({GDbS*JPoZ=$C5}cM zv;4so7Q>}LWj?tB6(Y8j&eK_;3beO)NaCm=re18GJmbQ_8#&c@=a?ijSH+$zRm4+y zLAEb>=PqRSvy5dRdCa}DErRROR&U*c;JURS%$}CQ0LraTqVb@<9{yFU;BRg&f#oWe zQc)k_HEXcuyWd6A*RK{0P5eFz*)Bs5SJYsd08rBbpqsRC+*`A}#CTFll>?L7yxuwqzeFW zF z#KoYQueE9j3Gp8CLQwJjpj6g^b7&J9X=+)lpSav7wSr0YDqUP~0mjB1gqr2Sq9(7l zMofv)c&GHd28z-;5O)u~zpf6Ub?XId$D7u2nM_%xTKKu@8dNni5L;XC@P}%R5-IB* zO3;U0hp(|7b&Z#J)JmQo7@-(|OdV&4y5yr|L>vZT_fm*WpGRx4VgR5V32UO>CTj@` z^A_!fi+3V4&j2u=q2O``X$Jn%(HWS>*#~%xE~9zP){@2!j`~FNF>~Z7#@~7y(e56Y zu9^~i3=vTZ-D%N|Z7F!-<-V86GW}l8d75e@O%+nltbO7s7<=zs7A@ByP*a1} z+itU%T07dO4hjV}NW|Qosf8FHmox))$b$GZ1l!xhv+2sKL&ya&Or(hV&H`64r`SF9 zU{j0CvN&e?@=ozkQ!@fp)$?mH$lUM7{ZgQ{6}fN-*_jM{CEP`m=N0pIc^a~ofsjzZ z5wuaq?2fWsf;HOCX5G*KQWsLh&vo`y=W_owrVT>46nJs&YR2uU?vi=Y5}woHh|lF(PeQexCBFNd;-a-h?1hn zi3SU=QQk}UwO6|I%Ff3_bsXo*MG|(0bF&#xH30z;z2jO2*b> ziUuv|o_nQ0=lCryNz%|Do;BOIq2sPQL3w${@Q6qgPki(dCO-H;0K?gV0i?27gB_$+ zBZHcHB`OO?-R^Z^>SXEMXNJ;>sxkAw_uR8{@;OWD3G(IwWyN2Erhq7-$i*x~yqI?_ zcmSjklyV20=|#TR1p8DK)b&q2pm;?WMW`ghzj(T;%Ygzg8(Y-7NR@tOUu`XdZLJ72 zH5sBm^Kp(B-jA*j85os!%1JXwtLy5;=(j3K{JEUmyb{qnD$c3Hw{Y;693K<2fbF8@ zau}cG6Dv@vSDNt7LJe-=)8)zbU3kp%CeTH$^QNhY!)+TfAcphs8LUf^{eIum&mc86 zfsKR1Sat8c@UcLRh}vB#jp@Nc6RPs&i_vVY)C`3}2ya*~o^7|@Dkg!%&Ys2ONBc4U z)>}dYbLPxhq+$s}?nDBEhDwQECgn9kvhuc=a$O8960R-gcdEo*m+V%lF^Y}S<#EwP zGIAyZ=&z|la8(Netxa%_$Rv)Kqr7$e3R`nx%0K~11)x;B%+vRL>W(iQg68uH?bBjb zlNPZp7P6Lb#mK;g#ti_^*V;6V zMW~t>ePEN{zGY}0C@$3hE!f&}X&o*^YK-#BH!a%<0bx2SV?>i5x`6NSJ8vW2*N5ow z6Il17AEEZ5?N;TU0+0yxFoJF)yzu_nDb`Me1Vr6M7mMfmAO4t~`+h_Y9md$(Z)5bG zcQO6haWM;=J7Pao=MlToz4SuRv=p#Ik-IrhuaS4>^A1<95vNp&l*ol0R>rxvMa)e} zCs4JYop&j7y-iWWnWHYAbh)m&f8`hn>H+{f<;w*cLz^~&C^Ip0D0c{#jrY7KcW?)p z7#l@$WEi=0cFy$F+>IcMA)ZnRYjDA7osUkhyc=&YfJH{Pidr7E-H%`JVmT40O`ko3 z*uVdOm^^wEoeTuF-+BxDO^sHgiKx?aG%gU=xhD&LKjgX|wICi=Ajvhrs@8RiXUE^& zgVgX4ra%5fXb%p*@dl>8_#Ct8v`7&L^(IN%UQx1WT9xOY1D?Ng;bpUwOgvdWHlQR) z7_P6*4wNtF@lM34%6GwHmwq3Jm60&bk-UnTNR$PCLr9K}8f8(%ZKt{JGg)Br$iLEz zgt=&9^cxp{?%Ie@`zpsTXyu&&MQOsOh2=CS zny#Yk%g0{DW|h%CWMwRJ(aS=Y?67`C>>QCT(eiSx?!ZPeWYjT=ivc_?CzNFd zc6M+Or+@c*488ga+HbrGYrp*+w0`3o2na^dA>?c7g&E?^i%|79k7-ZKud-klDM&g$eN=q^zp3)0tUQ1Cp+~W)q&Zf9J!dm~Bb`mk3~m$%ra(7CTQ zsFFq&i&co?c1-W^88cEjBN*=+K=&X1h@rndkCtn{j{D_*+aKIjk#>EQU{t^y!+1Th9 zW(J2WHE>eKd(xtAK3U?GF8s3#0B~W}ol3MpE|WzronCauobNu<0%(;KVn1LOR1*dS zHGRG*J4=bFN%TMeJVsxA74`&~(jJsJ~r#RA^oR-fEJn48jr5bM;lT z@=`DvpT*?+AENKkCouTJ3y2Q(S%6COSZrY;cB->Ji_QF8cq~URK#g$*bP<^w>K@Nk zfnz05L88gQ_=wJi@&C-EQW*L4Q;f3b>EAwxrpqov`wibj>vh+oZr3gZYQud5SE>ZfyUzc9t{OVU}MR`b3c{MvZvk|EB2T%7g*?kngZ}y^L1InuT?M|+?d5K z#`zhaQOs)E@@@uKujybq$G%TCnb388C#R4Y9!2!?6PWzqJxm@rfZ4u&tL9JB?4Yld zOIS)6y@F~0silcjRab|Gt=mz%Wh*nVwGQS?A_~g-6c`5CeTVr*NsTc8I5KDfQ8J$g z-e^J84@!2K#Y7h#i|Mq?$rZxTEfV;1rk(OJIpyvP-C0TU>IR_^5b`Nhu=~l8arD3Z z8irnZ9aRkY)okT)cVb5h^Mk&#JE~cM)d`lu-nDXxwMc4^aR8;T%LDHWF zn;&d##fG2!1WkMPqUZMyq37|(5b5m^{n7!^F|678fpq@(F)Q7gNf*#}yzp4gKu`d{ zR1&GtF;Rjf$Abj&#G4Ap58{+QhG=-`fAmQVJ@-5^Q{(VA*Fy`3^fR0@_c^tQ3u5eb z&ry=n>x#SP{I9d#-|;!F1|TB6hT6oA{$m|HX81H9J_3>f!0gnNsPW@-&9m(1egi-S z%%(I&;N2ZoEJt6tqG|xmbOvwwsJ-}Ngg0&UX6{J&194pAoTS^DOT>|y97k$;+G<20 z^PR^K3}E&G1Gv%wo`=zJX-hGnqxpS{|K+H<`<;fBRCLYM8ZRjKx$u+chdyOPq*K{B zNRE$V^!@iR#-3+?^`EHOxCu>HT!E(Ru0_M{-Kgp8M4+)z0)+X7F3MuLM7cgnsG|2( ziltDli>f2;0--X>?FV)_&~AB;#># zp*6XFRV&fHm2%z1kZiQTdO5Gh>pRJ>@fp{{pCJ`(s=r5z>)>B5gA-PW42qZnsT-@^|h)ZBvFO`A}^YbP3Z?LzI29jMv7SuljY>T31d z7*U$6TWAVUlZsc%4m#D0GF1Szyg~0G#+ef5%wHna!5N*k0$=5Hc954vW->yEJ;>lxO>K5hPCPiL{t`!RpjK0Z)%SgydD(z??eIHq zA;ImN7%f+M1KV=7NHlLyap5tSy+}_@BiYxB^yr8U0IhhV+&ba>t%?4cI#ji^qq@Ec z8Rqkd#gb``6fK=o_pWq!N=w@3*4!_rmXiY

0;7E;D7HW>86uRH~UZ)4yb~7<768 z04kf)Ou1Gu;8(q6BZ93hiW!F00bH)s0WFAuGQ2*Zw-*`abVxR9&&&0w*QuQTU5YMX zYNL+xVrv++CPV{SvVB>a=_*DMUb*wU3?N4raY-342{G`;p0dVe@s7jUPV0`5iGvdJ z(mS))BWH1J)R0@@x7;VQc}53rdNzjS$&;95&%URhMvwv7PHy;q=_JvmcY zwSFD6>MErUQQ!LZ3=&dgEJO?J1>)g=s5GKd^h8&M(R$O3i1+s+H8O(9FHQ)ihdUX~ zvM?9K-@d9387y<(mmMC(>=!55e(6Kiwr%!4qr|q~<#dCX0)vjRi-G1A=4-d1y0Z(h zfnF6T5h=`}GV4Z^{D5j5XhmxwpE=?gj48;@>d^Oa9o9Fc()16_TyaY6vrC9nKB%7f zxg_7_z6%$Gpo?;{ruH8{1mSgSP`_pS2fV zgfPz}m>PNVeYY+|^SF2NgdkF+UGY}G3%0eQ^|qTabMB0oF&>{7x20Py@MB+j00_hH z@xQ0jNkqQ*9Fdc!P=Cdhmj0~@6-k+&L#(}To&{eOJ2N|Xpl~l}By*Xw~zoPoQ zYYWm*Pw+$MArb0IraFT&YLh-Rj~taX-&cW=@(H6-R)FZ8`7nY)BKKrb<+tYw?rG6? zc;O!Y<-Wm*?JeDm2(_gQ($KZ6g6r0ydSjRPyB)x2j+ld#5ePZAtoqAh79aTa|P#)(!vLvD(;;aphFLI1OTY277Y&m+L}dMV_xQvVS6B(RfB+> zBo9HPnVIJOphlyERlnvil2mdQL|0C>PAidt6m>+zMp}zVh?&SBkW!^y*JK!Vy+LOD zsNK!ayC|nloy0hM`kr_k;ksJXZ`q30>#s-09e1JW>Z{;0(rT2bN>IqhVw7BJtZ*pS zp03}u3+=bujOekWNbY+RStHWWl)-Zs9$&qO9Y%4`#eLvxe?KCheTL-VApBdmTKiQ7 zf935L=f2k8rEbSIv|M)$rjLAz#Cv15E}>DLktKQ~6_Mqmym~Q9E^Kwr@-l6Y5;ziK z{RfeoIEfA3bn|3eAyGzR&^T7TG1bTHiBOVgh7HishiOwNA#>XGa#`MmB3=B;e|sY@ zOQLJ-Q!Bq8ZfHQw+I0xFv`FC3K{Hn*nUQ~!a-b0#=tp9F+}bz-h)B^7DgCH<179qG zU_S?)fq*VMvJ7{M$?xQ3qcA%QIuiwD&V7C$ra218E+=r_28{tTKLZb1RTyBOON+z- z&fYP#4$Y2r%}zAU=Z7y4Vt)n~ZIx5wlSuRrAU83oNE{KF$s~FgFOdKkCH7j$saYyD zicpWH5$iJyP?sZ4=8JfoOoewH=PY$7^?_@|!={lT*j zJ%pC4uEgs5?nC=+x1)N~CdH08dppVrGKdHNKrMM}g4#`+#dGq*{i5R%4rXPpZbOpi zXBPnE`40co|IV{^cno z`uZ@%Yv93aRdeuZ#G!y>v-(PnX9b{1mb-Cwc~Ilc?ToL16)3fUVixxB2>FVI9pEJ| zlnOiKgPAVQDZv*UOy_)OZM`~|zcK)@xNWH~5Kn~FtX+$mt}gf+8uP9uEl?#;Gz;W$ zj#3j7NREyQc7&80)XWJpm(bYoG#CefKL3Jk#!7bspc45xuGcg(1DZ_E?^-DPLETBg znmUAJn-LC4X%f@;5~!M)ra{h0OGJ%3i!Vm)&YhKS5&?cl-uDP^=)(H@ z??;9OO__%tMwIzMVGDEAp5bksM{1l`GA}YlPEyi3`^tOgtjs`GI`5Wph~LM~RV%{| zn^Hl))<+a#0kt?77ZM@i_0h zfKA3H5DcPvLnn)RIz?BX%G}6gDw&7V=BWQ;AS2B-24xOXQ_dQZ_^B0OX~^>I1ePOG zbNzWbBtAKb*ysq-Gf_*ssnV%PgizPLl|f*D1s_%I9SAixBG%uRch}J(fxp~?W*RKf z?Os=pAOi!wy1K<<0B0f$)J`Iuh%3SpG|!-4bGr}&6q<4sA_~`hY^@qlw`MhJHf%uk z>eUF;vup8d$TGm5W&u^Ae+coRA!c;Pk!EKr!+*}-he}MS0oXJv!ne~vrWY^Qk~ek}+CfJ*)41qAmMeb}PlgxKsew|kQZ525+!aa3>H4lUpphoyW)ODgH3dzV2~ zZP|tmKmTU|?9M&%2%-Z6VvmNXIRS?l**NOz^7mx$in(@@XLuU1rJO`PBDF@R3%|g> zS1=q#(~j+ey==bb8r1K&2;nvB;BRcu%Z1GM=F?7+DZRvtUDNd8PcicPs~COz9mK>G zkes1UYUd?ri4%1eGR3>%0H7khLiKcwK=BOph1ae{c-1O>!+UHBN7AbF<3^=hCA~qK z9k|565Hb@}>SxlWyRq|cYuGAhvSMt{a=a$FAlP*Doc-ewTxMo=0k}VB7@|W@9|JKw zf(*8|gPhQWlDxBn*B0^hAomHeyXBu-rN5vUU8LJd#z_n@jZnWKc3tDct9yMFGBFKOs;nFfb&1fjm_ZqL= zOhw4<7<%btRCRWt{kGfSW6neY?-j^Rk$k_$o4&#!kPuJ%YeKY{ zl<;xI#5@;L!RH_GXYN*F>{0Hcc#t)H;xmlC^*U-U+Jc5lFO$4pMKiEm*pnK*ke`y; z?c1^afBiqG+qem5e)l_!e*6)5u|kNagU!%f>KG%GNSTh(BN#&SD+*dZz_2}{NtAtd zW7kH#uJ`ua(R}q)B28Yftcm@bk3Vaw5nA0LrVXvT|9(uo`!>2C{sRVHcmav=36U}I zWBwbnzS1>-#TY1afqcw~@aQE2KaocTTAdT{)nnD=EqJRP0mfb)5nyfd!;l3kcSb_AKxv4X80g;cRrQBi88E~?h7 zM&o6dqVA&Yi?+VmR0^q~VWj%{*x%Eh%So-?7#o_TsLuKY`OMpI-h>T5_yO8(z6rrq z9dlYHEnFoUU8*;%N7EI1*$@8#xkN$$!YBh_lOG+x`1|i;^6+8A28Rq7PK}yAQ;3~N z0h`p_N4=O=>R=@FL^QP_p%DwQdl63vRv;IT3jk<2H=3((qfwV*7eoXDyD1)Ij!lRl zjFf0Iy_o0=0y5_{_ooD4#xNPHG$S!Jg|YYEL;a<@QQf&woTK@G5!TrzRI0ot)=mv{ zw4?Kv|0-r%cmL@T^!)kHi1u}hb0kuxVyq$T`dnK2cXIAyM|H6{v2wN{+}wnYy?e3d z?z@@oxdpXbw-r=RaFI7eJ&zhY@2$7o#sKd{sN1mvJr6yM$jOu9^Zavqh~@QIrT~z5 zRz6x&lOzLaHh_fcYY}c~hQGGX!)2?zLbOB>NU5XYoY=paV~#P|*N<3FHxkil%Sro8 z9;b}mK$q=3AxqGGQmmUJR^h)n{fMt)vcDg*Cr_dA^22D9C4pZ5<7pyf9?PeP@E^F%7R$cgLb-?_G}O#r{nfBGlXU2=(=TTn-2 zDC0Rz%`KDp=f=0Hvr|0V@3;fm*%?HR9>wVEZ(w}iK1>}xg4wZAB#rCxQEH`%%{8WG z`iMGp31ufDrLYa{FSCA#--G(CTT#DbI|7p6E-?$;Njc%AmyV9Tsj@RMqy`xP9~o0> zm^4~kE#Ud$lnPCdSWqy{R+9JgE!N!X?j@+dVh?s+@-=kabtiiM_(u#eI~W_)ZHJGVHN$2XztMq9 ziBzLs;L3?qb|SK^deD_K?4)4(`~fs>+lKaAZo%qr-Hj#&0E3N9bNgCPu|6u<>zp;y zIJ|y6*4_VOWa3F=e*Zhn^59qrJd0EQphcdCuT~R?t20P9hB@hPpFE;-3FVJ+=*XPBBP`UrM0Ju-| z_8@ldtQdx#g@$^Vik3w4n2cKSb9reu0{cE^>r!j-l<;gKIF#X%vts z4Yc>w)S~I?Ys54A-~KCRjvvSP+wWrZ-S;rbfMINCK-3PJk}~GnYmzL5<;twJCsO60 z{u=%cViE_tpDov4&z#CVXt?B3I}o&-S($yc&M}ijb-CHtERv&RNKH*zPDaZEmhy!* zB#(3XDyM$UT1u|<$ZZ>!*ji2uUoqhuku~~^-R)yn#&u9fUwIjUx?1=e>e0&1h{~_n znkf`2yHdJfjGi2j5ite;&F^u(gc0Xe3Yf}1gWBDLLAJqb7#goyyPh53fcgvb##j+g0Lcse zr%xQmY;Ui%pngKU$IqS54_*t!jpH(mkexE8#54~4{zM~)@cZ-SNii1|rh%uWHMHcL z=b%b}*qyJ0MW7vb|D6~=*0Osy2LJk3OrAJ_xFMwNgQ+ZU@8z5Uj7(v3GuR1*tI*CO z*tOsJE>_=j4~ytK=VW{;bulXYH-*TdgP1w-8M4W^_1ifD$H+t5Sc<@mPqMh^ezd4Tp1y`gG+gs_@$CG!SPOl2 zg2suGy70LyR_o0-i)XB_2U8#I$K;0}B6{ou5@&mm92!OwzR6Zji@eWJ`S0@12XZLP+p%p@wq5S*CfMC zrSDfLD$mc%EJK(@y$=Uj>hA^OI-tamMc{C2_FOk2$Bv`rnrjhUv${;G)p4w;sw}UW zcb!j6F^r5zg)s2P=g+SD(T_3y;eL#N@ByZd9Yw7B98%+Bpj@OH>QFCVxEi(X9jM*B zSt}q#;q*ZU02zqR8H~H!^=AH` z%qVih($KXDtyg^=br)T%elE2KLJ@gg3CWYboExmm>@R<?v@blA_2NSJX?xPqd52%EW+&Yq z@)e)KN4eOqMklAFo5*nATqq9ih;tcPap0`augarpX_W08R+8gQ@3>+ zv#+}t0NjEA*Z(CRq>*J?%Hg}IJs=DeF-8s_5*>k*FQsn0wY|8Mm}( zxR^e63~{N+NrT>TXpZVI>vv44nm{0g`ipj=ks0SubBhCcQjgm2O2Ra%M2N)7(MURa z)inrg-O3!sR{OV@v(L=V3h`WV9})@u9)znzH#e85;Wfqb*hQ-?L_X7$I4`gC147jf zUs)C8pO}8+X8{_|vdjgTi2T8%Jf%$YJDcPvk>t?QlM|Tw`~;$B&Iml>hj$I&1qQHu z($xlk#7#&Eovwy@QH-sH!*0_d&uk)Nh7uY2@IKnPW#Ww(m_uj-Rj^uJqr^IgGBIzUGf0JCA%Wcd)(95w;lu%*0uP zLo4R$iM0OiD#Z|2o40;j<4uC<30YfB6?Q?7hMrddbQI)E$hJ zz?<2@F|qBSP42iQwJb{>3<@?c(9%*Q09FHWISuW8T_xl2h)y&RJAfQ}>n)5v{~Y2c zzYzZ4zf5S6^Be#Ig$1>#RVU!{`9+&|sI3(~7Evr@2&u4tV`G>)azxBsOv~(_s@+i( zgeyiQ*hx{*B{49|)$~!T=0uhxFjteqjv3}i$KHMy4VPYu@ai?p$b|AZ8(P3js6#AW z(WVU2@_1X@sOFS7)!V44V3Ww@(3L7$!%kn?L6WAdTzYgABd@)V(br!WBMvo3kR#9I zcCJz;6-Oo(K`t3{1Vz&N%D{ohSZ}D0_E#0KUZls&rXdwaNr}Y=LHJ zcN5iqn5}!W(-EBho#}2cY z1_t`7+uKpq(IL8yyr3d+RghP{+|lDFFn#nhBn|OrneCx-2pN!~43n+Eu1N=jl6kB# zpl&4$ck8;br8Oezqo6ri8dC7+FBU^!$_OaJ2E-gpu6K!ze)JLik3Ru_Ya7~cy;VhJ zgeaiE%Xt&GNQ=4##Ctuwz+<6RA|5r3^9jnS=Q(hI&};^y@4kcn7hb@`$&Pqn*^ zIt;unyJE=iOhtqwOXTP=)a|$!T1|}s&V3H1LahZX|GK<{D!kT_%)N$AXJHEaYc>;@ z?>*F+pj2{J#I^dw^V`}#o%rAb^gZ$?jKB4km0sciGbe%P()u*r4#)a$Uw#RcO76^@ z3?;R@I}2$Rl6hq_35YY$62?Ny8;p?>SAe>%g5=%fL}DH(it2ZA0eE|!HgV|I*}v~M zyi+QXK<{7vg4ECm5`Fzxeed7HFLVMmC2-1rCTSjllYI54qyY4hrm7Q_52OVF87aaV zs@VW}CJ;Qz%v`LYqpV1_C-MG14F2^QF%={piAX|ZUiK{iJuF6?{VP8USk0t5=J8fn z!QaxX=y7=&yV6Zq{-c-Z>lI4iQw&g~(D=c~jxYu(@n1>F`>=dROA5d~+y2=zaW&~T#@>D#-3)w;z5l+|_>r$K&?%hC zcPCfhpE`ILgU>vRYTgNb>n$L%WRD}Ct`68+QY+*6bLDImanPtU3qYtx6{*_+nXid_ z{0aJg_j?RK|02>ET|!7BL@s^HF{w5ktjD#liRAMWp)-#twdruAlr= zXywUJmFB6MqH|atQq;APIjtC3kn=3Z{m$Zic`ONWU{w2s$-x2i|LG6tdFUZbpFX3< zPiE6aDLv>byeGc(A>W0v@(Vs5FE$S4+`NQ@Vi(sRRyJPqB{8p9lK?j{`&fl+ z4t1Q-l`%tysQt~hWsq`oreqKmQsVY?Pk;O|&i%)Kp!dlq5NBuIoHc6AG>xwE9`wasH?X?|9i5R;hDgjlr3c2cZ=0B8R9e_(q5 z0R{qph}GZzHbSe{8JI^FM$cJyj@S@U+SBI5ol5v(vfyXZYH%_Cn^G6+>bhsrBl_8A zEHL{W`X74~QMPt^L!4%ejHFU&&jkQDe-XLSf+N=rnM^~lx)!0vX85aX90yM=a4)pE z6b6HMMG3aaN_6*N{JjrES7bIvrLG@!Saw0SWKIT9X0oUyEhBX8`uc?SV1@x1e_g#4 zpb%GT%8YPGp?P=;sbO?HnX(?zVx;)I?Nq;i zWd3^gm&e^u8^I{`1_CDk#lg_%8*k#=uO7g_bI&1_Ojr|Fh{L|*OXSaW2B}o%sH9wD zY2>0Q(1gwK=M2MO)d-fTo2jzAR0)(V@G~}wbbmjx%)TtP{m{iy^r;zqbXsh92xd$J_$g8h1 zyJlqmh-TFR%TiGEf)3z9`8Tz?!XFAV@K>u3lQ-{OImRj@b6uO2pCo1pVoEwzC4Z9 z_uh-p+BMLjj|OET0l|s@fo|^0EJ`O9V=bT4cux-o{_+=e|KSf9KX}mATjc3c$21{Y z;rD_gaN~cbM#qroWr5`c17d4e&x>ETvuXM7WW0X}Gt90e*yqYpT4Yh~5w!r9SOaF; zc-J*$fe+DqWv9N?tC#Cg-3ytT7(?{SlVZ|NJ^^Hk!sGEsaUr42=$cxUL6{&bg&^htYfxo z>fomsc>D?UKl= zK1wMT%>$-p&-P&Q{SOg6d=%L%wHA-s#H6e4f|O;PZFEM=T0P?{apo_^ry86*g@#=_ zEiI({>0a-jQ<`6(kT}3!b|xyOolG)d5RbyiHueSl<(N?y0p<$Mr2Cnkm_X#@=a@Wu4zWc7e=BdS5ERBk65o-94B-bQrO7J>tK8m^%edO0)&;pV)TW4D>}djr~W4 zXGo?e(eun-F!J(?XxwuJI_|p{9e3V=+HKo(_TIBE*Q?)k8HRDL47_)l8PA4He)JLg zo_qpB&pn5kbKMs3BgQ$l%4j4V)$`3(Eze0H9vfIr>}3t36=0jOhD9e;Tmr_U1GrK) zMMi~Olyd5WcQNtKJBW>pDh(T6x4#k+SYbhol%!_dEPmaQqet1{dnCW`9Oo|gd0u36(M0eamQpAIv| z?0dtmU1F}hX32_GC{dm#hK%?3V&cs=5jpTNvqQ9~^zXdvOJWyEk({wljpfjrM06jL zU?8af-M2B!{9gS751{qh>(F-NO=!I8N>pv^lmzwN1qc)#Y1L(8CB5%wE;@_ZlV4!` z{r51kZyzQ;I)GSTzvT1OxyyE!HF4AdP#Lf05z_Mp2rgR&kV-RuWyc~HF8gX~#Hgk~ zb5r>~^QjvNvZ(e$B%*1~Br14bRpO9j(EtTueAvNdM3K07^yp;uoMHo^8%lQsMS0En1(ekBmR^RAk35??@R67g zI>`1=gc&>vGu>#;BsSiNk}{mJ3cNL{>KB@OILU&jo@f7x{+C`t!;T$jzu^Y7-gF}x z_v}U0y7hB5FfGrJ)d{*CcYpznnbTil?Dc&ZeC~OSeeeO|<747ALDQZPXYKMrjHgxG zUA`(Ua)6c?JRVT_KYA)W9H>@aT=ejk~>{m~+J=p)$Qy6{kJrRUC8;ut9PDxIM z|CMuEycUjku8-~i5J3k1f~z~wa>F+))K)SGrXDF==@%2jLl}7SDN%+J8R$3c``q81 z%)>sl^-3isP_Y|&kj(v$7$=v_VVc>ADfT?~=p(4<>O}M2J!re`dNf~sHEK9B=+NMG z%eF7L;a&-Yd7KHF=Of$zn$Mnaa2-&4cKJ%Of0vSpTCZ1SLZqzu#L@CZfo-4fo z04p<5)HNx}J|I+%E=$jcd-lvxDQXvW0h;xB$-zMkzy2nM-rJ9OLhp+70}e4(Vqr*G z@}V5yOJo2^h{7dkRCl1!-d>#f?QcbK{e~a^m_@B$Q~QuzDK%S_-AvC}`dc2k9-2&u z)YRDre}jP+Uqs3Pe}0EqUtZuZ59{aAAVIAJkQw>vO$&S;{M5-W#k2eIC((Sxm1w`^ zW;9=Wtw@ap8k&k^zi583W@~n?UJ&lp!RKn;@Tf0wf+SD&jMw0ek0N^P7{=aw3&U@` zg{h-Qk(`=PfCnMOHN(>hq$_i}u=MoAbUdnq&P+0e$-_s)^X#vGjoM9{#LQj3?hTh+ zj@s?p#N1ClwWDMZEG-`OWPtK-UV?nxmegbI^REsspO`&+8WSIWi1B@IVq*UR%=Gjk z%bX9lFCiy8NGbAH5YOL9qp~nBv!6bL(U@hnju*No`uni{AAgG0Z+=6J*mSDE<;*^0 z>YTA^HhkD}SV}GN%nS=ApBJCOyUjD1tX@xLRpQYSVRjkNmlBuKhh~7l46}O!e|`e# z$q{r8{tT<`x*PubMt9QFyiY{te574M>_~Yc`f^U)!MbpPS)$Xyo6L_Kjs7c@o|=! z*%@XBCy*Q%MC{x-M85a}krT%eWq-!mc}zwlR{yR~oJ*;>)2L;J!v=VBpNmUytVjTu zw<*Ixt%~8$EIJ`sTDlRCytUj^LM*n;FyPS{j6Cxkh8}+kiF0R_uHU?TP6hXdNV;Lv z5vA!(Cz|*UTpN(rkDUJB{|D2b9KyQqeGeVC-HNKt4eq)riP@X0u7{_(r;i-Qz+az5 z|FeI^%!$v%OREg0NAvifWzh*-^ygD)2!t6;5NpOQXQ_CZL40fseJ{R%ftO!KxUC)a z7i~k+p3Bj6`Q@nFwTrEF7kmv3iUW6pX^+^DSD&<&@?nOAk#-H4+cK&5G}Vqp8LWbU5%182^?{Br$dT1SZ(C zn>&}LX4GuhfZ8paQL}Y3syA*zRo5m|Z|FjJRlAr8>SX@COErn7#FET{dDg;~=#a#0 z;mIk{(7{LNMHr}^VrOak)aQr|4I-CFStBET%KfIud$8sK^mv|AY6nNAdEm_eye?MM zfIapo+dH3N)ji+B>ih0PM>WNX2jqkP8olRS={ETQeB65Qd}>od-)CBw${`)qF?BJ4T9^;Oya2)DKg z09d_l9XqG%QN^F^?;-ZHP)9ohhK=x5S3~1XoBZrb=eIZs96qyIkJJhC{o>4}l1Rs9 zL_KYeHxo@vF#ylb;p7++BSVO>?(Ly%az~4M zZwiEgbOi%I)9cA4{ATl#Ic#1$ee72GHBa%j+uqHqX6G$8a!Gzc{AvU&UNw#)r zq|w~lIp^H%oV(0=XEaN<>sqDJZ1*hPU-#+$nvBmwEdqlf*mLR>4Bvhfa%1C= zD;8zKqzMegCZfs?*rhGCDb_E24$J4x!Q%U8Ve#XSVRQC|dYXSUqatQiiUD>L^ie|! zM2|3Qks*(w!H?eN{g{L_2#&2Na5lv?_x3wb7%D*VzyTPUKBkhzNAEfb<97>ya>q0b zPfkL9Vghm#V%!Bl$qg4>ikSwB84}H?->_aNJx9*n#wL^nNZq({SD9v1iZCO!y z;y$---GohXE&TIC zm&Ql-?%gv1LkA|sI3I-K)L|H&7KY};oiHXGpW%ZC1t=6_KQ^I$T4MZBjK9oPlH}=F z6{6JE7joR~?QN(CC&^x2aU%*h+=zm#qTalG88)v7V=Z}Gjqik}}r>H2jwCN71B4||*# zA8&o&q!o=3kCeL$!vlfh-^SJJ@ZV>i5zg@M;kE}JfCHyb!(ORZr>9lpf!z4GI{K7g z#@;a*QQFb%-J? zqh_CYy?KNCza2c02!Q z!HQ5yJJ)AnLtNGeAGnb;2{497ltGlo#6acO79L=nDgC%Oi_&StziwYfJ>ttE{X+Ss0Y^vbY2&s?0Ayd0_#zg^`sUjS`ed zub4Ck$p?Iv(c%_0#ij#4jIv;7rp$s=2^|FMRgsb2o^p*^WV%^?#6k8j-4vGvmyEcP zCBR``7?0ej7=N+WWh42asVM;#4=Q?}A+aCi;}VqTWduSPB}+cPD1PSM+CIBt!%lfi zfjohn0i~f?7eHopRgAINA2-FA&&|R1oB(+9H(^K2hnyQnfNa~#Bh>-l5QLnFx-oS; z=S`2xQ!MUMU;l_^^{bv~h>^TQ%QNzBN`#~6duGKo_sXk~6YExvUt#iqit@<5+Ib0t zEDrz*$7Dy$PwCn<@w#iUEgTe?K4J%kSLiInm~JCY**8RM(j@rvi@^we#~-zb7X=_e z<*VMf0kf~X0&}mu3VE?-WfvitdtN+z7z$#INgycKpWJ`WW=Y)tvRET?D$lPhbgU$q zb{q;$mI@d`5r?Rw3<}LzO49mvC#8y@DjWliXxXPNQ+ro{w34_sZ_LG_?|R{jAKXBb zl0%IVMLy99p_<3>YR1bf4cs_EkjDy0tTFKzmmsm&p5i+cyLPsE9snkBa)+BzpIBJm z0Ft~_8=EZ|r=+m`(z(B@Rxfih|81)jQobNYc!N?FQih{J5k65Zdo4)TrC?J?FVq%> za#3CM*=NS)Ns4~>QpBj+am`%!P%?L{7I>{JvHGm7`Myb8gf z`%Q}S^pAAOTc@ErqXRwCP97cRdF4YqpN6iOCZ1N z2gUbq{Qi^IbXFiRF}IN@q8q}hP>V3k|8is>*=^Vs7Ye<*Ix}N@XMe1n1ig~e^;N{J zg#^br`#qlsYqY+%8m*O<6X1V;^7dv~0GTau;hfmx=RXbUjuN8F`r5FxlP2_#CsEYZ zqFvFS^$i!rRu5@u1hL?Za-8)sp&;*+k~!-`CxDW3V0DKt2i0hUe3};b)spbqF?5+m z^dEg4McuIaD%0B;t&Qn~3~^ys9|7w|DVoSHH(gnJr^_p_Bb0uVXCYejA)G?l7U%NQ zzl7^Az9@{!dXV>rT7&nRTxhMTY@@HYm$MRU^MhVxba+pemXfXKa#2Jv=L{tn$$|7E zuvGuj?!Cw$f|(gfhG|GT<~J(RQR^G*X|%j<+{hen*D$((T7nCwY{PcB44AUfb*~mR z1!yIVI|il(yaaqlb^8cF7nvS*(!A;ZJtdVbw$-!6fT7Gw7>$Xwz z+oXk@oaWJwts7){gThI&#Z{4DCgRy!k>8V!j*az!n)|3Z295!;FcIi>&exB-Kd8ac zSo8Xr{`K0?1?qty?15meB`Y#6{;{`TIO6CXQLz5I$GCcIZ3P+>I|(iDj2-5K3O6?l zwYGe@$ePjDik~a!0v|7wL3#-q0(7u*L^@GaT>}ONmygzc%5-WlV!zGEb2Rl8HQSn& zUv4%^dfv7k6S=&hpO-35SIvDF(#jTni~Y2jd%uq*&tX?a=Y zANWbiwTw-;zvC5sOMiJ6zIgg+xcc(Tu(i4F@l#n|^ntW^Wc5u%EpY*b#+wXFkA~kI z6bDcU`1FMvtyanzQB`x}#2SYarY0u$zL=CavB+kXqwbJGAt7Ifl08<`yjCj$dTM(8 z7(1vnD&)f$lMP9?62JA@b){%1{7xKaP%NrWb$n-kokrKWm0(A5fRW-YiW@~t;I4}l zJ7ASax?%fbYsjfjW3qM6#-&Rt-(u{}<5kVP?r9O4hrage zs@n(k*=J$?op)fzu|4pIMyt0-bGWudzY<%U5$bNW;XBr{ENM;Znm5?}1_XEGQ>d|` z6~jQ)OFBwDKR=iPV5)URXp}mIk{r*}8K~pEslLzw_Q-yyHO9?%rs$6Qq-67-0CCgb zhoC>m%j;PcjpS&y(jFA+_*S(_>&*PcwD;|97Qe(=;EcX#KHDWi*)Kiq7?QNmbKZ*z z><9q3`tc{Q{@Dc>oxaoUT?*0GNqXaX_jgM_^8M&Txboa{@a35oRmpge&*N9A5p}e^ zbDF2vLp`@y+N6D{uT4#Tdt+CYKQ*%d2YZeN(@~_p-gDjLP-j0k(bE7Nh|Z3q`G?M3@n~I2bD_2jrs*i z`Dh$tP=~fbj0UF3&%})8gr$4c*&xm>cImvZ^!IwIrekS<_hT!ztvlDl;OzG70AN=A ziV&+Ff$I4xlKwNm zr%)+vs(}~*Ew{i2ei+hbAatrituaH-#%Zt&6VLZxfKC>cegbx^xB3(SW;(G%Mzvx* z;acMa^5`MtYgR7Kz{XF12D7id4*MT`2u6?I;Wevv6rbAG@}laFu=$@EMclf*yc|?; zjre(f=vHbPZMTeS$lWUos+Ng@ytxJnX!J7}>DCAVwP7AvdJnAB(!n&~b6?9&v3}`8 z0GJd8$5z21#otRkj1;em^!TGHYwK|H?0c{%F7+5%9>K1p9&iE^(Wf?>x&1;{9rFZr!>z6DLRNS#>7b3_e0_fPP1&-{WN44+CxCx(= zs@f!l6qFH`eC=ft>bbmW9tW2KeYOI9K0#>#O!l`ZV>#+Q=Rycrb1J%Z0}i@3+V2V# z2jsqa9kaA!jn!nFXkaZ8uh**g-wlAPJM~M9fGu^LRN%`Nh^A7Jtn~m9VyiX-!1O7U zeUlX}C`S7Z)I0G>d4EY%k6>^yC6$=_k-;R=+~~8+O5r4SKeN=F8dev(?`84PFat%t zSN^^%+07I2{I_)fG(h{cHV~$&_(*T!AW861wGa)v7j+N-rt`2Dr>0Oof43 zM=!0vl-XKOi0ortoW28!$Bv0#vH^frb2n*b#Esp30`@<6Ka3wguD-YpZco}Eeuj|& z@Cqx;W;oqAap}*cUHqQWi>3FKMl*BC>!5cd11vnYJeJ+1d$Z7^Xj~XHo4|y>#T!a^ zAZ_X=fm9ltv zh}@>@>iII_N2K-3jE)=zjiT!%UB-+TKQ*|i_*jaC=a+@YpT~^HlE+cUB+2iJv4<#V zQlWja*SAz1Ogu>)x_*xlI!lYz!;6-S&`oxAyR~{RX&nKmh0jN*rh=SKP5M=R^=uqr!ly#59(y!j@qo<9#;D{g^E8nFsy zG!cy`OzMD=r8d29H!OVY&}T*|f$I6}PJmKu!|UsP-+o$G?V5{b8`)zQ?J=HX7M9-9 zJJt5C$u=B5CIeu_efwbVy{F*N;s?YSe0^ zsan*J25epJ_ImB6vE+7IEG#_?3Q=P*@erb_n21%Za_>2hLiz1(ob6R9l2SIf;!T0Au`xwVPRomVPWZe!PMWY#rD!W zv9%&?27qStF9d^T1&g2Jh1goL1q%xc3kwSi%Wg_yypA+5hi1DAqi!|@`c>~5+?4hIkX0I>EQU|VmGg@uKMg@uJ> zH{l>P0rlFCjPjLAMfK}#l!m1}Uz@=n3kwSi3kyrXfxz|)k$$X Date: Wed, 20 Jan 2016 22:02:07 +0800 Subject: [PATCH 029/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=82=E5=90=88?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=9B=BE=E6=96=87=E7=9A=84=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 34dd2e79a..9f5d2ed04 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -126,7 +126,7 @@ class WechatsController < ActionController::Base end request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: 'http://www.baidu.com/' + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo2.png', url: 'http://www.baidu.com/' end else openid = request[:FromUserName] @@ -135,7 +135,7 @@ class WechatsController < ActionController::Base uw = UserWechat.create!(attrs) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_url(openid: uw.id) + article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo2.png', url: login_wechat_url(openid: uw.id) end end end From 3df2a8a3cc701357d6f9c860d9284f0cc24dd284 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 22:03:18 +0800 Subject: [PATCH 030/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=82=E5=90=88?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=9B=BE=E6=96=87=E7=9A=84=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 9f5d2ed04..19644a624 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -126,7 +126,7 @@ class WechatsController < ActionController::Base end request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo2.png', url: 'http://www.baidu.com/' + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', url: 'http://www.baidu.com/' end else openid = request[:FromUserName] @@ -135,7 +135,7 @@ class WechatsController < ActionController::Base uw = UserWechat.create!(attrs) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo2.png', url: login_wechat_url(openid: uw.id) + article.item title: "#{n[:title]}", description: n[:content], pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', url: login_wechat_url(openid: uw.id) end end end From 27c2e9eddc06b1b998447f76c81bfff023c1d8b3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 22:05:19 +0800 Subject: [PATCH 031/507] =?UTF-8?q?=E6=98=AF=E5=90=A6=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 19644a624..78522d1ed 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -119,7 +119,7 @@ class WechatsController < ActionController::Base on :click, with: 'MY_NEWS' do |request, key| uw = user_binded?(request[:FromUserName]) - if uw + if uw && uw.user ua = UserActivity.where(user_id: uw.user.id).order("id desc").limit(5) news = ua.map do |ua| {title: "act_type: #{ua.act_type}, act_id: #{ua.act_id}", content: "container_id: #{ua.container_id}, container_type: #{ua.container_type}"} From 55b61e9e90f45f8b425387a0b52a5e8449982186 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 22:14:47 +0800 Subject: [PATCH 032/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0js=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/bind.html.erb | 16 +++++++++++----- app/views/wechats/login.html.erb | 11 +++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/views/wechats/bind.html.erb b/app/views/wechats/bind.html.erb index ab35351c4..29022043e 100644 --- a/app/views/wechats/bind.html.erb +++ b/app/views/wechats/bind.html.erb @@ -5,6 +5,15 @@ 绑定用户 + + + @@ -17,13 +26,10 @@

- +
diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index c305cd9d5..e6a936f4e 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -5,11 +5,18 @@ 绑定用户 + +
-

+

<%= @wechat_bind_errors %>

@@ -34,7 +41,7 @@
From 95070b7e838d3703e0d094246d5fe8e3ebfa3bcc Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 22:21:50 +0800 Subject: [PATCH 033/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0js=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/bind.html.erb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/views/wechats/bind.html.erb b/app/views/wechats/bind.html.erb index 29022043e..ada22cd69 100644 --- a/app/views/wechats/bind.html.erb +++ b/app/views/wechats/bind.html.erb @@ -5,12 +5,9 @@ 绑定用户 - - @@ -22,7 +19,7 @@

操作成功

-

内容详情,可根据实际需要安排

+

您已成功绑定微信

From 02cf9b56e1e4acd8cb1476f8a7d757c572a12179 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 22:25:14 +0800 Subject: [PATCH 034/507] =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 78522d1ed..85b9ba5ba 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -121,12 +121,16 @@ class WechatsController < ActionController::Base uw = user_binded?(request[:FromUserName]) if uw && uw.user ua = UserActivity.where(user_id: uw.user.id).order("id desc").limit(5) + logo = "trustie_logo2.png" news = ua.map do |ua| - {title: "act_type: #{ua.act_type}, act_id: #{ua.act_id}", content: "container_id: #{ua.container_id}, container_type: #{ua.container_type}"} + {title: "act_type: #{ua.act_type}, act_id: #{ua.act_id}", + content: "container_id: #{ua.container_id}, container_type: #{ua.container_type}", + pic_url:"http://wechat.trustie.net/images/trustie_logo#{logo}.png" } + logo = "trustie_logo1.png" end request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', url: 'http://www.baidu.com/' + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: n[:pic_url], url: 'http://www.baidu.com/' end else openid = request[:FromUserName] From a72339fe2c91888dae4dfd3d00a40cc3e3789b08 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 22:27:50 +0800 Subject: [PATCH 035/507] =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 85b9ba5ba..2bf75798f 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -125,12 +125,12 @@ class WechatsController < ActionController::Base news = ua.map do |ua| {title: "act_type: #{ua.act_type}, act_id: #{ua.act_id}", content: "container_id: #{ua.container_id}, container_type: #{ua.container_type}", - pic_url:"http://wechat.trustie.net/images/trustie_logo#{logo}.png" } + picurl: "http://wechat.trustie.net/images/#{logo}" } logo = "trustie_logo1.png" end request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: n[:pic_url], url: 'http://www.baidu.com/' + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: n[:picurl], url: 'http://www.baidu.com/' end else openid = request[:FromUserName] From f644aa114492bd049d2e96233cd24998b6426c01 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 22:31:36 +0800 Subject: [PATCH 036/507] =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 2bf75798f..9ae28abcd 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -122,15 +122,19 @@ class WechatsController < ActionController::Base if uw && uw.user ua = UserActivity.where(user_id: uw.user.id).order("id desc").limit(5) logo = "trustie_logo2.png" + i = 0 news = ua.map do |ua| + i += 1 {title: "act_type: #{ua.act_type}, act_id: #{ua.act_id}", content: "container_id: #{ua.container_id}, container_type: #{ua.container_type}", - picurl: "http://wechat.trustie.net/images/#{logo}" } - logo = "trustie_logo1.png" + picurl: "http://wechat.trustie.net/images/#{i == 1 ? logo : 'trustie_logo1.png'}" } end request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: n[:picurl], url: 'http://www.baidu.com/' + article.item title: "#{index} #{n[:title]}", + description: n[:content], + pic_url: n[:picurl], + url: 'http://www.baidu.com/' end else openid = request[:FromUserName] @@ -139,7 +143,10 @@ class WechatsController < ActionController::Base uw = UserWechat.create!(attrs) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{n[:title]}", description: n[:content], pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', url: login_wechat_url(openid: uw.id) + article.item title: "#{n[:title]}", + description: n[:content], + pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', + url: login_wechat_url(openid: uw.id) end end end From fce8d853806a4259de71dc414a8b682209bf48f3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:15:22 +0800 Subject: [PATCH 037/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 51 ++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 9ae28abcd..06d3fae96 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -120,14 +120,23 @@ class WechatsController < ActionController::Base on :click, with: 'MY_NEWS' do |request, key| uw = user_binded?(request[:FromUserName]) if uw && uw.user - ua = UserActivity.where(user_id: uw.user.id).order("id desc").limit(5) + + ua = user_activity(uw.user) + logo = "trustie_logo2.png" i = 0 - news = ua.map do |ua| + news =[] + ua.each do |ua| i += 1 - {title: "act_type: #{ua.act_type}, act_id: #{ua.act_id}", - content: "container_id: #{ua.container_id}, container_type: #{ua.container_type}", - picurl: "http://wechat.trustie.net/images/#{i == 1 ? logo : 'trustie_logo1.png'}" } + activity = process_activity(ua) + if activity + news << {title: activity[0], + content: activity[1], + picurl: "http://wechat.trustie.net/images/#{i == 1 ? logo : activity[2]}", + url: activity[3] + } + end + end request.reply.news(news) do |article, n, index| # article is return object @@ -175,4 +184,36 @@ class WechatsController < ActionController::Base def user_binded?(openid) uw = UserWechat.where(openid: openid).first end + + def user_activity(user) + @user = user + shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id) + @page = params[:page] ? params[:page].to_i + 1 : 0 + user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + project_types = "('Message','Issue','ProjectCreateInfo')" + principal_types = "JournalsForMessage" + + blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10) + + + end + + def process_activity(user_activity) + act= user_activity.act + case user_activity.container_type.to_s + when 'Course' + when 'Project' + case user_activity.act_type.to_s + when 'Issue' + [activity.project.name.to_s+" | 项目问题", activity.subject.to_s, project_issues_path(activity.project), url_to_avatar(activity.author)] + end + end + end end From 6d732ff5ff35650c5e9fa75171b63dcfd1a9fe4c Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:17:17 +0800 Subject: [PATCH 038/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 06d3fae96..9483043c8 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -122,13 +122,12 @@ class WechatsController < ActionController::Base if uw && uw.user ua = user_activity(uw.user) - logo = "trustie_logo2.png" i = 0 news =[] - ua.each do |ua| + ua.each do |a| i += 1 - activity = process_activity(ua) + activity = process_activity(a) if activity news << {title: activity[0], content: activity[1], From 4607d1a78d741c19eb3e39a77bfb251986f2c24e Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:18:21 +0800 Subject: [PATCH 039/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 9483043c8..475594687 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -211,7 +211,7 @@ class WechatsController < ActionController::Base when 'Project' case user_activity.act_type.to_s when 'Issue' - [activity.project.name.to_s+" | 项目问题", activity.subject.to_s, project_issues_path(activity.project), url_to_avatar(activity.author)] + [act.project.name.to_s+" | 项目问题", act.subject.to_s, project_issues_path(act.project), url_to_avatar(act.author)] end end end From c439d62a647e2c22682aead0ff5b8b84fc55ffd0 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:20:44 +0800 Subject: [PATCH 040/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 475594687..33939c140 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -1,6 +1,8 @@ class WechatsController < ActionController::Base wechat_responder + included ApplicationHelper + # default text responder when no other match on :text do |request, content| request.reply.text "echo: #{content}" # Just echo From 22a83bee0e1c99e46691f01adebe62887017ea0b Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:26:58 +0800 Subject: [PATCH 041/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 33939c140..e44f6acd0 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -1,7 +1,7 @@ class WechatsController < ActionController::Base wechat_responder - included ApplicationHelper + include ApplicationHelper # default text responder when no other match on :text do |request, content| From 472c6acf2b4989ca2650376cb5a284afd3bb3a73 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:29:22 +0800 Subject: [PATCH 042/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index e44f6acd0..e07e15d51 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -144,7 +144,7 @@ class WechatsController < ActionController::Base article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: n[:picurl], - url: 'http://www.baidu.com/' + url: n[:url] end else openid = request[:FromUserName] @@ -213,7 +213,7 @@ class WechatsController < ActionController::Base when 'Project' case user_activity.act_type.to_s when 'Issue' - [act.project.name.to_s+" | 项目问题", act.subject.to_s, project_issues_path(act.project), url_to_avatar(act.author)] + [act.project.name.to_s+" | 项目问题", act.subject.to_s, url_to_avatar(act.author),project_issues_url(act.project)] end end end From 74b643584fbfb45fc277bcab799c8e3e83e3e1c1 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:31:29 +0800 Subject: [PATCH 043/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index e07e15d51..025df5f78 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -144,7 +144,7 @@ class WechatsController < ActionController::Base article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: n[:picurl], - url: n[:url] + url: "https://www.turstie.net"+n[:url] end else openid = request[:FromUserName] From 9d33dcf2f38a7310e226c2ea33586b594e703dcf Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:32:43 +0800 Subject: [PATCH 044/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 025df5f78..0232551be 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -141,8 +141,8 @@ class WechatsController < ActionController::Base end request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{index} #{n[:title]}", - description: n[:content], + article.item title: "#{n[:content]}", + description: n[:title], pic_url: n[:picurl], url: "https://www.turstie.net"+n[:url] end From 6075f4478656bbd9582519f65f81bb4fb959395d Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:34:05 +0800 Subject: [PATCH 045/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 0232551be..a46ea368e 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -143,8 +143,8 @@ class WechatsController < ActionController::Base request.reply.news(news) do |article, n, index| # article is return object article.item title: "#{n[:content]}", description: n[:title], - pic_url: n[:picurl], - url: "https://www.turstie.net"+n[:url] + pic_url: "https://www.turstie.net#{n[:picurl]}", + url: n[:url] end else openid = request[:FromUserName] From 745b8399d1648e46fe3ed2033f85ceae5dd66bbb Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:38:40 +0800 Subject: [PATCH 046/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index a46ea368e..72717914c 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -124,7 +124,7 @@ class WechatsController < ActionController::Base if uw && uw.user ua = user_activity(uw.user) - logo = "trustie_logo2.png" + logo = "http://wechat.trustie.net/images/trustie_logo2.png" i = 0 news =[] ua.each do |a| @@ -133,7 +133,7 @@ class WechatsController < ActionController::Base if activity news << {title: activity[0], content: activity[1], - picurl: "http://wechat.trustie.net/images/#{i == 1 ? logo : activity[2]}", + picurl: "#{i == 1 ? logo : 'https://www.trustie.net'+activity[2]}", url: activity[3] } end @@ -143,7 +143,7 @@ class WechatsController < ActionController::Base request.reply.news(news) do |article, n, index| # article is return object article.item title: "#{n[:content]}", description: n[:title], - pic_url: "https://www.turstie.net#{n[:picurl]}", + pic_url: "#{n[:picurl]}", url: n[:url] end else From 769b044df5784c32b268e36ff24be17dd014ea1e Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 20 Jan 2016 23:39:47 +0800 Subject: [PATCH 047/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 72717914c..eeb3a8455 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -133,7 +133,7 @@ class WechatsController < ActionController::Base if activity news << {title: activity[0], content: activity[1], - picurl: "#{i == 1 ? logo : 'https://www.trustie.net'+activity[2]}", + picurl: "#{i == 1 ? logo : 'https://www.trustie.net/'+activity[2]}", url: activity[3] } end From 0ab579af98b32e6e3a9d176a7b05009c65a418e1 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sun, 28 Feb 2016 22:22:10 +0800 Subject: [PATCH 048/507] =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=97=B6=E5=8F=91?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 29 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index eeb3a8455..b6b6cc237 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -23,7 +23,7 @@ class WechatsController < ActionController::Base end on :event, with: 'subscribe' do |request| - request.reply.text "#{request[:FromUserName]} subscribe now" + sendBind end # When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account @@ -147,17 +147,22 @@ class WechatsController < ActionController::Base url: n[:url] end else - openid = request[:FromUserName] - attrs = wechat.user(openid) - UserWechat.delete_all(openid: openid) - uw = UserWechat.create!(attrs) - news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } - request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{n[:title]}", - description: n[:content], - pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', - url: login_wechat_url(openid: uw.id) - end + sendBind + end + end + + def sendBind + openid = request[:FromUserName] + attrs = wechat.user(openid) + UserWechat.delete_all(openid: openid) + uw = UserWechat.create!(attrs) + news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } + request.reply.news(news) do |article, n, index| # article is return object + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{self.corpid}&redirect_uri=#{login_wechat_url(uid: uw.id)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" + article.item title: "#{n[:title]}", + description: n[:content], + pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', + url: url end end From 35f9dc6e77b80dd9d6b031accfaf3b734b776e55 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sun, 28 Feb 2016 22:28:44 +0800 Subject: [PATCH 049/507] =?UTF-8?q?=E4=BC=A0request=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index b6b6cc237..ea51059df 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -23,7 +23,7 @@ class WechatsController < ActionController::Base end on :event, with: 'subscribe' do |request| - sendBind + sendBind(request) end # When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account @@ -147,11 +147,11 @@ class WechatsController < ActionController::Base url: n[:url] end else - sendBind + sendBind(request) end end - def sendBind + def sendBind(request) openid = request[:FromUserName] attrs = wechat.user(openid) UserWechat.delete_all(openid: openid) From 60b35a46cea7eb8ddd4d1d44d9b5b3c2ee1e312a Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 14:05:18 +0800 Subject: [PATCH 050/507] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BC=81=E4=B8=9Aid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ea51059df..0429ebd91 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -158,7 +158,7 @@ class WechatsController < ActionController::Base uw = UserWechat.create!(attrs) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{self.corpid}&redirect_uri=#{login_wechat_url(uid: uw.id)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.corpid}&redirect_uri=#{login_wechat_url(uid: uw.id)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" article.item title: "#{n[:title]}", description: n[:content], pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', From 8f5645e5c1b18c7f40908756d8a93601791a6683 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 14:32:10 +0800 Subject: [PATCH 051/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9wechat=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/wechat.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/config/wechat.yml b/config/wechat.yml index 20b6382c3..98941c578 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -12,19 +12,7 @@ default: &default jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" production: - corpid: <%= ENV['WECHAT_CORPID'] %> - corpsecret: <%= ENV['WECHAT_CORPSECRET'] %> - agentid: <%= ENV['WECHAT_AGENTID'] %> -# Or if using public account, only need above two line -# appid: -# secret: - token: <%= ENV['WECHAT_TOKEN'] %> - timeout: 30, - skip_verify_ssl: true - access_token: <%= ENV['WECHAT_ACCESS_TOKEN'] %> - encrypt_mode: false # if true must fill encoding_aes_key - encoding_aes_key: <%= ENV['WECHAT_ENCODING_AES_KEY'] %> - jsapi_ticket: + <<: *default development: <<: *default From a7220a535eed78ff9730371ab3c004e306a6f04b Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 14:33:36 +0800 Subject: [PATCH 052/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9wechat=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/wechat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/wechat.yml b/config/wechat.yml index 98941c578..5b528487b 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -7,7 +7,7 @@ default: &default secret: "dff5b606e34dcafe24163ec82c2715f8" token: "123456" access_token: "1234567" - encrypt_mode: true # if true must fill encoding_aes_key + encrypt_mode: false # if true must fill encoding_aes_key encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6" jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket" From dce93c83130192f5adbea99fecd9ce319154704c Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 14:50:05 +0800 Subject: [PATCH 053/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9wechat=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 0429ebd91..5be3c8bdf 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -152,13 +152,14 @@ class WechatsController < ActionController::Base end def sendBind(request) + logger.deb openid = request[:FromUserName] attrs = wechat.user(openid) UserWechat.delete_all(openid: openid) uw = UserWechat.create!(attrs) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.corpid}&redirect_uri=#{login_wechat_url(uid: uw.id)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url(uid: uw.id)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" article.item title: "#{n[:title]}", description: n[:content], pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', From e32fdf6bcb090eabcc5a76aa3d12d973267f76d2 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 15:21:20 +0800 Subject: [PATCH 054/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9wechat=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 6 +++--- app/views/wechats/login.html.erb | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 5be3c8bdf..ef5562bf0 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -159,7 +159,7 @@ class WechatsController < ActionController::Base uw = UserWechat.create!(attrs) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url(uid: uw.id)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url}&response_type=code&scope=snsapi_base&state=#{uw.id}#wechat_redirect" article.item title: "#{n[:title]}", description: n[:content], pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', @@ -169,12 +169,12 @@ class WechatsController < ActionController::Base def bind begin - raise "非法操作, 微信ID不存在" unless params[:openid] + raise "非法操作, 微信ID不存在" unless params[:state] user, last_login_on = User.try_to_login(params[:username], params[:password]) raise "用户名或密码错误,请重新登录" unless user #补全用户信息 - uw = UserWechat.find_by_id(params[:openid]) + uw = UserWechat.find_by_id(params[:state]) uw.user_id = user.id uw.save! rescue Exception=>e diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index e6a936f4e..f3fa64a56 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -5,12 +5,23 @@ 绑定用户 + @@ -41,7 +52,7 @@

From e2ecd546639eb206bc3cc4acca9dcd168b29bce6 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 15:24:30 +0800 Subject: [PATCH 055/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9wechat=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/login.html.erb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index f3fa64a56..32b70d1e2 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -7,14 +7,13 @@
@@ -66,5 +47,27 @@
+ + + \ No newline at end of file From b5a8625e40fd549d12ca67e9401eea1edf8b8029 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 15:39:18 +0800 Subject: [PATCH 060/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9wechat=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/login.html.erb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index a9a5d54f3..ddea5af18 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -6,9 +6,7 @@ 绑定用户 -
From 42edbce8f26ee8547566083ab44bc21eae203371 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 15:41:33 +0800 Subject: [PATCH 061/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9wechat=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/login.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index ddea5af18..2614c1b08 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -58,7 +58,7 @@ $.ajax({ type: "POST", - url: $(this).parent("form").attr("action"), + url: $("#submitForm").attr("action"), data:data, dataType: "json" }); From 4d1969e715c4da6025d3d4092d8d7bf268047fbd Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 15:42:37 +0800 Subject: [PATCH 062/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9wechat=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/login.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index 2614c1b08..481b89f7a 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -58,7 +58,7 @@ $.ajax({ type: "POST", - url: $("#submitForm").attr("action"), + url: $("#main_login_form").attr("action"), data:data, dataType: "json" }); From e487b39d16b6ec2ebee296dfb6a1821237254f1d Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 15:46:05 +0800 Subject: [PATCH 063/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9wechat=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ef5562bf0..5d61667a6 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -177,9 +177,9 @@ class WechatsController < ActionController::Base uw = UserWechat.find_by_id(params[:state]) uw.user_id = user.id uw.save! + render :text => {status:0, msg: "绑定成功"} rescue Exception=>e - @wechat_bind_errors = e.message - render :login + render :text => {status: -1, msg: e.message} end end From 445bae6de9bc7dc4bd3fbf73cc2b6d2818798d53 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 16:13:13 +0800 Subject: [PATCH 064/507] =?UTF-8?q?patch=20mysql5.7=E7=9A=84create=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/layout.html.erb | 0 config/initializers/abstract_mysql_adapter.rb | 3 ++ public/javascripts/wechat/alert.js | 38 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 app/views/wechats/layout.html.erb create mode 100644 config/initializers/abstract_mysql_adapter.rb create mode 100644 public/javascripts/wechat/alert.js diff --git a/app/views/wechats/layout.html.erb b/app/views/wechats/layout.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/initializers/abstract_mysql_adapter.rb b/config/initializers/abstract_mysql_adapter.rb new file mode 100644 index 000000000..5083a562b --- /dev/null +++ b/config/initializers/abstract_mysql_adapter.rb @@ -0,0 +1,3 @@ +class ActiveRecord::ConnectionAdapters::Mysql2Adapter + NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY" +end diff --git a/public/javascripts/wechat/alert.js b/public/javascripts/wechat/alert.js new file mode 100644 index 000000000..bda0150a9 --- /dev/null +++ b/public/javascripts/wechat/alert.js @@ -0,0 +1,38 @@ +$(function(){ + window.byAlert = function(info, title){ + if(typeof title === 'undefined'){ + title = '提示'; + } + $('.weui_dialog_alert .weui_dialog_title').text(title); + $('.weui_dialog_alert .weui_dialog_info').text(info); + + var $dialog = $('#dialog2'); + $dialog.show(); + $dialog.find('.weui_btn_dialog').one('click', function () { + $dialog.hide(); + }); + }; + + + window.byConfirm = function(info, cb){ + var title; + if(typeof title === 'undefined'){ + title = '提示'; + } + $('.weui_dialog_confirm .weui_dialog_title').text(title); + $('.weui_dialog_confirm .weui_dialog_info').text(info); + + var $dialog = $('#dialog1'); + $dialog.show(); + $dialog.find('.weui_btn_dialog.confirm').one('click', function () { + $dialog.hide(); + if(typeof cb === 'function'){ + cb(); + } + }); + + $dialog.find('.weui_btn_dialog.cancel').one('click', function () { + $dialog.hide(); + }); + } +}); \ No newline at end of file From a59f65a45567557417f0706fefbe1efa0c1c6887 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 16:13:37 +0800 Subject: [PATCH 065/507] wechat --- Gemfile | 2 +- app/controllers/wechats_controller.rb | 2 + app/views/wechats/layout.html.erb | 43 + app/views/wechats/login.html.erb | 17 +- db/schema.rb | 2142 +------------------------ 5 files changed, 76 insertions(+), 2130 deletions(-) diff --git a/Gemfile b/Gemfile index 95484139d..e292279ef 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,7 @@ gem 'daemons' gem 'grape', '~> 0.9.0' gem 'grape-entity' gem 'seems_rateable', '~> 1.0.13' -gem "rails", "3.2.13" +gem 'rails', '~> 3.2', '>= 3.2.22' gem "jquery-rails", "~> 2.0.2" gem "i18n", "~> 0.6.0" gem 'coderay', '~> 1.1.0' diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 5d61667a6..1c14aece0 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -1,4 +1,6 @@ class WechatsController < ActionController::Base + layout 'wechat/layout' + wechat_responder include ApplicationHelper diff --git a/app/views/wechats/layout.html.erb b/app/views/wechats/layout.html.erb index e69de29bb..8f93ac9a1 100644 --- a/app/views/wechats/layout.html.erb +++ b/app/views/wechats/layout.html.erb @@ -0,0 +1,43 @@ + + + + + <%= csrf_meta_tag %> + + 绑定用户 + + + + +<%= yield %> + + + + + + + + + + + + \ No newline at end of file diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index 481b89f7a..d0cecb5f9 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -1,13 +1,3 @@ - - - - - <%= csrf_meta_tag %> - - 绑定用户 - - -
@@ -61,11 +51,10 @@ url: $("#main_login_form").attr("action"), data:data, dataType: "json" + }).done(function(data){ + }); }) }); - - - - \ No newline at end of file + \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index d47a676fb..c9b53c6aa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,2120 +11,6 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160119034447) do - create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - t.integer "activity_container_id" - t.string "activity_container_type", :default => "" - t.datetime "created_at" - end - - add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" - add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" - add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - - create_table "activity_notifies", :force => true do |t| - t.integer "activity_container_id" - t.string "activity_container_type" - t.integer "activity_id" - t.string "activity_type" - t.integer "notify_to" - t.datetime "created_on" - t.integer "is_read" - end - - add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" - add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" - add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" - - create_table "api_keys", :force => true do |t| - t.string "access_token" - t.datetime "expires_at" - t.integer "user_id" - t.boolean "active", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" - add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" - - create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - end - - create_table "apply_project_masters", :force => true do |t| - t.integer "user_id" - t.string "apply_type" - t.integer "apply_id" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "at_messages", :force => true do |t| - t.integer "user_id" - t.integer "at_message_id" - t.string "at_message_type" - t.boolean "viewed", :default => false - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sender_id" - end - - add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" - - create_table "attachment_histories", :force => true do |t| - t.integer "container_id" - t.string "container_type" - t.string "filename", :default => "" - t.string "disk_filename", :default => "" - t.integer "filesize", :default => 0 - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "" - t.integer "downloads", :default => 0 - t.integer "author_id" - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.integer "copy_from" - t.integer "quotes" - t.integer "version" - t.integer "attachment_id" -<<<<<<< HEAD -======= - t.integer "is_publish", :default => 1 - t.date "publish_time" ->>>>>>> origin/szzh - end - - create_table "attachments", :force => true do |t| - t.integer "container_id" - t.string "container_type", :limit => 30 - t.string "filename", :default => "", :null => false - t.string "disk_filename", :default => "", :null => false - t.integer "filesize", :default => 0, :null => false - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "", :null => false - t.integer "downloads", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype", :default => 1 - t.integer "is_public", :default => 1 - t.integer "copy_from" - t.integer "quotes" -<<<<<<< HEAD -======= - t.integer "is_publish", :default => 1 - t.date "publish_time" ->>>>>>> origin/szzh - end - - add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" - add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" - add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" - - create_table "attachmentstypes", :force => true do |t| - t.integer "typeId", :null => false - t.string "typeName", :limit => 50 - end - - create_table "auth_sources", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 60, :default => "", :null => false - t.string "host", :limit => 60 - t.integer "port" - t.string "account" - t.string "account_password", :default => "" - t.string "base_dn" - t.string "attr_login", :limit => 30 - t.string "attr_firstname", :limit => 30 - t.string "attr_lastname", :limit => 30 - t.string "attr_mail", :limit => 30 - t.boolean "onthefly_register", :default => false, :null => false - t.boolean "tls", :default => false, :null => false - t.string "filter" - t.integer "timeout" - end - - add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" - - create_table "biding_projects", :force => true do |t| - t.integer "project_id" - t.integer "bid_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "bids", :force => true do |t| - t.string "name" - t.string "budget", :null => false - t.integer "author_id" - t.date "deadline" - t.text "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.integer "commit" - t.integer "reward_type" - t.integer "homework_type" - t.integer "parent_id" - t.string "password" - t.integer "is_evaluation" - t.integer "proportion", :default => 60 - t.integer "comment_status", :default => 0 - t.integer "evaluation_num", :default => 3 - t.integer "open_anonymous_evaluation", :default => 1 - end - - create_table "blog_comments", :force => true do |t| - t.integer "blog_id", :null => false - t.integer "parent_id" - t.string "title", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comment_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "blogs", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.integer "position", :default => 1 - t.integer "article_count", :default => 0, :null => false - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comments_id" - t.integer "parent_id" - t.integer "author_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "homepage_id" - end - - create_table "boards", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :default => "", :null => false - t.string "description" - t.integer "position", :default => 1 - t.integer "topics_count", :default => 0, :null => false - t.integer "messages_count", :default => 0, :null => false - t.integer "last_message_id" - t.integer "parent_id" - t.integer "course_id" - t.integer "org_subfield_id" - end - - add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" - add_index "boards", ["project_id"], :name => "boards_project_id" - - create_table "bug_to_osps", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "changes", :force => true do |t| - t.integer "changeset_id", :null => false - t.string "action", :limit => 1, :default => "", :null => false - t.text "path", :null => false - t.text "from_path" - t.string "from_revision" - t.string "revision" - t.string "branch" - end - - add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" - - create_table "changeset_parents", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "parent_id", :null => false - end - - add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" - add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" - - create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false - t.string "committer" - t.datetime "committed_on", :null => false - t.text "comments" - t.date "commit_date" - t.string "scmid" - t.integer "user_id" - end - - add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" - add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true - add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" - add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" - add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" - - create_table "changesets_issues", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "issue_id", :null => false - end - - add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - - create_table "comments", :force => true do |t| - t.string "commented_type", :limit => 30, :default => "", :null => false - t.integer "commented_id", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.text "comments" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "comments", ["author_id"], :name => "index_comments_on_author_id" - add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" - - create_table "contest_notifications", :force => true do |t| - t.text "title" - t.text "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" - t.integer "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contestnotifications", :force => true do |t| - t.integer "contest_id" - t.string "title" - t.string "summary" - t.text "description" - t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contests", :force => true do |t| - t.string "name" - t.string "budget", :default => "" - t.integer "author_id" - t.date "deadline" - t.string "description" - t.integer "commit" - t.string "password" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - create_table "course_activities", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_act_id" - t.string "course_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_attachments", :force => true do |t| - t.string "filename" - t.string "disk_filename" - t.integer "filesize" - t.string "content_type" - t.string "digest" - t.integer "downloads" - t.string "author_id" - t.string "integer" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "container_id", :default => 0 - end - - create_table "course_contributor_scores", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.integer "message_num" - t.integer "message_reply_num" - t.integer "news_reply_num" - t.integer "resource_num" - t.integer "journal_num" - t.integer "journal_reply_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "total_score" - end - - create_table "course_groups", :force => true do |t| - t.string "name" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_infos", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_messages", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_message_id" - t.string "course_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "content" - t.integer "status" - end - - create_table "course_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "course_id" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "courses", :force => true do |t| - t.integer "tea_id" - t.string "name" - t.integer "state" - t.string "code" - t.integer "time" - t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "location" - t.string "term" - t.string "string" - t.string "password" - t.string "setup_time" - t.string "endup_time" - t.string "class_period" - t.integer "school_id" - t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 - t.integer "lft" - t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "is_delete", :default => 0 - t.integer "end_time" - t.string "end_term" -<<<<<<< HEAD -======= - t.integer "is_excellent", :default => 0 - t.integer "excellent_option", :default => 0 - t.integer "is_copy", :default => 0 ->>>>>>> origin/szzh - end - - create_table "custom_fields", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.string "field_format", :limit => 30, :default => "", :null => false - t.text "possible_values" - t.string "regexp", :default => "" - t.integer "min_length", :default => 0, :null => false - t.integer "max_length", :default => 0, :null => false - t.boolean "is_required", :default => false, :null => false - t.boolean "is_for_all", :default => false, :null => false - t.boolean "is_filter", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "searchable", :default => false - t.text "default_value" - t.boolean "editable", :default => true - t.boolean "visible", :default => true, :null => false - t.boolean "multiple", :default => false - end - - add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" - - create_table "custom_fields_projects", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "project_id", :default => 0, :null => false - end - - add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true - - create_table "custom_fields_trackers", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true - - create_table "custom_values", :force => true do |t| - t.string "customized_type", :limit => 30, :default => "", :null => false - t.integer "customized_id", :default => 0, :null => false - t.integer "custom_field_id", :default => 0, :null => false - t.text "value" - end - - add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" - add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" - - create_table "delayed_jobs", :force => true do |t| - t.integer "priority", :default => 0, :null => false - t.integer "attempts", :default => 0, :null => false - t.text "handler", :null => false - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "documents", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "category_id", :default => 0, :null => false - t.string "title", :limit => 60, :default => "", :null => false - t.text "description" - t.datetime "created_on" - t.integer "user_id", :default => 0 - t.integer "is_public", :default => 1 - end - - add_index "documents", ["category_id"], :name => "index_documents_on_category_id" - add_index "documents", ["created_on"], :name => "index_documents_on_created_on" - add_index "documents", ["project_id"], :name => "documents_project_id" - - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 - t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false - end - - create_table "editor_of_documents", :force => true do |t| - t.integer "editor_id" - t.integer "org_document_comment_id" - t.datetime "created_at" - end - - create_table "enabled_modules", :force => true do |t| - t.integer "project_id" - t.string "name", :null => false - t.integer "course_id" - end - - add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" - - create_table "enumerations", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "is_default", :default => false, :null => false - t.string "type" - t.boolean "active", :default => true, :null => false - t.integer "project_id" - t.integer "parent_id" - t.string "position_name", :limit => 30 - end - - add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" - add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" - - create_table "exercise_answers", :force => true do |t| - t.integer "user_id" - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_choices", :force => true do |t| - t.integer "exercise_question_id" - t.text "choice_text" - t.integer "choice_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_questions", :force => true do |t| - t.text "question_title" - t.integer "question_type" - t.integer "question_number" - t.integer "exercise_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_score" - end - - create_table "exercise_standard_answers", :force => true do |t| - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_users", :force => true do |t| - t.integer "user_id" - t.integer "exercise_id" - t.integer "score" - t.datetime "start_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "end_at" - t.integer "status" - end - - create_table "exercises", :force => true do |t| - t.text "exercise_name" - t.text "exercise_description" - t.integer "course_id" - t.integer "exercise_status" - t.integer "user_id" - t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "publish_time" - t.datetime "end_time" - t.integer "show_result" - end - - create_table "first_pages", :force => true do |t| - t.string "web_title" - t.string "title" - t.text "description" - t.string "page_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sort_type" - t.integer "image_width", :default => 107 - t.integer "image_height", :default => 63 - t.integer "show_course", :default => 1 - t.integer "show_contest", :default => 1 - end - - create_table "forge_activities", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_act_id" - t.string "forge_act_type" - t.integer "org_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" - - create_table "forge_messages", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_message_id" - t.string "forge_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "secret_key" - t.integer "status" - end - - create_table "forums", :force => true do |t| - t.string "name", :null => false - t.text "description" - t.integer "topic_count", :default => 0 - t.integer "memo_count", :default => 0 - t.integer "last_memo_id", :default => 0 - t.integer "creator_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sticky" - t.integer "locked" - end - - create_table "groups_users", :id => false, :force => true do |t| - t.integer "group_id", :null => false - t.integer "user_id", :null => false - end - - add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true - - create_table "homework_attaches", :force => true do |t| - t.integer "bid_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - t.string "name" - t.text "description" - t.integer "state" - t.integer "project_id", :default => 0 - t.float "score", :default => 0.0 - t.integer "is_teacher_score", :default => 0 - end - - add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" - - create_table "homework_commons", :force => true do |t| - t.string "name" - t.integer "user_id" - t.text "description" - t.date "publish_time" - t.date "end_time" - t.integer "homework_type", :default => 1 - t.string "late_penalty" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "teacher_priority", :default => 1 - t.integer "anonymous_comment", :default => 0 -<<<<<<< HEAD -======= - t.integer "quotes", :default => 0 ->>>>>>> origin/szzh - end - - add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" - - create_table "homework_detail_groups", :force => true do |t| - t.integer "homework_common_id" - t.integer "min_num" - t.integer "max_num" - t.integer "base_on_project" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" - - create_table "homework_detail_manuals", :force => true do |t| - t.float "ta_proportion" - t.integer "comment_status" - t.date "evaluation_start" - t.date "evaluation_end" - t.integer "evaluation_num" - t.integer "absence_penalty", :default => 1 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_detail_programings", :force => true do |t| - t.string "language" - t.text "standard_code", :limit => 2147483647 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "ta_proportion", :default => 0.1 - t.integer "question_id" - end - - create_table "homework_evaluations", :force => true do |t| - t.string "user_id" - t.string "homework_attach_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_for_courses", :force => true do |t| - t.integer "course_id" - t.integer "bid_id" - end - - add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" - add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" - - create_table "homework_tests", :force => true do |t| - t.text "input" - t.text "output" - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "result" - t.text "error_msg" - end - - create_table "homework_users", :force => true do |t| - t.string "homework_attach_id" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "invite_lists", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "mail" - end - - create_table "issue_categories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.integer "assigned_to_id" - end - - add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" - add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" - - create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :default => "", :null => false - t.integer "delay" - end - - add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true - add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" - add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" - - create_table "issue_statuses", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_closed", :default => false, :null => false - t.boolean "is_default", :default => false, :null => false - t.integer "position", :default => 1 - t.integer "default_done_ratio" - end - - add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" - add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" - add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" - - create_table "issues", :force => true do |t| - t.integer "tracker_id", :null => false - t.integer "project_id", :null => false - t.string "subject", :default => "", :null => false - t.text "description" - t.date "due_date" - t.integer "category_id" - t.integer "status_id", :null => false - t.integer "assigned_to_id" - t.integer "priority_id", :null => false - t.integer "fixed_version_id" - t.integer "author_id", :null => false - t.integer "lock_version", :default => 0, :null => false - t.datetime "created_on" - t.datetime "updated_on" - t.date "start_date" - t.integer "done_ratio", :default => 0, :null => false - t.float "estimated_hours" - t.integer "parent_id" - t.integer "root_id" - t.integer "lft" - t.integer "rgt" - t.boolean "is_private", :default => false, :null => false - t.datetime "closed_on" - t.integer "project_issues_index" - end - - add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" - add_index "issues", ["category_id"], :name => "index_issues_on_category_id" - add_index "issues", ["created_on"], :name => "index_issues_on_created_on" - add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" - add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" - add_index "issues", ["project_id"], :name => "issues_project_id" - add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" - add_index "issues", ["status_id"], :name => "index_issues_on_status_id" - add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" - - create_table "join_in_competitions", :force => true do |t| - t.integer "user_id" - t.integer "competition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "join_in_contests", :force => true do |t| - t.integer "user_id" - t.integer "bid_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "journal_details", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - - create_table "journal_replies", :id => false, :force => true do |t| - t.integer "journal_id" - t.integer "user_id" - t.integer "reply_id" - end - - add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" - add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" - add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" - - create_table "journals", :force => true do |t| - t.integer "journalized_id", :default => 0, :null => false - t.string "journalized_type", :limit => 30, :default => "", :null => false - t.integer "user_id", :default => 0, :null => false - t.text "notes" - t.datetime "created_on", :null => false - t.boolean "private_notes", :default => false, :null => false - end - - add_index "journals", ["created_on"], :name => "index_journals_on_created_on" - add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" - add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" - add_index "journals", ["user_id"], :name => "index_journals_on_user_id" - - create_table "journals_for_messages", :force => true do |t| - t.integer "jour_id" - t.string "jour_type" - t.integer "user_id" - t.text "notes" - t.integer "status" - t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.string "m_parent_id" - t.boolean "is_readed" - t.integer "m_reply_count" - t.integer "m_reply_id" - t.integer "is_comprehensive_evaluation" - t.integer "private", :default => 0 - end - - create_table "kindeditor_assets", :force => true do |t| - t.string "asset" - t.integer "file_size" - t.string "file_type" - t.integer "owner_id" - t.string "asset_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "owner_type", :default => 0 - end - - create_table "member_roles", :force => true do |t| - t.integer "member_id", :null => false - t.integer "role_id", :null => false - t.integer "inherited_from" - end - - add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" - add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" - - create_table "members", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "project_id", :default => 0 - t.datetime "created_on" - t.boolean "mail_notification", :default => false, :null => false - t.integer "course_id", :default => -1 - t.integer "course_group_id", :default => 0 - end - - add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true - add_index "members", ["user_id"], :name => "index_members_on_user_id" - - create_table "memo_messages", :force => true do |t| - t.integer "user_id" - t.integer "forum_id" - t.integer "memo_id" - t.string "memo_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "memos", :force => true do |t| - t.integer "forum_id", :null => false - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false - t.integer "author_id", :null => false - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count", :default => 0 - end - - create_table "message_alls", :force => true do |t| - t.integer "user_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "messages", :force => true do |t| - t.integer "board_id", :null => false - t.integer "parent_id" - t.string "subject", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "replies_count", :default => 0, :null => false - t.integer "last_reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.integer "quotes" -<<<<<<< HEAD -======= - t.integer "status", :default => 0 ->>>>>>> origin/szzh - end - - add_index "messages", ["author_id"], :name => "index_messages_on_author_id" - add_index "messages", ["board_id"], :name => "messages_board_id" - add_index "messages", ["created_on"], :name => "index_messages_on_created_on" - add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" - add_index "messages", ["parent_id"], :name => "messages_parent_id" - - create_table "news", :force => true do |t| - t.integer "project_id" -<<<<<<< HEAD - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" - t.text "description" - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false - t.integer "course_id" - t.integer "sticky", :default => 0 -======= - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" - t.text "description" - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false - t.integer "course_id" - t.integer "sticky", :default => 0 - t.integer "org_subfield_id" ->>>>>>> origin/szzh - end - - add_index "news", ["author_id"], :name => "index_news_on_author_id" - add_index "news", ["created_on"], :name => "index_news_on_created_on" - add_index "news", ["project_id"], :name => "news_project_id" - - create_table "no_uses", :force => true do |t| - t.integer "user_id", :null => false - t.string "no_use_type" - t.integer "no_use_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "notificationcomments", :force => true do |t| - t.string "notificationcommented_type" - t.integer "notificationcommented_id" - t.integer "author_id" - t.text "notificationcomments" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "onclick_times", :force => true do |t| - t.integer "user_id" - t.datetime "onclick_time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "open_id_authentication_associations", :force => true do |t| - t.integer "issued" - t.integer "lifetime" - t.string "handle" - t.string "assoc_type" - t.binary "server_url" - t.binary "secret" - end - - create_table "open_id_authentication_nonces", :force => true do |t| - t.integer "timestamp", :null => false - t.string "server_url" - t.string "salt", :null => false - end - - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.text "description" - t.integer "commit_count", :default => 0 - t.integer "code_line", :default => 0 - t.integer "users_count", :default => 0 - t.date "last_commit_time" - t.string "url" - t.date "date_collected" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "option_numbers", :force => true do |t| - t.integer "user_id" - t.integer "memo" - t.integer "messages_for_issues" - t.integer "issues_status" - t.integer "replay_for_message" - t.integer "replay_for_memo" - t.integer "follow" - t.integer "tread" - t.integer "praise_by_one" - t.integer "praise_by_two" - t.integer "praise_by_three" - t.integer "tread_by_one" - t.integer "tread_by_two" - t.integer "tread_by_three" - t.integer "changeset" - t.integer "document" - t.integer "attachment" - t.integer "issue_done_ratio" - t.integer "post_issue" - t.integer "score_type" - t.integer "total_score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - end - - create_table "org_activities", :force => true do |t| - t.integer "user_id" - t.integer "org_act_id" - t.string "org_act_type" - t.integer "container_id" - t.string "container_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_courses", :force => true do |t| - t.integer "organization_id" - t.integer "course_id" - t.datetime "created_at" - end - - create_table "org_document_comments", :force => true do |t| - t.text "title" - t.text "content" - t.integer "organization_id" - t.integer "creator_id" - t.integer "parent_id" - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "org_subfield_id" - end - - create_table "org_member_roles", :force => true do |t| - t.integer "org_member_id" - t.integer "role_id" - end - - create_table "org_members", :force => true do |t| - t.integer "user_id" - t.integer "organization_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_messages", :force => true do |t| - t.integer "user_id" - t.integer "sender_id" - t.integer "organization_id" - t.string "message_type" - t.integer "message_id" - t.integer "viewed" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "status", :default => 0 - end - - create_table "org_projects", :force => true do |t| - t.integer "organization_id" - t.integer "project_id" - t.datetime "created_at" - end - - create_table "org_subfield_messages", :force => true do |t| - t.integer "org_subfield_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_subfields", :force => true do |t| - t.integer "organization_id" - t.integer "priority" - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "field_type" - t.integer "hide", :default => 0 - end - - create_table "organizations", :force => true do |t| - t.string "name" - t.text "description" - t.integer "creator_id" - t.integer "home_id" -<<<<<<< HEAD - t.string "domain" - t.boolean "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false -======= - t.boolean "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "allow_guest_download", :default => true ->>>>>>> origin/szzh - end - - create_table "phone_app_versions", :force => true do |t| - t.string "version" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_answers", :force => true do |t| - t.integer "poll_question_id" - t.text "answer_text" - t.integer "answer_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_questions", :force => true do |t| - t.string "question_title" - t.integer "question_type" - t.integer "is_necessary" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_number" - end - - create_table "poll_users", :force => true do |t| - t.integer "user_id" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_votes", :force => true do |t| - t.integer "user_id" - t.integer "poll_question_id" - t.integer "poll_answer_id" - t.text "vote_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "polls", :force => true do |t| - t.string "polls_name" - t.string "polls_type" - t.integer "polls_group_id" - t.integer "polls_status" - t.integer "user_id" - t.datetime "published_at" - t.datetime "closed_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "polls_description" - t.integer "show_result", :default => 1 - end - - create_table "praise_tread_caches", :force => true do |t| - t.integer "object_id", :null => false - t.string "object_type" - t.integer "praise_num" - t.integer "tread_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "praise_treads", :force => true do |t| - t.integer "user_id", :null => false - t.integer "praise_tread_object_id" - t.string "praise_tread_object_type" - t.integer "praise_or_tread" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "principal_activities", :force => true do |t| - t.integer "user_id" - t.integer "principal_id" - t.integer "principal_act_id" - t.string "principal_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_infos", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_scores", :force => true do |t| - t.string "project_id" - t.integer "score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "issue_num", :default => 0 - t.integer "issue_journal_num", :default => 0 - t.integer "news_num", :default => 0 - t.integer "documents_num", :default => 0 - t.integer "changeset_num", :default => 0 - t.integer "board_message_num", :default => 0 - t.integer "board_num", :default => 0 - t.integer "attach_num", :default => 0 -<<<<<<< HEAD -======= - t.datetime "commit_time" ->>>>>>> origin/szzh - end - - create_table "project_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "project_id" - t.integer "project_type" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - end - - add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - - create_table "projecting_softapplictions", :force => true do |t| - t.integer "user_id" - t.integer "softapplication_id" - t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false - t.integer "parent_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "identifier" - t.integer "status", :default => 1, :null => false - t.integer "lft" - t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false - t.integer "project_type" - t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 - t.integer "user_id" - t.integer "dts_test", :default => 0 - t.string "enterprise_name" - t.integer "organization_id" - t.integer "project_new_type" - t.integer "gpid" - t.integer "forked_from_project_id" - t.integer "forked_count" - t.integer "commits_count", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "issues_count", :default => 0 - t.integer "attachments_count", :default => 0 - t.integer "boards_count", :default => 0 - t.integer "news_count", :default => 0 - t.integer "acts_count", :default => 0 - t.integer "journals_count", :default => 0 - t.integer "boards_reply_count", :default => 0 - end - - add_index "projects", ["lft"], :name => "index_projects_on_lft" - add_index "projects", ["rgt"], :name => "index_projects_on_rgt" - - create_table "projects_trackers", :id => false, :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true - add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" - - create_table "queries", :force => true do |t| - t.integer "project_id" - t.string "name", :default => "", :null => false - t.text "filters" - t.integer "user_id", :default => 0, :null => false - t.boolean "is_public", :default => false, :null => false - t.text "column_names" - t.text "sort_criteria" - t.string "group_by" - t.string "type" - end - - add_index "queries", ["project_id"], :name => "index_queries_on_project_id" - add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - - create_table "relative_memo_to_open_source_projects", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "relative_memos", :force => true do |t| - t.integer "osp_id" - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 16777215, :null => false - t.integer "author_id" - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 - t.string "url" - t.string "username" - t.string "userhomeurl" - t.date "date_collected" - t.string "topic_resource" - end - - create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" - t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 - t.text "extra_info" - t.string "identifier" - t.boolean "is_default", :default => false - t.boolean "hidden", :default => false - end - - add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - - create_table "roles", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "assignable", :default => true - t.integer "builtin", :default => 0, :null => false - t.text "permissions" - t.string "issues_visibility", :limit => 30, :default => "default", :null => false - end - - create_table "schools", :force => true do |t| - t.string "name" - t.string "province" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "logo_link" - t.string "pinyin" - end - -<<<<<<< HEAD -======= - create_table "secdomains", :force => true do |t| - t.integer "sub_type" - t.string "subname" - t.integer "pid", :default => 0 - t.string "desc" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - ->>>>>>> origin/szzh - create_table "seems_rateable_cached_ratings", :force => true do |t| - t.integer "cacheable_id", :limit => 8 - t.string "cacheable_type" - t.float "avg", :null => false - t.integer "cnt", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_rates", :force => true do |t| - t.integer "rater_id", :limit => 8 - t.integer "rateable_id" - t.string "rateable_type" - t.float "stars", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "is_teacher_score", :default => 0 - end - - create_table "settings", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "value" - t.datetime "updated_on" - end - - add_index "settings", ["name"], :name => "index_settings_on_name" - - create_table "shares", :force => true do |t| - t.date "created_on" - t.string "url" - t.string "title" - t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - t.integer "user_id" - t.string "description" - end - - create_table "shield_activities", :force => true do |t| - t.string "container_type" - t.integer "container_id" - t.string "shield_type" - t.integer "shield_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "softapplications", :force => true do |t| - t.string "name" - t.text "description" - t.integer "app_type_id" - t.string "app_type_name" - t.string "android_min_version_available" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "contest_id" - t.integer "softapplication_id" - t.integer "is_public" - t.string "application_developers" - t.string "deposit_project_url" - t.string "deposit_project" - t.integer "project_id" - end - - create_table "student_work_projects", :force => true do |t| - t.integer "homework_common_id" - t.integer "student_work_id" - t.integer "project_id" - t.integer "user_id" - t.integer "is_leader" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "student_work_projects", ["homework_common_id"], :name => "index_student_work_projects_on_homework_common_id" - add_index "student_work_projects", ["project_id"], :name => "index_student_work_projects_on_project_id" - add_index "student_work_projects", ["student_work_id"], :name => "index_student_work_projects_on_student_work_id" - add_index "student_work_projects", ["user_id"], :name => "index_student_work_projects_on_user_id" - - create_table "student_work_tests", :force => true do |t| - t.integer "student_work_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "status", :default => 9 - t.text "results" - t.text "src" - end - - create_table "student_works", :force => true do |t| - t.string "name" - t.text "description", :limit => 2147483647 - t.integer "homework_common_id" - t.integer "user_id" - t.float "final_score" - t.float "teacher_score" - t.float "student_score" - t.float "teaching_asistant_score" - t.integer "project_id", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "late_penalty", :default => 0 - t.integer "absence_penalty", :default => 0 - t.float "system_score", :default => 0.0 - t.boolean "is_test", :default => false - end - - add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" - - create_table "student_works_evaluation_distributions", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "student_works_scores", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.integer "score" - t.text "comment" - t.integer "reviewer_role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "students_for_courses", :force => true do |t| - t.integer "student_id" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" - add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" - - create_table "subfield_subdomain_dirs", :force => true do |t| - t.integer "org_subfield_id" - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "system_messages", :force => true do |t| - t.integer "user_id" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "description" - t.string "subject" - end - - create_table "taggings", :force => true do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", :limit => 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" - - create_table "tags", :force => true do |t| - t.string "name" - end - - create_table "teachers", :force => true do |t| - t.string "tea_name" - t.string "location" - t.integer "couurse_time" - t.integer "course_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "extra" - end - - create_table "time_entries", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "issue_id" - t.float "hours", :null => false - t.string "comments" - t.integer "activity_id", :null => false - t.date "spent_on", :null => false - t.integer "tyear", :null => false - t.integer "tmonth", :null => false - t.integer "tweek", :null => false - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" - add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" - add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" - add_index "time_entries", ["project_id"], :name => "time_entries_project_id" - add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - - create_table "tokens", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40, :default => "", :null => false - t.datetime "created_on", :null => false - end - - add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" - add_index "tokens", ["value"], :name => "tokens_value", :unique => true - - create_table "trackers", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_in_chlog", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "is_in_roadmap", :default => true, :null => false - t.integer "fields_bits", :default => 0 - end - - create_table "user_activities", :force => true do |t| - t.string "act_type" - t.integer "act_id" - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "user_id" - end - - create_table "user_extensions", :force => true do |t| - t.integer "user_id", :null => false - t.date "birthday" - t.string "brief_introduction" - t.integer "gender" - t.string "location" - t.string "occupation" - t.integer "work_experience" - t.integer "zip_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "technical_title" - t.integer "identity" - t.string "student_id" - t.string "teacher_realname" - t.string "student_realname" - t.string "location_city" - t.integer "school_id" - t.string "description", :default => "" - end - - create_table "user_feedback_messages", :force => true do |t| - t.integer "user_id" - t.integer "journals_for_message_id" - t.string "journals_for_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_grades", :force => true do |t| - t.integer "user_id", :null => false - t.integer "project_id", :null => false - t.float "grade", :default => 0.0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" - add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" - add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" - - create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - end - - create_table "user_preferences", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.text "others" - t.boolean "hide_mail", :default => false - t.string "time_zone" - end - - add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" - - create_table "user_score_details", :force => true do |t| - t.integer "current_user_id" - t.integer "target_user_id" - t.string "score_type" - t.string "score_action" - t.integer "user_id" - t.integer "old_score" - t.integer "new_score" - t.integer "current_user_level" - t.integer "target_user_level" - t.integer "score_changeable_obj_id" - t.string "score_changeable_obj_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "grade", :default => 0.0 - end - - add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" - add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" - add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" - -<<<<<<< HEAD - create_table "user_wechats", :force => true do |t| - t.integer "subscribe" - t.string "openid" - t.string "nickname" - t.integer "sex" - t.string "language" - t.string "city" - t.string "province" - t.string "country" - t.string "headimgurl" - t.string "subscribe_time" - t.string "unionid" - t.string "remark" - t.integer "groupid" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -======= ->>>>>>> origin/szzh - create_table "users", :force => true do |t| - t.string "login", :default => "", :null => false - t.string "hashed_password", :limit => 40, :default => "", :null => false - t.string "firstname", :limit => 30, :default => "", :null => false - t.string "lastname", :default => "", :null => false - t.string "mail", :limit => 60, :default => "", :null => false - t.boolean "admin", :default => false, :null => false - t.integer "status", :default => 1, :null => false - t.datetime "last_login_on" - t.string "language", :limit => 5, :default => "" - t.integer "auth_source_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "type" - t.string "identity_url" - t.string "mail_notification", :default => "", :null => false - t.string "salt", :limit => 64 - t.integer "gid" - end - - add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" - add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" - add_index "users", ["type"], :name => "index_users_on_type" - - create_table "versions", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :default => "", :null => false - t.string "description", :default => "" - t.date "effective_date" - t.datetime "created_on" - t.datetime "updated_on" - t.string "wiki_page_title" - t.string "status", :default => "open" - t.string "sharing", :default => "none", :null => false - end - - add_index "versions", ["project_id"], :name => "versions_project_id" - add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - - create_table "visitors", :force => true do |t| - t.integer "user_id" - t.integer "master_id" - t.datetime "updated_on" - t.datetime "created_on" - end - - add_index "visitors", ["master_id"], :name => "index_visitors_master_id" - add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" - add_index "visitors", ["user_id"], :name => "index_visitors_user_id" - - create_table "watchers", :force => true do |t| - t.string "watchable_type", :default => "", :null => false - t.integer "watchable_id", :default => 0, :null => false - t.integer "user_id" - end - - add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" - add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" - add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" - - create_table "web_footer_companies", :force => true do |t| - t.string "name" - t.string "logo_size" - t.string "url" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "web_footer_oranizers", :force => true do |t| - t.string "name" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -<<<<<<< HEAD - create_table "wechat_logs", :force => true do |t| - t.string "openid", :null => false - t.text "request_raw" - t.text "response_raw" - t.text "session_raw" - t.datetime "created_at", :null => false - end - -======= ->>>>>>> origin/szzh - create_table "wiki_content_versions", :force => true do |t| - t.integer "wiki_content_id", :null => false - t.integer "page_id", :null => false - t.integer "author_id" - t.binary "data", :limit => 2147483647 - t.string "compression", :limit => 6, :default => "" - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" - add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" - - create_table "wiki_contents", :force => true do |t| - t.integer "page_id", :null => false - t.integer "author_id" - t.text "text", :limit => 2147483647 - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" - add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" - - create_table "wiki_pages", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title", :null => false - t.datetime "created_on", :null => false - t.boolean "protected", :default => false, :null => false - t.integer "parent_id" - end - - add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" - add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" - add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" - - create_table "wiki_redirects", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title" - t.string "redirects_to" - t.datetime "created_on", :null => false - end - - add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" - add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" - - create_table "wikis", :force => true do |t| - t.integer "project_id", :null => false - t.string "start_page", :null => false - t.integer "status", :default => 1, :null => false - end - - add_index "wikis", ["project_id"], :name => "wikis_project_id" - - create_table "workflows", :force => true do |t| - t.integer "tracker_id", :default => 0, :null => false - t.integer "old_status_id", :default => 0, :null => false - t.integer "new_status_id", :default => 0, :null => false - t.integer "role_id", :default => 0, :null => false - t.boolean "assignee", :default => false, :null => false - t.boolean "author", :default => false, :null => false - t.string "type", :limit => 30 - t.string "field_name", :limit => 30 - t.string "rule", :limit => 30 - end - - add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" - add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" - add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" - add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - - create_table "works_categories", :force => true do |t| - t.string "category" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "zip_packs", :force => true do |t| - t.integer "user_id" - t.integer "homework_id" - t.string "file_digest" - t.string "file_path" - t.integer "pack_times", :default => 1 - t.integer "pack_size", :default => 0 - t.text "file_digests" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -end -======= -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - ActiveRecord::Schema.define(:version => 20160225024759) do create_table "activities", :force => true do |t| @@ -3996,6 +1882,25 @@ ActiveRecord::Schema.define(:version => 20160225024759) do add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" + create_table "user_wechats", :force => true do |t| + t.integer "subscribe" + t.string "openid" + t.string "nickname" + t.integer "sex" + t.string "language" + t.string "city" + t.string "province" + t.string "country" + t.string "headimgurl" + t.string "subscribe_time" + t.string "unionid" + t.string "remark" + t.integer "groupid" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "users", :force => true do |t| t.string "login", :default => "", :null => false t.string "hashed_password", :limit => 40, :default => "", :null => false @@ -4071,6 +1976,14 @@ ActiveRecord::Schema.define(:version => 20160225024759) do t.datetime "updated_at", :null => false end + create_table "wechat_logs", :force => true do |t| + t.string "openid", :null => false + t.text "request_raw" + t.text "response_raw" + t.text "session_raw" + t.datetime "created_at", :null => false + end + create_table "wiki_content_versions", :force => true do |t| t.integer "wiki_content_id", :null => false t.integer "page_id", :null => false @@ -4163,4 +2076,3 @@ ActiveRecord::Schema.define(:version => 20160225024759) do end end ->>>>>>> origin/szzh From 509d4a3df7e56893c0ca00f9f16564b58d96c853 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 16:56:37 +0800 Subject: [PATCH 066/507] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=94=B9=E4=B8=BAajax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 6 +++--- .../base_wechat.html.erb} | 1 + app/views/wechats/login.html.erb | 14 +++++++++++--- public/javascripts/wechat/alert.js | 5 +++++ 4 files changed, 20 insertions(+), 6 deletions(-) rename app/views/{wechats/layout.html.erb => layouts/base_wechat.html.erb} (96%) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 1c14aece0..01dd135be 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -1,5 +1,5 @@ class WechatsController < ActionController::Base - layout 'wechat/layout' + layout 'base_wechat' wechat_responder @@ -179,9 +179,9 @@ class WechatsController < ActionController::Base uw = UserWechat.find_by_id(params[:state]) uw.user_id = user.id uw.save! - render :text => {status:0, msg: "绑定成功"} + render :text => {status:0, msg: "绑定成功"}.to_json rescue Exception=>e - render :text => {status: -1, msg: e.message} + render :text => {status: -1, msg: e.message}.to_json end end diff --git a/app/views/wechats/layout.html.erb b/app/views/layouts/base_wechat.html.erb similarity index 96% rename from app/views/wechats/layout.html.erb rename to app/views/layouts/base_wechat.html.erb index 8f93ac9a1..729f762ac 100644 --- a/app/views/wechats/layout.html.erb +++ b/app/views/layouts/base_wechat.html.erb @@ -7,6 +7,7 @@ 绑定用户 + <%= yield %> diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index d0cecb5f9..3d8037c7c 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -50,9 +50,17 @@ type: "POST", url: $("#main_login_form").attr("action"), data:data, - dataType: "json" - }).done(function(data){ - + dataType: 'json', + success: function(data){ + console.log(data); + if(data.status == 0){ + byConfirm(data.msg, function(){ + window.closeWindow(); + }); + } else { + byAlert(data.msg, "绑定失败"); + } + } }); }) diff --git a/public/javascripts/wechat/alert.js b/public/javascripts/wechat/alert.js index bda0150a9..e41718fc2 100644 --- a/public/javascripts/wechat/alert.js +++ b/public/javascripts/wechat/alert.js @@ -35,4 +35,9 @@ $(function(){ $dialog.hide(); }); } + + + window.closeWindow = function(){ + WeixinJSBridge.call('closeWindow'); + } }); \ No newline at end of file From d5e894561965121d6ab4cd91e9f3002d23ec6822 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 17:06:40 +0800 Subject: [PATCH 067/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 6 +++++- config/menu.yml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 01dd135be..beee86472 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -7,7 +7,7 @@ class WechatsController < ActionController::Base # default text responder when no other match on :text do |request, content| - request.reply.text "echo: #{content}" # Just echo + request.reply.text "您的意见已收到" # Just echo end # When receive 'help', will trigger this responder @@ -121,6 +121,10 @@ class WechatsController < ActionController::Base # Any not match above will fail to below on :fallback, respond: 'fallback message' + on :click, with: 'FEEDBACK' do |request, key| + request.reply.text "如有反馈问题,请直接切入至输入框,发微信给我们即可" + end + on :click, with: 'MY_NEWS' do |request, key| uw = user_binded?(request[:FromUserName]) if uw && uw.user diff --git a/config/menu.yml b/config/menu.yml index 1a4927fbd..2f38a48a9 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -6,4 +6,8 @@ button: - type: "view" name: "进入网站" - url: "http://www.trustie.net/" \ No newline at end of file + url: "http://www.trustie.net/" + - + type: "click" + name: "意见返馈" + url: "FEEDBACK" \ No newline at end of file From c33b35383ddbb8e5148896d678ab345dcf7e7499 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 17:13:06 +0800 Subject: [PATCH 068/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- config/menu.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index beee86472..211979318 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -1,3 +1,4 @@ +#coding=utf-8 class WechatsController < ActionController::Base layout 'base_wechat' @@ -158,7 +159,6 @@ class WechatsController < ActionController::Base end def sendBind(request) - logger.deb openid = request[:FromUserName] attrs = wechat.user(openid) UserWechat.delete_all(openid: openid) diff --git a/config/menu.yml b/config/menu.yml index 2f38a48a9..95bc50cc5 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -10,4 +10,4 @@ button: - type: "click" name: "意见返馈" - url: "FEEDBACK" \ No newline at end of file + key: "FEEDBACK" \ No newline at end of file From b82341326752016d7855dfe16cb962a4b6d2cd40 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 17:16:48 +0800 Subject: [PATCH 069/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 211979318..b05099139 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -1,7 +1,5 @@ #coding=utf-8 class WechatsController < ActionController::Base - layout 'base_wechat' - wechat_responder include ApplicationHelper @@ -191,6 +189,7 @@ class WechatsController < ActionController::Base def login @openid = params[:openid] #TODO 安全性 + render 'wechats/login', layout: 'base_wechat' end private From 1b171e414c9d679fdd38a8fda9d61f71c94bd0ec Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 17:31:44 +0800 Subject: [PATCH 070/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index b05099139..937b6af5f 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -157,10 +157,6 @@ class WechatsController < ActionController::Base end def sendBind(request) - openid = request[:FromUserName] - attrs = wechat.user(openid) - UserWechat.delete_all(openid: openid) - uw = UserWechat.create!(attrs) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url}&response_type=code&scope=snsapi_base&state=#{uw.id}#wechat_redirect" @@ -173,14 +169,21 @@ class WechatsController < ActionController::Base def bind begin - raise "非法操作, 微信ID不存在" unless params[:state] + raise "非法操作, 用户ID不存在" unless params[:state] + raise "非法操作, code不存在" unless params[:code] + openid = get_openid(params[:code]) + raise "无法获取到openid" unless openid + user, last_login_on = User.try_to_login(params[:username], params[:password]) raise "用户名或密码错误,请重新登录" unless user #补全用户信息 - uw = UserWechat.find_by_id(params[:state]) - uw.user_id = user.id - uw.save! + raise "此用户已经绑定了公众号" if user.user_wechat + + UserWechat.create!( + openid: openid, + user: user + ) render :text => {status:0, msg: "绑定成功"}.to_json rescue Exception=>e render :text => {status: -1, msg: e.message}.to_json @@ -193,6 +196,12 @@ class WechatsController < ActionController::Base end private + def get_openid(code) + url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code" + JSON.parse(URI.parse(url).read)["openid"] + end + + def user_binded?(openid) uw = UserWechat.where(openid: openid).first end From 8e1624fafe4ca21f7b0172c5d5f9567d24639b28 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 17:33:48 +0800 Subject: [PATCH 071/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 937b6af5f..4caf5668f 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -159,7 +159,7 @@ class WechatsController < ActionController::Base def sendBind(request) news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } } request.reply.news(news) do |article, n, index| # article is return object - url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url}&response_type=code&scope=snsapi_base&state=#{uw.id}#wechat_redirect" + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" article.item title: "#{n[:title]}", description: n[:content], pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png', @@ -169,7 +169,6 @@ class WechatsController < ActionController::Base def bind begin - raise "非法操作, 用户ID不存在" unless params[:state] raise "非法操作, code不存在" unless params[:code] openid = get_openid(params[:code]) raise "无法获取到openid" unless openid From f53d9e19f79a512933b14bab50885fcbac796234 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 17:55:03 +0800 Subject: [PATCH 072/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- app/views/wechats/login.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 4caf5668f..ccb3e4bfb 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -190,7 +190,7 @@ class WechatsController < ActionController::Base end def login - @openid = params[:openid] #TODO 安全性 + @code = params[:code] #TODO 安全性 render 'wechats/login', layout: 'base_wechat' end diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index 3d8037c7c..27898b690 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -23,7 +23,7 @@
- +
确定 From 697906509b17ed3d7a01bcec0ae50cb387a3c87b Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 1 Mar 2016 17:58:54 +0800 Subject: [PATCH 073/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ccb3e4bfb..77c737359 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -172,6 +172,7 @@ class WechatsController < ActionController::Base raise "非法操作, code不存在" unless params[:code] openid = get_openid(params[:code]) raise "无法获取到openid" unless openid + raise "此微信号已绑定用户, 不能得复绑定" if UserWechat.where(openid: openid).first user, last_login_on = User.try_to_login(params[:username], params[:password]) raise "用户名或密码错误,请重新登录" unless user From 79004e1328829288543d16ebb59752f55e708e3d Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 3 Mar 2016 23:27:05 +0800 Subject: [PATCH 074/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 14 +++++++++----- config/menu.yml | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 77c737359..ac744106a 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -24,7 +24,7 @@ class WechatsController < ActionController::Base end on :event, with: 'subscribe' do |request| - sendBind(request) + default_msg(request) end # When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account @@ -125,6 +125,10 @@ class WechatsController < ActionController::Base end on :click, with: 'MY_NEWS' do |request, key| + default_msg(req) + end + + def default_msg(request) uw = user_binded?(request[:FromUserName]) if uw && uw.user @@ -137,9 +141,9 @@ class WechatsController < ActionController::Base activity = process_activity(a) if activity news << {title: activity[0], - content: activity[1], - picurl: "#{i == 1 ? logo : 'https://www.trustie.net/'+activity[2]}", - url: activity[3] + content: activity[1], + picurl: "#{i == 1 ? logo : 'https://www.trustie.net/'+activity[2]}", + url: activity[3] } end @@ -172,7 +176,7 @@ class WechatsController < ActionController::Base raise "非法操作, code不存在" unless params[:code] openid = get_openid(params[:code]) raise "无法获取到openid" unless openid - raise "此微信号已绑定用户, 不能得复绑定" if UserWechat.where(openid: openid).first + raise "此微信号已绑定用户, 不能得复绑定" if user_binded?(openid) user, last_login_on = User.try_to_login(params[:username], params[:password]) raise "用户名或密码错误,请重新登录" unless user diff --git a/config/menu.yml b/config/menu.yml index 95bc50cc5..c88e94ec4 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -3,11 +3,11 @@ button: type: "click" name: "最新动态" key: "MY_NEWS" - - - type: "view" - name: "进入网站" - url: "http://www.trustie.net/" - type: "click" name: "意见返馈" - key: "FEEDBACK" \ No newline at end of file + key: "FEEDBACK" + - + type: "view" + name: "进入网站" + url: "http://www.trustie.net/" \ No newline at end of file From 3c513085d2cf3a832911b812eca0744391717204 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 7 Mar 2016 21:43:18 +0800 Subject: [PATCH 075/507] =?UTF-8?q?request=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ac744106a..131d08b1b 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -125,7 +125,7 @@ class WechatsController < ActionController::Base end on :click, with: 'MY_NEWS' do |request, key| - default_msg(req) + default_msg(request) end def default_msg(request) From fbe1b2dac261a3a8557c25bc4970db50c11a73ad Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 21 Mar 2016 18:17:39 +0800 Subject: [PATCH 076/507] Merge branch 'guange_dev' into weixin_guange # Conflicts: # Gemfile # db/schema.rb --- app/api/mobile/api.rb | 3 + app/api/mobile/apis/issues.rb | 17 + app/api/mobile/entities/issue.rb | 9 + app/controllers/wechats_controller.rb | 2 +- public/javascripts/wechat/CommentBox.jsx | 108 + public/javascripts/wechat/JSXTransformer.js | 15924 +++++++++++++ public/javascripts/wechat/browser.min.js | 44 + public/javascripts/wechat/jquery.min.js | 5 + public/javascripts/wechat/marked.min.js | 6 + public/javascripts/wechat/react-dom.js | 42 + public/javascripts/wechat/react.js | 19535 ++++++++++++++++ public/javascripts/wechat/react.min.js | 15 + public/javascripts/wechat/wechat.jsx | 81 + .../javascripts/code_review.js | 706 +- .../stylesheets/activity.css | 6 +- .../stylesheets/code_review.css | 192 +- .../stylesheets/window_js/MIT-LICENSE | 38 +- .../stylesheets/window_js/alert.css | 238 +- .../stylesheets/window_js/alert_lite.css | 176 +- .../stylesheets/window_js/alphacube.css | 300 +- .../stylesheets/window_js/behavior.htc | 100 +- .../stylesheets/window_js/darkX.css | 242 +- .../stylesheets/window_js/debug.css | 50 +- .../stylesheets/window_js/default.css | 310 +- .../stylesheets/window_js/iefix/iepngfix.css | 6 +- .../stylesheets/window_js/iefix/iepngfix.htc | 106 +- .../stylesheets/window_js/lighting.css | 1920 +- .../window_js/lighting/pngbehavior.htc | 134 +- .../stylesheets/window_js/mac_os_x.css | 666 +- .../stylesheets/window_js/mac_os_x_dialog.css | 320 +- .../stylesheets/window_js/nuncio.css | 328 +- .../stylesheets/window_js/spread.css | 216 +- public/stylesheets/weui/weixin.css | 41 + 33 files changed, 38858 insertions(+), 3028 deletions(-) create mode 100644 app/api/mobile/apis/issues.rb create mode 100644 app/api/mobile/entities/issue.rb create mode 100644 public/javascripts/wechat/CommentBox.jsx create mode 100644 public/javascripts/wechat/JSXTransformer.js create mode 100644 public/javascripts/wechat/browser.min.js create mode 100644 public/javascripts/wechat/jquery.min.js create mode 100644 public/javascripts/wechat/marked.min.js create mode 100644 public/javascripts/wechat/react-dom.js create mode 100644 public/javascripts/wechat/react.js create mode 100644 public/javascripts/wechat/react.min.js create mode 100644 public/javascripts/wechat/wechat.jsx create mode 100644 public/stylesheets/weui/weixin.css diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index a59b01776..91cae64ef 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -7,6 +7,8 @@ module Mobile require_relative 'apis/upgrade' require_relative 'apis/homeworks' require_relative 'apis/comments' + require_relative 'apis/issues' + class API < Grape::API version 'v1', using: :path format :json @@ -39,6 +41,7 @@ module Mobile mount Apis::Upgrade mount Apis::Homeworks mount Apis::Comments + mount Apis::Issues #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb new file mode 100644 index 000000000..212a505e7 --- /dev/null +++ b/app/api/mobile/apis/issues.rb @@ -0,0 +1,17 @@ +#coding=utf-8 + +module Mobile + module Apis + class Issues< Grape::API + resources :issues do + + desc "get special issuse" + get ':id' do + issue = Issue.find(params[:id]) + present :data, issue, with: Mobile::Entities::Issue + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb new file mode 100644 index 000000000..08edae5e2 --- /dev/null +++ b/app/api/mobile/entities/issue.rb @@ -0,0 +1,9 @@ +module Mobile + module Entities + class Issue + + +
+ ); + } +}); + +var CommentList = React.createClass({ + render: function(){ + + var commentNodes = this.props.data.map(function(comment){ + return ( + + {comment.text} + + ) + }); + + return ( +
+ {commentNodes} +
+ ); + } +}); + +var CommentForm = React.createClass({ + handleSubmit: function(e){ + e.preventDefault(); + + var author = this.refs.author.value.trim(); + var text = this.refs.text.value.trim(); + if(!text || !author){ + return; + } + + this.props.onCommentSubmit({author: author, text: text}); + + this.refs.author.value = ''; + this.refs.text.value = ''; + return; + }, + render: function(){ + return ( +
+ + + +
+ ); + } +}); + + +var Comment = React.createClass({ + + rawMarkup: function() { + var rawMarkup = marked(this.props.children.toString(), {sanitize: true}); + return { __html: rawMarkup }; + }, + + render: function(){ + return ( +
+

+ {this.props.author} +

+ +
+ ) + } +}) + +React.render(, document.getElementById("example")); \ No newline at end of file diff --git a/public/javascripts/wechat/JSXTransformer.js b/public/javascripts/wechat/JSXTransformer.js new file mode 100644 index 000000000..63608d408 --- /dev/null +++ b/public/javascripts/wechat/JSXTransformer.js @@ -0,0 +1,15924 @@ +/** + * JSXTransformer v0.13.0 + */ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JSXTransformer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o + * @license MIT + */ + +var base64 = _dereq_('base64-js') +var ieee754 = _dereq_('ieee754') +var isArray = _dereq_('is-array') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 +Buffer.poolSize = 8192 // not used by this implementation + +var kMaxLength = 0x3fffffff +var rootParent = {} + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Note: + * + * - Implementation must support adding new properties to `Uint8Array` instances. + * Firefox 4-29 lacked support, fixed in Firefox 30+. + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + * + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will + * get the Object implementation, which is slower but will work correctly. + */ +Buffer.TYPED_ARRAY_SUPPORT = (function () { + try { + var buf = new ArrayBuffer(0) + var arr = new Uint8Array(buf) + arr.foo = function () { return 42 } + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } +})() + +/** + * Class: Buffer + * ============= + * + * The Buffer constructor returns instances of `Uint8Array` that are augmented + * with function properties for all the node `Buffer` API functions. We use + * `Uint8Array` so that square bracket notation works as expected -- it returns + * a single octet. + * + * By augmenting the instances, we can avoid modifying the `Uint8Array` + * prototype. + */ +function Buffer (subject, encoding, noZero) { + if (!(this instanceof Buffer)) return new Buffer(subject, encoding, noZero) + + var type = typeof subject + var length + + if (type === 'number') { + length = +subject + } else if (type === 'string') { + length = Buffer.byteLength(subject, encoding) + } else if (type === 'object' && subject !== null) { + // assume object is array-like + if (subject.type === 'Buffer' && isArray(subject.data)) subject = subject.data + length = +subject.length + } else { + throw new TypeError('must start with number, buffer, array or string') + } + + if (length > kMaxLength) { + throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x' + + kMaxLength.toString(16) + ' bytes') + } + + if (length < 0) length = 0 + else length >>>= 0 // coerce to uint32 + + var self = this + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Preferred: Return an augmented `Uint8Array` instance for best performance + /*eslint-disable consistent-this */ + self = Buffer._augment(new Uint8Array(length)) + /*eslint-enable consistent-this */ + } else { + // Fallback: Return THIS instance of Buffer (created by `new`) + self.length = length + self._isBuffer = true + } + + var i + if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') { + // Speed optimization -- use set if we're copying from a typed array + self._set(subject) + } else if (isArrayish(subject)) { + // Treat array-ish objects as a byte array + if (Buffer.isBuffer(subject)) { + for (i = 0; i < length; i++) { + self[i] = subject.readUInt8(i) + } + } else { + for (i = 0; i < length; i++) { + self[i] = ((subject[i] % 256) + 256) % 256 + } + } + } else if (type === 'string') { + self.write(subject, 0, encoding) + } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) { + for (i = 0; i < length; i++) { + self[i] = 0 + } + } + + if (length > 0 && length <= Buffer.poolSize) self.parent = rootParent + + return self +} + +function SlowBuffer (subject, encoding, noZero) { + if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding, noZero) + + var buf = new Buffer(subject, encoding, noZero) + delete buf.parent + return buf +} + +Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {} + if (i !== len) { + x = a[i] + y = b[i] + } + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'binary': + case 'base64': + case 'raw': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, totalLength) { + if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])') + + if (list.length === 0) { + return new Buffer(0) + } else if (list.length === 1) { + return list[0] + } + + var i + if (totalLength === undefined) { + totalLength = 0 + for (i = 0; i < list.length; i++) { + totalLength += list[i].length + } + } + + var buf = new Buffer(totalLength) + var pos = 0 + for (i = 0; i < list.length; i++) { + var item = list[i] + item.copy(buf, pos) + pos += item.length + } + return buf +} + +Buffer.byteLength = function byteLength (str, encoding) { + var ret + str = str + '' + switch (encoding || 'utf8') { + case 'ascii': + case 'binary': + case 'raw': + ret = str.length + break + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + ret = str.length * 2 + break + case 'hex': + ret = str.length >>> 1 + break + case 'utf8': + case 'utf-8': + ret = utf8ToBytes(str).length + break + case 'base64': + ret = base64ToBytes(str).length + break + default: + ret = str.length + } + return ret +} + +// pre-set for values that may exist in the future +Buffer.prototype.length = undefined +Buffer.prototype.parent = undefined + +// toString(encoding, start=0, end=buffer.length) +Buffer.prototype.toString = function toString (encoding, start, end) { + var loweredCase = false + + start = start >>> 0 + end = end === undefined || end === Infinity ? this.length : end >>> 0 + + if (!encoding) encoding = 'utf8' + if (start < 0) start = 0 + if (end > this.length) end = this.length + if (end <= start) return '' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'binary': + return binarySlice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return 0 + return Buffer.compare(this, b) +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset) { + if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff + else if (byteOffset < -0x80000000) byteOffset = -0x80000000 + byteOffset >>= 0 + + if (this.length === 0) return -1 + if (byteOffset >= this.length) return -1 + + // Negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) + + if (typeof val === 'string') { + if (val.length === 0) return -1 // special case: looking for empty string always fails + return String.prototype.indexOf.call(this, val, byteOffset) + } + if (Buffer.isBuffer(val)) { + return arrayIndexOf(this, val, byteOffset) + } + if (typeof val === 'number') { + if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { + return Uint8Array.prototype.indexOf.call(this, val, byteOffset) + } + return arrayIndexOf(this, [ val ], byteOffset) + } + + function arrayIndexOf (arr, val, byteOffset) { + var foundIndex = -1 + for (var i = 0; byteOffset + i < arr.length; i++) { + if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex + } else { + foundIndex = -1 + } + } + return -1 + } + + throw new TypeError('val must be string, number or Buffer') +} + +// `get` will be removed in Node 0.13+ +Buffer.prototype.get = function get (offset) { + console.log('.get() is deprecated. Access using array indexes instead.') + return this.readUInt8(offset) +} + +// `set` will be removed in Node 0.13+ +Buffer.prototype.set = function set (v, offset) { + console.log('.set() is deprecated. Access using array indexes instead.') + return this.writeUInt8(v, offset) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new Error('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; i++) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) throw new Error('Invalid hex string') + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) + return charsWritten +} + +function asciiWrite (buf, string, offset, length) { + var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length) + return charsWritten +} + +function binaryWrite (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length) + return charsWritten +} + +function utf16leWrite (buf, string, offset, length) { + var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) + return charsWritten +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Support both (string, offset, length, encoding) + // and the legacy (string, encoding, offset, length) + if (isFinite(offset)) { + if (!isFinite(length)) { + encoding = length + length = undefined + } + } else { // legacy + var swap = encoding + encoding = offset + offset = length + length = swap + } + + offset = Number(offset) || 0 + + if (length < 0 || offset < 0 || offset > this.length) { + throw new RangeError('attempt to write outside buffer bounds') + } + + var remaining = this.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + encoding = String(encoding || 'utf8').toLowerCase() + + var ret + switch (encoding) { + case 'hex': + ret = hexWrite(this, string, offset, length) + break + case 'utf8': + case 'utf-8': + ret = utf8Write(this, string, offset, length) + break + case 'ascii': + ret = asciiWrite(this, string, offset, length) + break + case 'binary': + ret = binaryWrite(this, string, offset, length) + break + case 'base64': + ret = base64Write(this, string, offset, length) + break + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + ret = utf16leWrite(this, string, offset, length) + break + default: + throw new TypeError('Unknown encoding: ' + encoding) + } + return ret +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + var res = '' + var tmp = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + if (buf[i] <= 0x7F) { + res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) + tmp = '' + } else { + tmp += '%' + buf[i].toString(16) + } + } + + return res + decodeUtf8Char(tmp) +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function binarySlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; i++) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = Buffer._augment(this.subarray(start, end)) + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined, true) + for (var i = 0; i < sliceLen; i++) { + newBuf[i] = this[i + start] + } + } + + if (newBuf.length) newBuf.parent = this.parent || this + + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) >>> 0 & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) >>> 0 & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = value + return offset + 1 +} + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = value + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = value + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = value + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkInt( + this, value, offset, byteLength, + Math.pow(2, 8 * byteLength - 1) - 1, + -Math.pow(2, 8 * byteLength - 1) + ) + } + + var i = 0 + var mul = 1 + var sub = value < 0 ? 1 : 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkInt( + this, value, offset, byteLength, + Math.pow(2, 8 * byteLength - 1) - 1, + -Math.pow(2, 8 * byteLength - 1) + ) + } + + var i = byteLength - 1 + var mul = 1 + var sub = value < 0 ? 1 : 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = value + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = value + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = value + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') + if (offset < 0) throw new RangeError('index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, target_start, start, end) { + var self = this // source + + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (target_start >= target.length) target_start = target.length + if (!target_start) target_start = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || self.length === 0) return 0 + + // Fatal error conditions + if (target_start < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= self.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - target_start < end - start) { + end = target.length - target_start + start + } + + var len = end - start + + if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < len; i++) { + target[i + target_start] = this[i + start] + } + } else { + target._set(this.subarray(start, start + len), target_start) + } + + return len +} + +// fill(value, start=0, end=buffer.length) +Buffer.prototype.fill = function fill (value, start, end) { + if (!value) value = 0 + if (!start) start = 0 + if (!end) end = this.length + + if (end < start) throw new RangeError('end < start') + + // Fill 0 bytes; we're done + if (end === start) return + if (this.length === 0) return + + if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') + if (end < 0 || end > this.length) throw new RangeError('end out of bounds') + + var i + if (typeof value === 'number') { + for (i = start; i < end; i++) { + this[i] = value + } + } else { + var bytes = utf8ToBytes(value.toString()) + var len = bytes.length + for (i = start; i < end; i++) { + this[i] = bytes[i % len] + } + } + + return this +} + +/** + * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. + * Added in Node 0.12. Only available in browsers that support ArrayBuffer. + */ +Buffer.prototype.toArrayBuffer = function toArrayBuffer () { + if (typeof Uint8Array !== 'undefined') { + if (Buffer.TYPED_ARRAY_SUPPORT) { + return (new Buffer(this)).buffer + } else { + var buf = new Uint8Array(this.length) + for (var i = 0, len = buf.length; i < len; i += 1) { + buf[i] = this[i] + } + return buf.buffer + } + } else { + throw new TypeError('Buffer.toArrayBuffer not supported in this browser') + } +} + +// HELPER FUNCTIONS +// ================ + +var BP = Buffer.prototype + +/** + * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods + */ +Buffer._augment = function _augment (arr) { + arr.constructor = Buffer + arr._isBuffer = true + + // save reference to original Uint8Array get/set methods before overwriting + arr._get = arr.get + arr._set = arr.set + + // deprecated, will be removed in node 0.13+ + arr.get = BP.get + arr.set = BP.set + + arr.write = BP.write + arr.toString = BP.toString + arr.toLocaleString = BP.toString + arr.toJSON = BP.toJSON + arr.equals = BP.equals + arr.compare = BP.compare + arr.indexOf = BP.indexOf + arr.copy = BP.copy + arr.slice = BP.slice + arr.readUIntLE = BP.readUIntLE + arr.readUIntBE = BP.readUIntBE + arr.readUInt8 = BP.readUInt8 + arr.readUInt16LE = BP.readUInt16LE + arr.readUInt16BE = BP.readUInt16BE + arr.readUInt32LE = BP.readUInt32LE + arr.readUInt32BE = BP.readUInt32BE + arr.readIntLE = BP.readIntLE + arr.readIntBE = BP.readIntBE + arr.readInt8 = BP.readInt8 + arr.readInt16LE = BP.readInt16LE + arr.readInt16BE = BP.readInt16BE + arr.readInt32LE = BP.readInt32LE + arr.readInt32BE = BP.readInt32BE + arr.readFloatLE = BP.readFloatLE + arr.readFloatBE = BP.readFloatBE + arr.readDoubleLE = BP.readDoubleLE + arr.readDoubleBE = BP.readDoubleBE + arr.writeUInt8 = BP.writeUInt8 + arr.writeUIntLE = BP.writeUIntLE + arr.writeUIntBE = BP.writeUIntBE + arr.writeUInt16LE = BP.writeUInt16LE + arr.writeUInt16BE = BP.writeUInt16BE + arr.writeUInt32LE = BP.writeUInt32LE + arr.writeUInt32BE = BP.writeUInt32BE + arr.writeIntLE = BP.writeIntLE + arr.writeIntBE = BP.writeIntBE + arr.writeInt8 = BP.writeInt8 + arr.writeInt16LE = BP.writeInt16LE + arr.writeInt16BE = BP.writeInt16BE + arr.writeInt32LE = BP.writeInt32LE + arr.writeInt32BE = BP.writeInt32BE + arr.writeFloatLE = BP.writeFloatLE + arr.writeFloatBE = BP.writeFloatBE + arr.writeDoubleLE = BP.writeDoubleLE + arr.writeDoubleBE = BP.writeDoubleBE + arr.fill = BP.fill + arr.inspect = BP.inspect + arr.toArrayBuffer = BP.toArrayBuffer + + return arr +} + +var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function isArrayish (subject) { + return isArray(subject) || Buffer.isBuffer(subject) || + subject && typeof subject === 'object' && + typeof subject.length === 'number' +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + var i = 0 + + for (; i < length; i++) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (leadSurrogate) { + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } else { + // valid surrogate pair + codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 + leadSurrogate = null + } + } else { + // no lead yet + + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else { + // valid lead + leadSurrogate = codePoint + continue + } + } + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = null + } + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x200000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; i++) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; i++) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; i++) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +function decodeUtf8Char (str) { + try { + return decodeURIComponent(str) + } catch (err) { + return String.fromCharCode(0xFFFD) // UTF 8 invalid char + } +} + +},{"base64-js":4,"ieee754":5,"is-array":6}],4:[function(_dereq_,module,exports){ +var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + +;(function (exports) { + 'use strict'; + + var Arr = (typeof Uint8Array !== 'undefined') + ? Uint8Array + : Array + + var PLUS = '+'.charCodeAt(0) + var SLASH = '/'.charCodeAt(0) + var NUMBER = '0'.charCodeAt(0) + var LOWER = 'a'.charCodeAt(0) + var UPPER = 'A'.charCodeAt(0) + var PLUS_URL_SAFE = '-'.charCodeAt(0) + var SLASH_URL_SAFE = '_'.charCodeAt(0) + + function decode (elt) { + var code = elt.charCodeAt(0) + if (code === PLUS || + code === PLUS_URL_SAFE) + return 62 // '+' + if (code === SLASH || + code === SLASH_URL_SAFE) + return 63 // '/' + if (code < NUMBER) + return -1 //no match + if (code < NUMBER + 10) + return code - NUMBER + 26 + 26 + if (code < UPPER + 26) + return code - UPPER + if (code < LOWER + 26) + return code - LOWER + 26 + } + + function b64ToByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + + if (b64.length % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + var len = b64.length + placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 + + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(b64.length * 3 / 4 - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? b64.length - 4 : b64.length + + var L = 0 + + function push (v) { + arr[L++] = v + } + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) + push((tmp & 0xFF0000) >> 16) + push((tmp & 0xFF00) >> 8) + push(tmp & 0xFF) + } + + if (placeHolders === 2) { + tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) + push(tmp & 0xFF) + } else if (placeHolders === 1) { + tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) + push((tmp >> 8) & 0xFF) + push(tmp & 0xFF) + } + + return arr + } + + function uint8ToBase64 (uint8) { + var i, + extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes + output = "", + temp, length + + function encode (num) { + return lookup.charAt(num) + } + + function tripletToBase64 (num) { + return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) + } + + // go through the array every three bytes, we'll deal with trailing stuff later + for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { + temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output += tripletToBase64(temp) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + switch (extraBytes) { + case 1: + temp = uint8[uint8.length - 1] + output += encode(temp >> 2) + output += encode((temp << 4) & 0x3F) + output += '==' + break + case 2: + temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) + output += encode(temp >> 10) + output += encode((temp >> 4) & 0x3F) + output += encode((temp << 2) & 0x3F) + output += '=' + break + } + + return output + } + + exports.toByteArray = b64ToByteArray + exports.fromByteArray = uint8ToBase64 +}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) + +},{}],5:[function(_dereq_,module,exports){ +exports.read = function(buffer, offset, isLE, mLen, nBytes) { + var e, m, + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + nBits = -7, + i = isLE ? (nBytes - 1) : 0, + d = isLE ? -1 : 1, + s = buffer[offset + i]; + + i += d; + + e = s & ((1 << (-nBits)) - 1); + s >>= (-nBits); + nBits += eLen; + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); + + m = e & ((1 << (-nBits)) - 1); + e >>= (-nBits); + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity); + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen); +}; + +exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c, + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), + i = isLE ? 0 : (nBytes - 1), + d = isLE ? 1 : -1, + s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); + + buffer[offset + i - d] |= s * 128; +}; + +},{}],6:[function(_dereq_,module,exports){ + +/** + * isArray + */ + +var isArray = Array.isArray; + +/** + * toString + */ + +var str = Object.prototype.toString; + +/** + * Whether or not the given `val` + * is an array. + * + * example: + * + * isArray([]); + * // > true + * isArray(arguments); + * // > false + * isArray(''); + * // > false + * + * @param {mixed} val + * @return {bool} + */ + +module.exports = isArray || function (val) { + return !! val && '[object Array]' == str.call(val); +}; + +},{}],7:[function(_dereq_,module,exports){ +(function (process){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// resolves . and .. elements in a path array with directory names there +// must be no slashes, empty elements, or device names (c:\) in the array +// (so also no leading and trailing slashes - it does not distinguish +// relative and absolute paths) +function normalizeArray(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = parts.length - 1; i >= 0; i--) { + var last = parts[i]; + if (last === '.') { + parts.splice(i, 1); + } else if (last === '..') { + parts.splice(i, 1); + up++; + } else if (up) { + parts.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + for (; up--; up) { + parts.unshift('..'); + } + } + + return parts; +} + +// Split a filename into [root, dir, basename, ext], unix version +// 'root' is just a slash, or nothing. +var splitPathRe = + /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; +var splitPath = function(filename) { + return splitPathRe.exec(filename).slice(1); +}; + +// path.resolve([from ...], to) +// posix version +exports.resolve = function() { + var resolvedPath = '', + resolvedAbsolute = false; + + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path = (i >= 0) ? arguments[i] : process.cwd(); + + // Skip empty and invalid entries + if (typeof path !== 'string') { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if (!path) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.charAt(0) === '/'; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { + return !!p; + }), !resolvedAbsolute).join('/'); + + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; +}; + +// path.normalize(path) +// posix version +exports.normalize = function(path) { + var isAbsolute = exports.isAbsolute(path), + trailingSlash = substr(path, -1) === '/'; + + // Normalize the path + path = normalizeArray(filter(path.split('/'), function(p) { + return !!p; + }), !isAbsolute).join('/'); + + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + + return (isAbsolute ? '/' : '') + path; +}; + +// posix version +exports.isAbsolute = function(path) { + return path.charAt(0) === '/'; +}; + +// posix version +exports.join = function() { + var paths = Array.prototype.slice.call(arguments, 0); + return exports.normalize(filter(paths, function(p, index) { + if (typeof p !== 'string') { + throw new TypeError('Arguments to path.join must be strings'); + } + return p; + }).join('/')); +}; + + +// path.relative(from, to) +// posix version +exports.relative = function(from, to) { + from = exports.resolve(from).substr(1); + to = exports.resolve(to).substr(1); + + function trim(arr) { + var start = 0; + for (; start < arr.length; start++) { + if (arr[start] !== '') break; + } + + var end = arr.length - 1; + for (; end >= 0; end--) { + if (arr[end] !== '') break; + } + + if (start > end) return []; + return arr.slice(start, end - start + 1); + } + + var fromParts = trim(from.split('/')); + var toParts = trim(to.split('/')); + + var length = Math.min(fromParts.length, toParts.length); + var samePartsLength = length; + for (var i = 0; i < length; i++) { + if (fromParts[i] !== toParts[i]) { + samePartsLength = i; + break; + } + } + + var outputParts = []; + for (var i = samePartsLength; i < fromParts.length; i++) { + outputParts.push('..'); + } + + outputParts = outputParts.concat(toParts.slice(samePartsLength)); + + return outputParts.join('/'); +}; + +exports.sep = '/'; +exports.delimiter = ':'; + +exports.dirname = function(path) { + var result = splitPath(path), + root = result[0], + dir = result[1]; + + if (!root && !dir) { + // No dirname whatsoever + return '.'; + } + + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1); + } + + return root + dir; +}; + + +exports.basename = function(path, ext) { + var f = splitPath(path)[2]; + // TODO: make this comparison case-insensitive on windows? + if (ext && f.substr(-1 * ext.length) === ext) { + f = f.substr(0, f.length - ext.length); + } + return f; +}; + + +exports.extname = function(path) { + return splitPath(path)[3]; +}; + +function filter (xs, f) { + if (xs.filter) return xs.filter(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + if (f(xs[i], i, xs)) res.push(xs[i]); + } + return res; +} + +// String.prototype.substr - negative index don't work in IE8 +var substr = 'ab'.substr(-1) === 'b' + ? function (str, start, len) { return str.substr(start, len) } + : function (str, start, len) { + if (start < 0) start = str.length + start; + return str.substr(start, len); + } +; + +}).call(this,_dereq_('_process')) +},{"_process":8}],8:[function(_dereq_,module,exports){ +// shim for using process in browser + +var process = module.exports = {}; +var queue = []; +var draining = false; + +function drainQueue() { + if (draining) { + return; + } + draining = true; + var currentQueue; + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + var i = -1; + while (++i < len) { + currentQueue[i](); + } + len = queue.length; + } + draining = false; +} +process.nextTick = function (fun) { + queue.push(fun); + if (!draining) { + setTimeout(drainQueue, 0); + } +}; + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +// TODO(shtylman) +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],9:[function(_dereq_,module,exports){ +/* + Copyright (C) 2013 Ariya Hidayat + Copyright (C) 2013 Thaddee Tyl + Copyright (C) 2012 Ariya Hidayat + Copyright (C) 2012 Mathias Bynens + Copyright (C) 2012 Joost-Wim Boekesteijn + Copyright (C) 2012 Kris Kowal + Copyright (C) 2012 Yusuke Suzuki + Copyright (C) 2012 Arpad Borsos + Copyright (C) 2011 Ariya Hidayat + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +(function (root, factory) { + 'use strict'; + + // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, + // Rhino, and plain browser loading. + + /* istanbul ignore next */ + if (typeof define === 'function' && define.amd) { + define(['exports'], factory); + } else if (typeof exports !== 'undefined') { + factory(exports); + } else { + factory((root.esprima = {})); + } +}(this, function (exports) { + 'use strict'; + + var Token, + TokenName, + FnExprTokens, + Syntax, + PropertyKind, + Messages, + Regex, + SyntaxTreeDelegate, + XHTMLEntities, + ClassPropertyType, + source, + strict, + index, + lineNumber, + lineStart, + length, + delegate, + lookahead, + state, + extra; + + Token = { + BooleanLiteral: 1, + EOF: 2, + Identifier: 3, + Keyword: 4, + NullLiteral: 5, + NumericLiteral: 6, + Punctuator: 7, + StringLiteral: 8, + RegularExpression: 9, + Template: 10, + JSXIdentifier: 11, + JSXText: 12 + }; + + TokenName = {}; + TokenName[Token.BooleanLiteral] = 'Boolean'; + TokenName[Token.EOF] = ''; + TokenName[Token.Identifier] = 'Identifier'; + TokenName[Token.Keyword] = 'Keyword'; + TokenName[Token.NullLiteral] = 'Null'; + TokenName[Token.NumericLiteral] = 'Numeric'; + TokenName[Token.Punctuator] = 'Punctuator'; + TokenName[Token.StringLiteral] = 'String'; + TokenName[Token.JSXIdentifier] = 'JSXIdentifier'; + TokenName[Token.JSXText] = 'JSXText'; + TokenName[Token.RegularExpression] = 'RegularExpression'; + + // A function following one of those tokens is an expression. + FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', + 'return', 'case', 'delete', 'throw', 'void', + // assignment operators + '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', + '&=', '|=', '^=', ',', + // binary/unary operators + '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&', + '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', + '<=', '<', '>', '!=', '!==']; + + Syntax = { + AnyTypeAnnotation: 'AnyTypeAnnotation', + ArrayExpression: 'ArrayExpression', + ArrayPattern: 'ArrayPattern', + ArrayTypeAnnotation: 'ArrayTypeAnnotation', + ArrowFunctionExpression: 'ArrowFunctionExpression', + AssignmentExpression: 'AssignmentExpression', + BinaryExpression: 'BinaryExpression', + BlockStatement: 'BlockStatement', + BooleanTypeAnnotation: 'BooleanTypeAnnotation', + BreakStatement: 'BreakStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ClassBody: 'ClassBody', + ClassDeclaration: 'ClassDeclaration', + ClassExpression: 'ClassExpression', + ClassImplements: 'ClassImplements', + ClassProperty: 'ClassProperty', + ComprehensionBlock: 'ComprehensionBlock', + ComprehensionExpression: 'ComprehensionExpression', + ConditionalExpression: 'ConditionalExpression', + ContinueStatement: 'ContinueStatement', + DebuggerStatement: 'DebuggerStatement', + DeclareClass: 'DeclareClass', + DeclareFunction: 'DeclareFunction', + DeclareModule: 'DeclareModule', + DeclareVariable: 'DeclareVariable', + DoWhileStatement: 'DoWhileStatement', + EmptyStatement: 'EmptyStatement', + ExportDeclaration: 'ExportDeclaration', + ExportBatchSpecifier: 'ExportBatchSpecifier', + ExportSpecifier: 'ExportSpecifier', + ExpressionStatement: 'ExpressionStatement', + ForInStatement: 'ForInStatement', + ForOfStatement: 'ForOfStatement', + ForStatement: 'ForStatement', + FunctionDeclaration: 'FunctionDeclaration', + FunctionExpression: 'FunctionExpression', + FunctionTypeAnnotation: 'FunctionTypeAnnotation', + FunctionTypeParam: 'FunctionTypeParam', + GenericTypeAnnotation: 'GenericTypeAnnotation', + Identifier: 'Identifier', + IfStatement: 'IfStatement', + ImportDeclaration: 'ImportDeclaration', + ImportDefaultSpecifier: 'ImportDefaultSpecifier', + ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', + ImportSpecifier: 'ImportSpecifier', + InterfaceDeclaration: 'InterfaceDeclaration', + InterfaceExtends: 'InterfaceExtends', + IntersectionTypeAnnotation: 'IntersectionTypeAnnotation', + LabeledStatement: 'LabeledStatement', + Literal: 'Literal', + LogicalExpression: 'LogicalExpression', + MemberExpression: 'MemberExpression', + MethodDefinition: 'MethodDefinition', + ModuleSpecifier: 'ModuleSpecifier', + NewExpression: 'NewExpression', + NullableTypeAnnotation: 'NullableTypeAnnotation', + NumberTypeAnnotation: 'NumberTypeAnnotation', + ObjectExpression: 'ObjectExpression', + ObjectPattern: 'ObjectPattern', + ObjectTypeAnnotation: 'ObjectTypeAnnotation', + ObjectTypeCallProperty: 'ObjectTypeCallProperty', + ObjectTypeIndexer: 'ObjectTypeIndexer', + ObjectTypeProperty: 'ObjectTypeProperty', + Program: 'Program', + Property: 'Property', + QualifiedTypeIdentifier: 'QualifiedTypeIdentifier', + ReturnStatement: 'ReturnStatement', + SequenceExpression: 'SequenceExpression', + SpreadElement: 'SpreadElement', + SpreadProperty: 'SpreadProperty', + StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation', + StringTypeAnnotation: 'StringTypeAnnotation', + SwitchCase: 'SwitchCase', + SwitchStatement: 'SwitchStatement', + TaggedTemplateExpression: 'TaggedTemplateExpression', + TemplateElement: 'TemplateElement', + TemplateLiteral: 'TemplateLiteral', + ThisExpression: 'ThisExpression', + ThrowStatement: 'ThrowStatement', + TupleTypeAnnotation: 'TupleTypeAnnotation', + TryStatement: 'TryStatement', + TypeAlias: 'TypeAlias', + TypeAnnotation: 'TypeAnnotation', + TypeCastExpression: 'TypeCastExpression', + TypeofTypeAnnotation: 'TypeofTypeAnnotation', + TypeParameterDeclaration: 'TypeParameterDeclaration', + TypeParameterInstantiation: 'TypeParameterInstantiation', + UnaryExpression: 'UnaryExpression', + UnionTypeAnnotation: 'UnionTypeAnnotation', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + VoidTypeAnnotation: 'VoidTypeAnnotation', + WhileStatement: 'WhileStatement', + WithStatement: 'WithStatement', + JSXIdentifier: 'JSXIdentifier', + JSXNamespacedName: 'JSXNamespacedName', + JSXMemberExpression: 'JSXMemberExpression', + JSXEmptyExpression: 'JSXEmptyExpression', + JSXExpressionContainer: 'JSXExpressionContainer', + JSXElement: 'JSXElement', + JSXClosingElement: 'JSXClosingElement', + JSXOpeningElement: 'JSXOpeningElement', + JSXAttribute: 'JSXAttribute', + JSXSpreadAttribute: 'JSXSpreadAttribute', + JSXText: 'JSXText', + YieldExpression: 'YieldExpression', + AwaitExpression: 'AwaitExpression' + }; + + PropertyKind = { + Data: 1, + Get: 2, + Set: 4 + }; + + ClassPropertyType = { + 'static': 'static', + prototype: 'prototype' + }; + + // Error messages should be identical to V8. + Messages = { + UnexpectedToken: 'Unexpected token %0', + UnexpectedNumber: 'Unexpected number', + UnexpectedString: 'Unexpected string', + UnexpectedIdentifier: 'Unexpected identifier', + UnexpectedReserved: 'Unexpected reserved word', + UnexpectedTemplate: 'Unexpected quasi %0', + UnexpectedEOS: 'Unexpected end of input', + NewlineAfterThrow: 'Illegal newline after throw', + InvalidRegExp: 'Invalid regular expression', + UnterminatedRegExp: 'Invalid regular expression: missing /', + InvalidLHSInAssignment: 'Invalid left-hand side in assignment', + InvalidLHSInFormalsList: 'Invalid left-hand side in formals list', + InvalidLHSInForIn: 'Invalid left-hand side in for-in', + MultipleDefaultsInSwitch: 'More than one default clause in switch statement', + NoCatchOrFinally: 'Missing catch or finally after try', + UnknownLabel: 'Undefined label \'%0\'', + Redeclaration: '%0 \'%1\' has already been declared', + IllegalContinue: 'Illegal continue statement', + IllegalBreak: 'Illegal break statement', + IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition', + IllegalClassConstructorProperty: 'Illegal constructor property in class definition', + IllegalReturn: 'Illegal return statement', + IllegalSpread: 'Illegal spread element', + StrictModeWith: 'Strict mode code may not include a with statement', + StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', + StrictVarName: 'Variable name may not be eval or arguments in strict mode', + StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', + StrictParamDupe: 'Strict mode function may not have duplicate parameter names', + ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list', + DefaultRestParameter: 'Rest parameter can not have a default value', + ElementAfterSpreadElement: 'Spread must be the final element of an element list', + PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal', + ObjectPatternAsRestParameter: 'Invalid rest parameter', + ObjectPatternAsSpread: 'Invalid spread argument', + StrictFunctionName: 'Function name may not be eval or arguments in strict mode', + StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', + StrictDelete: 'Delete of an unqualified identifier in strict mode.', + StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode', + AccessorDataProperty: 'Object literal may not have data and accessor property with the same name', + AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name', + StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', + StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', + StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', + StrictReservedWord: 'Use of future reserved word in strict mode', + MissingFromClause: 'Missing from clause', + NoAsAfterImportNamespace: 'Missing as after import *', + InvalidModuleSpecifier: 'Invalid module specifier', + IllegalImportDeclaration: 'Illegal import declaration', + IllegalExportDeclaration: 'Illegal export declaration', + NoUninitializedConst: 'Const must be initialized', + ComprehensionRequiresBlock: 'Comprehension must have at least one block', + ComprehensionError: 'Comprehension Error', + EachNotAllowed: 'Each is not supported', + InvalidJSXAttributeValue: 'JSX value should be either an expression or a quoted JSX text', + ExpectedJSXClosingTag: 'Expected corresponding JSX closing tag for %0', + AdjacentJSXElements: 'Adjacent JSX elements must be wrapped in an enclosing tag', + ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' + + 'you are trying to write a function type, but you ended up ' + + 'writing a grouped type followed by an =>, which is a syntax ' + + 'error. Remember, function type parameters are named so function ' + + 'types look like (name1: type1, name2: type2) => returnType. You ' + + 'probably wrote (type1) => returnType' + }; + + // See also tools/generate-unicode-regex.py. + Regex = { + NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'), + NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'), + LeadingZeros: new RegExp('^0+(?!$)') + }; + + // Ensure the condition is true, otherwise throw an error. + // This is only to have a better contract semantic, i.e. another safety net + // to catch a logic error. The condition shall be fulfilled in normal case. + // Do NOT use this to enforce a certain condition on any user input. + + function assert(condition, message) { + /* istanbul ignore if */ + if (!condition) { + throw new Error('ASSERT: ' + message); + } + } + + function StringMap() { + this.$data = {}; + } + + StringMap.prototype.get = function (key) { + key = '$' + key; + return this.$data[key]; + }; + + StringMap.prototype.set = function (key, value) { + key = '$' + key; + this.$data[key] = value; + return this; + }; + + StringMap.prototype.has = function (key) { + key = '$' + key; + return Object.prototype.hasOwnProperty.call(this.$data, key); + }; + + StringMap.prototype["delete"] = function (key) { + key = '$' + key; + return delete this.$data[key]; + }; + + function isDecimalDigit(ch) { + return (ch >= 48 && ch <= 57); // 0..9 + } + + function isHexDigit(ch) { + return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; + } + + function isOctalDigit(ch) { + return '01234567'.indexOf(ch) >= 0; + } + + + // 7.2 White Space + + function isWhiteSpace(ch) { + return (ch === 32) || // space + (ch === 9) || // tab + (ch === 0xB) || + (ch === 0xC) || + (ch === 0xA0) || + (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0); + } + + // 7.3 Line Terminators + + function isLineTerminator(ch) { + return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029); + } + + // 7.6 Identifier Names and Identifiers + + function isIdentifierStart(ch) { + return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) + (ch >= 65 && ch <= 90) || // A..Z + (ch >= 97 && ch <= 122) || // a..z + (ch === 92) || // \ (backslash) + ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); + } + + function isIdentifierPart(ch) { + return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) + (ch >= 65 && ch <= 90) || // A..Z + (ch >= 97 && ch <= 122) || // a..z + (ch >= 48 && ch <= 57) || // 0..9 + (ch === 92) || // \ (backslash) + ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); + } + + // 7.6.1.2 Future Reserved Words + + function isFutureReservedWord(id) { + switch (id) { + case 'class': + case 'enum': + case 'export': + case 'extends': + case 'import': + case 'super': + return true; + default: + return false; + } + } + + function isStrictModeReservedWord(id) { + switch (id) { + case 'implements': + case 'interface': + case 'package': + case 'private': + case 'protected': + case 'public': + case 'static': + case 'yield': + case 'let': + return true; + default: + return false; + } + } + + function isRestrictedWord(id) { + return id === 'eval' || id === 'arguments'; + } + + // 7.6.1.1 Keywords + + function isKeyword(id) { + if (strict && isStrictModeReservedWord(id)) { + return true; + } + + // 'const' is specialized as Keyword in V8. + // 'yield' is only treated as a keyword in strict mode. + // 'let' is for compatiblity with SpiderMonkey and ES.next. + // Some others are from future reserved words. + + switch (id.length) { + case 2: + return (id === 'if') || (id === 'in') || (id === 'do'); + case 3: + return (id === 'var') || (id === 'for') || (id === 'new') || + (id === 'try') || (id === 'let'); + case 4: + return (id === 'this') || (id === 'else') || (id === 'case') || + (id === 'void') || (id === 'with') || (id === 'enum'); + case 5: + return (id === 'while') || (id === 'break') || (id === 'catch') || + (id === 'throw') || (id === 'const') || + (id === 'class') || (id === 'super'); + case 6: + return (id === 'return') || (id === 'typeof') || (id === 'delete') || + (id === 'switch') || (id === 'export') || (id === 'import'); + case 7: + return (id === 'default') || (id === 'finally') || (id === 'extends'); + case 8: + return (id === 'function') || (id === 'continue') || (id === 'debugger'); + case 10: + return (id === 'instanceof'); + default: + return false; + } + } + + // 7.4 Comments + + function addComment(type, value, start, end, loc) { + var comment; + assert(typeof start === 'number', 'Comment must have valid position'); + + // Because the way the actual token is scanned, often the comments + // (if any) are skipped twice during the lexical analysis. + // Thus, we need to skip adding a comment if the comment array already + // handled it. + if (state.lastCommentStart >= start) { + return; + } + state.lastCommentStart = start; + + comment = { + type: type, + value: value + }; + if (extra.range) { + comment.range = [start, end]; + } + if (extra.loc) { + comment.loc = loc; + } + extra.comments.push(comment); + if (extra.attachComment) { + extra.leadingComments.push(comment); + extra.trailingComments.push(comment); + } + } + + function skipSingleLineComment() { + var start, loc, ch, comment; + + start = index - 2; + loc = { + start: { + line: lineNumber, + column: index - lineStart - 2 + } + }; + + while (index < length) { + ch = source.charCodeAt(index); + ++index; + if (isLineTerminator(ch)) { + if (extra.comments) { + comment = source.slice(start + 2, index - 1); + loc.end = { + line: lineNumber, + column: index - lineStart - 1 + }; + addComment('Line', comment, start, index - 1, loc); + } + if (ch === 13 && source.charCodeAt(index) === 10) { + ++index; + } + ++lineNumber; + lineStart = index; + return; + } + } + + if (extra.comments) { + comment = source.slice(start + 2, index); + loc.end = { + line: lineNumber, + column: index - lineStart + }; + addComment('Line', comment, start, index, loc); + } + } + + function skipMultiLineComment() { + var start, loc, ch, comment; + + if (extra.comments) { + start = index - 2; + loc = { + start: { + line: lineNumber, + column: index - lineStart - 2 + } + }; + } + + while (index < length) { + ch = source.charCodeAt(index); + if (isLineTerminator(ch)) { + if (ch === 13 && source.charCodeAt(index + 1) === 10) { + ++index; + } + ++lineNumber; + ++index; + lineStart = index; + if (index >= length) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + } else if (ch === 42) { + // Block comment ends with '*/' (char #42, char #47). + if (source.charCodeAt(index + 1) === 47) { + ++index; + ++index; + if (extra.comments) { + comment = source.slice(start + 2, index - 2); + loc.end = { + line: lineNumber, + column: index - lineStart + }; + addComment('Block', comment, start, index, loc); + } + return; + } + ++index; + } else { + ++index; + } + } + + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + function skipComment() { + var ch; + + while (index < length) { + ch = source.charCodeAt(index); + + if (isWhiteSpace(ch)) { + ++index; + } else if (isLineTerminator(ch)) { + ++index; + if (ch === 13 && source.charCodeAt(index) === 10) { + ++index; + } + ++lineNumber; + lineStart = index; + } else if (ch === 47) { // 47 is '/' + ch = source.charCodeAt(index + 1); + if (ch === 47) { + ++index; + ++index; + skipSingleLineComment(); + } else if (ch === 42) { // 42 is '*' + ++index; + ++index; + skipMultiLineComment(); + } else { + break; + } + } else { + break; + } + } + } + + function scanHexEscape(prefix) { + var i, len, ch, code = 0; + + len = (prefix === 'u') ? 4 : 2; + for (i = 0; i < len; ++i) { + if (index < length && isHexDigit(source[index])) { + ch = source[index++]; + code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); + } else { + return ''; + } + } + return String.fromCharCode(code); + } + + function scanUnicodeCodePointEscape() { + var ch, code, cu1, cu2; + + ch = source[index]; + code = 0; + + // At least, one hex digit is required. + if (ch === '}') { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + while (index < length) { + ch = source[index++]; + if (!isHexDigit(ch)) { + break; + } + code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); + } + + if (code > 0x10FFFF || ch !== '}') { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + // UTF-16 Encoding + if (code <= 0xFFFF) { + return String.fromCharCode(code); + } + cu1 = ((code - 0x10000) >> 10) + 0xD800; + cu2 = ((code - 0x10000) & 1023) + 0xDC00; + return String.fromCharCode(cu1, cu2); + } + + function getEscapedIdentifier() { + var ch, id; + + ch = source.charCodeAt(index++); + id = String.fromCharCode(ch); + + // '\u' (char #92, char #117) denotes an escaped character. + if (ch === 92) { + if (source.charCodeAt(index) !== 117) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + ++index; + ch = scanHexEscape('u'); + if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + id = ch; + } + + while (index < length) { + ch = source.charCodeAt(index); + if (!isIdentifierPart(ch)) { + break; + } + ++index; + id += String.fromCharCode(ch); + + // '\u' (char #92, char #117) denotes an escaped character. + if (ch === 92) { + id = id.substr(0, id.length - 1); + if (source.charCodeAt(index) !== 117) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + ++index; + ch = scanHexEscape('u'); + if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + id += ch; + } + } + + return id; + } + + function getIdentifier() { + var start, ch; + + start = index++; + while (index < length) { + ch = source.charCodeAt(index); + if (ch === 92) { + // Blackslash (char #92) marks Unicode escape sequence. + index = start; + return getEscapedIdentifier(); + } + if (isIdentifierPart(ch)) { + ++index; + } else { + break; + } + } + + return source.slice(start, index); + } + + function scanIdentifier() { + var start, id, type; + + start = index; + + // Backslash (char #92) starts an escaped character. + id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier(); + + // There is no keyword or literal with only one character. + // Thus, it must be an identifier. + if (id.length === 1) { + type = Token.Identifier; + } else if (isKeyword(id)) { + type = Token.Keyword; + } else if (id === 'null') { + type = Token.NullLiteral; + } else if (id === 'true' || id === 'false') { + type = Token.BooleanLiteral; + } else { + type = Token.Identifier; + } + + return { + type: type, + value: id, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + + // 7.7 Punctuators + + function scanPunctuator() { + var start = index, + code = source.charCodeAt(index), + code2, + ch1 = source[index], + ch2, + ch3, + ch4; + + if (state.inJSXTag || state.inJSXChild) { + // Don't need to check for '{' and '}' as it's already handled + // correctly by default. + switch (code) { + case 60: // < + case 62: // > + ++index; + return { + type: Token.Punctuator, + value: String.fromCharCode(code), + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + } + + switch (code) { + // Check for most common single-character punctuators. + case 40: // ( open bracket + case 41: // ) close bracket + case 59: // ; semicolon + case 44: // , comma + case 123: // { open curly brace + case 125: // } close curly brace + case 91: // [ + case 93: // ] + case 58: // : + case 63: // ? + case 126: // ~ + ++index; + if (extra.tokenize) { + if (code === 40) { + extra.openParenToken = extra.tokens.length; + } else if (code === 123) { + extra.openCurlyToken = extra.tokens.length; + } + } + return { + type: Token.Punctuator, + value: String.fromCharCode(code), + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + + default: + code2 = source.charCodeAt(index + 1); + + // '=' (char #61) marks an assignment or comparison operator. + if (code2 === 61) { + switch (code) { + case 37: // % + case 38: // & + case 42: // *: + case 43: // + + case 45: // - + case 47: // / + case 60: // < + case 62: // > + case 94: // ^ + case 124: // | + index += 2; + return { + type: Token.Punctuator, + value: String.fromCharCode(code) + String.fromCharCode(code2), + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + + case 33: // ! + case 61: // = + index += 2; + + // !== and === + if (source.charCodeAt(index) === 61) { + ++index; + } + return { + type: Token.Punctuator, + value: source.slice(start, index), + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + default: + break; + } + } + break; + } + + // Peek more characters. + + ch2 = source[index + 1]; + ch3 = source[index + 2]; + ch4 = source[index + 3]; + + // 4-character punctuator: >>>= + + if (ch1 === '>' && ch2 === '>' && ch3 === '>') { + if (ch4 === '=') { + index += 4; + return { + type: Token.Punctuator, + value: '>>>=', + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + } + + // 3-character punctuators: === !== >>> <<= >>= + + if (ch1 === '>' && ch2 === '>' && ch3 === '>' && !state.inType) { + index += 3; + return { + type: Token.Punctuator, + value: '>>>', + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + if (ch1 === '<' && ch2 === '<' && ch3 === '=') { + index += 3; + return { + type: Token.Punctuator, + value: '<<=', + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + if (ch1 === '>' && ch2 === '>' && ch3 === '=') { + index += 3; + return { + type: Token.Punctuator, + value: '>>=', + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + if (ch1 === '.' && ch2 === '.' && ch3 === '.') { + index += 3; + return { + type: Token.Punctuator, + value: '...', + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + // Other 2-character punctuators: ++ -- << >> && || + + // Don't match these tokens if we're in a type, since they never can + // occur and can mess up types like Map> + if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) { + index += 2; + return { + type: Token.Punctuator, + value: ch1 + ch2, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + if (ch1 === '=' && ch2 === '>') { + index += 2; + return { + type: Token.Punctuator, + value: '=>', + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { + ++index; + return { + type: Token.Punctuator, + value: ch1, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + if (ch1 === '.') { + ++index; + return { + type: Token.Punctuator, + value: ch1, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + // 7.8.3 Numeric Literals + + function scanHexLiteral(start) { + var number = ''; + + while (index < length) { + if (!isHexDigit(source[index])) { + break; + } + number += source[index++]; + } + + if (number.length === 0) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + if (isIdentifierStart(source.charCodeAt(index))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + return { + type: Token.NumericLiteral, + value: parseInt('0x' + number, 16), + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + function scanBinaryLiteral(start) { + var ch, number; + + number = ''; + + while (index < length) { + ch = source[index]; + if (ch !== '0' && ch !== '1') { + break; + } + number += source[index++]; + } + + if (number.length === 0) { + // only 0b or 0B + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + if (index < length) { + ch = source.charCodeAt(index); + /* istanbul ignore else */ + if (isIdentifierStart(ch) || isDecimalDigit(ch)) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + } + + return { + type: Token.NumericLiteral, + value: parseInt(number, 2), + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + function scanOctalLiteral(prefix, start) { + var number, octal; + + if (isOctalDigit(prefix)) { + octal = true; + number = '0' + source[index++]; + } else { + octal = false; + ++index; + number = ''; + } + + while (index < length) { + if (!isOctalDigit(source[index])) { + break; + } + number += source[index++]; + } + + if (!octal && number.length === 0) { + // only 0o or 0O + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + return { + type: Token.NumericLiteral, + value: parseInt(number, 8), + octal: octal, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + function scanNumericLiteral() { + var number, start, ch; + + ch = source[index]; + assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), + 'Numeric literal must start with a decimal digit or a decimal point'); + + start = index; + number = ''; + if (ch !== '.') { + number = source[index++]; + ch = source[index]; + + // Hex number starts with '0x'. + // Octal number starts with '0'. + // Octal number in ES6 starts with '0o'. + // Binary number in ES6 starts with '0b'. + if (number === '0') { + if (ch === 'x' || ch === 'X') { + ++index; + return scanHexLiteral(start); + } + if (ch === 'b' || ch === 'B') { + ++index; + return scanBinaryLiteral(start); + } + if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) { + return scanOctalLiteral(ch, start); + } + // decimal number starts with '0' such as '09' is illegal. + if (ch && isDecimalDigit(ch.charCodeAt(0))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + } + + while (isDecimalDigit(source.charCodeAt(index))) { + number += source[index++]; + } + ch = source[index]; + } + + if (ch === '.') { + number += source[index++]; + while (isDecimalDigit(source.charCodeAt(index))) { + number += source[index++]; + } + ch = source[index]; + } + + if (ch === 'e' || ch === 'E') { + number += source[index++]; + + ch = source[index]; + if (ch === '+' || ch === '-') { + number += source[index++]; + } + if (isDecimalDigit(source.charCodeAt(index))) { + while (isDecimalDigit(source.charCodeAt(index))) { + number += source[index++]; + } + } else { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + } + + if (isIdentifierStart(source.charCodeAt(index))) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + return { + type: Token.NumericLiteral, + value: parseFloat(number), + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + // 7.8.4 String Literals + + function scanStringLiteral() { + var str = '', quote, start, ch, code, unescaped, restore, octal = false; + + quote = source[index]; + assert((quote === '\'' || quote === '"'), + 'String literal must starts with a quote'); + + start = index; + ++index; + + while (index < length) { + ch = source[index++]; + + if (ch === quote) { + quote = ''; + break; + } else if (ch === '\\') { + ch = source[index++]; + if (!ch || !isLineTerminator(ch.charCodeAt(0))) { + switch (ch) { + case 'n': + str += '\n'; + break; + case 'r': + str += '\r'; + break; + case 't': + str += '\t'; + break; + case 'u': + case 'x': + if (source[index] === '{') { + ++index; + str += scanUnicodeCodePointEscape(); + } else { + restore = index; + unescaped = scanHexEscape(ch); + if (unescaped) { + str += unescaped; + } else { + index = restore; + str += ch; + } + } + break; + case 'b': + str += '\b'; + break; + case 'f': + str += '\f'; + break; + case 'v': + str += '\x0B'; + break; + + default: + if (isOctalDigit(ch)) { + code = '01234567'.indexOf(ch); + + // \0 is not octal escape sequence + if (code !== 0) { + octal = true; + } + + /* istanbul ignore else */ + if (index < length && isOctalDigit(source[index])) { + octal = true; + code = code * 8 + '01234567'.indexOf(source[index++]); + + // 3 digits are only allowed when string starts + // with 0, 1, 2, 3 + if ('0123'.indexOf(ch) >= 0 && + index < length && + isOctalDigit(source[index])) { + code = code * 8 + '01234567'.indexOf(source[index++]); + } + } + str += String.fromCharCode(code); + } else { + str += ch; + } + break; + } + } else { + ++lineNumber; + if (ch === '\r' && source[index] === '\n') { + ++index; + } + lineStart = index; + } + } else if (isLineTerminator(ch.charCodeAt(0))) { + break; + } else { + str += ch; + } + } + + if (quote !== '') { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + return { + type: Token.StringLiteral, + value: str, + octal: octal, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + function scanTemplate() { + var cooked = '', ch, start, terminated, tail, restore, unescaped, code, octal; + + terminated = false; + tail = false; + start = index; + + ++index; + + while (index < length) { + ch = source[index++]; + if (ch === '`') { + tail = true; + terminated = true; + break; + } else if (ch === '$') { + if (source[index] === '{') { + ++index; + terminated = true; + break; + } + cooked += ch; + } else if (ch === '\\') { + ch = source[index++]; + if (!isLineTerminator(ch.charCodeAt(0))) { + switch (ch) { + case 'n': + cooked += '\n'; + break; + case 'r': + cooked += '\r'; + break; + case 't': + cooked += '\t'; + break; + case 'u': + case 'x': + if (source[index] === '{') { + ++index; + cooked += scanUnicodeCodePointEscape(); + } else { + restore = index; + unescaped = scanHexEscape(ch); + if (unescaped) { + cooked += unescaped; + } else { + index = restore; + cooked += ch; + } + } + break; + case 'b': + cooked += '\b'; + break; + case 'f': + cooked += '\f'; + break; + case 'v': + cooked += '\v'; + break; + + default: + if (isOctalDigit(ch)) { + code = '01234567'.indexOf(ch); + + // \0 is not octal escape sequence + if (code !== 0) { + octal = true; + } + + /* istanbul ignore else */ + if (index < length && isOctalDigit(source[index])) { + octal = true; + code = code * 8 + '01234567'.indexOf(source[index++]); + + // 3 digits are only allowed when string starts + // with 0, 1, 2, 3 + if ('0123'.indexOf(ch) >= 0 && + index < length && + isOctalDigit(source[index])) { + code = code * 8 + '01234567'.indexOf(source[index++]); + } + } + cooked += String.fromCharCode(code); + } else { + cooked += ch; + } + break; + } + } else { + ++lineNumber; + if (ch === '\r' && source[index] === '\n') { + ++index; + } + lineStart = index; + } + } else if (isLineTerminator(ch.charCodeAt(0))) { + ++lineNumber; + if (ch === '\r' && source[index] === '\n') { + ++index; + } + lineStart = index; + cooked += '\n'; + } else { + cooked += ch; + } + } + + if (!terminated) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + return { + type: Token.Template, + value: { + cooked: cooked, + raw: source.slice(start + 1, index - ((tail) ? 1 : 2)) + }, + tail: tail, + octal: octal, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + function scanTemplateElement(option) { + var startsWith, template; + + lookahead = null; + skipComment(); + + startsWith = (option.head) ? '`' : '}'; + + if (source[index] !== startsWith) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + template = scanTemplate(); + + peek(); + + return template; + } + + function testRegExp(pattern, flags) { + var tmp = pattern, + value; + + if (flags.indexOf('u') >= 0) { + // Replace each astral symbol and every Unicode code point + // escape sequence with a single ASCII symbol to avoid throwing on + // regular expressions that are only valid in combination with the + // `/u` flag. + // Note: replacing with the ASCII symbol `x` might cause false + // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a + // perfectly valid pattern that is equivalent to `[a-b]`, but it + // would be replaced by `[x-b]` which throws an error. + tmp = tmp + .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) { + if (parseInt($1, 16) <= 0x10FFFF) { + return 'x'; + } + throwError({}, Messages.InvalidRegExp); + }) + .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x'); + } + + // First, detect invalid regular expressions. + try { + value = new RegExp(tmp); + } catch (e) { + throwError({}, Messages.InvalidRegExp); + } + + // Return a regular expression object for this pattern-flag pair, or + // `null` in case the current environment doesn't support the flags it + // uses. + try { + return new RegExp(pattern, flags); + } catch (exception) { + return null; + } + } + + function scanRegExpBody() { + var ch, str, classMarker, terminated, body; + + ch = source[index]; + assert(ch === '/', 'Regular expression literal must start with a slash'); + str = source[index++]; + + classMarker = false; + terminated = false; + while (index < length) { + ch = source[index++]; + str += ch; + if (ch === '\\') { + ch = source[index++]; + // ECMA-262 7.8.5 + if (isLineTerminator(ch.charCodeAt(0))) { + throwError({}, Messages.UnterminatedRegExp); + } + str += ch; + } else if (isLineTerminator(ch.charCodeAt(0))) { + throwError({}, Messages.UnterminatedRegExp); + } else if (classMarker) { + if (ch === ']') { + classMarker = false; + } + } else { + if (ch === '/') { + terminated = true; + break; + } else if (ch === '[') { + classMarker = true; + } + } + } + + if (!terminated) { + throwError({}, Messages.UnterminatedRegExp); + } + + // Exclude leading and trailing slash. + body = str.substr(1, str.length - 2); + return { + value: body, + literal: str + }; + } + + function scanRegExpFlags() { + var ch, str, flags, restore; + + str = ''; + flags = ''; + while (index < length) { + ch = source[index]; + if (!isIdentifierPart(ch.charCodeAt(0))) { + break; + } + + ++index; + if (ch === '\\' && index < length) { + ch = source[index]; + if (ch === 'u') { + ++index; + restore = index; + ch = scanHexEscape('u'); + if (ch) { + flags += ch; + for (str += '\\u'; restore < index; ++restore) { + str += source[restore]; + } + } else { + index = restore; + flags += 'u'; + str += '\\u'; + } + throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL'); + } else { + str += '\\'; + throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + } else { + flags += ch; + str += ch; + } + } + + return { + value: flags, + literal: str + }; + } + + function scanRegExp() { + var start, body, flags, value; + + lookahead = null; + skipComment(); + start = index; + + body = scanRegExpBody(); + flags = scanRegExpFlags(); + value = testRegExp(body.value, flags.value); + + if (extra.tokenize) { + return { + type: Token.RegularExpression, + value: value, + regex: { + pattern: body.value, + flags: flags.value + }, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + return { + literal: body.literal + flags.literal, + value: value, + regex: { + pattern: body.value, + flags: flags.value + }, + range: [start, index] + }; + } + + function isIdentifierName(token) { + return token.type === Token.Identifier || + token.type === Token.Keyword || + token.type === Token.BooleanLiteral || + token.type === Token.NullLiteral; + } + + function advanceSlash() { + var prevToken, + checkToken; + // Using the following algorithm: + // https://github.com/mozilla/sweet.js/wiki/design + prevToken = extra.tokens[extra.tokens.length - 1]; + if (!prevToken) { + // Nothing before that: it cannot be a division. + return scanRegExp(); + } + if (prevToken.type === 'Punctuator') { + if (prevToken.value === ')') { + checkToken = extra.tokens[extra.openParenToken - 1]; + if (checkToken && + checkToken.type === 'Keyword' && + (checkToken.value === 'if' || + checkToken.value === 'while' || + checkToken.value === 'for' || + checkToken.value === 'with')) { + return scanRegExp(); + } + return scanPunctuator(); + } + if (prevToken.value === '}') { + // Dividing a function by anything makes little sense, + // but we have to check for that. + if (extra.tokens[extra.openCurlyToken - 3] && + extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') { + // Anonymous function. + checkToken = extra.tokens[extra.openCurlyToken - 4]; + if (!checkToken) { + return scanPunctuator(); + } + } else if (extra.tokens[extra.openCurlyToken - 4] && + extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') { + // Named function. + checkToken = extra.tokens[extra.openCurlyToken - 5]; + if (!checkToken) { + return scanRegExp(); + } + } else { + return scanPunctuator(); + } + // checkToken determines whether the function is + // a declaration or an expression. + if (FnExprTokens.indexOf(checkToken.value) >= 0) { + // It is an expression. + return scanPunctuator(); + } + // It is a declaration. + return scanRegExp(); + } + return scanRegExp(); + } + if (prevToken.type === 'Keyword' && prevToken.value !== 'this') { + return scanRegExp(); + } + return scanPunctuator(); + } + + function advance() { + var ch; + + if (!state.inJSXChild) { + skipComment(); + } + + if (index >= length) { + return { + type: Token.EOF, + lineNumber: lineNumber, + lineStart: lineStart, + range: [index, index] + }; + } + + if (state.inJSXChild) { + return advanceJSXChild(); + } + + ch = source.charCodeAt(index); + + // Very common: ( and ) and ; + if (ch === 40 || ch === 41 || ch === 58) { + return scanPunctuator(); + } + + // String literal starts with single quote (#39) or double quote (#34). + if (ch === 39 || ch === 34) { + if (state.inJSXTag) { + return scanJSXStringLiteral(); + } + return scanStringLiteral(); + } + + if (state.inJSXTag && isJSXIdentifierStart(ch)) { + return scanJSXIdentifier(); + } + + if (ch === 96) { + return scanTemplate(); + } + if (isIdentifierStart(ch)) { + return scanIdentifier(); + } + + // Dot (.) char #46 can also start a floating-point number, hence the need + // to check the next character. + if (ch === 46) { + if (isDecimalDigit(source.charCodeAt(index + 1))) { + return scanNumericLiteral(); + } + return scanPunctuator(); + } + + if (isDecimalDigit(ch)) { + return scanNumericLiteral(); + } + + // Slash (/) char #47 can also start a regex. + if (extra.tokenize && ch === 47) { + return advanceSlash(); + } + + return scanPunctuator(); + } + + function lex() { + var token; + + token = lookahead; + index = token.range[1]; + lineNumber = token.lineNumber; + lineStart = token.lineStart; + + lookahead = advance(); + + index = token.range[1]; + lineNumber = token.lineNumber; + lineStart = token.lineStart; + + return token; + } + + function peek() { + var pos, line, start; + + pos = index; + line = lineNumber; + start = lineStart; + lookahead = advance(); + index = pos; + lineNumber = line; + lineStart = start; + } + + function lookahead2() { + var adv, pos, line, start, result; + + // If we are collecting the tokens, don't grab the next one yet. + /* istanbul ignore next */ + adv = (typeof extra.advance === 'function') ? extra.advance : advance; + + pos = index; + line = lineNumber; + start = lineStart; + + // Scan for the next immediate token. + /* istanbul ignore if */ + if (lookahead === null) { + lookahead = adv(); + } + index = lookahead.range[1]; + lineNumber = lookahead.lineNumber; + lineStart = lookahead.lineStart; + + // Grab the token right after. + result = adv(); + index = pos; + lineNumber = line; + lineStart = start; + + return result; + } + + function rewind(token) { + index = token.range[0]; + lineNumber = token.lineNumber; + lineStart = token.lineStart; + lookahead = token; + } + + function markerCreate() { + if (!extra.loc && !extra.range) { + return undefined; + } + skipComment(); + return {offset: index, line: lineNumber, col: index - lineStart}; + } + + function markerCreatePreserveWhitespace() { + if (!extra.loc && !extra.range) { + return undefined; + } + return {offset: index, line: lineNumber, col: index - lineStart}; + } + + function processComment(node) { + var lastChild, + trailingComments, + bottomRight = extra.bottomRightStack, + last = bottomRight[bottomRight.length - 1]; + + if (node.type === Syntax.Program) { + /* istanbul ignore else */ + if (node.body.length > 0) { + return; + } + } + + if (extra.trailingComments.length > 0) { + if (extra.trailingComments[0].range[0] >= node.range[1]) { + trailingComments = extra.trailingComments; + extra.trailingComments = []; + } else { + extra.trailingComments.length = 0; + } + } else { + if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) { + trailingComments = last.trailingComments; + delete last.trailingComments; + } + } + + // Eating the stack. + if (last) { + while (last && last.range[0] >= node.range[0]) { + lastChild = last; + last = bottomRight.pop(); + } + } + + if (lastChild) { + if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) { + node.leadingComments = lastChild.leadingComments; + delete lastChild.leadingComments; + } + } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) { + node.leadingComments = extra.leadingComments; + extra.leadingComments = []; + } + + if (trailingComments) { + node.trailingComments = trailingComments; + } + + bottomRight.push(node); + } + + function markerApply(marker, node) { + if (extra.range) { + node.range = [marker.offset, index]; + } + if (extra.loc) { + node.loc = { + start: { + line: marker.line, + column: marker.col + }, + end: { + line: lineNumber, + column: index - lineStart + } + }; + node = delegate.postProcess(node); + } + if (extra.attachComment) { + processComment(node); + } + return node; + } + + SyntaxTreeDelegate = { + + name: 'SyntaxTree', + + postProcess: function (node) { + return node; + }, + + createArrayExpression: function (elements) { + return { + type: Syntax.ArrayExpression, + elements: elements + }; + }, + + createAssignmentExpression: function (operator, left, right) { + return { + type: Syntax.AssignmentExpression, + operator: operator, + left: left, + right: right + }; + }, + + createBinaryExpression: function (operator, left, right) { + var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : + Syntax.BinaryExpression; + return { + type: type, + operator: operator, + left: left, + right: right + }; + }, + + createBlockStatement: function (body) { + return { + type: Syntax.BlockStatement, + body: body + }; + }, + + createBreakStatement: function (label) { + return { + type: Syntax.BreakStatement, + label: label + }; + }, + + createCallExpression: function (callee, args) { + return { + type: Syntax.CallExpression, + callee: callee, + 'arguments': args + }; + }, + + createCatchClause: function (param, body) { + return { + type: Syntax.CatchClause, + param: param, + body: body + }; + }, + + createConditionalExpression: function (test, consequent, alternate) { + return { + type: Syntax.ConditionalExpression, + test: test, + consequent: consequent, + alternate: alternate + }; + }, + + createContinueStatement: function (label) { + return { + type: Syntax.ContinueStatement, + label: label + }; + }, + + createDebuggerStatement: function () { + return { + type: Syntax.DebuggerStatement + }; + }, + + createDoWhileStatement: function (body, test) { + return { + type: Syntax.DoWhileStatement, + body: body, + test: test + }; + }, + + createEmptyStatement: function () { + return { + type: Syntax.EmptyStatement + }; + }, + + createExpressionStatement: function (expression) { + return { + type: Syntax.ExpressionStatement, + expression: expression + }; + }, + + createForStatement: function (init, test, update, body) { + return { + type: Syntax.ForStatement, + init: init, + test: test, + update: update, + body: body + }; + }, + + createForInStatement: function (left, right, body) { + return { + type: Syntax.ForInStatement, + left: left, + right: right, + body: body, + each: false + }; + }, + + createForOfStatement: function (left, right, body) { + return { + type: Syntax.ForOfStatement, + left: left, + right: right, + body: body + }; + }, + + createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression, + isAsync, returnType, typeParameters) { + var funDecl = { + type: Syntax.FunctionDeclaration, + id: id, + params: params, + defaults: defaults, + body: body, + rest: rest, + generator: generator, + expression: expression, + returnType: returnType, + typeParameters: typeParameters + }; + + if (isAsync) { + funDecl.async = true; + } + + return funDecl; + }, + + createFunctionExpression: function (id, params, defaults, body, rest, generator, expression, + isAsync, returnType, typeParameters) { + var funExpr = { + type: Syntax.FunctionExpression, + id: id, + params: params, + defaults: defaults, + body: body, + rest: rest, + generator: generator, + expression: expression, + returnType: returnType, + typeParameters: typeParameters + }; + + if (isAsync) { + funExpr.async = true; + } + + return funExpr; + }, + + createIdentifier: function (name) { + return { + type: Syntax.Identifier, + name: name, + // Only here to initialize the shape of the object to ensure + // that the 'typeAnnotation' key is ordered before others that + // are added later (like 'loc' and 'range'). This just helps + // keep the shape of Identifier nodes consistent with everything + // else. + typeAnnotation: undefined, + optional: undefined + }; + }, + + createTypeAnnotation: function (typeAnnotation) { + return { + type: Syntax.TypeAnnotation, + typeAnnotation: typeAnnotation + }; + }, + + createTypeCast: function (expression, typeAnnotation) { + return { + type: Syntax.TypeCastExpression, + expression: expression, + typeAnnotation: typeAnnotation + }; + }, + + createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) { + return { + type: Syntax.FunctionTypeAnnotation, + params: params, + returnType: returnType, + rest: rest, + typeParameters: typeParameters + }; + }, + + createFunctionTypeParam: function (name, typeAnnotation, optional) { + return { + type: Syntax.FunctionTypeParam, + name: name, + typeAnnotation: typeAnnotation, + optional: optional + }; + }, + + createNullableTypeAnnotation: function (typeAnnotation) { + return { + type: Syntax.NullableTypeAnnotation, + typeAnnotation: typeAnnotation + }; + }, + + createArrayTypeAnnotation: function (elementType) { + return { + type: Syntax.ArrayTypeAnnotation, + elementType: elementType + }; + }, + + createGenericTypeAnnotation: function (id, typeParameters) { + return { + type: Syntax.GenericTypeAnnotation, + id: id, + typeParameters: typeParameters + }; + }, + + createQualifiedTypeIdentifier: function (qualification, id) { + return { + type: Syntax.QualifiedTypeIdentifier, + qualification: qualification, + id: id + }; + }, + + createTypeParameterDeclaration: function (params) { + return { + type: Syntax.TypeParameterDeclaration, + params: params + }; + }, + + createTypeParameterInstantiation: function (params) { + return { + type: Syntax.TypeParameterInstantiation, + params: params + }; + }, + + createAnyTypeAnnotation: function () { + return { + type: Syntax.AnyTypeAnnotation + }; + }, + + createBooleanTypeAnnotation: function () { + return { + type: Syntax.BooleanTypeAnnotation + }; + }, + + createNumberTypeAnnotation: function () { + return { + type: Syntax.NumberTypeAnnotation + }; + }, + + createStringTypeAnnotation: function () { + return { + type: Syntax.StringTypeAnnotation + }; + }, + + createStringLiteralTypeAnnotation: function (token) { + return { + type: Syntax.StringLiteralTypeAnnotation, + value: token.value, + raw: source.slice(token.range[0], token.range[1]) + }; + }, + + createVoidTypeAnnotation: function () { + return { + type: Syntax.VoidTypeAnnotation + }; + }, + + createTypeofTypeAnnotation: function (argument) { + return { + type: Syntax.TypeofTypeAnnotation, + argument: argument + }; + }, + + createTupleTypeAnnotation: function (types) { + return { + type: Syntax.TupleTypeAnnotation, + types: types + }; + }, + + createObjectTypeAnnotation: function (properties, indexers, callProperties) { + return { + type: Syntax.ObjectTypeAnnotation, + properties: properties, + indexers: indexers, + callProperties: callProperties + }; + }, + + createObjectTypeIndexer: function (id, key, value, isStatic) { + return { + type: Syntax.ObjectTypeIndexer, + id: id, + key: key, + value: value, + "static": isStatic + }; + }, + + createObjectTypeCallProperty: function (value, isStatic) { + return { + type: Syntax.ObjectTypeCallProperty, + value: value, + "static": isStatic + }; + }, + + createObjectTypeProperty: function (key, value, optional, isStatic) { + return { + type: Syntax.ObjectTypeProperty, + key: key, + value: value, + optional: optional, + "static": isStatic + }; + }, + + createUnionTypeAnnotation: function (types) { + return { + type: Syntax.UnionTypeAnnotation, + types: types + }; + }, + + createIntersectionTypeAnnotation: function (types) { + return { + type: Syntax.IntersectionTypeAnnotation, + types: types + }; + }, + + createTypeAlias: function (id, typeParameters, right) { + return { + type: Syntax.TypeAlias, + id: id, + typeParameters: typeParameters, + right: right + }; + }, + + createInterface: function (id, typeParameters, body, extended) { + return { + type: Syntax.InterfaceDeclaration, + id: id, + typeParameters: typeParameters, + body: body, + "extends": extended + }; + }, + + createInterfaceExtends: function (id, typeParameters) { + return { + type: Syntax.InterfaceExtends, + id: id, + typeParameters: typeParameters + }; + }, + + createDeclareFunction: function (id) { + return { + type: Syntax.DeclareFunction, + id: id + }; + }, + + createDeclareVariable: function (id) { + return { + type: Syntax.DeclareVariable, + id: id + }; + }, + + createDeclareModule: function (id, body) { + return { + type: Syntax.DeclareModule, + id: id, + body: body + }; + }, + + createJSXAttribute: function (name, value) { + return { + type: Syntax.JSXAttribute, + name: name, + value: value || null + }; + }, + + createJSXSpreadAttribute: function (argument) { + return { + type: Syntax.JSXSpreadAttribute, + argument: argument + }; + }, + + createJSXIdentifier: function (name) { + return { + type: Syntax.JSXIdentifier, + name: name + }; + }, + + createJSXNamespacedName: function (namespace, name) { + return { + type: Syntax.JSXNamespacedName, + namespace: namespace, + name: name + }; + }, + + createJSXMemberExpression: function (object, property) { + return { + type: Syntax.JSXMemberExpression, + object: object, + property: property + }; + }, + + createJSXElement: function (openingElement, closingElement, children) { + return { + type: Syntax.JSXElement, + openingElement: openingElement, + closingElement: closingElement, + children: children + }; + }, + + createJSXEmptyExpression: function () { + return { + type: Syntax.JSXEmptyExpression + }; + }, + + createJSXExpressionContainer: function (expression) { + return { + type: Syntax.JSXExpressionContainer, + expression: expression + }; + }, + + createJSXOpeningElement: function (name, attributes, selfClosing) { + return { + type: Syntax.JSXOpeningElement, + name: name, + selfClosing: selfClosing, + attributes: attributes + }; + }, + + createJSXClosingElement: function (name) { + return { + type: Syntax.JSXClosingElement, + name: name + }; + }, + + createIfStatement: function (test, consequent, alternate) { + return { + type: Syntax.IfStatement, + test: test, + consequent: consequent, + alternate: alternate + }; + }, + + createLabeledStatement: function (label, body) { + return { + type: Syntax.LabeledStatement, + label: label, + body: body + }; + }, + + createLiteral: function (token) { + var object = { + type: Syntax.Literal, + value: token.value, + raw: source.slice(token.range[0], token.range[1]) + }; + if (token.regex) { + object.regex = token.regex; + } + return object; + }, + + createMemberExpression: function (accessor, object, property) { + return { + type: Syntax.MemberExpression, + computed: accessor === '[', + object: object, + property: property + }; + }, + + createNewExpression: function (callee, args) { + return { + type: Syntax.NewExpression, + callee: callee, + 'arguments': args + }; + }, + + createObjectExpression: function (properties) { + return { + type: Syntax.ObjectExpression, + properties: properties + }; + }, + + createPostfixExpression: function (operator, argument) { + return { + type: Syntax.UpdateExpression, + operator: operator, + argument: argument, + prefix: false + }; + }, + + createProgram: function (body) { + return { + type: Syntax.Program, + body: body + }; + }, + + createProperty: function (kind, key, value, method, shorthand, computed) { + return { + type: Syntax.Property, + key: key, + value: value, + kind: kind, + method: method, + shorthand: shorthand, + computed: computed + }; + }, + + createReturnStatement: function (argument) { + return { + type: Syntax.ReturnStatement, + argument: argument + }; + }, + + createSequenceExpression: function (expressions) { + return { + type: Syntax.SequenceExpression, + expressions: expressions + }; + }, + + createSwitchCase: function (test, consequent) { + return { + type: Syntax.SwitchCase, + test: test, + consequent: consequent + }; + }, + + createSwitchStatement: function (discriminant, cases) { + return { + type: Syntax.SwitchStatement, + discriminant: discriminant, + cases: cases + }; + }, + + createThisExpression: function () { + return { + type: Syntax.ThisExpression + }; + }, + + createThrowStatement: function (argument) { + return { + type: Syntax.ThrowStatement, + argument: argument + }; + }, + + createTryStatement: function (block, guardedHandlers, handlers, finalizer) { + return { + type: Syntax.TryStatement, + block: block, + guardedHandlers: guardedHandlers, + handlers: handlers, + finalizer: finalizer + }; + }, + + createUnaryExpression: function (operator, argument) { + if (operator === '++' || operator === '--') { + return { + type: Syntax.UpdateExpression, + operator: operator, + argument: argument, + prefix: true + }; + } + return { + type: Syntax.UnaryExpression, + operator: operator, + argument: argument, + prefix: true + }; + }, + + createVariableDeclaration: function (declarations, kind) { + return { + type: Syntax.VariableDeclaration, + declarations: declarations, + kind: kind + }; + }, + + createVariableDeclarator: function (id, init) { + return { + type: Syntax.VariableDeclarator, + id: id, + init: init + }; + }, + + createWhileStatement: function (test, body) { + return { + type: Syntax.WhileStatement, + test: test, + body: body + }; + }, + + createWithStatement: function (object, body) { + return { + type: Syntax.WithStatement, + object: object, + body: body + }; + }, + + createTemplateElement: function (value, tail) { + return { + type: Syntax.TemplateElement, + value: value, + tail: tail + }; + }, + + createTemplateLiteral: function (quasis, expressions) { + return { + type: Syntax.TemplateLiteral, + quasis: quasis, + expressions: expressions + }; + }, + + createSpreadElement: function (argument) { + return { + type: Syntax.SpreadElement, + argument: argument + }; + }, + + createSpreadProperty: function (argument) { + return { + type: Syntax.SpreadProperty, + argument: argument + }; + }, + + createTaggedTemplateExpression: function (tag, quasi) { + return { + type: Syntax.TaggedTemplateExpression, + tag: tag, + quasi: quasi + }; + }, + + createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) { + var arrowExpr = { + type: Syntax.ArrowFunctionExpression, + id: null, + params: params, + defaults: defaults, + body: body, + rest: rest, + generator: false, + expression: expression + }; + + if (isAsync) { + arrowExpr.async = true; + } + + return arrowExpr; + }, + + createMethodDefinition: function (propertyType, kind, key, value, computed) { + return { + type: Syntax.MethodDefinition, + key: key, + value: value, + kind: kind, + 'static': propertyType === ClassPropertyType["static"], + computed: computed + }; + }, + + createClassProperty: function (key, typeAnnotation, computed, isStatic) { + return { + type: Syntax.ClassProperty, + key: key, + typeAnnotation: typeAnnotation, + computed: computed, + "static": isStatic + }; + }, + + createClassBody: function (body) { + return { + type: Syntax.ClassBody, + body: body + }; + }, + + createClassImplements: function (id, typeParameters) { + return { + type: Syntax.ClassImplements, + id: id, + typeParameters: typeParameters + }; + }, + + createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) { + return { + type: Syntax.ClassExpression, + id: id, + superClass: superClass, + body: body, + typeParameters: typeParameters, + superTypeParameters: superTypeParameters, + "implements": implemented + }; + }, + + createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) { + return { + type: Syntax.ClassDeclaration, + id: id, + superClass: superClass, + body: body, + typeParameters: typeParameters, + superTypeParameters: superTypeParameters, + "implements": implemented + }; + }, + + createModuleSpecifier: function (token) { + return { + type: Syntax.ModuleSpecifier, + value: token.value, + raw: source.slice(token.range[0], token.range[1]) + }; + }, + + createExportSpecifier: function (id, name) { + return { + type: Syntax.ExportSpecifier, + id: id, + name: name + }; + }, + + createExportBatchSpecifier: function () { + return { + type: Syntax.ExportBatchSpecifier + }; + }, + + createImportDefaultSpecifier: function (id) { + return { + type: Syntax.ImportDefaultSpecifier, + id: id + }; + }, + + createImportNamespaceSpecifier: function (id) { + return { + type: Syntax.ImportNamespaceSpecifier, + id: id + }; + }, + + createExportDeclaration: function (isDefault, declaration, specifiers, src) { + return { + type: Syntax.ExportDeclaration, + 'default': !!isDefault, + declaration: declaration, + specifiers: specifiers, + source: src + }; + }, + + createImportSpecifier: function (id, name) { + return { + type: Syntax.ImportSpecifier, + id: id, + name: name + }; + }, + + createImportDeclaration: function (specifiers, src, isType) { + return { + type: Syntax.ImportDeclaration, + specifiers: specifiers, + source: src, + isType: isType + }; + }, + + createYieldExpression: function (argument, dlg) { + return { + type: Syntax.YieldExpression, + argument: argument, + delegate: dlg + }; + }, + + createAwaitExpression: function (argument) { + return { + type: Syntax.AwaitExpression, + argument: argument + }; + }, + + createComprehensionExpression: function (filter, blocks, body) { + return { + type: Syntax.ComprehensionExpression, + filter: filter, + blocks: blocks, + body: body + }; + } + + }; + + // Return true if there is a line terminator before the next token. + + function peekLineTerminator() { + var pos, line, start, found; + + pos = index; + line = lineNumber; + start = lineStart; + skipComment(); + found = lineNumber !== line; + index = pos; + lineNumber = line; + lineStart = start; + + return found; + } + + // Throw an exception + + function throwError(token, messageFormat) { + var error, + args = Array.prototype.slice.call(arguments, 2), + msg = messageFormat.replace( + /%(\d)/g, + function (whole, idx) { + assert(idx < args.length, 'Message reference must be in range'); + return args[idx]; + } + ); + + if (typeof token.lineNumber === 'number') { + error = new Error('Line ' + token.lineNumber + ': ' + msg); + error.index = token.range[0]; + error.lineNumber = token.lineNumber; + error.column = token.range[0] - lineStart + 1; + } else { + error = new Error('Line ' + lineNumber + ': ' + msg); + error.index = index; + error.lineNumber = lineNumber; + error.column = index - lineStart + 1; + } + + error.description = msg; + throw error; + } + + function throwErrorTolerant() { + try { + throwError.apply(null, arguments); + } catch (e) { + if (extra.errors) { + extra.errors.push(e); + } else { + throw e; + } + } + } + + + // Throw an exception because of the token. + + function throwUnexpected(token) { + if (token.type === Token.EOF) { + throwError(token, Messages.UnexpectedEOS); + } + + if (token.type === Token.NumericLiteral) { + throwError(token, Messages.UnexpectedNumber); + } + + if (token.type === Token.StringLiteral || token.type === Token.JSXText) { + throwError(token, Messages.UnexpectedString); + } + + if (token.type === Token.Identifier) { + throwError(token, Messages.UnexpectedIdentifier); + } + + if (token.type === Token.Keyword) { + if (isFutureReservedWord(token.value)) { + throwError(token, Messages.UnexpectedReserved); + } else if (strict && isStrictModeReservedWord(token.value)) { + throwErrorTolerant(token, Messages.StrictReservedWord); + return; + } + throwError(token, Messages.UnexpectedToken, token.value); + } + + if (token.type === Token.Template) { + throwError(token, Messages.UnexpectedTemplate, token.value.raw); + } + + // BooleanLiteral, NullLiteral, or Punctuator. + throwError(token, Messages.UnexpectedToken, token.value); + } + + // Expect the next token to match the specified punctuator. + // If not, an exception will be thrown. + + function expect(value) { + var token = lex(); + if (token.type !== Token.Punctuator || token.value !== value) { + throwUnexpected(token); + } + } + + // Expect the next token to match the specified keyword. + // If not, an exception will be thrown. + + function expectKeyword(keyword, contextual) { + var token = lex(); + if (token.type !== (contextual ? Token.Identifier : Token.Keyword) || + token.value !== keyword) { + throwUnexpected(token); + } + } + + // Expect the next token to match the specified contextual keyword. + // If not, an exception will be thrown. + + function expectContextualKeyword(keyword) { + return expectKeyword(keyword, true); + } + + // Return true if the next token matches the specified punctuator. + + function match(value) { + return lookahead.type === Token.Punctuator && lookahead.value === value; + } + + // Return true if the next token matches the specified keyword + + function matchKeyword(keyword, contextual) { + var expectedType = contextual ? Token.Identifier : Token.Keyword; + return lookahead.type === expectedType && lookahead.value === keyword; + } + + // Return true if the next token matches the specified contextual keyword + + function matchContextualKeyword(keyword) { + return matchKeyword(keyword, true); + } + + // Return true if the next token is an assignment operator + + function matchAssign() { + var op; + + if (lookahead.type !== Token.Punctuator) { + return false; + } + op = lookahead.value; + return op === '=' || + op === '*=' || + op === '/=' || + op === '%=' || + op === '+=' || + op === '-=' || + op === '<<=' || + op === '>>=' || + op === '>>>=' || + op === '&=' || + op === '^=' || + op === '|='; + } + + // Note that 'yield' is treated as a keyword in strict mode, but a + // contextual keyword (identifier) in non-strict mode, so we need to + // use matchKeyword('yield', false) and matchKeyword('yield', true) + // (i.e. matchContextualKeyword) appropriately. + function matchYield() { + return state.yieldAllowed && matchKeyword('yield', !strict); + } + + function matchAsync() { + var backtrackToken = lookahead, matches = false; + + if (matchContextualKeyword('async')) { + lex(); // Make sure peekLineTerminator() starts after 'async'. + matches = !peekLineTerminator(); + rewind(backtrackToken); // Revert the lex(). + } + + return matches; + } + + function matchAwait() { + return state.awaitAllowed && matchContextualKeyword('await'); + } + + function consumeSemicolon() { + var line, oldIndex = index, oldLineNumber = lineNumber, + oldLineStart = lineStart, oldLookahead = lookahead; + + // Catch the very common case first: immediately a semicolon (char #59). + if (source.charCodeAt(index) === 59) { + lex(); + return; + } + + line = lineNumber; + skipComment(); + if (lineNumber !== line) { + index = oldIndex; + lineNumber = oldLineNumber; + lineStart = oldLineStart; + lookahead = oldLookahead; + return; + } + + if (match(';')) { + lex(); + return; + } + + if (lookahead.type !== Token.EOF && !match('}')) { + throwUnexpected(lookahead); + } + } + + // Return true if provided expression is LeftHandSideExpression + + function isLeftHandSide(expr) { + return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression; + } + + function isAssignableLeftHandSide(expr) { + return isLeftHandSide(expr) || expr.type === Syntax.ObjectPattern || expr.type === Syntax.ArrayPattern; + } + + // 11.1.4 Array Initialiser + + function parseArrayInitialiser() { + var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true, + marker = markerCreate(); + + expect('['); + while (!match(']')) { + if (lookahead.value === 'for' && + lookahead.type === Token.Keyword) { + if (!possiblecomprehension) { + throwError({}, Messages.ComprehensionError); + } + matchKeyword('for'); + tmp = parseForStatement({ignoreBody: true}); + tmp.of = tmp.type === Syntax.ForOfStatement; + tmp.type = Syntax.ComprehensionBlock; + if (tmp.left.kind) { // can't be let or const + throwError({}, Messages.ComprehensionError); + } + blocks.push(tmp); + } else if (lookahead.value === 'if' && + lookahead.type === Token.Keyword) { + if (!possiblecomprehension) { + throwError({}, Messages.ComprehensionError); + } + expectKeyword('if'); + expect('('); + filter = parseExpression(); + expect(')'); + } else if (lookahead.value === ',' && + lookahead.type === Token.Punctuator) { + possiblecomprehension = false; // no longer allowed. + lex(); + elements.push(null); + } else { + tmp = parseSpreadOrAssignmentExpression(); + elements.push(tmp); + if (tmp && tmp.type === Syntax.SpreadElement) { + if (!match(']')) { + throwError({}, Messages.ElementAfterSpreadElement); + } + } else if (!(match(']') || matchKeyword('for') || matchKeyword('if'))) { + expect(','); // this lexes. + possiblecomprehension = false; + } + } + } + + expect(']'); + + if (filter && !blocks.length) { + throwError({}, Messages.ComprehensionRequiresBlock); + } + + if (blocks.length) { + if (elements.length !== 1) { + throwError({}, Messages.ComprehensionError); + } + return markerApply(marker, delegate.createComprehensionExpression(filter, blocks, elements[0])); + } + return markerApply(marker, delegate.createArrayExpression(elements)); + } + + // 11.1.5 Object Initialiser + + function parsePropertyFunction(options) { + var previousStrict, previousYieldAllowed, previousAwaitAllowed, + params, defaults, body, marker = markerCreate(); + + previousStrict = strict; + previousYieldAllowed = state.yieldAllowed; + state.yieldAllowed = options.generator; + previousAwaitAllowed = state.awaitAllowed; + state.awaitAllowed = options.async; + params = options.params || []; + defaults = options.defaults || []; + + body = parseConciseBody(); + if (options.name && strict && isRestrictedWord(params[0].name)) { + throwErrorTolerant(options.name, Messages.StrictParamName); + } + strict = previousStrict; + state.yieldAllowed = previousYieldAllowed; + state.awaitAllowed = previousAwaitAllowed; + + return markerApply(marker, delegate.createFunctionExpression( + null, + params, + defaults, + body, + options.rest || null, + options.generator, + body.type !== Syntax.BlockStatement, + options.async, + options.returnType, + options.typeParameters + )); + } + + + function parsePropertyMethodFunction(options) { + var previousStrict, tmp, method; + + previousStrict = strict; + strict = true; + + tmp = parseParams(); + + if (tmp.stricted) { + throwErrorTolerant(tmp.stricted, tmp.message); + } + + method = parsePropertyFunction({ + params: tmp.params, + defaults: tmp.defaults, + rest: tmp.rest, + generator: options.generator, + async: options.async, + returnType: tmp.returnType, + typeParameters: options.typeParameters + }); + + strict = previousStrict; + + return method; + } + + + function parseObjectPropertyKey() { + var marker = markerCreate(), + token = lex(), + propertyKey, + result; + + // Note: This function is called only from parseObjectProperty(), where + // EOF and Punctuator tokens are already filtered out. + + if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) { + if (strict && token.octal) { + throwErrorTolerant(token, Messages.StrictOctalLiteral); + } + return markerApply(marker, delegate.createLiteral(token)); + } + + if (token.type === Token.Punctuator && token.value === '[') { + // For computed properties we should skip the [ and ], and + // capture in marker only the assignment expression itself. + marker = markerCreate(); + propertyKey = parseAssignmentExpression(); + result = markerApply(marker, propertyKey); + expect(']'); + return result; + } + + return markerApply(marker, delegate.createIdentifier(token.value)); + } + + function parseObjectProperty() { + var token, key, id, param, computed, + marker = markerCreate(), returnType, typeParameters; + + token = lookahead; + computed = (token.value === '[' && token.type === Token.Punctuator); + + if (token.type === Token.Identifier || computed || matchAsync()) { + id = parseObjectPropertyKey(); + + if (match(':')) { + lex(); + + return markerApply( + marker, + delegate.createProperty( + 'init', + id, + parseAssignmentExpression(), + false, + false, + computed + ) + ); + } + + if (match('(') || match('<')) { + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + return markerApply( + marker, + delegate.createProperty( + 'init', + id, + parsePropertyMethodFunction({ + generator: false, + async: false, + typeParameters: typeParameters + }), + true, + false, + computed + ) + ); + } + + // Property Assignment: Getter and Setter. + + if (token.value === 'get') { + computed = (lookahead.value === '['); + key = parseObjectPropertyKey(); + + expect('('); + expect(')'); + if (match(':')) { + returnType = parseTypeAnnotation(); + } + + return markerApply( + marker, + delegate.createProperty( + 'get', + key, + parsePropertyFunction({ + generator: false, + async: false, + returnType: returnType + }), + false, + false, + computed + ) + ); + } + + if (token.value === 'set') { + computed = (lookahead.value === '['); + key = parseObjectPropertyKey(); + + expect('('); + token = lookahead; + param = [ parseTypeAnnotatableIdentifier() ]; + expect(')'); + if (match(':')) { + returnType = parseTypeAnnotation(); + } + + return markerApply( + marker, + delegate.createProperty( + 'set', + key, + parsePropertyFunction({ + params: param, + generator: false, + async: false, + name: token, + returnType: returnType + }), + false, + false, + computed + ) + ); + } + + if (token.value === 'async') { + computed = (lookahead.value === '['); + key = parseObjectPropertyKey(); + + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + + return markerApply( + marker, + delegate.createProperty( + 'init', + key, + parsePropertyMethodFunction({ + generator: false, + async: true, + typeParameters: typeParameters + }), + true, + false, + computed + ) + ); + } + + if (computed) { + // Computed properties can only be used with full notation. + throwUnexpected(lookahead); + } + + return markerApply( + marker, + delegate.createProperty('init', id, id, false, true, false) + ); + } + + if (token.type === Token.EOF || token.type === Token.Punctuator) { + if (!match('*')) { + throwUnexpected(token); + } + lex(); + + computed = (lookahead.type === Token.Punctuator && lookahead.value === '['); + + id = parseObjectPropertyKey(); + + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + + if (!match('(')) { + throwUnexpected(lex()); + } + + return markerApply(marker, delegate.createProperty( + 'init', + id, + parsePropertyMethodFunction({ + generator: true, + typeParameters: typeParameters + }), + true, + false, + computed + )); + } + key = parseObjectPropertyKey(); + if (match(':')) { + lex(); + return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false)); + } + if (match('(') || match('<')) { + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + return markerApply(marker, delegate.createProperty( + 'init', + key, + parsePropertyMethodFunction({ + generator: false, + typeParameters: typeParameters + }), + true, + false, + false + )); + } + throwUnexpected(lex()); + } + + function parseObjectSpreadProperty() { + var marker = markerCreate(); + expect('...'); + return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression())); + } + + function getFieldName(key) { + var toString = String; + if (key.type === Syntax.Identifier) { + return key.name; + } + return toString(key.value); + } + + function parseObjectInitialiser() { + var properties = [], property, name, kind, storedKind, map = new StringMap(), + marker = markerCreate(), toString = String; + + expect('{'); + + while (!match('}')) { + if (match('...')) { + property = parseObjectSpreadProperty(); + } else { + property = parseObjectProperty(); + + if (property.key.type === Syntax.Identifier) { + name = property.key.name; + } else { + name = toString(property.key.value); + } + kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set; + + if (map.has(name)) { + storedKind = map.get(name); + if (storedKind === PropertyKind.Data) { + if (strict && kind === PropertyKind.Data) { + throwErrorTolerant({}, Messages.StrictDuplicateProperty); + } else if (kind !== PropertyKind.Data) { + throwErrorTolerant({}, Messages.AccessorDataProperty); + } + } else { + if (kind === PropertyKind.Data) { + throwErrorTolerant({}, Messages.AccessorDataProperty); + } else if (storedKind & kind) { + throwErrorTolerant({}, Messages.AccessorGetSet); + } + } + map.set(name, storedKind | kind); + } else { + map.set(name, kind); + } + } + + properties.push(property); + + if (!match('}')) { + expect(','); + } + } + + expect('}'); + + return markerApply(marker, delegate.createObjectExpression(properties)); + } + + function parseTemplateElement(option) { + var marker = markerCreate(), + token = scanTemplateElement(option); + if (strict && token.octal) { + throwError(token, Messages.StrictOctalLiteral); + } + return markerApply(marker, delegate.createTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail)); + } + + function parseTemplateLiteral() { + var quasi, quasis, expressions, marker = markerCreate(); + + quasi = parseTemplateElement({ head: true }); + quasis = [ quasi ]; + expressions = []; + + while (!quasi.tail) { + expressions.push(parseExpression()); + quasi = parseTemplateElement({ head: false }); + quasis.push(quasi); + } + + return markerApply(marker, delegate.createTemplateLiteral(quasis, expressions)); + } + + // 11.1.6 The Grouping Operator + + function parseGroupExpression() { + var expr, marker, typeAnnotation; + + expect('('); + + ++state.parenthesizedCount; + + marker = markerCreate(); + + expr = parseExpression(); + + if (match(':')) { + typeAnnotation = parseTypeAnnotation(); + expr = markerApply(marker, delegate.createTypeCast( + expr, + typeAnnotation + )); + } + + expect(')'); + + return expr; + } + + function matchAsyncFuncExprOrDecl() { + var token; + + if (matchAsync()) { + token = lookahead2(); + if (token.type === Token.Keyword && token.value === 'function') { + return true; + } + } + + return false; + } + + // 11.1 Primary Expressions + + function parsePrimaryExpression() { + var marker, type, token, expr; + + type = lookahead.type; + + if (type === Token.Identifier) { + marker = markerCreate(); + return markerApply(marker, delegate.createIdentifier(lex().value)); + } + + if (type === Token.StringLiteral || type === Token.NumericLiteral) { + if (strict && lookahead.octal) { + throwErrorTolerant(lookahead, Messages.StrictOctalLiteral); + } + marker = markerCreate(); + return markerApply(marker, delegate.createLiteral(lex())); + } + + if (type === Token.Keyword) { + if (matchKeyword('this')) { + marker = markerCreate(); + lex(); + return markerApply(marker, delegate.createThisExpression()); + } + + if (matchKeyword('function')) { + return parseFunctionExpression(); + } + + if (matchKeyword('class')) { + return parseClassExpression(); + } + + if (matchKeyword('super')) { + marker = markerCreate(); + lex(); + return markerApply(marker, delegate.createIdentifier('super')); + } + } + + if (type === Token.BooleanLiteral) { + marker = markerCreate(); + token = lex(); + token.value = (token.value === 'true'); + return markerApply(marker, delegate.createLiteral(token)); + } + + if (type === Token.NullLiteral) { + marker = markerCreate(); + token = lex(); + token.value = null; + return markerApply(marker, delegate.createLiteral(token)); + } + + if (match('[')) { + return parseArrayInitialiser(); + } + + if (match('{')) { + return parseObjectInitialiser(); + } + + if (match('(')) { + return parseGroupExpression(); + } + + if (match('/') || match('/=')) { + marker = markerCreate(); + expr = delegate.createLiteral(scanRegExp()); + peek(); + return markerApply(marker, expr); + } + + if (type === Token.Template) { + return parseTemplateLiteral(); + } + + if (match('<')) { + return parseJSXElement(); + } + + throwUnexpected(lex()); + } + + // 11.2 Left-Hand-Side Expressions + + function parseArguments() { + var args = [], arg; + + expect('('); + + if (!match(')')) { + while (index < length) { + arg = parseSpreadOrAssignmentExpression(); + args.push(arg); + + if (match(')')) { + break; + } else if (arg.type === Syntax.SpreadElement) { + throwError({}, Messages.ElementAfterSpreadElement); + } + + expect(','); + } + } + + expect(')'); + + return args; + } + + function parseSpreadOrAssignmentExpression() { + if (match('...')) { + var marker = markerCreate(); + lex(); + return markerApply(marker, delegate.createSpreadElement(parseAssignmentExpression())); + } + return parseAssignmentExpression(); + } + + function parseNonComputedProperty() { + var marker = markerCreate(), + token = lex(); + + if (!isIdentifierName(token)) { + throwUnexpected(token); + } + + return markerApply(marker, delegate.createIdentifier(token.value)); + } + + function parseNonComputedMember() { + expect('.'); + + return parseNonComputedProperty(); + } + + function parseComputedMember() { + var expr; + + expect('['); + + expr = parseExpression(); + + expect(']'); + + return expr; + } + + function parseNewExpression() { + var callee, args, marker = markerCreate(); + + expectKeyword('new'); + callee = parseLeftHandSideExpression(); + args = match('(') ? parseArguments() : []; + + return markerApply(marker, delegate.createNewExpression(callee, args)); + } + + function parseLeftHandSideExpressionAllowCall() { + var expr, args, marker = markerCreate(); + + expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); + + while (match('.') || match('[') || match('(') || lookahead.type === Token.Template) { + if (match('(')) { + args = parseArguments(); + expr = markerApply(marker, delegate.createCallExpression(expr, args)); + } else if (match('[')) { + expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember())); + } else if (match('.')) { + expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember())); + } else { + expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral())); + } + } + + return expr; + } + + function parseLeftHandSideExpression() { + var expr, marker = markerCreate(); + + expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); + + while (match('.') || match('[') || lookahead.type === Token.Template) { + if (match('[')) { + expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember())); + } else if (match('.')) { + expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember())); + } else { + expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral())); + } + } + + return expr; + } + + // 11.3 Postfix Expressions + + function parsePostfixExpression() { + var marker = markerCreate(), + expr = parseLeftHandSideExpressionAllowCall(), + token; + + if (lookahead.type !== Token.Punctuator) { + return expr; + } + + if ((match('++') || match('--')) && !peekLineTerminator()) { + // 11.3.1, 11.3.2 + if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { + throwErrorTolerant({}, Messages.StrictLHSPostfix); + } + + if (!isLeftHandSide(expr)) { + throwError({}, Messages.InvalidLHSInAssignment); + } + + token = lex(); + expr = markerApply(marker, delegate.createPostfixExpression(token.value, expr)); + } + + return expr; + } + + // 11.4 Unary Operators + + function parseUnaryExpression() { + var marker, token, expr; + + if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) { + return parsePostfixExpression(); + } + + if (match('++') || match('--')) { + marker = markerCreate(); + token = lex(); + expr = parseUnaryExpression(); + // 11.4.4, 11.4.5 + if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { + throwErrorTolerant({}, Messages.StrictLHSPrefix); + } + + if (!isLeftHandSide(expr)) { + throwError({}, Messages.InvalidLHSInAssignment); + } + + return markerApply(marker, delegate.createUnaryExpression(token.value, expr)); + } + + if (match('+') || match('-') || match('~') || match('!')) { + marker = markerCreate(); + token = lex(); + expr = parseUnaryExpression(); + return markerApply(marker, delegate.createUnaryExpression(token.value, expr)); + } + + if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { + marker = markerCreate(); + token = lex(); + expr = parseUnaryExpression(); + expr = markerApply(marker, delegate.createUnaryExpression(token.value, expr)); + if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { + throwErrorTolerant({}, Messages.StrictDelete); + } + return expr; + } + + return parsePostfixExpression(); + } + + function binaryPrecedence(token, allowIn) { + var prec = 0; + + if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { + return 0; + } + + switch (token.value) { + case '||': + prec = 1; + break; + + case '&&': + prec = 2; + break; + + case '|': + prec = 3; + break; + + case '^': + prec = 4; + break; + + case '&': + prec = 5; + break; + + case '==': + case '!=': + case '===': + case '!==': + prec = 6; + break; + + case '<': + case '>': + case '<=': + case '>=': + case 'instanceof': + prec = 7; + break; + + case 'in': + prec = allowIn ? 7 : 0; + break; + + case '<<': + case '>>': + case '>>>': + prec = 8; + break; + + case '+': + case '-': + prec = 9; + break; + + case '*': + case '/': + case '%': + prec = 11; + break; + + default: + break; + } + + return prec; + } + + // 11.5 Multiplicative Operators + // 11.6 Additive Operators + // 11.7 Bitwise Shift Operators + // 11.8 Relational Operators + // 11.9 Equality Operators + // 11.10 Binary Bitwise Operators + // 11.11 Binary Logical Operators + + function parseBinaryExpression() { + var expr, token, prec, previousAllowIn, stack, right, operator, left, i, + marker, markers; + + previousAllowIn = state.allowIn; + state.allowIn = true; + + marker = markerCreate(); + left = parseUnaryExpression(); + + token = lookahead; + prec = binaryPrecedence(token, previousAllowIn); + if (prec === 0) { + return left; + } + token.prec = prec; + lex(); + + markers = [marker, markerCreate()]; + right = parseUnaryExpression(); + + stack = [left, token, right]; + + while ((prec = binaryPrecedence(lookahead, previousAllowIn)) > 0) { + + // Reduce: make a binary expression from the three topmost entries. + while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { + right = stack.pop(); + operator = stack.pop().value; + left = stack.pop(); + expr = delegate.createBinaryExpression(operator, left, right); + markers.pop(); + marker = markers.pop(); + markerApply(marker, expr); + stack.push(expr); + markers.push(marker); + } + + // Shift. + token = lex(); + token.prec = prec; + stack.push(token); + markers.push(markerCreate()); + expr = parseUnaryExpression(); + stack.push(expr); + } + + state.allowIn = previousAllowIn; + + // Final reduce to clean-up the stack. + i = stack.length - 1; + expr = stack[i]; + markers.pop(); + while (i > 1) { + expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr); + i -= 2; + marker = markers.pop(); + markerApply(marker, expr); + } + + return expr; + } + + + // 11.12 Conditional Operator + + function parseConditionalExpression() { + var expr, previousAllowIn, consequent, alternate, marker = markerCreate(); + expr = parseBinaryExpression(); + + if (match('?')) { + lex(); + previousAllowIn = state.allowIn; + state.allowIn = true; + consequent = parseAssignmentExpression(); + state.allowIn = previousAllowIn; + expect(':'); + alternate = parseAssignmentExpression(); + + expr = markerApply(marker, delegate.createConditionalExpression(expr, consequent, alternate)); + } + + return expr; + } + + // 11.13 Assignment Operators + + // 12.14.5 AssignmentPattern + + function reinterpretAsAssignmentBindingPattern(expr) { + var i, len, property, element; + + if (expr.type === Syntax.ObjectExpression) { + expr.type = Syntax.ObjectPattern; + for (i = 0, len = expr.properties.length; i < len; i += 1) { + property = expr.properties[i]; + if (property.type === Syntax.SpreadProperty) { + if (i < len - 1) { + throwError({}, Messages.PropertyAfterSpreadProperty); + } + reinterpretAsAssignmentBindingPattern(property.argument); + } else { + if (property.kind !== 'init') { + throwError({}, Messages.InvalidLHSInAssignment); + } + reinterpretAsAssignmentBindingPattern(property.value); + } + } + } else if (expr.type === Syntax.ArrayExpression) { + expr.type = Syntax.ArrayPattern; + for (i = 0, len = expr.elements.length; i < len; i += 1) { + element = expr.elements[i]; + /* istanbul ignore else */ + if (element) { + reinterpretAsAssignmentBindingPattern(element); + } + } + } else if (expr.type === Syntax.Identifier) { + if (isRestrictedWord(expr.name)) { + throwError({}, Messages.InvalidLHSInAssignment); + } + } else if (expr.type === Syntax.SpreadElement) { + reinterpretAsAssignmentBindingPattern(expr.argument); + if (expr.argument.type === Syntax.ObjectPattern) { + throwError({}, Messages.ObjectPatternAsSpread); + } + } else { + /* istanbul ignore else */ + if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) { + throwError({}, Messages.InvalidLHSInAssignment); + } + } + } + + // 13.2.3 BindingPattern + + function reinterpretAsDestructuredParameter(options, expr) { + var i, len, property, element; + + if (expr.type === Syntax.ObjectExpression) { + expr.type = Syntax.ObjectPattern; + for (i = 0, len = expr.properties.length; i < len; i += 1) { + property = expr.properties[i]; + if (property.type === Syntax.SpreadProperty) { + if (i < len - 1) { + throwError({}, Messages.PropertyAfterSpreadProperty); + } + reinterpretAsDestructuredParameter(options, property.argument); + } else { + if (property.kind !== 'init') { + throwError({}, Messages.InvalidLHSInFormalsList); + } + reinterpretAsDestructuredParameter(options, property.value); + } + } + } else if (expr.type === Syntax.ArrayExpression) { + expr.type = Syntax.ArrayPattern; + for (i = 0, len = expr.elements.length; i < len; i += 1) { + element = expr.elements[i]; + if (element) { + reinterpretAsDestructuredParameter(options, element); + } + } + } else if (expr.type === Syntax.Identifier) { + validateParam(options, expr, expr.name); + } else if (expr.type === Syntax.SpreadElement) { + // BindingRestElement only allows BindingIdentifier + if (expr.argument.type !== Syntax.Identifier) { + throwError({}, Messages.InvalidLHSInFormalsList); + } + validateParam(options, expr.argument, expr.argument.name); + } else { + throwError({}, Messages.InvalidLHSInFormalsList); + } + } + + function reinterpretAsCoverFormalsList(expressions) { + var i, len, param, params, defaults, defaultCount, options, rest; + + params = []; + defaults = []; + defaultCount = 0; + rest = null; + options = { + paramSet: new StringMap() + }; + + for (i = 0, len = expressions.length; i < len; i += 1) { + param = expressions[i]; + if (param.type === Syntax.Identifier) { + params.push(param); + defaults.push(null); + validateParam(options, param, param.name); + } else if (param.type === Syntax.ObjectExpression || param.type === Syntax.ArrayExpression) { + reinterpretAsDestructuredParameter(options, param); + params.push(param); + defaults.push(null); + } else if (param.type === Syntax.SpreadElement) { + assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression'); + if (param.argument.type !== Syntax.Identifier) { + throwError({}, Messages.InvalidLHSInFormalsList); + } + reinterpretAsDestructuredParameter(options, param.argument); + rest = param.argument; + } else if (param.type === Syntax.AssignmentExpression) { + params.push(param.left); + defaults.push(param.right); + ++defaultCount; + validateParam(options, param.left, param.left.name); + } else { + return null; + } + } + + if (options.message === Messages.StrictParamDupe) { + throwError( + strict ? options.stricted : options.firstRestricted, + options.message + ); + } + + if (defaultCount === 0) { + defaults = []; + } + + return { + params: params, + defaults: defaults, + rest: rest, + stricted: options.stricted, + firstRestricted: options.firstRestricted, + message: options.message + }; + } + + function parseArrowFunctionExpression(options, marker) { + var previousStrict, previousYieldAllowed, previousAwaitAllowed, body; + + expect('=>'); + + previousStrict = strict; + previousYieldAllowed = state.yieldAllowed; + state.yieldAllowed = false; + previousAwaitAllowed = state.awaitAllowed; + state.awaitAllowed = !!options.async; + body = parseConciseBody(); + + if (strict && options.firstRestricted) { + throwError(options.firstRestricted, options.message); + } + if (strict && options.stricted) { + throwErrorTolerant(options.stricted, options.message); + } + + strict = previousStrict; + state.yieldAllowed = previousYieldAllowed; + state.awaitAllowed = previousAwaitAllowed; + + return markerApply(marker, delegate.createArrowFunctionExpression( + options.params, + options.defaults, + body, + options.rest, + body.type !== Syntax.BlockStatement, + !!options.async + )); + } + + function parseAssignmentExpression() { + var marker, expr, token, params, oldParenthesizedCount, + startsWithParen = false, backtrackToken = lookahead, + possiblyAsync = false; + + if (matchYield()) { + return parseYieldExpression(); + } + + if (matchAwait()) { + return parseAwaitExpression(); + } + + oldParenthesizedCount = state.parenthesizedCount; + + marker = markerCreate(); + + if (matchAsyncFuncExprOrDecl()) { + return parseFunctionExpression(); + } + + if (matchAsync()) { + // We can't be completely sure that this 'async' token is + // actually a contextual keyword modifying a function + // expression, so we might have to un-lex() it later by + // calling rewind(backtrackToken). + possiblyAsync = true; + lex(); + } + + if (match('(')) { + token = lookahead2(); + if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') { + params = parseParams(); + if (!match('=>')) { + throwUnexpected(lex()); + } + params.async = possiblyAsync; + return parseArrowFunctionExpression(params, marker); + } + startsWithParen = true; + } + + token = lookahead; + + // If the 'async' keyword is not followed by a '(' character or an + // identifier, then it can't be an arrow function modifier, and we + // should interpret it as a normal identifer. + if (possiblyAsync && !match('(') && token.type !== Token.Identifier) { + possiblyAsync = false; + rewind(backtrackToken); + } + + expr = parseConditionalExpression(); + + if (match('=>') && + (state.parenthesizedCount === oldParenthesizedCount || + state.parenthesizedCount === (oldParenthesizedCount + 1))) { + if (expr.type === Syntax.Identifier) { + params = reinterpretAsCoverFormalsList([ expr ]); + } else if (expr.type === Syntax.AssignmentExpression || + expr.type === Syntax.ArrayExpression || + expr.type === Syntax.ObjectExpression) { + if (!startsWithParen) { + throwUnexpected(lex()); + } + params = reinterpretAsCoverFormalsList([ expr ]); + } else if (expr.type === Syntax.SequenceExpression) { + params = reinterpretAsCoverFormalsList(expr.expressions); + } + if (params) { + params.async = possiblyAsync; + return parseArrowFunctionExpression(params, marker); + } + } + + // If we haven't returned by now, then the 'async' keyword was not + // a function modifier, and we should rewind and interpret it as a + // normal identifier. + if (possiblyAsync) { + possiblyAsync = false; + rewind(backtrackToken); + expr = parseConditionalExpression(); + } + + if (matchAssign()) { + // 11.13.1 + if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { + throwErrorTolerant(token, Messages.StrictLHSAssignment); + } + + // ES.next draf 11.13 Runtime Semantics step 1 + if (match('=') && (expr.type === Syntax.ObjectExpression || expr.type === Syntax.ArrayExpression)) { + reinterpretAsAssignmentBindingPattern(expr); + } else if (!isLeftHandSide(expr)) { + throwError({}, Messages.InvalidLHSInAssignment); + } + + expr = markerApply(marker, delegate.createAssignmentExpression(lex().value, expr, parseAssignmentExpression())); + } + + return expr; + } + + // 11.14 Comma Operator + + function parseExpression() { + var marker, expr, expressions, sequence, spreadFound; + + marker = markerCreate(); + expr = parseAssignmentExpression(); + expressions = [ expr ]; + + if (match(',')) { + while (index < length) { + if (!match(',')) { + break; + } + + lex(); + expr = parseSpreadOrAssignmentExpression(); + expressions.push(expr); + + if (expr.type === Syntax.SpreadElement) { + spreadFound = true; + if (!match(')')) { + throwError({}, Messages.ElementAfterSpreadElement); + } + break; + } + } + + sequence = markerApply(marker, delegate.createSequenceExpression(expressions)); + } + + if (spreadFound && lookahead2().value !== '=>') { + throwError({}, Messages.IllegalSpread); + } + + return sequence || expr; + } + + // 12.1 Block + + function parseStatementList() { + var list = [], + statement; + + while (index < length) { + if (match('}')) { + break; + } + statement = parseSourceElement(); + if (typeof statement === 'undefined') { + break; + } + list.push(statement); + } + + return list; + } + + function parseBlock() { + var block, marker = markerCreate(); + + expect('{'); + + block = parseStatementList(); + + expect('}'); + + return markerApply(marker, delegate.createBlockStatement(block)); + } + + // 12.2 Variable Statement + + function parseTypeParameterDeclaration() { + var marker = markerCreate(), paramTypes = []; + + expect('<'); + while (!match('>')) { + paramTypes.push(parseTypeAnnotatableIdentifier()); + if (!match('>')) { + expect(','); + } + } + expect('>'); + + return markerApply(marker, delegate.createTypeParameterDeclaration( + paramTypes + )); + } + + function parseTypeParameterInstantiation() { + var marker = markerCreate(), oldInType = state.inType, paramTypes = []; + + state.inType = true; + + expect('<'); + while (!match('>')) { + paramTypes.push(parseType()); + if (!match('>')) { + expect(','); + } + } + expect('>'); + + state.inType = oldInType; + + return markerApply(marker, delegate.createTypeParameterInstantiation( + paramTypes + )); + } + + function parseObjectTypeIndexer(marker, isStatic) { + var id, key, value; + + expect('['); + id = parseObjectPropertyKey(); + expect(':'); + key = parseType(); + expect(']'); + expect(':'); + value = parseType(); + + return markerApply(marker, delegate.createObjectTypeIndexer( + id, + key, + value, + isStatic + )); + } + + function parseObjectTypeMethodish(marker) { + var params = [], rest = null, returnType, typeParameters = null; + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + + expect('('); + while (lookahead.type === Token.Identifier) { + params.push(parseFunctionTypeParam()); + if (!match(')')) { + expect(','); + } + } + + if (match('...')) { + lex(); + rest = parseFunctionTypeParam(); + } + expect(')'); + expect(':'); + returnType = parseType(); + + return markerApply(marker, delegate.createFunctionTypeAnnotation( + params, + returnType, + rest, + typeParameters + )); + } + + function parseObjectTypeMethod(marker, isStatic, key) { + var optional = false, value; + value = parseObjectTypeMethodish(marker); + + return markerApply(marker, delegate.createObjectTypeProperty( + key, + value, + optional, + isStatic + )); + } + + function parseObjectTypeCallProperty(marker, isStatic) { + var valueMarker = markerCreate(); + return markerApply(marker, delegate.createObjectTypeCallProperty( + parseObjectTypeMethodish(valueMarker), + isStatic + )); + } + + function parseObjectType(allowStatic) { + var callProperties = [], indexers = [], marker, optional = false, + properties = [], propertyKey, propertyTypeAnnotation, + token, isStatic, matchStatic; + + expect('{'); + + while (!match('}')) { + marker = markerCreate(); + matchStatic = + strict + ? matchKeyword('static') + : matchContextualKeyword('static'); + + if (allowStatic && matchStatic) { + token = lex(); + isStatic = true; + } + + if (match('[')) { + indexers.push(parseObjectTypeIndexer(marker, isStatic)); + } else if (match('(') || match('<')) { + callProperties.push(parseObjectTypeCallProperty(marker, allowStatic)); + } else { + if (isStatic && match(':')) { + propertyKey = markerApply(marker, delegate.createIdentifier(token)); + throwErrorTolerant(token, Messages.StrictReservedWord); + } else { + propertyKey = parseObjectPropertyKey(); + } + if (match('<') || match('(')) { + // This is a method property + properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey)); + } else { + if (match('?')) { + lex(); + optional = true; + } + expect(':'); + propertyTypeAnnotation = parseType(); + properties.push(markerApply(marker, delegate.createObjectTypeProperty( + propertyKey, + propertyTypeAnnotation, + optional, + isStatic + ))); + } + } + + if (match(';')) { + lex(); + } else if (!match('}')) { + throwUnexpected(lookahead); + } + } + + expect('}'); + + return delegate.createObjectTypeAnnotation( + properties, + indexers, + callProperties + ); + } + + function parseGenericType() { + var marker = markerCreate(), + typeParameters = null, typeIdentifier; + + typeIdentifier = parseVariableIdentifier(); + + while (match('.')) { + expect('.'); + typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier( + typeIdentifier, + parseVariableIdentifier() + )); + } + + if (match('<')) { + typeParameters = parseTypeParameterInstantiation(); + } + + return markerApply(marker, delegate.createGenericTypeAnnotation( + typeIdentifier, + typeParameters + )); + } + + function parseVoidType() { + var marker = markerCreate(); + expectKeyword('void'); + return markerApply(marker, delegate.createVoidTypeAnnotation()); + } + + function parseTypeofType() { + var argument, marker = markerCreate(); + expectKeyword('typeof'); + argument = parsePrimaryType(); + return markerApply(marker, delegate.createTypeofTypeAnnotation( + argument + )); + } + + function parseTupleType() { + var marker = markerCreate(), types = []; + expect('['); + // We allow trailing commas + while (index < length && !match(']')) { + types.push(parseType()); + if (match(']')) { + break; + } + expect(','); + } + expect(']'); + return markerApply(marker, delegate.createTupleTypeAnnotation( + types + )); + } + + function parseFunctionTypeParam() { + var marker = markerCreate(), name, optional = false, typeAnnotation; + name = parseVariableIdentifier(); + if (match('?')) { + lex(); + optional = true; + } + expect(':'); + typeAnnotation = parseType(); + return markerApply(marker, delegate.createFunctionTypeParam( + name, + typeAnnotation, + optional + )); + } + + function parseFunctionTypeParams() { + var ret = { params: [], rest: null }; + while (lookahead.type === Token.Identifier) { + ret.params.push(parseFunctionTypeParam()); + if (!match(')')) { + expect(','); + } + } + + if (match('...')) { + lex(); + ret.rest = parseFunctionTypeParam(); + } + return ret; + } + + // The parsing of types roughly parallels the parsing of expressions, and + // primary types are kind of like primary expressions...they're the + // primitives with which other types are constructed. + function parsePrimaryType() { + var params = null, returnType = null, + marker = markerCreate(), rest = null, tmp, + typeParameters, token, type, isGroupedType = false; + + switch (lookahead.type) { + case Token.Identifier: + switch (lookahead.value) { + case 'any': + lex(); + return markerApply(marker, delegate.createAnyTypeAnnotation()); + case 'bool': // fallthrough + case 'boolean': + lex(); + return markerApply(marker, delegate.createBooleanTypeAnnotation()); + case 'number': + lex(); + return markerApply(marker, delegate.createNumberTypeAnnotation()); + case 'string': + lex(); + return markerApply(marker, delegate.createStringTypeAnnotation()); + } + return markerApply(marker, parseGenericType()); + case Token.Punctuator: + switch (lookahead.value) { + case '{': + return markerApply(marker, parseObjectType()); + case '[': + return parseTupleType(); + case '<': + typeParameters = parseTypeParameterDeclaration(); + expect('('); + tmp = parseFunctionTypeParams(); + params = tmp.params; + rest = tmp.rest; + expect(')'); + + expect('=>'); + + returnType = parseType(); + + return markerApply(marker, delegate.createFunctionTypeAnnotation( + params, + returnType, + rest, + typeParameters + )); + case '(': + lex(); + // Check to see if this is actually a grouped type + if (!match(')') && !match('...')) { + if (lookahead.type === Token.Identifier) { + token = lookahead2(); + isGroupedType = token.value !== '?' && token.value !== ':'; + } else { + isGroupedType = true; + } + } + + if (isGroupedType) { + type = parseType(); + expect(')'); + + // If we see a => next then someone was probably confused about + // function types, so we can provide a better error message + if (match('=>')) { + throwError({}, Messages.ConfusedAboutFunctionType); + } + + return type; + } + + tmp = parseFunctionTypeParams(); + params = tmp.params; + rest = tmp.rest; + + expect(')'); + + expect('=>'); + + returnType = parseType(); + + return markerApply(marker, delegate.createFunctionTypeAnnotation( + params, + returnType, + rest, + null /* typeParameters */ + )); + } + break; + case Token.Keyword: + switch (lookahead.value) { + case 'void': + return markerApply(marker, parseVoidType()); + case 'typeof': + return markerApply(marker, parseTypeofType()); + } + break; + case Token.StringLiteral: + token = lex(); + if (token.octal) { + throwError(token, Messages.StrictOctalLiteral); + } + return markerApply(marker, delegate.createStringLiteralTypeAnnotation( + token + )); + } + + throwUnexpected(lookahead); + } + + function parsePostfixType() { + var marker = markerCreate(), t = parsePrimaryType(); + if (match('[')) { + expect('['); + expect(']'); + return markerApply(marker, delegate.createArrayTypeAnnotation(t)); + } + return t; + } + + function parsePrefixType() { + var marker = markerCreate(); + if (match('?')) { + lex(); + return markerApply(marker, delegate.createNullableTypeAnnotation( + parsePrefixType() + )); + } + return parsePostfixType(); + } + + + function parseIntersectionType() { + var marker = markerCreate(), type, types; + type = parsePrefixType(); + types = [type]; + while (match('&')) { + lex(); + types.push(parsePrefixType()); + } + + return types.length === 1 ? + type : + markerApply(marker, delegate.createIntersectionTypeAnnotation( + types + )); + } + + function parseUnionType() { + var marker = markerCreate(), type, types; + type = parseIntersectionType(); + types = [type]; + while (match('|')) { + lex(); + types.push(parseIntersectionType()); + } + return types.length === 1 ? + type : + markerApply(marker, delegate.createUnionTypeAnnotation( + types + )); + } + + function parseType() { + var oldInType = state.inType, type; + state.inType = true; + + type = parseUnionType(); + + state.inType = oldInType; + return type; + } + + function parseTypeAnnotation() { + var marker = markerCreate(), type; + + expect(':'); + type = parseType(); + + return markerApply(marker, delegate.createTypeAnnotation(type)); + } + + function parseVariableIdentifier() { + var marker = markerCreate(), + token = lex(); + + if (token.type !== Token.Identifier) { + throwUnexpected(token); + } + + return markerApply(marker, delegate.createIdentifier(token.value)); + } + + function parseTypeAnnotatableIdentifier(requireTypeAnnotation, canBeOptionalParam) { + var marker = markerCreate(), + ident = parseVariableIdentifier(), + isOptionalParam = false; + + if (canBeOptionalParam && match('?')) { + expect('?'); + isOptionalParam = true; + } + + if (requireTypeAnnotation || match(':')) { + ident.typeAnnotation = parseTypeAnnotation(); + ident = markerApply(marker, ident); + } + + if (isOptionalParam) { + ident.optional = true; + ident = markerApply(marker, ident); + } + + return ident; + } + + function parseVariableDeclaration(kind) { + var id, + marker = markerCreate(), + init = null, + typeAnnotationMarker = markerCreate(); + if (match('{')) { + id = parseObjectInitialiser(); + reinterpretAsAssignmentBindingPattern(id); + if (match(':')) { + id.typeAnnotation = parseTypeAnnotation(); + markerApply(typeAnnotationMarker, id); + } + } else if (match('[')) { + id = parseArrayInitialiser(); + reinterpretAsAssignmentBindingPattern(id); + if (match(':')) { + id.typeAnnotation = parseTypeAnnotation(); + markerApply(typeAnnotationMarker, id); + } + } else { + /* istanbul ignore next */ + id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier(); + // 12.2.1 + if (strict && isRestrictedWord(id.name)) { + throwErrorTolerant({}, Messages.StrictVarName); + } + } + + if (kind === 'const') { + if (!match('=')) { + throwError({}, Messages.NoUninitializedConst); + } + expect('='); + init = parseAssignmentExpression(); + } else if (match('=')) { + lex(); + init = parseAssignmentExpression(); + } + + return markerApply(marker, delegate.createVariableDeclarator(id, init)); + } + + function parseVariableDeclarationList(kind) { + var list = []; + + do { + list.push(parseVariableDeclaration(kind)); + if (!match(',')) { + break; + } + lex(); + } while (index < length); + + return list; + } + + function parseVariableStatement() { + var declarations, marker = markerCreate(); + + expectKeyword('var'); + + declarations = parseVariableDeclarationList(); + + consumeSemicolon(); + + return markerApply(marker, delegate.createVariableDeclaration(declarations, 'var')); + } + + // kind may be `const` or `let` + // Both are experimental and not in the specification yet. + // see http://wiki.ecmascript.org/doku.php?id=harmony:const + // and http://wiki.ecmascript.org/doku.php?id=harmony:let + function parseConstLetDeclaration(kind) { + var declarations, marker = markerCreate(); + + expectKeyword(kind); + + declarations = parseVariableDeclarationList(kind); + + consumeSemicolon(); + + return markerApply(marker, delegate.createVariableDeclaration(declarations, kind)); + } + + // people.mozilla.org/~jorendorff/es6-draft.html + + function parseModuleSpecifier() { + var marker = markerCreate(), + specifier; + + if (lookahead.type !== Token.StringLiteral) { + throwError({}, Messages.InvalidModuleSpecifier); + } + specifier = delegate.createModuleSpecifier(lookahead); + lex(); + return markerApply(marker, specifier); + } + + function parseExportBatchSpecifier() { + var marker = markerCreate(); + expect('*'); + return markerApply(marker, delegate.createExportBatchSpecifier()); + } + + function parseExportSpecifier() { + var id, name = null, marker = markerCreate(), from; + if (matchKeyword('default')) { + lex(); + id = markerApply(marker, delegate.createIdentifier('default')); + // export {default} from "something"; + } else { + id = parseVariableIdentifier(); + } + if (matchContextualKeyword('as')) { + lex(); + name = parseNonComputedProperty(); + } + + return markerApply(marker, delegate.createExportSpecifier(id, name)); + } + + function parseExportDeclaration() { + var declaration = null, + possibleIdentifierToken, sourceElement, + isExportFromIdentifier, + src = null, specifiers = [], + marker = markerCreate(); + + expectKeyword('export'); + + if (matchKeyword('default')) { + // covers: + // export default ... + lex(); + if (matchKeyword('function') || matchKeyword('class')) { + possibleIdentifierToken = lookahead2(); + if (isIdentifierName(possibleIdentifierToken)) { + // covers: + // export default function foo () {} + // export default class foo {} + sourceElement = parseSourceElement(); + return markerApply(marker, delegate.createExportDeclaration(true, sourceElement, [sourceElement.id], null)); + } + // covers: + // export default function () {} + // export default class {} + switch (lookahead.value) { + case 'class': + return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null)); + case 'function': + return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null)); + } + } + + if (matchContextualKeyword('from')) { + throwError({}, Messages.UnexpectedToken, lookahead.value); + } + + // covers: + // export default {}; + // export default []; + if (match('{')) { + declaration = parseObjectInitialiser(); + } else if (match('[')) { + declaration = parseArrayInitialiser(); + } else { + declaration = parseAssignmentExpression(); + } + consumeSemicolon(); + return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null)); + } + + // non-default export + if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) { + // covers: + // export var f = 1; + switch (lookahead.value) { + case 'type': + case 'let': + case 'const': + case 'var': + case 'class': + case 'function': + return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null)); + } + } + + if (match('*')) { + // covers: + // export * from "foo"; + specifiers.push(parseExportBatchSpecifier()); + + if (!matchContextualKeyword('from')) { + throwError({}, lookahead.value ? + Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); + } + lex(); + src = parseModuleSpecifier(); + consumeSemicolon(); + + return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src)); + } + + expect('{'); + if (!match('}')) { + do { + isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default'); + specifiers.push(parseExportSpecifier()); + } while (match(',') && lex()); + } + expect('}'); + + if (matchContextualKeyword('from')) { + // covering: + // export {default} from "foo"; + // export {foo} from "foo"; + lex(); + src = parseModuleSpecifier(); + consumeSemicolon(); + } else if (isExportFromIdentifier) { + // covering: + // export {default}; // missing fromClause + throwError({}, lookahead.value ? + Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); + } else { + // cover + // export {foo}; + consumeSemicolon(); + } + return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src)); + } + + + function parseImportSpecifier() { + // import {} ...; + var id, name = null, marker = markerCreate(); + + id = parseNonComputedProperty(); + if (matchContextualKeyword('as')) { + lex(); + name = parseVariableIdentifier(); + } + + return markerApply(marker, delegate.createImportSpecifier(id, name)); + } + + function parseNamedImports() { + var specifiers = []; + // {foo, bar as bas} + expect('{'); + if (!match('}')) { + do { + specifiers.push(parseImportSpecifier()); + } while (match(',') && lex()); + } + expect('}'); + return specifiers; + } + + function parseImportDefaultSpecifier() { + // import ...; + var id, marker = markerCreate(); + + id = parseNonComputedProperty(); + + return markerApply(marker, delegate.createImportDefaultSpecifier(id)); + } + + function parseImportNamespaceSpecifier() { + // import <* as foo> ...; + var id, marker = markerCreate(); + + expect('*'); + if (!matchContextualKeyword('as')) { + throwError({}, Messages.NoAsAfterImportNamespace); + } + lex(); + id = parseNonComputedProperty(); + + return markerApply(marker, delegate.createImportNamespaceSpecifier(id)); + } + + function parseImportDeclaration() { + var specifiers, src, marker = markerCreate(), isType = false, token2; + + expectKeyword('import'); + + if (matchContextualKeyword('type')) { + token2 = lookahead2(); + if ((token2.type === Token.Identifier && token2.value !== 'from') || + (token2.type === Token.Punctuator && + (token2.value === '{' || token2.value === '*'))) { + isType = true; + lex(); + } + } + + specifiers = []; + + if (lookahead.type === Token.StringLiteral) { + // covers: + // import "foo"; + src = parseModuleSpecifier(); + consumeSemicolon(); + return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType)); + } + + if (!matchKeyword('default') && isIdentifierName(lookahead)) { + // covers: + // import foo + // import foo, ... + specifiers.push(parseImportDefaultSpecifier()); + if (match(',')) { + lex(); + } + } + if (match('*')) { + // covers: + // import foo, * as foo + // import * as foo + specifiers.push(parseImportNamespaceSpecifier()); + } else if (match('{')) { + // covers: + // import foo, {bar} + // import {bar} + specifiers = specifiers.concat(parseNamedImports()); + } + + if (!matchContextualKeyword('from')) { + throwError({}, lookahead.value ? + Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); + } + lex(); + src = parseModuleSpecifier(); + consumeSemicolon(); + + return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType)); + } + + // 12.3 Empty Statement + + function parseEmptyStatement() { + var marker = markerCreate(); + expect(';'); + return markerApply(marker, delegate.createEmptyStatement()); + } + + // 12.4 Expression Statement + + function parseExpressionStatement() { + var marker = markerCreate(), expr = parseExpression(); + consumeSemicolon(); + return markerApply(marker, delegate.createExpressionStatement(expr)); + } + + // 12.5 If statement + + function parseIfStatement() { + var test, consequent, alternate, marker = markerCreate(); + + expectKeyword('if'); + + expect('('); + + test = parseExpression(); + + expect(')'); + + consequent = parseStatement(); + + if (matchKeyword('else')) { + lex(); + alternate = parseStatement(); + } else { + alternate = null; + } + + return markerApply(marker, delegate.createIfStatement(test, consequent, alternate)); + } + + // 12.6 Iteration Statements + + function parseDoWhileStatement() { + var body, test, oldInIteration, marker = markerCreate(); + + expectKeyword('do'); + + oldInIteration = state.inIteration; + state.inIteration = true; + + body = parseStatement(); + + state.inIteration = oldInIteration; + + expectKeyword('while'); + + expect('('); + + test = parseExpression(); + + expect(')'); + + if (match(';')) { + lex(); + } + + return markerApply(marker, delegate.createDoWhileStatement(body, test)); + } + + function parseWhileStatement() { + var test, body, oldInIteration, marker = markerCreate(); + + expectKeyword('while'); + + expect('('); + + test = parseExpression(); + + expect(')'); + + oldInIteration = state.inIteration; + state.inIteration = true; + + body = parseStatement(); + + state.inIteration = oldInIteration; + + return markerApply(marker, delegate.createWhileStatement(test, body)); + } + + function parseForVariableDeclaration() { + var marker = markerCreate(), + token = lex(), + declarations = parseVariableDeclarationList(); + + return markerApply(marker, delegate.createVariableDeclaration(declarations, token.value)); + } + + function parseForStatement(opts) { + var init, test, update, left, right, body, operator, oldInIteration, + marker = markerCreate(); + init = test = update = null; + expectKeyword('for'); + + // http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators&s=each + if (matchContextualKeyword('each')) { + throwError({}, Messages.EachNotAllowed); + } + + expect('('); + + if (match(';')) { + lex(); + } else { + if (matchKeyword('var') || matchKeyword('let') || matchKeyword('const')) { + state.allowIn = false; + init = parseForVariableDeclaration(); + state.allowIn = true; + + if (init.declarations.length === 1) { + if (matchKeyword('in') || matchContextualKeyword('of')) { + operator = lookahead; + if (!((operator.value === 'in' || init.kind !== 'var') && init.declarations[0].init)) { + lex(); + left = init; + right = parseExpression(); + init = null; + } + } + } + } else { + state.allowIn = false; + init = parseExpression(); + state.allowIn = true; + + if (matchContextualKeyword('of')) { + operator = lex(); + left = init; + right = parseExpression(); + init = null; + } else if (matchKeyword('in')) { + // LeftHandSideExpression + if (!isAssignableLeftHandSide(init)) { + throwError({}, Messages.InvalidLHSInForIn); + } + operator = lex(); + left = init; + right = parseExpression(); + init = null; + } + } + + if (typeof left === 'undefined') { + expect(';'); + } + } + + if (typeof left === 'undefined') { + + if (!match(';')) { + test = parseExpression(); + } + expect(';'); + + if (!match(')')) { + update = parseExpression(); + } + } + + expect(')'); + + oldInIteration = state.inIteration; + state.inIteration = true; + + if (!(opts !== undefined && opts.ignoreBody)) { + body = parseStatement(); + } + + state.inIteration = oldInIteration; + + if (typeof left === 'undefined') { + return markerApply(marker, delegate.createForStatement(init, test, update, body)); + } + + if (operator.value === 'in') { + return markerApply(marker, delegate.createForInStatement(left, right, body)); + } + return markerApply(marker, delegate.createForOfStatement(left, right, body)); + } + + // 12.7 The continue statement + + function parseContinueStatement() { + var label = null, marker = markerCreate(); + + expectKeyword('continue'); + + // Optimize the most common form: 'continue;'. + if (source.charCodeAt(index) === 59) { + lex(); + + if (!state.inIteration) { + throwError({}, Messages.IllegalContinue); + } + + return markerApply(marker, delegate.createContinueStatement(null)); + } + + if (peekLineTerminator()) { + if (!state.inIteration) { + throwError({}, Messages.IllegalContinue); + } + + return markerApply(marker, delegate.createContinueStatement(null)); + } + + if (lookahead.type === Token.Identifier) { + label = parseVariableIdentifier(); + + if (!state.labelSet.has(label.name)) { + throwError({}, Messages.UnknownLabel, label.name); + } + } + + consumeSemicolon(); + + if (label === null && !state.inIteration) { + throwError({}, Messages.IllegalContinue); + } + + return markerApply(marker, delegate.createContinueStatement(label)); + } + + // 12.8 The break statement + + function parseBreakStatement() { + var label = null, marker = markerCreate(); + + expectKeyword('break'); + + // Catch the very common case first: immediately a semicolon (char #59). + if (source.charCodeAt(index) === 59) { + lex(); + + if (!(state.inIteration || state.inSwitch)) { + throwError({}, Messages.IllegalBreak); + } + + return markerApply(marker, delegate.createBreakStatement(null)); + } + + if (peekLineTerminator()) { + if (!(state.inIteration || state.inSwitch)) { + throwError({}, Messages.IllegalBreak); + } + + return markerApply(marker, delegate.createBreakStatement(null)); + } + + if (lookahead.type === Token.Identifier) { + label = parseVariableIdentifier(); + + if (!state.labelSet.has(label.name)) { + throwError({}, Messages.UnknownLabel, label.name); + } + } + + consumeSemicolon(); + + if (label === null && !(state.inIteration || state.inSwitch)) { + throwError({}, Messages.IllegalBreak); + } + + return markerApply(marker, delegate.createBreakStatement(label)); + } + + // 12.9 The return statement + + function parseReturnStatement() { + var argument = null, marker = markerCreate(); + + expectKeyword('return'); + + if (!state.inFunctionBody) { + throwErrorTolerant({}, Messages.IllegalReturn); + } + + // 'return' followed by a space and an identifier is very common. + if (source.charCodeAt(index) === 32) { + if (isIdentifierStart(source.charCodeAt(index + 1))) { + argument = parseExpression(); + consumeSemicolon(); + return markerApply(marker, delegate.createReturnStatement(argument)); + } + } + + if (peekLineTerminator()) { + return markerApply(marker, delegate.createReturnStatement(null)); + } + + if (!match(';')) { + if (!match('}') && lookahead.type !== Token.EOF) { + argument = parseExpression(); + } + } + + consumeSemicolon(); + + return markerApply(marker, delegate.createReturnStatement(argument)); + } + + // 12.10 The with statement + + function parseWithStatement() { + var object, body, marker = markerCreate(); + + if (strict) { + throwErrorTolerant({}, Messages.StrictModeWith); + } + + expectKeyword('with'); + + expect('('); + + object = parseExpression(); + + expect(')'); + + body = parseStatement(); + + return markerApply(marker, delegate.createWithStatement(object, body)); + } + + // 12.10 The swith statement + + function parseSwitchCase() { + var test, + consequent = [], + sourceElement, + marker = markerCreate(); + + if (matchKeyword('default')) { + lex(); + test = null; + } else { + expectKeyword('case'); + test = parseExpression(); + } + expect(':'); + + while (index < length) { + if (match('}') || matchKeyword('default') || matchKeyword('case')) { + break; + } + sourceElement = parseSourceElement(); + if (typeof sourceElement === 'undefined') { + break; + } + consequent.push(sourceElement); + } + + return markerApply(marker, delegate.createSwitchCase(test, consequent)); + } + + function parseSwitchStatement() { + var discriminant, cases, clause, oldInSwitch, defaultFound, marker = markerCreate(); + + expectKeyword('switch'); + + expect('('); + + discriminant = parseExpression(); + + expect(')'); + + expect('{'); + + cases = []; + + if (match('}')) { + lex(); + return markerApply(marker, delegate.createSwitchStatement(discriminant, cases)); + } + + oldInSwitch = state.inSwitch; + state.inSwitch = true; + defaultFound = false; + + while (index < length) { + if (match('}')) { + break; + } + clause = parseSwitchCase(); + if (clause.test === null) { + if (defaultFound) { + throwError({}, Messages.MultipleDefaultsInSwitch); + } + defaultFound = true; + } + cases.push(clause); + } + + state.inSwitch = oldInSwitch; + + expect('}'); + + return markerApply(marker, delegate.createSwitchStatement(discriminant, cases)); + } + + // 12.13 The throw statement + + function parseThrowStatement() { + var argument, marker = markerCreate(); + + expectKeyword('throw'); + + if (peekLineTerminator()) { + throwError({}, Messages.NewlineAfterThrow); + } + + argument = parseExpression(); + + consumeSemicolon(); + + return markerApply(marker, delegate.createThrowStatement(argument)); + } + + // 12.14 The try statement + + function parseCatchClause() { + var param, body, marker = markerCreate(); + + expectKeyword('catch'); + + expect('('); + if (match(')')) { + throwUnexpected(lookahead); + } + + param = parseExpression(); + // 12.14.1 + if (strict && param.type === Syntax.Identifier && isRestrictedWord(param.name)) { + throwErrorTolerant({}, Messages.StrictCatchVariable); + } + + expect(')'); + body = parseBlock(); + return markerApply(marker, delegate.createCatchClause(param, body)); + } + + function parseTryStatement() { + var block, handlers = [], finalizer = null, marker = markerCreate(); + + expectKeyword('try'); + + block = parseBlock(); + + if (matchKeyword('catch')) { + handlers.push(parseCatchClause()); + } + + if (matchKeyword('finally')) { + lex(); + finalizer = parseBlock(); + } + + if (handlers.length === 0 && !finalizer) { + throwError({}, Messages.NoCatchOrFinally); + } + + return markerApply(marker, delegate.createTryStatement(block, [], handlers, finalizer)); + } + + // 12.15 The debugger statement + + function parseDebuggerStatement() { + var marker = markerCreate(); + expectKeyword('debugger'); + + consumeSemicolon(); + + return markerApply(marker, delegate.createDebuggerStatement()); + } + + // 12 Statements + + function parseStatement() { + var type = lookahead.type, + marker, + expr, + labeledBody; + + if (type === Token.EOF) { + throwUnexpected(lookahead); + } + + if (type === Token.Punctuator) { + switch (lookahead.value) { + case ';': + return parseEmptyStatement(); + case '{': + return parseBlock(); + case '(': + return parseExpressionStatement(); + default: + break; + } + } + + if (type === Token.Keyword) { + switch (lookahead.value) { + case 'break': + return parseBreakStatement(); + case 'continue': + return parseContinueStatement(); + case 'debugger': + return parseDebuggerStatement(); + case 'do': + return parseDoWhileStatement(); + case 'for': + return parseForStatement(); + case 'function': + return parseFunctionDeclaration(); + case 'class': + return parseClassDeclaration(); + case 'if': + return parseIfStatement(); + case 'return': + return parseReturnStatement(); + case 'switch': + return parseSwitchStatement(); + case 'throw': + return parseThrowStatement(); + case 'try': + return parseTryStatement(); + case 'var': + return parseVariableStatement(); + case 'while': + return parseWhileStatement(); + case 'with': + return parseWithStatement(); + default: + break; + } + } + + if (matchAsyncFuncExprOrDecl()) { + return parseFunctionDeclaration(); + } + + marker = markerCreate(); + expr = parseExpression(); + + // 12.12 Labelled Statements + if ((expr.type === Syntax.Identifier) && match(':')) { + lex(); + + if (state.labelSet.has(expr.name)) { + throwError({}, Messages.Redeclaration, 'Label', expr.name); + } + + state.labelSet.set(expr.name, true); + labeledBody = parseStatement(); + state.labelSet["delete"](expr.name); + return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody)); + } + + consumeSemicolon(); + + return markerApply(marker, delegate.createExpressionStatement(expr)); + } + + // 13 Function Definition + + function parseConciseBody() { + if (match('{')) { + return parseFunctionSourceElements(); + } + return parseAssignmentExpression(); + } + + function parseFunctionSourceElements() { + var sourceElement, sourceElements = [], token, directive, firstRestricted, + oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, oldParenthesizedCount, + marker = markerCreate(); + + expect('{'); + + while (index < length) { + if (lookahead.type !== Token.StringLiteral) { + break; + } + token = lookahead; + + sourceElement = parseSourceElement(); + sourceElements.push(sourceElement); + if (sourceElement.expression.type !== Syntax.Literal) { + // this is not directive + break; + } + directive = source.slice(token.range[0] + 1, token.range[1] - 1); + if (directive === 'use strict') { + strict = true; + if (firstRestricted) { + throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); + } + } else { + if (!firstRestricted && token.octal) { + firstRestricted = token; + } + } + } + + oldLabelSet = state.labelSet; + oldInIteration = state.inIteration; + oldInSwitch = state.inSwitch; + oldInFunctionBody = state.inFunctionBody; + oldParenthesizedCount = state.parenthesizedCount; + + state.labelSet = new StringMap(); + state.inIteration = false; + state.inSwitch = false; + state.inFunctionBody = true; + state.parenthesizedCount = 0; + + while (index < length) { + if (match('}')) { + break; + } + sourceElement = parseSourceElement(); + if (typeof sourceElement === 'undefined') { + break; + } + sourceElements.push(sourceElement); + } + + expect('}'); + + state.labelSet = oldLabelSet; + state.inIteration = oldInIteration; + state.inSwitch = oldInSwitch; + state.inFunctionBody = oldInFunctionBody; + state.parenthesizedCount = oldParenthesizedCount; + + return markerApply(marker, delegate.createBlockStatement(sourceElements)); + } + + function validateParam(options, param, name) { + if (strict) { + if (isRestrictedWord(name)) { + options.stricted = param; + options.message = Messages.StrictParamName; + } + if (options.paramSet.has(name)) { + options.stricted = param; + options.message = Messages.StrictParamDupe; + } + } else if (!options.firstRestricted) { + if (isRestrictedWord(name)) { + options.firstRestricted = param; + options.message = Messages.StrictParamName; + } else if (isStrictModeReservedWord(name)) { + options.firstRestricted = param; + options.message = Messages.StrictReservedWord; + } else if (options.paramSet.has(name)) { + options.firstRestricted = param; + options.message = Messages.StrictParamDupe; + } + } + options.paramSet.set(name, true); + } + + function parseParam(options) { + var marker, token, rest, param, def; + + token = lookahead; + if (token.value === '...') { + token = lex(); + rest = true; + } + + if (match('[')) { + marker = markerCreate(); + param = parseArrayInitialiser(); + reinterpretAsDestructuredParameter(options, param); + if (match(':')) { + param.typeAnnotation = parseTypeAnnotation(); + markerApply(marker, param); + } + } else if (match('{')) { + marker = markerCreate(); + if (rest) { + throwError({}, Messages.ObjectPatternAsRestParameter); + } + param = parseObjectInitialiser(); + reinterpretAsDestructuredParameter(options, param); + if (match(':')) { + param.typeAnnotation = parseTypeAnnotation(); + markerApply(marker, param); + } + } else { + param = + rest + ? parseTypeAnnotatableIdentifier( + false, /* requireTypeAnnotation */ + false /* canBeOptionalParam */ + ) + : parseTypeAnnotatableIdentifier( + false, /* requireTypeAnnotation */ + true /* canBeOptionalParam */ + ); + + validateParam(options, token, token.value); + } + + if (match('=')) { + if (rest) { + throwErrorTolerant(lookahead, Messages.DefaultRestParameter); + } + lex(); + def = parseAssignmentExpression(); + ++options.defaultCount; + } + + if (rest) { + if (!match(')')) { + throwError({}, Messages.ParameterAfterRestParameter); + } + options.rest = param; + return false; + } + + options.params.push(param); + options.defaults.push(def); + return !match(')'); + } + + function parseParams(firstRestricted) { + var options, marker = markerCreate(); + + options = { + params: [], + defaultCount: 0, + defaults: [], + rest: null, + firstRestricted: firstRestricted + }; + + expect('('); + + if (!match(')')) { + options.paramSet = new StringMap(); + while (index < length) { + if (!parseParam(options)) { + break; + } + expect(','); + } + } + + expect(')'); + + if (options.defaultCount === 0) { + options.defaults = []; + } + + if (match(':')) { + options.returnType = parseTypeAnnotation(); + } + + return markerApply(marker, options); + } + + function parseFunctionDeclaration() { + var id, body, token, tmp, firstRestricted, message, generator, isAsync, + previousStrict, previousYieldAllowed, previousAwaitAllowed, + marker = markerCreate(), typeParameters; + + isAsync = false; + if (matchAsync()) { + lex(); + isAsync = true; + } + + expectKeyword('function'); + + generator = false; + if (match('*')) { + lex(); + generator = true; + } + + token = lookahead; + + id = parseVariableIdentifier(); + + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + + if (strict) { + if (isRestrictedWord(token.value)) { + throwErrorTolerant(token, Messages.StrictFunctionName); + } + } else { + if (isRestrictedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictFunctionName; + } else if (isStrictModeReservedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictReservedWord; + } + } + + tmp = parseParams(firstRestricted); + firstRestricted = tmp.firstRestricted; + if (tmp.message) { + message = tmp.message; + } + + previousStrict = strict; + previousYieldAllowed = state.yieldAllowed; + state.yieldAllowed = generator; + previousAwaitAllowed = state.awaitAllowed; + state.awaitAllowed = isAsync; + + body = parseFunctionSourceElements(); + + if (strict && firstRestricted) { + throwError(firstRestricted, message); + } + if (strict && tmp.stricted) { + throwErrorTolerant(tmp.stricted, message); + } + strict = previousStrict; + state.yieldAllowed = previousYieldAllowed; + state.awaitAllowed = previousAwaitAllowed; + + return markerApply( + marker, + delegate.createFunctionDeclaration( + id, + tmp.params, + tmp.defaults, + body, + tmp.rest, + generator, + false, + isAsync, + tmp.returnType, + typeParameters + ) + ); + } + + function parseFunctionExpression() { + var token, id = null, firstRestricted, message, tmp, body, generator, isAsync, + previousStrict, previousYieldAllowed, previousAwaitAllowed, + marker = markerCreate(), typeParameters; + + isAsync = false; + if (matchAsync()) { + lex(); + isAsync = true; + } + + expectKeyword('function'); + + generator = false; + + if (match('*')) { + lex(); + generator = true; + } + + if (!match('(')) { + if (!match('<')) { + token = lookahead; + id = parseVariableIdentifier(); + + if (strict) { + if (isRestrictedWord(token.value)) { + throwErrorTolerant(token, Messages.StrictFunctionName); + } + } else { + if (isRestrictedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictFunctionName; + } else if (isStrictModeReservedWord(token.value)) { + firstRestricted = token; + message = Messages.StrictReservedWord; + } + } + } + + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + } + + tmp = parseParams(firstRestricted); + firstRestricted = tmp.firstRestricted; + if (tmp.message) { + message = tmp.message; + } + + previousStrict = strict; + previousYieldAllowed = state.yieldAllowed; + state.yieldAllowed = generator; + previousAwaitAllowed = state.awaitAllowed; + state.awaitAllowed = isAsync; + + body = parseFunctionSourceElements(); + + if (strict && firstRestricted) { + throwError(firstRestricted, message); + } + if (strict && tmp.stricted) { + throwErrorTolerant(tmp.stricted, message); + } + strict = previousStrict; + state.yieldAllowed = previousYieldAllowed; + state.awaitAllowed = previousAwaitAllowed; + + return markerApply( + marker, + delegate.createFunctionExpression( + id, + tmp.params, + tmp.defaults, + body, + tmp.rest, + generator, + false, + isAsync, + tmp.returnType, + typeParameters + ) + ); + } + + function parseYieldExpression() { + var delegateFlag, expr, marker = markerCreate(); + + expectKeyword('yield', !strict); + + delegateFlag = false; + if (match('*')) { + lex(); + delegateFlag = true; + } + + expr = parseAssignmentExpression(); + + return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag)); + } + + function parseAwaitExpression() { + var expr, marker = markerCreate(); + expectContextualKeyword('await'); + expr = parseAssignmentExpression(); + return markerApply(marker, delegate.createAwaitExpression(expr)); + } + + // 14 Functions and classes + + // 14.1 Functions is defined above (13 in ES5) + // 14.2 Arrow Functions Definitions is defined in (7.3 assignments) + + // 14.3 Method Definitions + // 14.3.7 + function specialMethod(methodDefinition) { + return methodDefinition.kind === 'get' || + methodDefinition.kind === 'set' || + methodDefinition.value.generator; + } + + function parseMethodDefinition(key, isStatic, generator, computed) { + var token, param, propType, + isAsync, typeParameters, tokenValue, returnType; + + propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype; + + if (generator) { + return delegate.createMethodDefinition( + propType, + '', + key, + parsePropertyMethodFunction({ generator: true }), + computed + ); + } + + tokenValue = key.type === 'Identifier' && key.name; + + if (tokenValue === 'get' && !match('(')) { + key = parseObjectPropertyKey(); + + expect('('); + expect(')'); + if (match(':')) { + returnType = parseTypeAnnotation(); + } + return delegate.createMethodDefinition( + propType, + 'get', + key, + parsePropertyFunction({ generator: false, returnType: returnType }), + computed + ); + } + if (tokenValue === 'set' && !match('(')) { + key = parseObjectPropertyKey(); + + expect('('); + token = lookahead; + param = [ parseTypeAnnotatableIdentifier() ]; + expect(')'); + if (match(':')) { + returnType = parseTypeAnnotation(); + } + return delegate.createMethodDefinition( + propType, + 'set', + key, + parsePropertyFunction({ + params: param, + generator: false, + name: token, + returnType: returnType + }), + computed + ); + } + + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + + isAsync = tokenValue === 'async' && !match('('); + if (isAsync) { + key = parseObjectPropertyKey(); + } + + return delegate.createMethodDefinition( + propType, + '', + key, + parsePropertyMethodFunction({ + generator: false, + async: isAsync, + typeParameters: typeParameters + }), + computed + ); + } + + function parseClassProperty(key, computed, isStatic) { + var typeAnnotation; + + typeAnnotation = parseTypeAnnotation(); + expect(';'); + + return delegate.createClassProperty( + key, + typeAnnotation, + computed, + isStatic + ); + } + + function parseClassElement() { + var computed = false, generator = false, key, marker = markerCreate(), + isStatic = false, possiblyOpenBracketToken; + if (match(';')) { + lex(); + return undefined; + } + + if (lookahead.value === 'static') { + lex(); + isStatic = true; + } + + if (match('*')) { + lex(); + generator = true; + } + + possiblyOpenBracketToken = lookahead; + if (matchContextualKeyword('get') || matchContextualKeyword('set')) { + possiblyOpenBracketToken = lookahead2(); + } + + if (possiblyOpenBracketToken.type === Token.Punctuator + && possiblyOpenBracketToken.value === '[') { + computed = true; + } + + key = parseObjectPropertyKey(); + + if (!generator && lookahead.value === ':') { + return markerApply(marker, parseClassProperty(key, computed, isStatic)); + } + + return markerApply(marker, parseMethodDefinition( + key, + isStatic, + generator, + computed + )); + } + + function parseClassBody() { + var classElement, classElements = [], existingProps = {}, + marker = markerCreate(), propName, propType; + + existingProps[ClassPropertyType["static"]] = new StringMap(); + existingProps[ClassPropertyType.prototype] = new StringMap(); + + expect('{'); + + while (index < length) { + if (match('}')) { + break; + } + classElement = parseClassElement(existingProps); + + if (typeof classElement !== 'undefined') { + classElements.push(classElement); + + propName = !classElement.computed && getFieldName(classElement.key); + if (propName !== false) { + propType = classElement["static"] ? + ClassPropertyType["static"] : + ClassPropertyType.prototype; + + if (classElement.type === Syntax.MethodDefinition) { + if (propName === 'constructor' && !classElement["static"]) { + if (specialMethod(classElement)) { + throwError(classElement, Messages.IllegalClassConstructorProperty); + } + if (existingProps[ClassPropertyType.prototype].has('constructor')) { + throwError(classElement.key, Messages.IllegalDuplicateClassProperty); + } + } + existingProps[propType].set(propName, true); + } + } + } + } + + expect('}'); + + return markerApply(marker, delegate.createClassBody(classElements)); + } + + function parseClassImplements() { + var id, implemented = [], marker, typeParameters; + if (strict) { + expectKeyword('implements'); + } else { + expectContextualKeyword('implements'); + } + while (index < length) { + marker = markerCreate(); + id = parseVariableIdentifier(); + if (match('<')) { + typeParameters = parseTypeParameterInstantiation(); + } else { + typeParameters = null; + } + implemented.push(markerApply(marker, delegate.createClassImplements( + id, + typeParameters + ))); + if (!match(',')) { + break; + } + expect(','); + } + return implemented; + } + + function parseClassExpression() { + var id, implemented, previousYieldAllowed, superClass = null, + superTypeParameters, marker = markerCreate(), typeParameters, + matchImplements; + + expectKeyword('class'); + + matchImplements = + strict + ? matchKeyword('implements') + : matchContextualKeyword('implements'); + + if (!matchKeyword('extends') && !matchImplements && !match('{')) { + id = parseVariableIdentifier(); + } + + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + + if (matchKeyword('extends')) { + expectKeyword('extends'); + previousYieldAllowed = state.yieldAllowed; + state.yieldAllowed = false; + superClass = parseLeftHandSideExpressionAllowCall(); + if (match('<')) { + superTypeParameters = parseTypeParameterInstantiation(); + } + state.yieldAllowed = previousYieldAllowed; + } + + if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) { + implemented = parseClassImplements(); + } + + return markerApply(marker, delegate.createClassExpression( + id, + superClass, + parseClassBody(), + typeParameters, + superTypeParameters, + implemented + )); + } + + function parseClassDeclaration() { + var id, implemented, previousYieldAllowed, superClass = null, + superTypeParameters, marker = markerCreate(), typeParameters; + + expectKeyword('class'); + + id = parseVariableIdentifier(); + + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + + if (matchKeyword('extends')) { + expectKeyword('extends'); + previousYieldAllowed = state.yieldAllowed; + state.yieldAllowed = false; + superClass = parseLeftHandSideExpressionAllowCall(); + if (match('<')) { + superTypeParameters = parseTypeParameterInstantiation(); + } + state.yieldAllowed = previousYieldAllowed; + } + + if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) { + implemented = parseClassImplements(); + } + + return markerApply(marker, delegate.createClassDeclaration( + id, + superClass, + parseClassBody(), + typeParameters, + superTypeParameters, + implemented + )); + } + + // 15 Program + + function parseSourceElement() { + var token; + if (lookahead.type === Token.Keyword) { + switch (lookahead.value) { + case 'const': + case 'let': + return parseConstLetDeclaration(lookahead.value); + case 'function': + return parseFunctionDeclaration(); + case 'export': + throwErrorTolerant({}, Messages.IllegalExportDeclaration); + return parseExportDeclaration(); + case 'import': + throwErrorTolerant({}, Messages.IllegalImportDeclaration); + return parseImportDeclaration(); + case 'interface': + if (lookahead2().type === Token.Identifier) { + return parseInterface(); + } + return parseStatement(); + default: + return parseStatement(); + } + } + + if (matchContextualKeyword('type') + && lookahead2().type === Token.Identifier) { + return parseTypeAlias(); + } + + if (matchContextualKeyword('interface') + && lookahead2().type === Token.Identifier) { + return parseInterface(); + } + + if (matchContextualKeyword('declare')) { + token = lookahead2(); + if (token.type === Token.Keyword) { + switch (token.value) { + case 'class': + return parseDeclareClass(); + case 'function': + return parseDeclareFunction(); + case 'var': + return parseDeclareVariable(); + } + } else if (token.type === Token.Identifier + && token.value === 'module') { + return parseDeclareModule(); + } + } + + if (lookahead.type !== Token.EOF) { + return parseStatement(); + } + } + + function parseProgramElement() { + var isModule = extra.sourceType === 'module' || extra.sourceType === 'nonStrictModule'; + + if (isModule && lookahead.type === Token.Keyword) { + switch (lookahead.value) { + case 'export': + return parseExportDeclaration(); + case 'import': + return parseImportDeclaration(); + } + } + + return parseSourceElement(); + } + + function parseProgramElements() { + var sourceElement, sourceElements = [], token, directive, firstRestricted; + + while (index < length) { + token = lookahead; + if (token.type !== Token.StringLiteral) { + break; + } + + sourceElement = parseProgramElement(); + sourceElements.push(sourceElement); + if (sourceElement.expression.type !== Syntax.Literal) { + // this is not directive + break; + } + directive = source.slice(token.range[0] + 1, token.range[1] - 1); + if (directive === 'use strict') { + strict = true; + if (firstRestricted) { + throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); + } + } else { + if (!firstRestricted && token.octal) { + firstRestricted = token; + } + } + } + + while (index < length) { + sourceElement = parseProgramElement(); + if (typeof sourceElement === 'undefined') { + break; + } + sourceElements.push(sourceElement); + } + return sourceElements; + } + + function parseProgram() { + var body, marker = markerCreate(); + strict = extra.sourceType === 'module'; + peek(); + body = parseProgramElements(); + return markerApply(marker, delegate.createProgram(body)); + } + + // 16 JSX + + XHTMLEntities = { + quot: '\u0022', + amp: '&', + apos: '\u0027', + lt: '<', + gt: '>', + nbsp: '\u00A0', + iexcl: '\u00A1', + cent: '\u00A2', + pound: '\u00A3', + curren: '\u00A4', + yen: '\u00A5', + brvbar: '\u00A6', + sect: '\u00A7', + uml: '\u00A8', + copy: '\u00A9', + ordf: '\u00AA', + laquo: '\u00AB', + not: '\u00AC', + shy: '\u00AD', + reg: '\u00AE', + macr: '\u00AF', + deg: '\u00B0', + plusmn: '\u00B1', + sup2: '\u00B2', + sup3: '\u00B3', + acute: '\u00B4', + micro: '\u00B5', + para: '\u00B6', + middot: '\u00B7', + cedil: '\u00B8', + sup1: '\u00B9', + ordm: '\u00BA', + raquo: '\u00BB', + frac14: '\u00BC', + frac12: '\u00BD', + frac34: '\u00BE', + iquest: '\u00BF', + Agrave: '\u00C0', + Aacute: '\u00C1', + Acirc: '\u00C2', + Atilde: '\u00C3', + Auml: '\u00C4', + Aring: '\u00C5', + AElig: '\u00C6', + Ccedil: '\u00C7', + Egrave: '\u00C8', + Eacute: '\u00C9', + Ecirc: '\u00CA', + Euml: '\u00CB', + Igrave: '\u00CC', + Iacute: '\u00CD', + Icirc: '\u00CE', + Iuml: '\u00CF', + ETH: '\u00D0', + Ntilde: '\u00D1', + Ograve: '\u00D2', + Oacute: '\u00D3', + Ocirc: '\u00D4', + Otilde: '\u00D5', + Ouml: '\u00D6', + times: '\u00D7', + Oslash: '\u00D8', + Ugrave: '\u00D9', + Uacute: '\u00DA', + Ucirc: '\u00DB', + Uuml: '\u00DC', + Yacute: '\u00DD', + THORN: '\u00DE', + szlig: '\u00DF', + agrave: '\u00E0', + aacute: '\u00E1', + acirc: '\u00E2', + atilde: '\u00E3', + auml: '\u00E4', + aring: '\u00E5', + aelig: '\u00E6', + ccedil: '\u00E7', + egrave: '\u00E8', + eacute: '\u00E9', + ecirc: '\u00EA', + euml: '\u00EB', + igrave: '\u00EC', + iacute: '\u00ED', + icirc: '\u00EE', + iuml: '\u00EF', + eth: '\u00F0', + ntilde: '\u00F1', + ograve: '\u00F2', + oacute: '\u00F3', + ocirc: '\u00F4', + otilde: '\u00F5', + ouml: '\u00F6', + divide: '\u00F7', + oslash: '\u00F8', + ugrave: '\u00F9', + uacute: '\u00FA', + ucirc: '\u00FB', + uuml: '\u00FC', + yacute: '\u00FD', + thorn: '\u00FE', + yuml: '\u00FF', + OElig: '\u0152', + oelig: '\u0153', + Scaron: '\u0160', + scaron: '\u0161', + Yuml: '\u0178', + fnof: '\u0192', + circ: '\u02C6', + tilde: '\u02DC', + Alpha: '\u0391', + Beta: '\u0392', + Gamma: '\u0393', + Delta: '\u0394', + Epsilon: '\u0395', + Zeta: '\u0396', + Eta: '\u0397', + Theta: '\u0398', + Iota: '\u0399', + Kappa: '\u039A', + Lambda: '\u039B', + Mu: '\u039C', + Nu: '\u039D', + Xi: '\u039E', + Omicron: '\u039F', + Pi: '\u03A0', + Rho: '\u03A1', + Sigma: '\u03A3', + Tau: '\u03A4', + Upsilon: '\u03A5', + Phi: '\u03A6', + Chi: '\u03A7', + Psi: '\u03A8', + Omega: '\u03A9', + alpha: '\u03B1', + beta: '\u03B2', + gamma: '\u03B3', + delta: '\u03B4', + epsilon: '\u03B5', + zeta: '\u03B6', + eta: '\u03B7', + theta: '\u03B8', + iota: '\u03B9', + kappa: '\u03BA', + lambda: '\u03BB', + mu: '\u03BC', + nu: '\u03BD', + xi: '\u03BE', + omicron: '\u03BF', + pi: '\u03C0', + rho: '\u03C1', + sigmaf: '\u03C2', + sigma: '\u03C3', + tau: '\u03C4', + upsilon: '\u03C5', + phi: '\u03C6', + chi: '\u03C7', + psi: '\u03C8', + omega: '\u03C9', + thetasym: '\u03D1', + upsih: '\u03D2', + piv: '\u03D6', + ensp: '\u2002', + emsp: '\u2003', + thinsp: '\u2009', + zwnj: '\u200C', + zwj: '\u200D', + lrm: '\u200E', + rlm: '\u200F', + ndash: '\u2013', + mdash: '\u2014', + lsquo: '\u2018', + rsquo: '\u2019', + sbquo: '\u201A', + ldquo: '\u201C', + rdquo: '\u201D', + bdquo: '\u201E', + dagger: '\u2020', + Dagger: '\u2021', + bull: '\u2022', + hellip: '\u2026', + permil: '\u2030', + prime: '\u2032', + Prime: '\u2033', + lsaquo: '\u2039', + rsaquo: '\u203A', + oline: '\u203E', + frasl: '\u2044', + euro: '\u20AC', + image: '\u2111', + weierp: '\u2118', + real: '\u211C', + trade: '\u2122', + alefsym: '\u2135', + larr: '\u2190', + uarr: '\u2191', + rarr: '\u2192', + darr: '\u2193', + harr: '\u2194', + crarr: '\u21B5', + lArr: '\u21D0', + uArr: '\u21D1', + rArr: '\u21D2', + dArr: '\u21D3', + hArr: '\u21D4', + forall: '\u2200', + part: '\u2202', + exist: '\u2203', + empty: '\u2205', + nabla: '\u2207', + isin: '\u2208', + notin: '\u2209', + ni: '\u220B', + prod: '\u220F', + sum: '\u2211', + minus: '\u2212', + lowast: '\u2217', + radic: '\u221A', + prop: '\u221D', + infin: '\u221E', + ang: '\u2220', + and: '\u2227', + or: '\u2228', + cap: '\u2229', + cup: '\u222A', + 'int': '\u222B', + there4: '\u2234', + sim: '\u223C', + cong: '\u2245', + asymp: '\u2248', + ne: '\u2260', + equiv: '\u2261', + le: '\u2264', + ge: '\u2265', + sub: '\u2282', + sup: '\u2283', + nsub: '\u2284', + sube: '\u2286', + supe: '\u2287', + oplus: '\u2295', + otimes: '\u2297', + perp: '\u22A5', + sdot: '\u22C5', + lceil: '\u2308', + rceil: '\u2309', + lfloor: '\u230A', + rfloor: '\u230B', + lang: '\u2329', + rang: '\u232A', + loz: '\u25CA', + spades: '\u2660', + clubs: '\u2663', + hearts: '\u2665', + diams: '\u2666' + }; + + function getQualifiedJSXName(object) { + if (object.type === Syntax.JSXIdentifier) { + return object.name; + } + if (object.type === Syntax.JSXNamespacedName) { + return object.namespace.name + ':' + object.name.name; + } + /* istanbul ignore else */ + if (object.type === Syntax.JSXMemberExpression) { + return ( + getQualifiedJSXName(object.object) + '.' + + getQualifiedJSXName(object.property) + ); + } + /* istanbul ignore next */ + throwUnexpected(object); + } + + function isJSXIdentifierStart(ch) { + // exclude backslash (\) + return (ch !== 92) && isIdentifierStart(ch); + } + + function isJSXIdentifierPart(ch) { + // exclude backslash (\) and add hyphen (-) + return (ch !== 92) && (ch === 45 || isIdentifierPart(ch)); + } + + function scanJSXIdentifier() { + var ch, start, value = ''; + + start = index; + while (index < length) { + ch = source.charCodeAt(index); + if (!isJSXIdentifierPart(ch)) { + break; + } + value += source[index++]; + } + + return { + type: Token.JSXIdentifier, + value: value, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + function scanJSXEntity() { + var ch, str = '', start = index, count = 0, code; + ch = source[index]; + assert(ch === '&', 'Entity must start with an ampersand'); + index++; + while (index < length && count++ < 10) { + ch = source[index++]; + if (ch === ';') { + break; + } + str += ch; + } + + // Well-formed entity (ending was found). + if (ch === ';') { + // Numeric entity. + if (str[0] === '#') { + if (str[1] === 'x') { + code = +('0' + str.substr(1)); + } else { + // Removing leading zeros in order to avoid treating as octal in old browsers. + code = +str.substr(1).replace(Regex.LeadingZeros, ''); + } + + if (!isNaN(code)) { + return String.fromCharCode(code); + } + /* istanbul ignore else */ + } else if (XHTMLEntities[str]) { + return XHTMLEntities[str]; + } + } + + // Treat non-entity sequences as regular text. + index = start + 1; + return '&'; + } + + function scanJSXText(stopChars) { + var ch, str = '', start; + start = index; + while (index < length) { + ch = source[index]; + if (stopChars.indexOf(ch) !== -1) { + break; + } + if (ch === '&') { + str += scanJSXEntity(); + } else { + index++; + if (ch === '\r' && source[index] === '\n') { + str += ch; + ch = source[index]; + index++; + } + if (isLineTerminator(ch.charCodeAt(0))) { + ++lineNumber; + lineStart = index; + } + str += ch; + } + } + return { + type: Token.JSXText, + value: str, + lineNumber: lineNumber, + lineStart: lineStart, + range: [start, index] + }; + } + + function scanJSXStringLiteral() { + var innerToken, quote, start; + + quote = source[index]; + assert((quote === '\'' || quote === '"'), + 'String literal must starts with a quote'); + + start = index; + ++index; + + innerToken = scanJSXText([quote]); + + if (quote !== source[index]) { + throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); + } + + ++index; + + innerToken.range = [start, index]; + + return innerToken; + } + + /** + * Between JSX opening and closing tags (e.g. HERE), anything that + * is not another JSX tag and is not an expression wrapped by {} is text. + */ + function advanceJSXChild() { + var ch = source.charCodeAt(index); + + // '<' 60, '>' 62, '{' 123, '}' 125 + if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) { + return scanJSXText(['<', '>', '{', '}']); + } + + return scanPunctuator(); + } + + function parseJSXIdentifier() { + var token, marker = markerCreate(); + + if (lookahead.type !== Token.JSXIdentifier) { + throwUnexpected(lookahead); + } + + token = lex(); + return markerApply(marker, delegate.createJSXIdentifier(token.value)); + } + + function parseJSXNamespacedName() { + var namespace, name, marker = markerCreate(); + + namespace = parseJSXIdentifier(); + expect(':'); + name = parseJSXIdentifier(); + + return markerApply(marker, delegate.createJSXNamespacedName(namespace, name)); + } + + function parseJSXMemberExpression() { + var marker = markerCreate(), + expr = parseJSXIdentifier(); + + while (match('.')) { + lex(); + expr = markerApply(marker, delegate.createJSXMemberExpression(expr, parseJSXIdentifier())); + } + + return expr; + } + + function parseJSXElementName() { + if (lookahead2().value === ':') { + return parseJSXNamespacedName(); + } + if (lookahead2().value === '.') { + return parseJSXMemberExpression(); + } + + return parseJSXIdentifier(); + } + + function parseJSXAttributeName() { + if (lookahead2().value === ':') { + return parseJSXNamespacedName(); + } + + return parseJSXIdentifier(); + } + + function parseJSXAttributeValue() { + var value, marker; + if (match('{')) { + value = parseJSXExpressionContainer(); + if (value.expression.type === Syntax.JSXEmptyExpression) { + throwError( + value, + 'JSX attributes must only be assigned a non-empty ' + + 'expression' + ); + } + } else if (match('<')) { + value = parseJSXElement(); + } else if (lookahead.type === Token.JSXText) { + marker = markerCreate(); + value = markerApply(marker, delegate.createLiteral(lex())); + } else { + throwError({}, Messages.InvalidJSXAttributeValue); + } + return value; + } + + function parseJSXEmptyExpression() { + var marker = markerCreatePreserveWhitespace(); + while (source.charAt(index) !== '}') { + index++; + } + return markerApply(marker, delegate.createJSXEmptyExpression()); + } + + function parseJSXExpressionContainer() { + var expression, origInJSXChild, origInJSXTag, marker = markerCreate(); + + origInJSXChild = state.inJSXChild; + origInJSXTag = state.inJSXTag; + state.inJSXChild = false; + state.inJSXTag = false; + + expect('{'); + + if (match('}')) { + expression = parseJSXEmptyExpression(); + } else { + expression = parseExpression(); + } + + state.inJSXChild = origInJSXChild; + state.inJSXTag = origInJSXTag; + + expect('}'); + + return markerApply(marker, delegate.createJSXExpressionContainer(expression)); + } + + function parseJSXSpreadAttribute() { + var expression, origInJSXChild, origInJSXTag, marker = markerCreate(); + + origInJSXChild = state.inJSXChild; + origInJSXTag = state.inJSXTag; + state.inJSXChild = false; + state.inJSXTag = false; + + expect('{'); + expect('...'); + + expression = parseAssignmentExpression(); + + state.inJSXChild = origInJSXChild; + state.inJSXTag = origInJSXTag; + + expect('}'); + + return markerApply(marker, delegate.createJSXSpreadAttribute(expression)); + } + + function parseJSXAttribute() { + var name, marker; + + if (match('{')) { + return parseJSXSpreadAttribute(); + } + + marker = markerCreate(); + + name = parseJSXAttributeName(); + + // HTML empty attribute + if (match('=')) { + lex(); + return markerApply(marker, delegate.createJSXAttribute(name, parseJSXAttributeValue())); + } + + return markerApply(marker, delegate.createJSXAttribute(name)); + } + + function parseJSXChild() { + var token, marker; + if (match('{')) { + token = parseJSXExpressionContainer(); + } else if (lookahead.type === Token.JSXText) { + marker = markerCreatePreserveWhitespace(); + token = markerApply(marker, delegate.createLiteral(lex())); + } else if (match('<')) { + token = parseJSXElement(); + } else { + throwUnexpected(lookahead); + } + return token; + } + + function parseJSXClosingElement() { + var name, origInJSXChild, origInJSXTag, marker = markerCreate(); + origInJSXChild = state.inJSXChild; + origInJSXTag = state.inJSXTag; + state.inJSXChild = false; + state.inJSXTag = true; + expect('<'); + expect('/'); + name = parseJSXElementName(); + // Because advance() (called by lex() called by expect()) expects there + // to be a valid token after >, it needs to know whether to look for a + // standard JS token or an JSX text node + state.inJSXChild = origInJSXChild; + state.inJSXTag = origInJSXTag; + expect('>'); + return markerApply(marker, delegate.createJSXClosingElement(name)); + } + + function parseJSXOpeningElement() { + var name, attributes = [], selfClosing = false, origInJSXChild, origInJSXTag, marker = markerCreate(); + + origInJSXChild = state.inJSXChild; + origInJSXTag = state.inJSXTag; + state.inJSXChild = false; + state.inJSXTag = true; + + expect('<'); + + name = parseJSXElementName(); + + while (index < length && + lookahead.value !== '/' && + lookahead.value !== '>') { + attributes.push(parseJSXAttribute()); + } + + state.inJSXTag = origInJSXTag; + + if (lookahead.value === '/') { + expect('/'); + // Because advance() (called by lex() called by expect()) expects + // there to be a valid token after >, it needs to know whether to + // look for a standard JS token or an JSX text node + state.inJSXChild = origInJSXChild; + expect('>'); + selfClosing = true; + } else { + state.inJSXChild = true; + expect('>'); + } + return markerApply(marker, delegate.createJSXOpeningElement(name, attributes, selfClosing)); + } + + function parseJSXElement() { + var openingElement, closingElement = null, children = [], origInJSXChild, origInJSXTag, marker = markerCreate(); + + origInJSXChild = state.inJSXChild; + origInJSXTag = state.inJSXTag; + openingElement = parseJSXOpeningElement(); + + if (!openingElement.selfClosing) { + while (index < length) { + state.inJSXChild = false; // Call lookahead2() with inJSXChild = false because one
two
; + // + // the default error message is a bit incomprehensible. Since it's + // rarely (never?) useful to write a less-than sign after an JSX + // element, we disallow it here in the parser in order to provide a + // better error message. (In the rare case that the less-than operator + // was intended, the left tag can be wrapped in parentheses.) + if (!origInJSXChild && match('<')) { + throwError(lookahead, Messages.AdjacentJSXElements); + } + + return markerApply(marker, delegate.createJSXElement(openingElement, closingElement, children)); + } + + function parseTypeAlias() { + var id, marker = markerCreate(), typeParameters = null, right; + expectContextualKeyword('type'); + id = parseVariableIdentifier(); + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + expect('='); + right = parseType(); + consumeSemicolon(); + return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right)); + } + + function parseInterfaceExtends() { + var marker = markerCreate(), id, typeParameters = null; + + id = parseVariableIdentifier(); + if (match('<')) { + typeParameters = parseTypeParameterInstantiation(); + } + + return markerApply(marker, delegate.createInterfaceExtends( + id, + typeParameters + )); + } + + function parseInterfaceish(marker, allowStatic) { + var body, bodyMarker, extended = [], id, + typeParameters = null; + + id = parseVariableIdentifier(); + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + + if (matchKeyword('extends')) { + expectKeyword('extends'); + + while (index < length) { + extended.push(parseInterfaceExtends()); + if (!match(',')) { + break; + } + expect(','); + } + } + + bodyMarker = markerCreate(); + body = markerApply(bodyMarker, parseObjectType(allowStatic)); + + return markerApply(marker, delegate.createInterface( + id, + typeParameters, + body, + extended + )); + } + + function parseInterface() { + var marker = markerCreate(); + + if (strict) { + expectKeyword('interface'); + } else { + expectContextualKeyword('interface'); + } + + return parseInterfaceish(marker, /* allowStatic */false); + } + + function parseDeclareClass() { + var marker = markerCreate(), ret; + expectContextualKeyword('declare'); + expectKeyword('class'); + + ret = parseInterfaceish(marker, /* allowStatic */true); + ret.type = Syntax.DeclareClass; + return ret; + } + + function parseDeclareFunction() { + var id, idMarker, + marker = markerCreate(), params, returnType, rest, tmp, + typeParameters = null, value, valueMarker; + + expectContextualKeyword('declare'); + expectKeyword('function'); + idMarker = markerCreate(); + id = parseVariableIdentifier(); + + valueMarker = markerCreate(); + if (match('<')) { + typeParameters = parseTypeParameterDeclaration(); + } + expect('('); + tmp = parseFunctionTypeParams(); + params = tmp.params; + rest = tmp.rest; + expect(')'); + + expect(':'); + returnType = parseType(); + + value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation( + params, + returnType, + rest, + typeParameters + )); + + id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation( + value + )); + markerApply(idMarker, id); + + consumeSemicolon(); + + return markerApply(marker, delegate.createDeclareFunction( + id + )); + } + + function parseDeclareVariable() { + var id, marker = markerCreate(); + expectContextualKeyword('declare'); + expectKeyword('var'); + id = parseTypeAnnotatableIdentifier(); + + consumeSemicolon(); + + return markerApply(marker, delegate.createDeclareVariable( + id + )); + } + + function parseDeclareModule() { + var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token; + expectContextualKeyword('declare'); + expectContextualKeyword('module'); + + if (lookahead.type === Token.StringLiteral) { + if (strict && lookahead.octal) { + throwErrorTolerant(lookahead, Messages.StrictOctalLiteral); + } + idMarker = markerCreate(); + id = markerApply(idMarker, delegate.createLiteral(lex())); + } else { + id = parseVariableIdentifier(); + } + + bodyMarker = markerCreate(); + expect('{'); + while (index < length && !match('}')) { + token = lookahead2(); + switch (token.value) { + case 'class': + body.push(parseDeclareClass()); + break; + case 'function': + body.push(parseDeclareFunction()); + break; + case 'var': + body.push(parseDeclareVariable()); + break; + default: + throwUnexpected(lookahead); + } + } + expect('}'); + + return markerApply(marker, delegate.createDeclareModule( + id, + markerApply(bodyMarker, delegate.createBlockStatement(body)) + )); + } + + function collectToken() { + var loc, token, range, value, entry; + + /* istanbul ignore else */ + if (!state.inJSXChild) { + skipComment(); + } + + loc = { + start: { + line: lineNumber, + column: index - lineStart + } + }; + + token = extra.advance(); + loc.end = { + line: lineNumber, + column: index - lineStart + }; + + if (token.type !== Token.EOF) { + range = [token.range[0], token.range[1]]; + value = source.slice(token.range[0], token.range[1]); + entry = { + type: TokenName[token.type], + value: value, + range: range, + loc: loc + }; + if (token.regex) { + entry.regex = { + pattern: token.regex.pattern, + flags: token.regex.flags + }; + } + extra.tokens.push(entry); + } + + return token; + } + + function collectRegex() { + var pos, loc, regex, token; + + skipComment(); + + pos = index; + loc = { + start: { + line: lineNumber, + column: index - lineStart + } + }; + + regex = extra.scanRegExp(); + loc.end = { + line: lineNumber, + column: index - lineStart + }; + + if (!extra.tokenize) { + /* istanbul ignore next */ + // Pop the previous token, which is likely '/' or '/=' + if (extra.tokens.length > 0) { + token = extra.tokens[extra.tokens.length - 1]; + if (token.range[0] === pos && token.type === 'Punctuator') { + if (token.value === '/' || token.value === '/=') { + extra.tokens.pop(); + } + } + } + + extra.tokens.push({ + type: 'RegularExpression', + value: regex.literal, + regex: regex.regex, + range: [pos, index], + loc: loc + }); + } + + return regex; + } + + function filterTokenLocation() { + var i, entry, token, tokens = []; + + for (i = 0; i < extra.tokens.length; ++i) { + entry = extra.tokens[i]; + token = { + type: entry.type, + value: entry.value + }; + if (entry.regex) { + token.regex = { + pattern: entry.regex.pattern, + flags: entry.regex.flags + }; + } + if (extra.range) { + token.range = entry.range; + } + if (extra.loc) { + token.loc = entry.loc; + } + tokens.push(token); + } + + extra.tokens = tokens; + } + + function patch() { + if (typeof extra.tokens !== 'undefined') { + extra.advance = advance; + extra.scanRegExp = scanRegExp; + + advance = collectToken; + scanRegExp = collectRegex; + } + } + + function unpatch() { + if (typeof extra.scanRegExp === 'function') { + advance = extra.advance; + scanRegExp = extra.scanRegExp; + } + } + + // This is used to modify the delegate. + + function extend(object, properties) { + var entry, result = {}; + + for (entry in object) { + /* istanbul ignore else */ + if (object.hasOwnProperty(entry)) { + result[entry] = object[entry]; + } + } + + for (entry in properties) { + /* istanbul ignore else */ + if (properties.hasOwnProperty(entry)) { + result[entry] = properties[entry]; + } + } + + return result; + } + + function tokenize(code, options) { + var toString, + token, + tokens; + + toString = String; + if (typeof code !== 'string' && !(code instanceof String)) { + code = toString(code); + } + + delegate = SyntaxTreeDelegate; + source = code; + index = 0; + lineNumber = (source.length > 0) ? 1 : 0; + lineStart = 0; + length = source.length; + lookahead = null; + state = { + allowKeyword: true, + allowIn: true, + labelSet: new StringMap(), + inFunctionBody: false, + inIteration: false, + inSwitch: false, + lastCommentStart: -1 + }; + + extra = {}; + + // Options matching. + options = options || {}; + + // Of course we collect tokens here. + options.tokens = true; + extra.tokens = []; + extra.tokenize = true; + // The following two fields are necessary to compute the Regex tokens. + extra.openParenToken = -1; + extra.openCurlyToken = -1; + + extra.range = (typeof options.range === 'boolean') && options.range; + extra.loc = (typeof options.loc === 'boolean') && options.loc; + + if (typeof options.comment === 'boolean' && options.comment) { + extra.comments = []; + } + if (typeof options.tolerant === 'boolean' && options.tolerant) { + extra.errors = []; + } + + patch(); + + try { + peek(); + if (lookahead.type === Token.EOF) { + return extra.tokens; + } + + token = lex(); + while (lookahead.type !== Token.EOF) { + try { + token = lex(); + } catch (lexError) { + token = lookahead; + if (extra.errors) { + extra.errors.push(lexError); + // We have to break on the first error + // to avoid infinite loops. + break; + } else { + throw lexError; + } + } + } + + filterTokenLocation(); + tokens = extra.tokens; + if (typeof extra.comments !== 'undefined') { + tokens.comments = extra.comments; + } + if (typeof extra.errors !== 'undefined') { + tokens.errors = extra.errors; + } + } catch (e) { + throw e; + } finally { + unpatch(); + extra = {}; + } + return tokens; + } + + function parse(code, options) { + var program, toString; + + toString = String; + if (typeof code !== 'string' && !(code instanceof String)) { + code = toString(code); + } + + delegate = SyntaxTreeDelegate; + source = code; + index = 0; + lineNumber = (source.length > 0) ? 1 : 0; + lineStart = 0; + length = source.length; + lookahead = null; + state = { + allowKeyword: false, + allowIn: true, + labelSet: new StringMap(), + parenthesizedCount: 0, + inFunctionBody: false, + inIteration: false, + inSwitch: false, + inJSXChild: false, + inJSXTag: false, + inType: false, + lastCommentStart: -1, + yieldAllowed: false, + awaitAllowed: false + }; + + extra = {}; + if (typeof options !== 'undefined') { + extra.range = (typeof options.range === 'boolean') && options.range; + extra.loc = (typeof options.loc === 'boolean') && options.loc; + extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; + + if (extra.loc && options.source !== null && options.source !== undefined) { + delegate = extend(delegate, { + 'postProcess': function (node) { + node.loc.source = toString(options.source); + return node; + } + }); + } + + extra.sourceType = options.sourceType; + if (typeof options.tokens === 'boolean' && options.tokens) { + extra.tokens = []; + } + if (typeof options.comment === 'boolean' && options.comment) { + extra.comments = []; + } + if (typeof options.tolerant === 'boolean' && options.tolerant) { + extra.errors = []; + } + if (extra.attachComment) { + extra.range = true; + extra.comments = []; + extra.bottomRightStack = []; + extra.trailingComments = []; + extra.leadingComments = []; + } + } + + patch(); + try { + program = parseProgram(); + if (typeof extra.comments !== 'undefined') { + program.comments = extra.comments; + } + if (typeof extra.tokens !== 'undefined') { + filterTokenLocation(); + program.tokens = extra.tokens; + } + if (typeof extra.errors !== 'undefined') { + program.errors = extra.errors; + } + } catch (e) { + throw e; + } finally { + unpatch(); + extra = {}; + } + + return program; + } + + // Sync with *.json manifests. + exports.version = '13001.1001.0-dev-harmony-fb'; + + exports.tokenize = tokenize; + + exports.parse = parse; + + // Deep copy. + /* istanbul ignore next */ + exports.Syntax = (function () { + var name, types = {}; + + if (typeof Object.create === 'function') { + types = Object.create(null); + } + + for (name in Syntax) { + if (Syntax.hasOwnProperty(name)) { + types[name] = Syntax[name]; + } + } + + if (typeof Object.freeze === 'function') { + Object.freeze(types); + } + + return types; + }()); + +})); +/* vim: set sw=4 ts=4 et tw=80 : */ + +},{}],10:[function(_dereq_,module,exports){ +var Base62 = (function (my) { + my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] + + my.encode = function(i){ + if (i === 0) {return '0'} + var s = '' + while (i > 0) { + s = this.chars[i % 62] + s + i = Math.floor(i/62) + } + return s + }; + my.decode = function(a,b,c,d){ + for ( + b = c = ( + a === (/\W|_|^$/.test(a += "") || a) + ) - 1; + d = a.charCodeAt(c++); + ) + b = b * 62 + d - [, 48, 29, 87][d >> 5]; + return b + }; + + return my; +}({})); + +module.exports = Base62 +},{}],11:[function(_dereq_,module,exports){ +/* + * Copyright 2009-2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE.txt or: + * http://opensource.org/licenses/BSD-3-Clause + */ +exports.SourceMapGenerator = _dereq_('./source-map/source-map-generator').SourceMapGenerator; +exports.SourceMapConsumer = _dereq_('./source-map/source-map-consumer').SourceMapConsumer; +exports.SourceNode = _dereq_('./source-map/source-node').SourceNode; + +},{"./source-map/source-map-consumer":16,"./source-map/source-map-generator":17,"./source-map/source-node":18}],12:[function(_dereq_,module,exports){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = _dereq_('amdefine')(module, _dereq_); +} +define(function (_dereq_, exports, module) { + + var util = _dereq_('./util'); + + /** + * A data structure which is a combination of an array and a set. Adding a new + * member is O(1), testing for membership is O(1), and finding the index of an + * element is O(1). Removing elements from the set is not supported. Only + * strings are supported for membership. + */ + function ArraySet() { + this._array = []; + this._set = {}; + } + + /** + * Static method for creating ArraySet instances from an existing array. + */ + ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { + var set = new ArraySet(); + for (var i = 0, len = aArray.length; i < len; i++) { + set.add(aArray[i], aAllowDuplicates); + } + return set; + }; + + /** + * Add the given string to this set. + * + * @param String aStr + */ + ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { + var isDuplicate = this.has(aStr); + var idx = this._array.length; + if (!isDuplicate || aAllowDuplicates) { + this._array.push(aStr); + } + if (!isDuplicate) { + this._set[util.toSetString(aStr)] = idx; + } + }; + + /** + * Is the given string a member of this set? + * + * @param String aStr + */ + ArraySet.prototype.has = function ArraySet_has(aStr) { + return Object.prototype.hasOwnProperty.call(this._set, + util.toSetString(aStr)); + }; + + /** + * What is the index of the given string in the array? + * + * @param String aStr + */ + ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { + if (this.has(aStr)) { + return this._set[util.toSetString(aStr)]; + } + throw new Error('"' + aStr + '" is not in the set.'); + }; + + /** + * What is the element at the given index? + * + * @param Number aIdx + */ + ArraySet.prototype.at = function ArraySet_at(aIdx) { + if (aIdx >= 0 && aIdx < this._array.length) { + return this._array[aIdx]; + } + throw new Error('No element indexed by ' + aIdx); + }; + + /** + * Returns the array representation of this set (which has the proper indices + * indicated by indexOf). Note that this is a copy of the internal array used + * for storing the members so that no one can mess with internal state. + */ + ArraySet.prototype.toArray = function ArraySet_toArray() { + return this._array.slice(); + }; + + exports.ArraySet = ArraySet; + +}); + +},{"./util":19,"amdefine":20}],13:[function(_dereq_,module,exports){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + * + * Based on the Base 64 VLQ implementation in Closure Compiler: + * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java + * + * Copyright 2011 The Closure Compiler Authors. All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +if (typeof define !== 'function') { + var define = _dereq_('amdefine')(module, _dereq_); +} +define(function (_dereq_, exports, module) { + + var base64 = _dereq_('./base64'); + + // A single base 64 digit can contain 6 bits of data. For the base 64 variable + // length quantities we use in the source map spec, the first bit is the sign, + // the next four bits are the actual value, and the 6th bit is the + // continuation bit. The continuation bit tells us whether there are more + // digits in this value following this digit. + // + // Continuation + // | Sign + // | | + // V V + // 101011 + + var VLQ_BASE_SHIFT = 5; + + // binary: 100000 + var VLQ_BASE = 1 << VLQ_BASE_SHIFT; + + // binary: 011111 + var VLQ_BASE_MASK = VLQ_BASE - 1; + + // binary: 100000 + var VLQ_CONTINUATION_BIT = VLQ_BASE; + + /** + * Converts from a two-complement value to a value where the sign bit is + * is placed in the least significant bit. For example, as decimals: + * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) + * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) + */ + function toVLQSigned(aValue) { + return aValue < 0 + ? ((-aValue) << 1) + 1 + : (aValue << 1) + 0; + } + + /** + * Converts to a two-complement value from a value where the sign bit is + * is placed in the least significant bit. For example, as decimals: + * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 + * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 + */ + function fromVLQSigned(aValue) { + var isNegative = (aValue & 1) === 1; + var shifted = aValue >> 1; + return isNegative + ? -shifted + : shifted; + } + + /** + * Returns the base 64 VLQ encoded value. + */ + exports.encode = function base64VLQ_encode(aValue) { + var encoded = ""; + var digit; + + var vlq = toVLQSigned(aValue); + + do { + digit = vlq & VLQ_BASE_MASK; + vlq >>>= VLQ_BASE_SHIFT; + if (vlq > 0) { + // There are still more digits in this value, so we must make sure the + // continuation bit is marked. + digit |= VLQ_CONTINUATION_BIT; + } + encoded += base64.encode(digit); + } while (vlq > 0); + + return encoded; + }; + + /** + * Decodes the next base 64 VLQ value from the given string and returns the + * value and the rest of the string. + */ + exports.decode = function base64VLQ_decode(aStr) { + var i = 0; + var strLen = aStr.length; + var result = 0; + var shift = 0; + var continuation, digit; + + do { + if (i >= strLen) { + throw new Error("Expected more digits in base 64 VLQ value."); + } + digit = base64.decode(aStr.charAt(i++)); + continuation = !!(digit & VLQ_CONTINUATION_BIT); + digit &= VLQ_BASE_MASK; + result = result + (digit << shift); + shift += VLQ_BASE_SHIFT; + } while (continuation); + + return { + value: fromVLQSigned(result), + rest: aStr.slice(i) + }; + }; + +}); + +},{"./base64":14,"amdefine":20}],14:[function(_dereq_,module,exports){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = _dereq_('amdefine')(module, _dereq_); +} +define(function (_dereq_, exports, module) { + + var charToIntMap = {}; + var intToCharMap = {}; + + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' + .split('') + .forEach(function (ch, index) { + charToIntMap[ch] = index; + intToCharMap[index] = ch; + }); + + /** + * Encode an integer in the range of 0 to 63 to a single base 64 digit. + */ + exports.encode = function base64_encode(aNumber) { + if (aNumber in intToCharMap) { + return intToCharMap[aNumber]; + } + throw new TypeError("Must be between 0 and 63: " + aNumber); + }; + + /** + * Decode a single base 64 digit to an integer. + */ + exports.decode = function base64_decode(aChar) { + if (aChar in charToIntMap) { + return charToIntMap[aChar]; + } + throw new TypeError("Not a valid base 64 digit: " + aChar); + }; + +}); + +},{"amdefine":20}],15:[function(_dereq_,module,exports){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = _dereq_('amdefine')(module, _dereq_); +} +define(function (_dereq_, exports, module) { + + /** + * Recursive implementation of binary search. + * + * @param aLow Indices here and lower do not contain the needle. + * @param aHigh Indices here and higher do not contain the needle. + * @param aNeedle The element being searched for. + * @param aHaystack The non-empty array being searched. + * @param aCompare Function which takes two elements and returns -1, 0, or 1. + */ + function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) { + // This function terminates when one of the following is true: + // + // 1. We find the exact element we are looking for. + // + // 2. We did not find the exact element, but we can return the next + // closest element that is less than that element. + // + // 3. We did not find the exact element, and there is no next-closest + // element which is less than the one we are searching for, so we + // return null. + var mid = Math.floor((aHigh - aLow) / 2) + aLow; + var cmp = aCompare(aNeedle, aHaystack[mid], true); + if (cmp === 0) { + // Found the element we are looking for. + return aHaystack[mid]; + } + else if (cmp > 0) { + // aHaystack[mid] is greater than our needle. + if (aHigh - mid > 1) { + // The element is in the upper half. + return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare); + } + // We did not find an exact match, return the next closest one + // (termination case 2). + return aHaystack[mid]; + } + else { + // aHaystack[mid] is less than our needle. + if (mid - aLow > 1) { + // The element is in the lower half. + return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare); + } + // The exact needle element was not found in this haystack. Determine if + // we are in termination case (2) or (3) and return the appropriate thing. + return aLow < 0 + ? null + : aHaystack[aLow]; + } + } + + /** + * This is an implementation of binary search which will always try and return + * the next lowest value checked if there is no exact hit. This is because + * mappings between original and generated line/col pairs are single points, + * and there is an implicit region between each of them, so a miss just means + * that you aren't on the very start of a region. + * + * @param aNeedle The element you are looking for. + * @param aHaystack The array that is being searched. + * @param aCompare A function which takes the needle and an element in the + * array and returns -1, 0, or 1 depending on whether the needle is less + * than, equal to, or greater than the element, respectively. + */ + exports.search = function search(aNeedle, aHaystack, aCompare) { + return aHaystack.length > 0 + ? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare) + : null; + }; + +}); + +},{"amdefine":20}],16:[function(_dereq_,module,exports){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = _dereq_('amdefine')(module, _dereq_); +} +define(function (_dereq_, exports, module) { + + var util = _dereq_('./util'); + var binarySearch = _dereq_('./binary-search'); + var ArraySet = _dereq_('./array-set').ArraySet; + var base64VLQ = _dereq_('./base64-vlq'); + + /** + * A SourceMapConsumer instance represents a parsed source map which we can + * query for information about the original file positions by giving it a file + * position in the generated source. + * + * The only parameter is the raw source map (either as a JSON string, or + * already parsed to an object). According to the spec, source maps have the + * following attributes: + * + * - version: Which version of the source map spec this map is following. + * - sources: An array of URLs to the original source files. + * - names: An array of identifiers which can be referrenced by individual mappings. + * - sourceRoot: Optional. The URL root from which all sources are relative. + * - sourcesContent: Optional. An array of contents of the original source files. + * - mappings: A string of base64 VLQs which contain the actual mappings. + * - file: The generated file this source map is associated with. + * + * Here is an example source map, taken from the source map spec[0]: + * + * { + * version : 3, + * file: "out.js", + * sourceRoot : "", + * sources: ["foo.js", "bar.js"], + * names: ["src", "maps", "are", "fun"], + * mappings: "AA,AB;;ABCDE;" + * } + * + * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# + */ + function SourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + var version = util.getArg(sourceMap, 'version'); + var sources = util.getArg(sourceMap, 'sources'); + // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which + // requires the array) to play nice here. + var names = util.getArg(sourceMap, 'names', []); + var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); + var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); + var mappings = util.getArg(sourceMap, 'mappings'); + var file = util.getArg(sourceMap, 'file', null); + + // Once again, Sass deviates from the spec and supplies the version as a + // string rather than a number, so we use loose equality checking here. + if (version != this._version) { + throw new Error('Unsupported version: ' + version); + } + + // Pass `true` below to allow duplicate names and sources. While source maps + // are intended to be compressed and deduplicated, the TypeScript compiler + // sometimes generates source maps with duplicates in them. See Github issue + // #72 and bugzil.la/889492. + this._names = ArraySet.fromArray(names, true); + this._sources = ArraySet.fromArray(sources, true); + + this.sourceRoot = sourceRoot; + this.sourcesContent = sourcesContent; + this._mappings = mappings; + this.file = file; + } + + /** + * Create a SourceMapConsumer from a SourceMapGenerator. + * + * @param SourceMapGenerator aSourceMap + * The source map that will be consumed. + * @returns SourceMapConsumer + */ + SourceMapConsumer.fromSourceMap = + function SourceMapConsumer_fromSourceMap(aSourceMap) { + var smc = Object.create(SourceMapConsumer.prototype); + + smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); + smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); + smc.sourceRoot = aSourceMap._sourceRoot; + smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), + smc.sourceRoot); + smc.file = aSourceMap._file; + + smc.__generatedMappings = aSourceMap._mappings.slice() + .sort(util.compareByGeneratedPositions); + smc.__originalMappings = aSourceMap._mappings.slice() + .sort(util.compareByOriginalPositions); + + return smc; + }; + + /** + * The version of the source mapping spec that we are consuming. + */ + SourceMapConsumer.prototype._version = 3; + + /** + * The list of original sources. + */ + Object.defineProperty(SourceMapConsumer.prototype, 'sources', { + get: function () { + return this._sources.toArray().map(function (s) { + return this.sourceRoot ? util.join(this.sourceRoot, s) : s; + }, this); + } + }); + + // `__generatedMappings` and `__originalMappings` are arrays that hold the + // parsed mapping coordinates from the source map's "mappings" attribute. They + // are lazily instantiated, accessed via the `_generatedMappings` and + // `_originalMappings` getters respectively, and we only parse the mappings + // and create these arrays once queried for a source location. We jump through + // these hoops because there can be many thousands of mappings, and parsing + // them is expensive, so we only want to do it if we must. + // + // Each object in the arrays is of the form: + // + // { + // generatedLine: The line number in the generated code, + // generatedColumn: The column number in the generated code, + // source: The path to the original source file that generated this + // chunk of code, + // originalLine: The line number in the original source that + // corresponds to this chunk of generated code, + // originalColumn: The column number in the original source that + // corresponds to this chunk of generated code, + // name: The name of the original symbol which generated this chunk of + // code. + // } + // + // All properties except for `generatedLine` and `generatedColumn` can be + // `null`. + // + // `_generatedMappings` is ordered by the generated positions. + // + // `_originalMappings` is ordered by the original positions. + + SourceMapConsumer.prototype.__generatedMappings = null; + Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { + get: function () { + if (!this.__generatedMappings) { + this.__generatedMappings = []; + this.__originalMappings = []; + this._parseMappings(this._mappings, this.sourceRoot); + } + + return this.__generatedMappings; + } + }); + + SourceMapConsumer.prototype.__originalMappings = null; + Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { + get: function () { + if (!this.__originalMappings) { + this.__generatedMappings = []; + this.__originalMappings = []; + this._parseMappings(this._mappings, this.sourceRoot); + } + + return this.__originalMappings; + } + }); + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + SourceMapConsumer.prototype._parseMappings = + function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { + var generatedLine = 1; + var previousGeneratedColumn = 0; + var previousOriginalLine = 0; + var previousOriginalColumn = 0; + var previousSource = 0; + var previousName = 0; + var mappingSeparator = /^[,;]/; + var str = aStr; + var mapping; + var temp; + + while (str.length > 0) { + if (str.charAt(0) === ';') { + generatedLine++; + str = str.slice(1); + previousGeneratedColumn = 0; + } + else if (str.charAt(0) === ',') { + str = str.slice(1); + } + else { + mapping = {}; + mapping.generatedLine = generatedLine; + + // Generated column. + temp = base64VLQ.decode(str); + mapping.generatedColumn = previousGeneratedColumn + temp.value; + previousGeneratedColumn = mapping.generatedColumn; + str = temp.rest; + + if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) { + // Original source. + temp = base64VLQ.decode(str); + mapping.source = this._sources.at(previousSource + temp.value); + previousSource += temp.value; + str = temp.rest; + if (str.length === 0 || mappingSeparator.test(str.charAt(0))) { + throw new Error('Found a source, but no line and column'); + } + + // Original line. + temp = base64VLQ.decode(str); + mapping.originalLine = previousOriginalLine + temp.value; + previousOriginalLine = mapping.originalLine; + // Lines are stored 0-based + mapping.originalLine += 1; + str = temp.rest; + if (str.length === 0 || mappingSeparator.test(str.charAt(0))) { + throw new Error('Found a source and line, but no column'); + } + + // Original column. + temp = base64VLQ.decode(str); + mapping.originalColumn = previousOriginalColumn + temp.value; + previousOriginalColumn = mapping.originalColumn; + str = temp.rest; + + if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) { + // Original name. + temp = base64VLQ.decode(str); + mapping.name = this._names.at(previousName + temp.value); + previousName += temp.value; + str = temp.rest; + } + } + + this.__generatedMappings.push(mapping); + if (typeof mapping.originalLine === 'number') { + this.__originalMappings.push(mapping); + } + } + } + + this.__originalMappings.sort(util.compareByOriginalPositions); + }; + + /** + * Find the mapping that best matches the hypothetical "needle" mapping that + * we are searching for in the given "haystack" of mappings. + */ + SourceMapConsumer.prototype._findMapping = + function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, + aColumnName, aComparator) { + // To return the position we are searching for, we must first find the + // mapping for the given position and then return the opposite position it + // points to. Because the mappings are sorted, we can use binary search to + // find the best mapping. + + if (aNeedle[aLineName] <= 0) { + throw new TypeError('Line must be greater than or equal to 1, got ' + + aNeedle[aLineName]); + } + if (aNeedle[aColumnName] < 0) { + throw new TypeError('Column must be greater than or equal to 0, got ' + + aNeedle[aColumnName]); + } + + return binarySearch.search(aNeedle, aMappings, aComparator); + }; + + /** + * Returns the original source, line, and column information for the generated + * source's line and column positions provided. The only argument is an object + * with the following properties: + * + * - line: The line number in the generated source. + * - column: The column number in the generated source. + * + * and an object is returned with the following properties: + * + * - source: The original source file, or null. + * - line: The line number in the original source, or null. + * - column: The column number in the original source, or null. + * - name: The original identifier, or null. + */ + SourceMapConsumer.prototype.originalPositionFor = + function SourceMapConsumer_originalPositionFor(aArgs) { + var needle = { + generatedLine: util.getArg(aArgs, 'line'), + generatedColumn: util.getArg(aArgs, 'column') + }; + + var mapping = this._findMapping(needle, + this._generatedMappings, + "generatedLine", + "generatedColumn", + util.compareByGeneratedPositions); + + if (mapping) { + var source = util.getArg(mapping, 'source', null); + if (source && this.sourceRoot) { + source = util.join(this.sourceRoot, source); + } + return { + source: source, + line: util.getArg(mapping, 'originalLine', null), + column: util.getArg(mapping, 'originalColumn', null), + name: util.getArg(mapping, 'name', null) + }; + } + + return { + source: null, + line: null, + column: null, + name: null + }; + }; + + /** + * Returns the original source content. The only argument is the url of the + * original source file. Returns null if no original source content is + * availible. + */ + SourceMapConsumer.prototype.sourceContentFor = + function SourceMapConsumer_sourceContentFor(aSource) { + if (!this.sourcesContent) { + return null; + } + + if (this.sourceRoot) { + aSource = util.relative(this.sourceRoot, aSource); + } + + if (this._sources.has(aSource)) { + return this.sourcesContent[this._sources.indexOf(aSource)]; + } + + var url; + if (this.sourceRoot + && (url = util.urlParse(this.sourceRoot))) { + // XXX: file:// URIs and absolute paths lead to unexpected behavior for + // many users. We can help them out when they expect file:// URIs to + // behave like it would if they were running a local HTTP server. See + // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. + var fileUriAbsPath = aSource.replace(/^file:\/\//, ""); + if (url.scheme == "file" + && this._sources.has(fileUriAbsPath)) { + return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] + } + + if ((!url.path || url.path == "/") + && this._sources.has("/" + aSource)) { + return this.sourcesContent[this._sources.indexOf("/" + aSource)]; + } + } + + throw new Error('"' + aSource + '" is not in the SourceMap.'); + }; + + /** + * Returns the generated line and column information for the original source, + * line, and column positions provided. The only argument is an object with + * the following properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * - column: The column number in the original source. + * + * and an object is returned with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + SourceMapConsumer.prototype.generatedPositionFor = + function SourceMapConsumer_generatedPositionFor(aArgs) { + var needle = { + source: util.getArg(aArgs, 'source'), + originalLine: util.getArg(aArgs, 'line'), + originalColumn: util.getArg(aArgs, 'column') + }; + + if (this.sourceRoot) { + needle.source = util.relative(this.sourceRoot, needle.source); + } + + var mapping = this._findMapping(needle, + this._originalMappings, + "originalLine", + "originalColumn", + util.compareByOriginalPositions); + + if (mapping) { + return { + line: util.getArg(mapping, 'generatedLine', null), + column: util.getArg(mapping, 'generatedColumn', null) + }; + } + + return { + line: null, + column: null + }; + }; + + SourceMapConsumer.GENERATED_ORDER = 1; + SourceMapConsumer.ORIGINAL_ORDER = 2; + + /** + * Iterate over each mapping between an original source/line/column and a + * generated line/column in this source map. + * + * @param Function aCallback + * The function that is called with each mapping. + * @param Object aContext + * Optional. If specified, this object will be the value of `this` every + * time that `aCallback` is called. + * @param aOrder + * Either `SourceMapConsumer.GENERATED_ORDER` or + * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to + * iterate over the mappings sorted by the generated file's line/column + * order or the original's source/line/column order, respectively. Defaults to + * `SourceMapConsumer.GENERATED_ORDER`. + */ + SourceMapConsumer.prototype.eachMapping = + function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { + var context = aContext || null; + var order = aOrder || SourceMapConsumer.GENERATED_ORDER; + + var mappings; + switch (order) { + case SourceMapConsumer.GENERATED_ORDER: + mappings = this._generatedMappings; + break; + case SourceMapConsumer.ORIGINAL_ORDER: + mappings = this._originalMappings; + break; + default: + throw new Error("Unknown order of iteration."); + } + + var sourceRoot = this.sourceRoot; + mappings.map(function (mapping) { + var source = mapping.source; + if (source && sourceRoot) { + source = util.join(sourceRoot, source); + } + return { + source: source, + generatedLine: mapping.generatedLine, + generatedColumn: mapping.generatedColumn, + originalLine: mapping.originalLine, + originalColumn: mapping.originalColumn, + name: mapping.name + }; + }).forEach(aCallback, context); + }; + + exports.SourceMapConsumer = SourceMapConsumer; + +}); + +},{"./array-set":12,"./base64-vlq":13,"./binary-search":15,"./util":19,"amdefine":20}],17:[function(_dereq_,module,exports){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = _dereq_('amdefine')(module, _dereq_); +} +define(function (_dereq_, exports, module) { + + var base64VLQ = _dereq_('./base64-vlq'); + var util = _dereq_('./util'); + var ArraySet = _dereq_('./array-set').ArraySet; + + /** + * An instance of the SourceMapGenerator represents a source map which is + * being built incrementally. To create a new one, you must pass an object + * with the following properties: + * + * - file: The filename of the generated source. + * - sourceRoot: An optional root for all URLs in this source map. + */ + function SourceMapGenerator(aArgs) { + this._file = util.getArg(aArgs, 'file'); + this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); + this._sources = new ArraySet(); + this._names = new ArraySet(); + this._mappings = []; + this._sourcesContents = null; + } + + SourceMapGenerator.prototype._version = 3; + + /** + * Creates a new SourceMapGenerator based on a SourceMapConsumer + * + * @param aSourceMapConsumer The SourceMap. + */ + SourceMapGenerator.fromSourceMap = + function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { + var sourceRoot = aSourceMapConsumer.sourceRoot; + var generator = new SourceMapGenerator({ + file: aSourceMapConsumer.file, + sourceRoot: sourceRoot + }); + aSourceMapConsumer.eachMapping(function (mapping) { + var newMapping = { + generated: { + line: mapping.generatedLine, + column: mapping.generatedColumn + } + }; + + if (mapping.source) { + newMapping.source = mapping.source; + if (sourceRoot) { + newMapping.source = util.relative(sourceRoot, newMapping.source); + } + + newMapping.original = { + line: mapping.originalLine, + column: mapping.originalColumn + }; + + if (mapping.name) { + newMapping.name = mapping.name; + } + } + + generator.addMapping(newMapping); + }); + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content) { + generator.setSourceContent(sourceFile, content); + } + }); + return generator; + }; + + /** + * Add a single mapping from original source line and column to the generated + * source's line and column for this source map being created. The mapping + * object should have the following properties: + * + * - generated: An object with the generated line and column positions. + * - original: An object with the original line and column positions. + * - source: The original source file (relative to the sourceRoot). + * - name: An optional original token name for this mapping. + */ + SourceMapGenerator.prototype.addMapping = + function SourceMapGenerator_addMapping(aArgs) { + var generated = util.getArg(aArgs, 'generated'); + var original = util.getArg(aArgs, 'original', null); + var source = util.getArg(aArgs, 'source', null); + var name = util.getArg(aArgs, 'name', null); + + this._validateMapping(generated, original, source, name); + + if (source && !this._sources.has(source)) { + this._sources.add(source); + } + + if (name && !this._names.has(name)) { + this._names.add(name); + } + + this._mappings.push({ + generatedLine: generated.line, + generatedColumn: generated.column, + originalLine: original != null && original.line, + originalColumn: original != null && original.column, + source: source, + name: name + }); + }; + + /** + * Set the source content for a source file. + */ + SourceMapGenerator.prototype.setSourceContent = + function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { + var source = aSourceFile; + if (this._sourceRoot) { + source = util.relative(this._sourceRoot, source); + } + + if (aSourceContent !== null) { + // Add the source content to the _sourcesContents map. + // Create a new _sourcesContents map if the property is null. + if (!this._sourcesContents) { + this._sourcesContents = {}; + } + this._sourcesContents[util.toSetString(source)] = aSourceContent; + } else { + // Remove the source file from the _sourcesContents map. + // If the _sourcesContents map is empty, set the property to null. + delete this._sourcesContents[util.toSetString(source)]; + if (Object.keys(this._sourcesContents).length === 0) { + this._sourcesContents = null; + } + } + }; + + /** + * Applies the mappings of a sub-source-map for a specific source file to the + * source map being generated. Each mapping to the supplied source file is + * rewritten using the supplied source map. Note: The resolution for the + * resulting mappings is the minimium of this map and the supplied map. + * + * @param aSourceMapConsumer The source map to be applied. + * @param aSourceFile Optional. The filename of the source file. + * If omitted, SourceMapConsumer's file property will be used. + */ + SourceMapGenerator.prototype.applySourceMap = + function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile) { + // If aSourceFile is omitted, we will use the file property of the SourceMap + if (!aSourceFile) { + aSourceFile = aSourceMapConsumer.file; + } + var sourceRoot = this._sourceRoot; + // Make "aSourceFile" relative if an absolute Url is passed. + if (sourceRoot) { + aSourceFile = util.relative(sourceRoot, aSourceFile); + } + // Applying the SourceMap can add and remove items from the sources and + // the names array. + var newSources = new ArraySet(); + var newNames = new ArraySet(); + + // Find mappings for the "aSourceFile" + this._mappings.forEach(function (mapping) { + if (mapping.source === aSourceFile && mapping.originalLine) { + // Check if it can be mapped by the source map, then update the mapping. + var original = aSourceMapConsumer.originalPositionFor({ + line: mapping.originalLine, + column: mapping.originalColumn + }); + if (original.source !== null) { + // Copy mapping + if (sourceRoot) { + mapping.source = util.relative(sourceRoot, original.source); + } else { + mapping.source = original.source; + } + mapping.originalLine = original.line; + mapping.originalColumn = original.column; + if (original.name !== null && mapping.name !== null) { + // Only use the identifier name if it's an identifier + // in both SourceMaps + mapping.name = original.name; + } + } + } + + var source = mapping.source; + if (source && !newSources.has(source)) { + newSources.add(source); + } + + var name = mapping.name; + if (name && !newNames.has(name)) { + newNames.add(name); + } + + }, this); + this._sources = newSources; + this._names = newNames; + + // Copy sourcesContents of applied map. + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content) { + if (sourceRoot) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + this.setSourceContent(sourceFile, content); + } + }, this); + }; + + /** + * A mapping can have one of the three levels of data: + * + * 1. Just the generated position. + * 2. The Generated position, original position, and original source. + * 3. Generated and original position, original source, as well as a name + * token. + * + * To maintain consistency, we validate that any new mapping being added falls + * in to one of these categories. + */ + SourceMapGenerator.prototype._validateMapping = + function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, + aName) { + if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aGenerated.line > 0 && aGenerated.column >= 0 + && !aOriginal && !aSource && !aName) { + // Case 1. + return; + } + else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aOriginal && 'line' in aOriginal && 'column' in aOriginal + && aGenerated.line > 0 && aGenerated.column >= 0 + && aOriginal.line > 0 && aOriginal.column >= 0 + && aSource) { + // Cases 2 and 3. + return; + } + else { + throw new Error('Invalid mapping: ' + JSON.stringify({ + generated: aGenerated, + source: aSource, + orginal: aOriginal, + name: aName + })); + } + }; + + /** + * Serialize the accumulated mappings in to the stream of base 64 VLQs + * specified by the source map format. + */ + SourceMapGenerator.prototype._serializeMappings = + function SourceMapGenerator_serializeMappings() { + var previousGeneratedColumn = 0; + var previousGeneratedLine = 1; + var previousOriginalColumn = 0; + var previousOriginalLine = 0; + var previousName = 0; + var previousSource = 0; + var result = ''; + var mapping; + + // The mappings must be guaranteed to be in sorted order before we start + // serializing them or else the generated line numbers (which are defined + // via the ';' separators) will be all messed up. Note: it might be more + // performant to maintain the sorting as we insert them, rather than as we + // serialize them, but the big O is the same either way. + this._mappings.sort(util.compareByGeneratedPositions); + + for (var i = 0, len = this._mappings.length; i < len; i++) { + mapping = this._mappings[i]; + + if (mapping.generatedLine !== previousGeneratedLine) { + previousGeneratedColumn = 0; + while (mapping.generatedLine !== previousGeneratedLine) { + result += ';'; + previousGeneratedLine++; + } + } + else { + if (i > 0) { + if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) { + continue; + } + result += ','; + } + } + + result += base64VLQ.encode(mapping.generatedColumn + - previousGeneratedColumn); + previousGeneratedColumn = mapping.generatedColumn; + + if (mapping.source) { + result += base64VLQ.encode(this._sources.indexOf(mapping.source) + - previousSource); + previousSource = this._sources.indexOf(mapping.source); + + // lines are stored 0-based in SourceMap spec version 3 + result += base64VLQ.encode(mapping.originalLine - 1 + - previousOriginalLine); + previousOriginalLine = mapping.originalLine - 1; + + result += base64VLQ.encode(mapping.originalColumn + - previousOriginalColumn); + previousOriginalColumn = mapping.originalColumn; + + if (mapping.name) { + result += base64VLQ.encode(this._names.indexOf(mapping.name) + - previousName); + previousName = this._names.indexOf(mapping.name); + } + } + } + + return result; + }; + + SourceMapGenerator.prototype._generateSourcesContent = + function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { + return aSources.map(function (source) { + if (!this._sourcesContents) { + return null; + } + if (aSourceRoot) { + source = util.relative(aSourceRoot, source); + } + var key = util.toSetString(source); + return Object.prototype.hasOwnProperty.call(this._sourcesContents, + key) + ? this._sourcesContents[key] + : null; + }, this); + }; + + /** + * Externalize the source map. + */ + SourceMapGenerator.prototype.toJSON = + function SourceMapGenerator_toJSON() { + var map = { + version: this._version, + file: this._file, + sources: this._sources.toArray(), + names: this._names.toArray(), + mappings: this._serializeMappings() + }; + if (this._sourceRoot) { + map.sourceRoot = this._sourceRoot; + } + if (this._sourcesContents) { + map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); + } + + return map; + }; + + /** + * Render the source map being generated to a string. + */ + SourceMapGenerator.prototype.toString = + function SourceMapGenerator_toString() { + return JSON.stringify(this); + }; + + exports.SourceMapGenerator = SourceMapGenerator; + +}); + +},{"./array-set":12,"./base64-vlq":13,"./util":19,"amdefine":20}],18:[function(_dereq_,module,exports){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = _dereq_('amdefine')(module, _dereq_); +} +define(function (_dereq_, exports, module) { + + var SourceMapGenerator = _dereq_('./source-map-generator').SourceMapGenerator; + var util = _dereq_('./util'); + + /** + * SourceNodes provide a way to abstract over interpolating/concatenating + * snippets of generated JavaScript source code while maintaining the line and + * column information associated with the original source code. + * + * @param aLine The original line number. + * @param aColumn The original column number. + * @param aSource The original source's filename. + * @param aChunks Optional. An array of strings which are snippets of + * generated JS, or other SourceNodes. + * @param aName The original identifier. + */ + function SourceNode(aLine, aColumn, aSource, aChunks, aName) { + this.children = []; + this.sourceContents = {}; + this.line = aLine === undefined ? null : aLine; + this.column = aColumn === undefined ? null : aColumn; + this.source = aSource === undefined ? null : aSource; + this.name = aName === undefined ? null : aName; + if (aChunks != null) this.add(aChunks); + } + + /** + * Creates a SourceNode from generated code and a SourceMapConsumer. + * + * @param aGeneratedCode The generated code + * @param aSourceMapConsumer The SourceMap for the generated code + */ + SourceNode.fromStringWithSourceMap = + function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer) { + // The SourceNode we want to fill with the generated code + // and the SourceMap + var node = new SourceNode(); + + // The generated code + // Processed fragments are removed from this array. + var remainingLines = aGeneratedCode.split('\n'); + + // We need to remember the position of "remainingLines" + var lastGeneratedLine = 1, lastGeneratedColumn = 0; + + // The generate SourceNodes we need a code range. + // To extract it current and last mapping is used. + // Here we store the last mapping. + var lastMapping = null; + + aSourceMapConsumer.eachMapping(function (mapping) { + if (lastMapping === null) { + // We add the generated code until the first mapping + // to the SourceNode without any mapping. + // Each line is added as separate string. + while (lastGeneratedLine < mapping.generatedLine) { + node.add(remainingLines.shift() + "\n"); + lastGeneratedLine++; + } + if (lastGeneratedColumn < mapping.generatedColumn) { + var nextLine = remainingLines[0]; + node.add(nextLine.substr(0, mapping.generatedColumn)); + remainingLines[0] = nextLine.substr(mapping.generatedColumn); + lastGeneratedColumn = mapping.generatedColumn; + } + } else { + // We add the code from "lastMapping" to "mapping": + // First check if there is a new line in between. + if (lastGeneratedLine < mapping.generatedLine) { + var code = ""; + // Associate full lines with "lastMapping" + do { + code += remainingLines.shift() + "\n"; + lastGeneratedLine++; + lastGeneratedColumn = 0; + } while (lastGeneratedLine < mapping.generatedLine); + // When we reached the correct line, we add code until we + // reach the correct column too. + if (lastGeneratedColumn < mapping.generatedColumn) { + var nextLine = remainingLines[0]; + code += nextLine.substr(0, mapping.generatedColumn); + remainingLines[0] = nextLine.substr(mapping.generatedColumn); + lastGeneratedColumn = mapping.generatedColumn; + } + // Create the SourceNode. + addMappingWithCode(lastMapping, code); + } else { + // There is no new line in between. + // Associate the code between "lastGeneratedColumn" and + // "mapping.generatedColumn" with "lastMapping" + var nextLine = remainingLines[0]; + var code = nextLine.substr(0, mapping.generatedColumn - + lastGeneratedColumn); + remainingLines[0] = nextLine.substr(mapping.generatedColumn - + lastGeneratedColumn); + lastGeneratedColumn = mapping.generatedColumn; + addMappingWithCode(lastMapping, code); + } + } + lastMapping = mapping; + }, this); + // We have processed all mappings. + // Associate the remaining code in the current line with "lastMapping" + // and add the remaining lines without any mapping + addMappingWithCode(lastMapping, remainingLines.join("\n")); + + // Copy sourcesContent into SourceNode + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content) { + node.setSourceContent(sourceFile, content); + } + }); + + return node; + + function addMappingWithCode(mapping, code) { + if (mapping === null || mapping.source === undefined) { + node.add(code); + } else { + node.add(new SourceNode(mapping.originalLine, + mapping.originalColumn, + mapping.source, + code, + mapping.name)); + } + } + }; + + /** + * Add a chunk of generated JS to this source node. + * + * @param aChunk A string snippet of generated JS code, another instance of + * SourceNode, or an array where each member is one of those things. + */ + SourceNode.prototype.add = function SourceNode_add(aChunk) { + if (Array.isArray(aChunk)) { + aChunk.forEach(function (chunk) { + this.add(chunk); + }, this); + } + else if (aChunk instanceof SourceNode || typeof aChunk === "string") { + if (aChunk) { + this.children.push(aChunk); + } + } + else { + throw new TypeError( + "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk + ); + } + return this; + }; + + /** + * Add a chunk of generated JS to the beginning of this source node. + * + * @param aChunk A string snippet of generated JS code, another instance of + * SourceNode, or an array where each member is one of those things. + */ + SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { + if (Array.isArray(aChunk)) { + for (var i = aChunk.length-1; i >= 0; i--) { + this.prepend(aChunk[i]); + } + } + else if (aChunk instanceof SourceNode || typeof aChunk === "string") { + this.children.unshift(aChunk); + } + else { + throw new TypeError( + "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk + ); + } + return this; + }; + + /** + * Walk over the tree of JS snippets in this node and its children. The + * walking function is called once for each snippet of JS and is passed that + * snippet and the its original associated source's line/column location. + * + * @param aFn The traversal function. + */ + SourceNode.prototype.walk = function SourceNode_walk(aFn) { + var chunk; + for (var i = 0, len = this.children.length; i < len; i++) { + chunk = this.children[i]; + if (chunk instanceof SourceNode) { + chunk.walk(aFn); + } + else { + if (chunk !== '') { + aFn(chunk, { source: this.source, + line: this.line, + column: this.column, + name: this.name }); + } + } + } + }; + + /** + * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between + * each of `this.children`. + * + * @param aSep The separator. + */ + SourceNode.prototype.join = function SourceNode_join(aSep) { + var newChildren; + var i; + var len = this.children.length; + if (len > 0) { + newChildren = []; + for (i = 0; i < len-1; i++) { + newChildren.push(this.children[i]); + newChildren.push(aSep); + } + newChildren.push(this.children[i]); + this.children = newChildren; + } + return this; + }; + + /** + * Call String.prototype.replace on the very right-most source snippet. Useful + * for trimming whitespace from the end of a source node, etc. + * + * @param aPattern The pattern to replace. + * @param aReplacement The thing to replace the pattern with. + */ + SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { + var lastChild = this.children[this.children.length - 1]; + if (lastChild instanceof SourceNode) { + lastChild.replaceRight(aPattern, aReplacement); + } + else if (typeof lastChild === 'string') { + this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); + } + else { + this.children.push(''.replace(aPattern, aReplacement)); + } + return this; + }; + + /** + * Set the source content for a source file. This will be added to the SourceMapGenerator + * in the sourcesContent field. + * + * @param aSourceFile The filename of the source file + * @param aSourceContent The content of the source file + */ + SourceNode.prototype.setSourceContent = + function SourceNode_setSourceContent(aSourceFile, aSourceContent) { + this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; + }; + + /** + * Walk over the tree of SourceNodes. The walking function is called for each + * source file content and is passed the filename and source content. + * + * @param aFn The traversal function. + */ + SourceNode.prototype.walkSourceContents = + function SourceNode_walkSourceContents(aFn) { + for (var i = 0, len = this.children.length; i < len; i++) { + if (this.children[i] instanceof SourceNode) { + this.children[i].walkSourceContents(aFn); + } + } + + var sources = Object.keys(this.sourceContents); + for (var i = 0, len = sources.length; i < len; i++) { + aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); + } + }; + + /** + * Return the string representation of this source node. Walks over the tree + * and concatenates all the various snippets together to one string. + */ + SourceNode.prototype.toString = function SourceNode_toString() { + var str = ""; + this.walk(function (chunk) { + str += chunk; + }); + return str; + }; + + /** + * Returns the string representation of this source node along with a source + * map. + */ + SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { + var generated = { + code: "", + line: 1, + column: 0 + }; + var map = new SourceMapGenerator(aArgs); + var sourceMappingActive = false; + var lastOriginalSource = null; + var lastOriginalLine = null; + var lastOriginalColumn = null; + var lastOriginalName = null; + this.walk(function (chunk, original) { + generated.code += chunk; + if (original.source !== null + && original.line !== null + && original.column !== null) { + if(lastOriginalSource !== original.source + || lastOriginalLine !== original.line + || lastOriginalColumn !== original.column + || lastOriginalName !== original.name) { + map.addMapping({ + source: original.source, + original: { + line: original.line, + column: original.column + }, + generated: { + line: generated.line, + column: generated.column + }, + name: original.name + }); + } + lastOriginalSource = original.source; + lastOriginalLine = original.line; + lastOriginalColumn = original.column; + lastOriginalName = original.name; + sourceMappingActive = true; + } else if (sourceMappingActive) { + map.addMapping({ + generated: { + line: generated.line, + column: generated.column + } + }); + lastOriginalSource = null; + sourceMappingActive = false; + } + chunk.split('').forEach(function (ch) { + if (ch === '\n') { + generated.line++; + generated.column = 0; + } else { + generated.column++; + } + }); + }); + this.walkSourceContents(function (sourceFile, sourceContent) { + map.setSourceContent(sourceFile, sourceContent); + }); + + return { code: generated.code, map: map }; + }; + + exports.SourceNode = SourceNode; + +}); + +},{"./source-map-generator":17,"./util":19,"amdefine":20}],19:[function(_dereq_,module,exports){ +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ +if (typeof define !== 'function') { + var define = _dereq_('amdefine')(module, _dereq_); +} +define(function (_dereq_, exports, module) { + + /** + * This is a helper function for getting values from parameter/options + * objects. + * + * @param args The object we are extracting values from + * @param name The name of the property we are getting. + * @param defaultValue An optional value to return if the property is missing + * from the object. If this is not specified and the property is missing, an + * error will be thrown. + */ + function getArg(aArgs, aName, aDefaultValue) { + if (aName in aArgs) { + return aArgs[aName]; + } else if (arguments.length === 3) { + return aDefaultValue; + } else { + throw new Error('"' + aName + '" is a required argument.'); + } + } + exports.getArg = getArg; + + var urlRegexp = /([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/; + var dataUrlRegexp = /^data:.+\,.+/; + + function urlParse(aUrl) { + var match = aUrl.match(urlRegexp); + if (!match) { + return null; + } + return { + scheme: match[1], + auth: match[3], + host: match[4], + port: match[6], + path: match[7] + }; + } + exports.urlParse = urlParse; + + function urlGenerate(aParsedUrl) { + var url = aParsedUrl.scheme + "://"; + if (aParsedUrl.auth) { + url += aParsedUrl.auth + "@" + } + if (aParsedUrl.host) { + url += aParsedUrl.host; + } + if (aParsedUrl.port) { + url += ":" + aParsedUrl.port + } + if (aParsedUrl.path) { + url += aParsedUrl.path; + } + return url; + } + exports.urlGenerate = urlGenerate; + + function join(aRoot, aPath) { + var url; + + if (aPath.match(urlRegexp) || aPath.match(dataUrlRegexp)) { + return aPath; + } + + if (aPath.charAt(0) === '/' && (url = urlParse(aRoot))) { + url.path = aPath; + return urlGenerate(url); + } + + return aRoot.replace(/\/$/, '') + '/' + aPath; + } + exports.join = join; + + /** + * Because behavior goes wacky when you set `__proto__` on objects, we + * have to prefix all the strings in our set with an arbitrary character. + * + * See https://github.com/mozilla/source-map/pull/31 and + * https://github.com/mozilla/source-map/issues/30 + * + * @param String aStr + */ + function toSetString(aStr) { + return '$' + aStr; + } + exports.toSetString = toSetString; + + function fromSetString(aStr) { + return aStr.substr(1); + } + exports.fromSetString = fromSetString; + + function relative(aRoot, aPath) { + aRoot = aRoot.replace(/\/$/, ''); + + var url = urlParse(aRoot); + if (aPath.charAt(0) == "/" && url && url.path == "/") { + return aPath.slice(1); + } + + return aPath.indexOf(aRoot + '/') === 0 + ? aPath.substr(aRoot.length + 1) + : aPath; + } + exports.relative = relative; + + function strcmp(aStr1, aStr2) { + var s1 = aStr1 || ""; + var s2 = aStr2 || ""; + return (s1 > s2) - (s1 < s2); + } + + /** + * Comparator between two mappings where the original positions are compared. + * + * Optionally pass in `true` as `onlyCompareGenerated` to consider two + * mappings with the same original source/line/column, but different generated + * line and column the same. Useful when searching for a mapping with a + * stubbed out mapping. + */ + function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { + var cmp; + + cmp = strcmp(mappingA.source, mappingB.source); + if (cmp) { + return cmp; + } + + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp) { + return cmp; + } + + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp || onlyCompareOriginal) { + return cmp; + } + + cmp = strcmp(mappingA.name, mappingB.name); + if (cmp) { + return cmp; + } + + cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp) { + return cmp; + } + + return mappingA.generatedColumn - mappingB.generatedColumn; + }; + exports.compareByOriginalPositions = compareByOriginalPositions; + + /** + * Comparator between two mappings where the generated positions are + * compared. + * + * Optionally pass in `true` as `onlyCompareGenerated` to consider two + * mappings with the same generated line and column, but different + * source/name/original line and column the same. Useful when searching for a + * mapping with a stubbed out mapping. + */ + function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) { + var cmp; + + cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp) { + return cmp; + } + + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp || onlyCompareGenerated) { + return cmp; + } + + cmp = strcmp(mappingA.source, mappingB.source); + if (cmp) { + return cmp; + } + + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp) { + return cmp; + } + + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp) { + return cmp; + } + + return strcmp(mappingA.name, mappingB.name); + }; + exports.compareByGeneratedPositions = compareByGeneratedPositions; + +}); + +},{"amdefine":20}],20:[function(_dereq_,module,exports){ +(function (process,__filename){ +/** vim: et:ts=4:sw=4:sts=4 + * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved. + * Available via the MIT or new BSD license. + * see: http://github.com/jrburke/amdefine for details + */ + +/*jslint node: true */ +/*global module, process */ +'use strict'; + +/** + * Creates a define for node. + * @param {Object} module the "module" object that is defined by Node for the + * current module. + * @param {Function} [requireFn]. Node's require function for the current module. + * It only needs to be passed in Node versions before 0.5, when module.require + * did not exist. + * @returns {Function} a define function that is usable for the current node + * module. + */ +function amdefine(module, requireFn) { + 'use strict'; + var defineCache = {}, + loaderCache = {}, + alreadyCalled = false, + path = _dereq_('path'), + makeRequire, stringRequire; + + /** + * Trims the . and .. from an array of path segments. + * It will keep a leading path segment if a .. will become + * the first path segment, to help with module name lookups, + * which act like paths, but can be remapped. But the end result, + * all paths that use this function should look normalized. + * NOTE: this method MODIFIES the input array. + * @param {Array} ary the array of path segments. + */ + function trimDots(ary) { + var i, part; + for (i = 0; ary[i]; i+= 1) { + part = ary[i]; + if (part === '.') { + ary.splice(i, 1); + i -= 1; + } else if (part === '..') { + if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { + //End of the line. Keep at least one non-dot + //path segment at the front so it can be mapped + //correctly to disk. Otherwise, there is likely + //no path mapping for a path starting with '..'. + //This can still fail, but catches the most reasonable + //uses of .. + break; + } else if (i > 0) { + ary.splice(i - 1, 2); + i -= 2; + } + } + } + } + + function normalize(name, baseName) { + var baseParts; + + //Adjust any relative paths. + if (name && name.charAt(0) === '.') { + //If have a base name, try to normalize against it, + //otherwise, assume it is a top-level require that will + //be relative to baseUrl in the end. + if (baseName) { + baseParts = baseName.split('/'); + baseParts = baseParts.slice(0, baseParts.length - 1); + baseParts = baseParts.concat(name.split('/')); + trimDots(baseParts); + name = baseParts.join('/'); + } + } + + return name; + } + + /** + * Create the normalize() function passed to a loader plugin's + * normalize method. + */ + function makeNormalize(relName) { + return function (name) { + return normalize(name, relName); + }; + } + + function makeLoad(id) { + function load(value) { + loaderCache[id] = value; + } + + load.fromText = function (id, text) { + //This one is difficult because the text can/probably uses + //define, and any relative paths and requires should be relative + //to that id was it would be found on disk. But this would require + //bootstrapping a module/require fairly deeply from node core. + //Not sure how best to go about that yet. + throw new Error('amdefine does not implement load.fromText'); + }; + + return load; + } + + makeRequire = function (systemRequire, exports, module, relId) { + function amdRequire(deps, callback) { + if (typeof deps === 'string') { + //Synchronous, single module require('') + return stringRequire(systemRequire, exports, module, deps, relId); + } else { + //Array of dependencies with a callback. + + //Convert the dependencies to modules. + deps = deps.map(function (depName) { + return stringRequire(systemRequire, exports, module, depName, relId); + }); + + //Wait for next tick to call back the require call. + process.nextTick(function () { + callback.apply(null, deps); + }); + } + } + + amdRequire.toUrl = function (filePath) { + if (filePath.indexOf('.') === 0) { + return normalize(filePath, path.dirname(module.filename)); + } else { + return filePath; + } + }; + + return amdRequire; + }; + + //Favor explicit value, passed in if the module wants to support Node 0.4. + requireFn = requireFn || function req() { + return module.require.apply(module, arguments); + }; + + function runFactory(id, deps, factory) { + var r, e, m, result; + + if (id) { + e = loaderCache[id] = {}; + m = { + id: id, + uri: __filename, + exports: e + }; + r = makeRequire(requireFn, e, m, id); + } else { + //Only support one define call per file + if (alreadyCalled) { + throw new Error('amdefine with no module ID cannot be called more than once per file.'); + } + alreadyCalled = true; + + //Use the real variables from node + //Use module.exports for exports, since + //the exports in here is amdefine exports. + e = module.exports; + m = module; + r = makeRequire(requireFn, e, m, module.id); + } + + //If there are dependencies, they are strings, so need + //to convert them to dependency values. + if (deps) { + deps = deps.map(function (depName) { + return r(depName); + }); + } + + //Call the factory with the right dependencies. + if (typeof factory === 'function') { + result = factory.apply(m.exports, deps); + } else { + result = factory; + } + + if (result !== undefined) { + m.exports = result; + if (id) { + loaderCache[id] = m.exports; + } + } + } + + stringRequire = function (systemRequire, exports, module, id, relId) { + //Split the ID by a ! so that + var index = id.indexOf('!'), + originalId = id, + prefix, plugin; + + if (index === -1) { + id = normalize(id, relId); + + //Straight module lookup. If it is one of the special dependencies, + //deal with it, otherwise, delegate to node. + if (id === 'require') { + return makeRequire(systemRequire, exports, module, relId); + } else if (id === 'exports') { + return exports; + } else if (id === 'module') { + return module; + } else if (loaderCache.hasOwnProperty(id)) { + return loaderCache[id]; + } else if (defineCache[id]) { + runFactory.apply(null, defineCache[id]); + return loaderCache[id]; + } else { + if(systemRequire) { + return systemRequire(originalId); + } else { + throw new Error('No module with ID: ' + id); + } + } + } else { + //There is a plugin in play. + prefix = id.substring(0, index); + id = id.substring(index + 1, id.length); + + plugin = stringRequire(systemRequire, exports, module, prefix, relId); + + if (plugin.normalize) { + id = plugin.normalize(id, makeNormalize(relId)); + } else { + //Normalize the ID normally. + id = normalize(id, relId); + } + + if (loaderCache[id]) { + return loaderCache[id]; + } else { + plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {}); + + return loaderCache[id]; + } + } + }; + + //Create a define function specific to the module asking for amdefine. + function define(id, deps, factory) { + if (Array.isArray(id)) { + factory = deps; + deps = id; + id = undefined; + } else if (typeof id !== 'string') { + factory = id; + id = deps = undefined; + } + + if (deps && !Array.isArray(deps)) { + factory = deps; + deps = undefined; + } + + if (!deps) { + deps = ['require', 'exports', 'module']; + } + + //Set up properties for this module. If an ID, then use + //internal cache. If no ID, then use the external variables + //for this node module. + if (id) { + //Put the module in deep freeze until there is a + //require call for it. + defineCache[id] = [id, deps, factory]; + } else { + runFactory(id, deps, factory); + } + } + + //define.require, which has access to all the values in the + //cache. Useful for AMD modules that all have IDs in the file, + //but need to finally export a value to node based on one of those + //IDs. + define.require = function (id) { + if (loaderCache[id]) { + return loaderCache[id]; + } + + if (defineCache[id]) { + runFactory.apply(null, defineCache[id]); + return loaderCache[id]; + } + }; + + define.amd = {}; + + return define; +} + +module.exports = amdefine; + +}).call(this,_dereq_('_process'),"/node_modules/jstransform/node_modules/source-map/node_modules/amdefine/amdefine.js") +},{"_process":8,"path":7}],21:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var docblockRe = /^\s*(\/\*\*(.|\r?\n)*?\*\/)/; +var ltrimRe = /^\s*/; +/** + * @param {String} contents + * @return {String} + */ +function extract(contents) { + var match = contents.match(docblockRe); + if (match) { + return match[0].replace(ltrimRe, '') || ''; + } + return ''; +} + + +var commentStartRe = /^\/\*\*?/; +var commentEndRe = /\*+\/$/; +var wsRe = /[\t ]+/g; +var stringStartRe = /(\r?\n|^) *\*/g; +var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *([^@\r\n\s][^@\r\n]+?) *\r?\n/g; +var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g; + +/** + * @param {String} contents + * @return {Array} + */ +function parse(docblock) { + docblock = docblock + .replace(commentStartRe, '') + .replace(commentEndRe, '') + .replace(wsRe, ' ') + .replace(stringStartRe, '$1'); + + // Normalize multi-line directives + var prev = ''; + while (prev != docblock) { + prev = docblock; + docblock = docblock.replace(multilineRe, "\n$1 $2\n"); + } + docblock = docblock.trim(); + + var result = []; + var match; + while (match = propertyRe.exec(docblock)) { + result.push([match[1], match[2]]); + } + + return result; +} + +/** + * Same as parse but returns an object of prop: value instead of array of paris + * If a property appers more than once the last one will be returned + * + * @param {String} contents + * @return {Object} + */ +function parseAsObject(docblock) { + var pairs = parse(docblock); + var result = {}; + for (var i = 0; i < pairs.length; i++) { + result[pairs[i][0]] = pairs[i][1]; + } + return result; +} + + +exports.extract = extract; +exports.parse = parse; +exports.parseAsObject = parseAsObject; + +},{}],22:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/*jslint node: true*/ +"use strict"; + +var esprima = _dereq_('esprima-fb'); +var utils = _dereq_('./utils'); + +var getBoundaryNode = utils.getBoundaryNode; +var declareIdentInScope = utils.declareIdentInLocalScope; +var initScopeMetadata = utils.initScopeMetadata; +var Syntax = esprima.Syntax; + +/** + * @param {object} node + * @param {object} parentNode + * @return {boolean} + */ +function _nodeIsClosureScopeBoundary(node, parentNode) { + if (node.type === Syntax.Program) { + return true; + } + + var parentIsFunction = + parentNode.type === Syntax.FunctionDeclaration + || parentNode.type === Syntax.FunctionExpression + || parentNode.type === Syntax.ArrowFunctionExpression; + + var parentIsCurlylessArrowFunc = + parentNode.type === Syntax.ArrowFunctionExpression + && node === parentNode.body; + + return parentIsFunction + && (node.type === Syntax.BlockStatement || parentIsCurlylessArrowFunc); +} + +function _nodeIsBlockScopeBoundary(node, parentNode) { + if (node.type === Syntax.Program) { + return false; + } + + return node.type === Syntax.BlockStatement + && parentNode.type === Syntax.CatchClause; +} + +/** + * @param {object} node + * @param {array} path + * @param {object} state + */ +function traverse(node, path, state) { + /*jshint -W004*/ + // Create a scope stack entry if this is the first node we've encountered in + // its local scope + var startIndex = null; + var parentNode = path[0]; + if (!Array.isArray(node) && state.localScope.parentNode !== parentNode) { + if (_nodeIsClosureScopeBoundary(node, parentNode)) { + var scopeIsStrict = state.scopeIsStrict; + if (!scopeIsStrict + && (node.type === Syntax.BlockStatement + || node.type === Syntax.Program)) { + scopeIsStrict = + node.body.length > 0 + && node.body[0].type === Syntax.ExpressionStatement + && node.body[0].expression.type === Syntax.Literal + && node.body[0].expression.value === 'use strict'; + } + + if (node.type === Syntax.Program) { + startIndex = state.g.buffer.length; + state = utils.updateState(state, { + scopeIsStrict: scopeIsStrict + }); + } else { + startIndex = state.g.buffer.length + 1; + state = utils.updateState(state, { + localScope: { + parentNode: parentNode, + parentScope: state.localScope, + identifiers: {}, + tempVarIndex: 0, + tempVars: [] + }, + scopeIsStrict: scopeIsStrict + }); + + // All functions have an implicit 'arguments' object in scope + declareIdentInScope('arguments', initScopeMetadata(node), state); + + // Include function arg identifiers in the scope boundaries of the + // function + if (parentNode.params.length > 0) { + var param; + var metadata = initScopeMetadata(parentNode, path.slice(1), path[0]); + for (var i = 0; i < parentNode.params.length; i++) { + param = parentNode.params[i]; + if (param.type === Syntax.Identifier) { + declareIdentInScope(param.name, metadata, state); + } + } + } + + // Include rest arg identifiers in the scope boundaries of their + // functions + if (parentNode.rest) { + var metadata = initScopeMetadata( + parentNode, + path.slice(1), + path[0] + ); + declareIdentInScope(parentNode.rest.name, metadata, state); + } + + // Named FunctionExpressions scope their name within the body block of + // themselves only + if (parentNode.type === Syntax.FunctionExpression && parentNode.id) { + var metaData = + initScopeMetadata(parentNode, path.parentNodeslice, parentNode); + declareIdentInScope(parentNode.id.name, metaData, state); + } + } + + // Traverse and find all local identifiers in this closure first to + // account for function/variable declaration hoisting + collectClosureIdentsAndTraverse(node, path, state); + } + + if (_nodeIsBlockScopeBoundary(node, parentNode)) { + startIndex = state.g.buffer.length; + state = utils.updateState(state, { + localScope: { + parentNode: parentNode, + parentScope: state.localScope, + identifiers: {}, + tempVarIndex: 0, + tempVars: [] + } + }); + + if (parentNode.type === Syntax.CatchClause) { + var metadata = initScopeMetadata( + parentNode, + path.slice(1), + parentNode + ); + declareIdentInScope(parentNode.param.name, metadata, state); + } + collectBlockIdentsAndTraverse(node, path, state); + } + } + + // Only catchup() before and after traversing a child node + function traverser(node, path, state) { + node.range && utils.catchup(node.range[0], state); + traverse(node, path, state); + node.range && utils.catchup(node.range[1], state); + } + + utils.analyzeAndTraverse(walker, traverser, node, path, state); + + // Inject temp variables into the scope. + if (startIndex !== null) { + utils.injectTempVarDeclarations(state, startIndex); + } +} + +function collectClosureIdentsAndTraverse(node, path, state) { + utils.analyzeAndTraverse( + visitLocalClosureIdentifiers, + collectClosureIdentsAndTraverse, + node, + path, + state + ); +} + +function collectBlockIdentsAndTraverse(node, path, state) { + utils.analyzeAndTraverse( + visitLocalBlockIdentifiers, + collectBlockIdentsAndTraverse, + node, + path, + state + ); +} + +function visitLocalClosureIdentifiers(node, path, state) { + var metaData; + switch (node.type) { + case Syntax.ArrowFunctionExpression: + case Syntax.FunctionExpression: + // Function expressions don't get their names (if there is one) added to + // the closure scope they're defined in + return false; + case Syntax.ClassDeclaration: + case Syntax.ClassExpression: + case Syntax.FunctionDeclaration: + if (node.id) { + metaData = initScopeMetadata(getBoundaryNode(path), path.slice(), node); + declareIdentInScope(node.id.name, metaData, state); + } + return false; + case Syntax.VariableDeclarator: + // Variables have function-local scope + if (path[0].kind === 'var') { + metaData = initScopeMetadata(getBoundaryNode(path), path.slice(), node); + declareIdentInScope(node.id.name, metaData, state); + } + break; + } +} + +function visitLocalBlockIdentifiers(node, path, state) { + // TODO: Support 'let' here...maybe...one day...or something... + if (node.type === Syntax.CatchClause) { + return false; + } +} + +function walker(node, path, state) { + var visitors = state.g.visitors; + for (var i = 0; i < visitors.length; i++) { + if (visitors[i].test(node, path, state)) { + return visitors[i](traverse, node, path, state); + } + } +} + +var _astCache = {}; + +function getAstForSource(source, options) { + if (_astCache[source] && !options.disableAstCache) { + return _astCache[source]; + } + var ast = esprima.parse(source, { + comment: true, + loc: true, + range: true, + sourceType: options.sourceType + }); + if (!options.disableAstCache) { + _astCache[source] = ast; + } + return ast; +} + +/** + * Applies all available transformations to the source + * @param {array} visitors + * @param {string} source + * @param {?object} options + * @return {object} + */ +function transform(visitors, source, options) { + options = options || {}; + var ast; + try { + ast = getAstForSource(source, options); + } catch (e) { + e.message = 'Parse Error: ' + e.message; + throw e; + } + var state = utils.createState(source, ast, options); + state.g.visitors = visitors; + + if (options.sourceMap) { + var SourceMapGenerator = _dereq_('source-map').SourceMapGenerator; + state.g.sourceMap = new SourceMapGenerator({file: options.filename || 'transformed.js'}); + } + + traverse(ast, [], state); + utils.catchup(source.length, state); + + var ret = {code: state.g.buffer, extra: state.g.extra}; + if (options.sourceMap) { + ret.sourceMap = state.g.sourceMap; + ret.sourceMapFilename = options.filename || 'source.js'; + } + return ret; +} + +exports.transform = transform; +exports.Syntax = Syntax; + +},{"./utils":23,"esprima-fb":9,"source-map":11}],23:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/*jslint node: true*/ +var Syntax = _dereq_('esprima-fb').Syntax; +var leadingIndentRegexp = /(^|\n)( {2}|\t)/g; +var nonWhiteRegexp = /(\S)/g; + +/** + * A `state` object represents the state of the parser. It has "local" and + * "global" parts. Global contains parser position, source, etc. Local contains + * scope based properties like current class name. State should contain all the + * info required for transformation. It's the only mandatory object that is + * being passed to every function in transform chain. + * + * @param {string} source + * @param {object} transformOptions + * @return {object} + */ +function createState(source, rootNode, transformOptions) { + return { + /** + * A tree representing the current local scope (and its lexical scope chain) + * Useful for tracking identifiers from parent scopes, etc. + * @type {Object} + */ + localScope: { + parentNode: rootNode, + parentScope: null, + identifiers: {}, + tempVarIndex: 0, + tempVars: [] + }, + /** + * The name (and, if applicable, expression) of the super class + * @type {Object} + */ + superClass: null, + /** + * The namespace to use when munging identifiers + * @type {String} + */ + mungeNamespace: '', + /** + * Ref to the node for the current MethodDefinition + * @type {Object} + */ + methodNode: null, + /** + * Ref to the node for the FunctionExpression of the enclosing + * MethodDefinition + * @type {Object} + */ + methodFuncNode: null, + /** + * Name of the enclosing class + * @type {String} + */ + className: null, + /** + * Whether we're currently within a `strict` scope + * @type {Bool} + */ + scopeIsStrict: null, + /** + * Indentation offset + * @type {Number} + */ + indentBy: 0, + /** + * Global state (not affected by updateState) + * @type {Object} + */ + g: { + /** + * A set of general options that transformations can consider while doing + * a transformation: + * + * - minify + * Specifies that transformation steps should do their best to minify + * the output source when possible. This is useful for places where + * minification optimizations are possible with higher-level context + * info than what jsxmin can provide. + * + * For example, the ES6 class transform will minify munged private + * variables if this flag is set. + */ + opts: transformOptions, + /** + * Current position in the source code + * @type {Number} + */ + position: 0, + /** + * Auxiliary data to be returned by transforms + * @type {Object} + */ + extra: {}, + /** + * Buffer containing the result + * @type {String} + */ + buffer: '', + /** + * Source that is being transformed + * @type {String} + */ + source: source, + + /** + * Cached parsed docblock (see getDocblock) + * @type {object} + */ + docblock: null, + + /** + * Whether the thing was used + * @type {Boolean} + */ + tagNamespaceUsed: false, + + /** + * If using bolt xjs transformation + * @type {Boolean} + */ + isBolt: undefined, + + /** + * Whether to record source map (expensive) or not + * @type {SourceMapGenerator|null} + */ + sourceMap: null, + + /** + * Filename of the file being processed. Will be returned as a source + * attribute in the source map + */ + sourceMapFilename: 'source.js', + + /** + * Only when source map is used: last line in the source for which + * source map was generated + * @type {Number} + */ + sourceLine: 1, + + /** + * Only when source map is used: last line in the buffer for which + * source map was generated + * @type {Number} + */ + bufferLine: 1, + + /** + * The top-level Program AST for the original file. + */ + originalProgramAST: null, + + sourceColumn: 0, + bufferColumn: 0 + } + }; +} + +/** + * Updates a copy of a given state with "update" and returns an updated state. + * + * @param {object} state + * @param {object} update + * @return {object} + */ +function updateState(state, update) { + var ret = Object.create(state); + Object.keys(update).forEach(function(updatedKey) { + ret[updatedKey] = update[updatedKey]; + }); + return ret; +} + +/** + * Given a state fill the resulting buffer from the original source up to + * the end + * + * @param {number} end + * @param {object} state + * @param {?function} contentTransformer Optional callback to transform newly + * added content. + */ +function catchup(end, state, contentTransformer) { + if (end < state.g.position) { + // cannot move backwards + return; + } + var source = state.g.source.substring(state.g.position, end); + var transformed = updateIndent(source, state); + if (state.g.sourceMap && transformed) { + // record where we are + state.g.sourceMap.addMapping({ + generated: { line: state.g.bufferLine, column: state.g.bufferColumn }, + original: { line: state.g.sourceLine, column: state.g.sourceColumn }, + source: state.g.sourceMapFilename + }); + + // record line breaks in transformed source + var sourceLines = source.split('\n'); + var transformedLines = transformed.split('\n'); + // Add line break mappings between last known mapping and the end of the + // added piece. So for the code piece + // (foo, bar); + // > var x = 2; + // > var b = 3; + // var c = + // only add lines marked with ">": 2, 3. + for (var i = 1; i < sourceLines.length - 1; i++) { + state.g.sourceMap.addMapping({ + generated: { line: state.g.bufferLine, column: 0 }, + original: { line: state.g.sourceLine, column: 0 }, + source: state.g.sourceMapFilename + }); + state.g.sourceLine++; + state.g.bufferLine++; + } + // offset for the last piece + if (sourceLines.length > 1) { + state.g.sourceLine++; + state.g.bufferLine++; + state.g.sourceColumn = 0; + state.g.bufferColumn = 0; + } + state.g.sourceColumn += sourceLines[sourceLines.length - 1].length; + state.g.bufferColumn += + transformedLines[transformedLines.length - 1].length; + } + state.g.buffer += + contentTransformer ? contentTransformer(transformed) : transformed; + state.g.position = end; +} + +/** + * Returns original source for an AST node. + * @param {object} node + * @param {object} state + * @return {string} + */ +function getNodeSourceText(node, state) { + return state.g.source.substring(node.range[0], node.range[1]); +} + +function _replaceNonWhite(value) { + return value.replace(nonWhiteRegexp, ' '); +} + +/** + * Removes all non-whitespace characters + */ +function _stripNonWhite(value) { + return value.replace(nonWhiteRegexp, ''); +} + +/** + * Finds the position of the next instance of the specified syntactic char in + * the pending source. + * + * NOTE: This will skip instances of the specified char if they sit inside a + * comment body. + * + * NOTE: This function also assumes that the buffer's current position is not + * already within a comment or a string. This is rarely the case since all + * of the buffer-advancement utility methods tend to be used on syntactic + * nodes' range values -- but it's a small gotcha that's worth mentioning. + */ +function getNextSyntacticCharOffset(char, state) { + var pendingSource = state.g.source.substring(state.g.position); + var pendingSourceLines = pendingSource.split('\n'); + + var charOffset = 0; + var line; + var withinBlockComment = false; + var withinString = false; + lineLoop: while ((line = pendingSourceLines.shift()) !== undefined) { + var lineEndPos = charOffset + line.length; + charLoop: for (; charOffset < lineEndPos; charOffset++) { + var currChar = pendingSource[charOffset]; + if (currChar === '"' || currChar === '\'') { + withinString = !withinString; + continue charLoop; + } else if (withinString) { + continue charLoop; + } else if (charOffset + 1 < lineEndPos) { + var nextTwoChars = currChar + line[charOffset + 1]; + if (nextTwoChars === '//') { + charOffset = lineEndPos + 1; + continue lineLoop; + } else if (nextTwoChars === '/*') { + withinBlockComment = true; + charOffset += 1; + continue charLoop; + } else if (nextTwoChars === '*/') { + withinBlockComment = false; + charOffset += 1; + continue charLoop; + } + } + + if (!withinBlockComment && currChar === char) { + return charOffset + state.g.position; + } + } + + // Account for '\n' + charOffset++; + withinString = false; + } + + throw new Error('`' + char + '` not found!'); +} + +/** + * Catches up as `catchup` but replaces non-whitespace chars with spaces. + */ +function catchupWhiteOut(end, state) { + catchup(end, state, _replaceNonWhite); +} + +/** + * Catches up as `catchup` but removes all non-whitespace characters. + */ +function catchupWhiteSpace(end, state) { + catchup(end, state, _stripNonWhite); +} + +/** + * Removes all non-newline characters + */ +var reNonNewline = /[^\n]/g; +function stripNonNewline(value) { + return value.replace(reNonNewline, function() { + return ''; + }); +} + +/** + * Catches up as `catchup` but removes all non-newline characters. + * + * Equivalent to appending as many newlines as there are in the original source + * between the current position and `end`. + */ +function catchupNewlines(end, state) { + catchup(end, state, stripNonNewline); +} + + +/** + * Same as catchup but does not touch the buffer + * + * @param {number} end + * @param {object} state + */ +function move(end, state) { + // move the internal cursors + if (state.g.sourceMap) { + if (end < state.g.position) { + state.g.position = 0; + state.g.sourceLine = 1; + state.g.sourceColumn = 0; + } + + var source = state.g.source.substring(state.g.position, end); + var sourceLines = source.split('\n'); + if (sourceLines.length > 1) { + state.g.sourceLine += sourceLines.length - 1; + state.g.sourceColumn = 0; + } + state.g.sourceColumn += sourceLines[sourceLines.length - 1].length; + } + state.g.position = end; +} + +/** + * Appends a string of text to the buffer + * + * @param {string} str + * @param {object} state + */ +function append(str, state) { + if (state.g.sourceMap && str) { + state.g.sourceMap.addMapping({ + generated: { line: state.g.bufferLine, column: state.g.bufferColumn }, + original: { line: state.g.sourceLine, column: state.g.sourceColumn }, + source: state.g.sourceMapFilename + }); + var transformedLines = str.split('\n'); + if (transformedLines.length > 1) { + state.g.bufferLine += transformedLines.length - 1; + state.g.bufferColumn = 0; + } + state.g.bufferColumn += + transformedLines[transformedLines.length - 1].length; + } + state.g.buffer += str; +} + +/** + * Update indent using state.indentBy property. Indent is measured in + * double spaces. Updates a single line only. + * + * @param {string} str + * @param {object} state + * @return {string} + */ +function updateIndent(str, state) { + /*jshint -W004*/ + var indentBy = state.indentBy; + if (indentBy < 0) { + for (var i = 0; i < -indentBy; i++) { + str = str.replace(leadingIndentRegexp, '$1'); + } + } else { + for (var i = 0; i < indentBy; i++) { + str = str.replace(leadingIndentRegexp, '$1$2$2'); + } + } + return str; +} + +/** + * Calculates indent from the beginning of the line until "start" or the first + * character before start. + * @example + * " foo.bar()" + * ^ + * start + * indent will be " " + * + * @param {number} start + * @param {object} state + * @return {string} + */ +function indentBefore(start, state) { + var end = start; + start = start - 1; + + while (start > 0 && state.g.source[start] != '\n') { + if (!state.g.source[start].match(/[ \t]/)) { + end = start; + } + start--; + } + return state.g.source.substring(start + 1, end); +} + +function getDocblock(state) { + if (!state.g.docblock) { + var docblock = _dereq_('./docblock'); + state.g.docblock = + docblock.parseAsObject(docblock.extract(state.g.source)); + } + return state.g.docblock; +} + +function identWithinLexicalScope(identName, state, stopBeforeNode) { + var currScope = state.localScope; + while (currScope) { + if (currScope.identifiers[identName] !== undefined) { + return true; + } + + if (stopBeforeNode && currScope.parentNode === stopBeforeNode) { + break; + } + + currScope = currScope.parentScope; + } + return false; +} + +function identInLocalScope(identName, state) { + return state.localScope.identifiers[identName] !== undefined; +} + +/** + * @param {object} boundaryNode + * @param {?array} path + * @return {?object} node + */ +function initScopeMetadata(boundaryNode, path, node) { + return { + boundaryNode: boundaryNode, + bindingPath: path, + bindingNode: node + }; +} + +function declareIdentInLocalScope(identName, metaData, state) { + state.localScope.identifiers[identName] = { + boundaryNode: metaData.boundaryNode, + path: metaData.bindingPath, + node: metaData.bindingNode, + state: Object.create(state) + }; +} + +function getLexicalBindingMetadata(identName, state) { + var currScope = state.localScope; + while (currScope) { + if (currScope.identifiers[identName] !== undefined) { + return currScope.identifiers[identName]; + } + + currScope = currScope.parentScope; + } +} + +function getLocalBindingMetadata(identName, state) { + return state.localScope.identifiers[identName]; +} + +/** + * Apply the given analyzer function to the current node. If the analyzer + * doesn't return false, traverse each child of the current node using the given + * traverser function. + * + * @param {function} analyzer + * @param {function} traverser + * @param {object} node + * @param {array} path + * @param {object} state + */ +function analyzeAndTraverse(analyzer, traverser, node, path, state) { + if (node.type) { + if (analyzer(node, path, state) === false) { + return; + } + path.unshift(node); + } + + getOrderedChildren(node).forEach(function(child) { + traverser(child, path, state); + }); + + node.type && path.shift(); +} + +/** + * It is crucial that we traverse in order, or else catchup() on a later + * node that is processed out of order can move the buffer past a node + * that we haven't handled yet, preventing us from modifying that node. + * + * This can happen when a node has multiple properties containing children. + * For example, XJSElement nodes have `openingElement`, `closingElement` and + * `children`. If we traverse `openingElement`, then `closingElement`, then + * when we get to `children`, the buffer has already caught up to the end of + * the closing element, after the children. + * + * This is basically a Schwartzian transform. Collects an array of children, + * each one represented as [child, startIndex]; sorts the array by start + * index; then traverses the children in that order. + */ +function getOrderedChildren(node) { + var queue = []; + for (var key in node) { + if (node.hasOwnProperty(key)) { + enqueueNodeWithStartIndex(queue, node[key]); + } + } + queue.sort(function(a, b) { return a[1] - b[1]; }); + return queue.map(function(pair) { return pair[0]; }); +} + +/** + * Helper function for analyzeAndTraverse which queues up all of the children + * of the given node. + * + * Children can also be found in arrays, so we basically want to merge all of + * those arrays together so we can sort them and then traverse the children + * in order. + * + * One example is the Program node. It contains `body` and `comments`, both + * arrays. Lexographically, comments are interspersed throughout the body + * nodes, but esprima's AST groups them together. + */ +function enqueueNodeWithStartIndex(queue, node) { + if (typeof node !== 'object' || node === null) { + return; + } + if (node.range) { + queue.push([node, node.range[0]]); + } else if (Array.isArray(node)) { + for (var ii = 0; ii < node.length; ii++) { + enqueueNodeWithStartIndex(queue, node[ii]); + } + } +} + +/** + * Checks whether a node or any of its sub-nodes contains + * a syntactic construct of the passed type. + * @param {object} node - AST node to test. + * @param {string} type - node type to lookup. + */ +function containsChildOfType(node, type) { + return containsChildMatching(node, function(node) { + return node.type === type; + }); +} + +function containsChildMatching(node, matcher) { + var foundMatchingChild = false; + function nodeTypeAnalyzer(node) { + if (matcher(node) === true) { + foundMatchingChild = true; + return false; + } + } + function nodeTypeTraverser(child, path, state) { + if (!foundMatchingChild) { + foundMatchingChild = containsChildMatching(child, matcher); + } + } + analyzeAndTraverse( + nodeTypeAnalyzer, + nodeTypeTraverser, + node, + [] + ); + return foundMatchingChild; +} + +var scopeTypes = {}; +scopeTypes[Syntax.ArrowFunctionExpression] = true; +scopeTypes[Syntax.FunctionExpression] = true; +scopeTypes[Syntax.FunctionDeclaration] = true; +scopeTypes[Syntax.Program] = true; + +function getBoundaryNode(path) { + for (var ii = 0; ii < path.length; ++ii) { + if (scopeTypes[path[ii].type]) { + return path[ii]; + } + } + throw new Error( + 'Expected to find a node with one of the following types in path:\n' + + JSON.stringify(Object.keys(scopeTypes)) + ); +} + +function getTempVar(tempVarIndex) { + return '$__' + tempVarIndex; +} + +function injectTempVar(state) { + var tempVar = '$__' + (state.localScope.tempVarIndex++); + state.localScope.tempVars.push(tempVar); + return tempVar; +} + +function injectTempVarDeclarations(state, index) { + if (state.localScope.tempVars.length) { + state.g.buffer = + state.g.buffer.slice(0, index) + + 'var ' + state.localScope.tempVars.join(', ') + ';' + + state.g.buffer.slice(index); + state.localScope.tempVars = []; + } +} + +exports.analyzeAndTraverse = analyzeAndTraverse; +exports.append = append; +exports.catchup = catchup; +exports.catchupNewlines = catchupNewlines; +exports.catchupWhiteOut = catchupWhiteOut; +exports.catchupWhiteSpace = catchupWhiteSpace; +exports.containsChildMatching = containsChildMatching; +exports.containsChildOfType = containsChildOfType; +exports.createState = createState; +exports.declareIdentInLocalScope = declareIdentInLocalScope; +exports.getBoundaryNode = getBoundaryNode; +exports.getDocblock = getDocblock; +exports.getLexicalBindingMetadata = getLexicalBindingMetadata; +exports.getLocalBindingMetadata = getLocalBindingMetadata; +exports.getNextSyntacticCharOffset = getNextSyntacticCharOffset; +exports.getNodeSourceText = getNodeSourceText; +exports.getOrderedChildren = getOrderedChildren; +exports.getTempVar = getTempVar; +exports.identInLocalScope = identInLocalScope; +exports.identWithinLexicalScope = identWithinLexicalScope; +exports.indentBefore = indentBefore; +exports.initScopeMetadata = initScopeMetadata; +exports.injectTempVar = injectTempVar; +exports.injectTempVarDeclarations = injectTempVarDeclarations; +exports.move = move; +exports.scopeTypes = scopeTypes; +exports.updateIndent = updateIndent; +exports.updateState = updateState; + +},{"./docblock":21,"esprima-fb":9}],24:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*global exports:true*/ + +/** + * Desugars ES6 Arrow functions to ES3 function expressions. + * If the function contains `this` expression -- automatically + * binds the function to current value of `this`. + * + * Single parameter, simple expression: + * + * [1, 2, 3].map(x => x * x); + * + * [1, 2, 3].map(function(x) { return x * x; }); + * + * Several parameters, complex block: + * + * this.users.forEach((user, idx) => { + * return this.isActive(idx) && this.send(user); + * }); + * + * this.users.forEach(function(user, idx) { + * return this.isActive(idx) && this.send(user); + * }.bind(this)); + * + */ +var restParamVisitors = _dereq_('./es6-rest-param-visitors'); +var destructuringVisitors = _dereq_('./es6-destructuring-visitors'); + +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); + +/** + * @public + */ +function visitArrowFunction(traverse, node, path, state) { + var notInExpression = (path[0].type === Syntax.ExpressionStatement); + + // Wrap a function into a grouping operator, if it's not + // in the expression position. + if (notInExpression) { + utils.append('(', state); + } + + utils.append('function', state); + renderParams(traverse, node, path, state); + + // Skip arrow. + utils.catchupWhiteSpace(node.body.range[0], state); + + var renderBody = node.body.type == Syntax.BlockStatement + ? renderStatementBody + : renderExpressionBody; + + path.unshift(node); + renderBody(traverse, node, path, state); + path.shift(); + + // Bind the function only if `this` value is used + // inside it or inside any sub-expression. + var containsBindingSyntax = + utils.containsChildMatching(node.body, function(node) { + return node.type === Syntax.ThisExpression + || (node.type === Syntax.Identifier + && node.name === "super"); + }); + + if (containsBindingSyntax) { + utils.append('.bind(this)', state); + } + + utils.catchupWhiteSpace(node.range[1], state); + + // Close wrapper if not in the expression. + if (notInExpression) { + utils.append(')', state); + } + + return false; +} + +function renderParams(traverse, node, path, state) { + // To preserve inline typechecking directives, we + // distinguish between parens-free and paranthesized single param. + if (isParensFreeSingleParam(node, state) || !node.params.length) { + utils.append('(', state); + } + if (node.params.length !== 0) { + path.unshift(node); + traverse(node.params, path, state); + path.unshift(); + } + utils.append(')', state); +} + +function isParensFreeSingleParam(node, state) { + return node.params.length === 1 && + state.g.source[state.g.position] !== '('; +} + +function renderExpressionBody(traverse, node, path, state) { + // Wrap simple expression bodies into a block + // with explicit return statement. + utils.append('{', state); + + // Special handling of rest param. + if (node.rest) { + utils.append( + restParamVisitors.renderRestParamSetup(node, state), + state + ); + } + + // Special handling of destructured params. + destructuringVisitors.renderDestructuredComponents( + node, + utils.updateState(state, { + localScope: { + parentNode: state.parentNode, + parentScope: state.parentScope, + identifiers: state.identifiers, + tempVarIndex: 0 + } + }) + ); + + utils.append('return ', state); + renderStatementBody(traverse, node, path, state); + utils.append(';}', state); +} + +function renderStatementBody(traverse, node, path, state) { + traverse(node.body, path, state); + utils.catchup(node.body.range[1], state); +} + +visitArrowFunction.test = function(node, path, state) { + return node.type === Syntax.ArrowFunctionExpression; +}; + +exports.visitorList = [ + visitArrowFunction +]; + + +},{"../src/utils":23,"./es6-destructuring-visitors":27,"./es6-rest-param-visitors":30,"esprima-fb":9}],25:[function(_dereq_,module,exports){ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + */ +/*global exports:true*/ + +/** + * Implements ES6 call spread. + * + * instance.method(a, b, c, ...d) + * + * instance.method.apply(instance, [a, b, c].concat(d)) + * + */ + +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); + +function process(traverse, node, path, state) { + utils.move(node.range[0], state); + traverse(node, path, state); + utils.catchup(node.range[1], state); +} + +function visitCallSpread(traverse, node, path, state) { + utils.catchup(node.range[0], state); + + if (node.type === Syntax.NewExpression) { + // Input = new Set(1, 2, ...list) + // Output = new (Function.prototype.bind.apply(Set, [null, 1, 2].concat(list))) + utils.append('new (Function.prototype.bind.apply(', state); + process(traverse, node.callee, path, state); + } else if (node.callee.type === Syntax.MemberExpression) { + // Input = get().fn(1, 2, ...more) + // Output = (_ = get()).fn.apply(_, [1, 2].apply(more)) + var tempVar = utils.injectTempVar(state); + utils.append('(' + tempVar + ' = ', state); + process(traverse, node.callee.object, path, state); + utils.append(')', state); + if (node.callee.property.type === Syntax.Identifier) { + utils.append('.', state); + process(traverse, node.callee.property, path, state); + } else { + utils.append('[', state); + process(traverse, node.callee.property, path, state); + utils.append(']', state); + } + utils.append('.apply(' + tempVar, state); + } else { + // Input = max(1, 2, ...list) + // Output = max.apply(null, [1, 2].concat(list)) + var needsToBeWrappedInParenthesis = + node.callee.type === Syntax.FunctionDeclaration || + node.callee.type === Syntax.FunctionExpression; + if (needsToBeWrappedInParenthesis) { + utils.append('(', state); + } + process(traverse, node.callee, path, state); + if (needsToBeWrappedInParenthesis) { + utils.append(')', state); + } + utils.append('.apply(null', state); + } + utils.append(', ', state); + + var args = node.arguments.slice(); + var spread = args.pop(); + if (args.length || node.type === Syntax.NewExpression) { + utils.append('[', state); + if (node.type === Syntax.NewExpression) { + utils.append('null' + (args.length ? ', ' : ''), state); + } + while (args.length) { + var arg = args.shift(); + utils.move(arg.range[0], state); + traverse(arg, path, state); + if (args.length) { + utils.catchup(args[0].range[0], state); + } else { + utils.catchup(arg.range[1], state); + } + } + utils.append('].concat(', state); + process(traverse, spread.argument, path, state); + utils.append(')', state); + } else { + process(traverse, spread.argument, path, state); + } + utils.append(node.type === Syntax.NewExpression ? '))' : ')', state); + + utils.move(node.range[1], state); + return false; +} + +visitCallSpread.test = function(node, path, state) { + return ( + ( + node.type === Syntax.CallExpression || + node.type === Syntax.NewExpression + ) && + node.arguments.length > 0 && + node.arguments[node.arguments.length - 1].type === Syntax.SpreadElement + ); +}; + +exports.visitorList = [ + visitCallSpread +]; + +},{"../src/utils":23,"esprima-fb":9}],26:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*jslint node:true*/ + +/** + * @typechecks + */ +'use strict'; + +var base62 = _dereq_('base62'); +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); +var reservedWordsHelper = _dereq_('./reserved-words-helper'); + +var declareIdentInLocalScope = utils.declareIdentInLocalScope; +var initScopeMetadata = utils.initScopeMetadata; + +var SUPER_PROTO_IDENT_PREFIX = '____SuperProtoOf'; + +var _anonClassUUIDCounter = 0; +var _mungedSymbolMaps = {}; + +function resetSymbols() { + _anonClassUUIDCounter = 0; + _mungedSymbolMaps = {}; +} + +/** + * Used to generate a unique class for use with code-gens for anonymous class + * expressions. + * + * @param {object} state + * @return {string} + */ +function _generateAnonymousClassName(state) { + var mungeNamespace = state.mungeNamespace || ''; + return '____Class' + mungeNamespace + base62.encode(_anonClassUUIDCounter++); +} + +/** + * Given an identifier name, munge it using the current state's mungeNamespace. + * + * @param {string} identName + * @param {object} state + * @return {string} + */ +function _getMungedName(identName, state) { + var mungeNamespace = state.mungeNamespace; + var shouldMinify = state.g.opts.minify; + + if (shouldMinify) { + if (!_mungedSymbolMaps[mungeNamespace]) { + _mungedSymbolMaps[mungeNamespace] = { + symbolMap: {}, + identUUIDCounter: 0 + }; + } + + var symbolMap = _mungedSymbolMaps[mungeNamespace].symbolMap; + if (!symbolMap[identName]) { + symbolMap[identName] = + base62.encode(_mungedSymbolMaps[mungeNamespace].identUUIDCounter++); + } + identName = symbolMap[identName]; + } + return '$' + mungeNamespace + identName; +} + +/** + * Extracts super class information from a class node. + * + * Information includes name of the super class and/or the expression string + * (if extending from an expression) + * + * @param {object} node + * @param {object} state + * @return {object} + */ +function _getSuperClassInfo(node, state) { + var ret = { + name: null, + expression: null + }; + if (node.superClass) { + if (node.superClass.type === Syntax.Identifier) { + ret.name = node.superClass.name; + } else { + // Extension from an expression + ret.name = _generateAnonymousClassName(state); + ret.expression = state.g.source.substring( + node.superClass.range[0], + node.superClass.range[1] + ); + } + } + return ret; +} + +/** + * Used with .filter() to find the constructor method in a list of + * MethodDefinition nodes. + * + * @param {object} classElement + * @return {boolean} + */ +function _isConstructorMethod(classElement) { + return classElement.type === Syntax.MethodDefinition && + classElement.key.type === Syntax.Identifier && + classElement.key.name === 'constructor'; +} + +/** + * @param {object} node + * @param {object} state + * @return {boolean} + */ +function _shouldMungeIdentifier(node, state) { + return ( + !!state.methodFuncNode && + !utils.getDocblock(state).hasOwnProperty('preventMunge') && + /^_(?!_)/.test(node.name) + ); +} + +/** + * @param {function} traverse + * @param {object} node + * @param {array} path + * @param {object} state + */ +function visitClassMethod(traverse, node, path, state) { + if (!state.g.opts.es5 && (node.kind === 'get' || node.kind === 'set')) { + throw new Error( + 'This transform does not support ' + node.kind + 'ter methods for ES6 ' + + 'classes. (line: ' + node.loc.start.line + ', col: ' + + node.loc.start.column + ')' + ); + } + state = utils.updateState(state, { + methodNode: node + }); + utils.catchup(node.range[0], state); + path.unshift(node); + traverse(node.value, path, state); + path.shift(); + return false; +} +visitClassMethod.test = function(node, path, state) { + return node.type === Syntax.MethodDefinition; +}; + +/** + * @param {function} traverse + * @param {object} node + * @param {array} path + * @param {object} state + */ +function visitClassFunctionExpression(traverse, node, path, state) { + var methodNode = path[0]; + var isGetter = methodNode.kind === 'get'; + var isSetter = methodNode.kind === 'set'; + + state = utils.updateState(state, { + methodFuncNode: node + }); + + if (methodNode.key.name === 'constructor') { + utils.append('function ' + state.className, state); + } else { + var methodAccessorComputed = false; + var methodAccessor; + var prototypeOrStatic = methodNode["static"] ? '' : '.prototype'; + var objectAccessor = state.className + prototypeOrStatic; + + if (methodNode.key.type === Syntax.Identifier) { + // foo() {} + methodAccessor = methodNode.key.name; + if (_shouldMungeIdentifier(methodNode.key, state)) { + methodAccessor = _getMungedName(methodAccessor, state); + } + if (isGetter || isSetter) { + methodAccessor = JSON.stringify(methodAccessor); + } else if (reservedWordsHelper.isReservedWord(methodAccessor)) { + methodAccessorComputed = true; + methodAccessor = JSON.stringify(methodAccessor); + } + } else if (methodNode.key.type === Syntax.Literal) { + // 'foo bar'() {} | get 'foo bar'() {} | set 'foo bar'() {} + methodAccessor = JSON.stringify(methodNode.key.value); + methodAccessorComputed = true; + } + + if (isSetter || isGetter) { + utils.append( + 'Object.defineProperty(' + + objectAccessor + ',' + + methodAccessor + ',' + + '{configurable:true,' + + methodNode.kind + ':function', + state + ); + } else { + if (state.g.opts.es3) { + if (methodAccessorComputed) { + methodAccessor = '[' + methodAccessor + ']'; + } else { + methodAccessor = '.' + methodAccessor; + } + utils.append( + objectAccessor + + methodAccessor + '=function' + (node.generator ? '*' : ''), + state + ); + } else { + if (!methodAccessorComputed) { + methodAccessor = JSON.stringify(methodAccessor); + } + utils.append( + 'Object.defineProperty(' + + objectAccessor + ',' + + methodAccessor + ',' + + '{writable:true,configurable:true,' + + 'value:function' + (node.generator ? '*' : ''), + state + ); + } + } + } + utils.move(methodNode.key.range[1], state); + utils.append('(', state); + + var params = node.params; + if (params.length > 0) { + utils.catchupNewlines(params[0].range[0], state); + for (var i = 0; i < params.length; i++) { + utils.catchup(node.params[i].range[0], state); + path.unshift(node); + traverse(params[i], path, state); + path.shift(); + } + } + + var closingParenPosition = utils.getNextSyntacticCharOffset(')', state); + utils.catchupWhiteSpace(closingParenPosition, state); + + var openingBracketPosition = utils.getNextSyntacticCharOffset('{', state); + utils.catchup(openingBracketPosition + 1, state); + + if (!state.scopeIsStrict) { + utils.append('"use strict";', state); + state = utils.updateState(state, { + scopeIsStrict: true + }); + } + utils.move(node.body.range[0] + '{'.length, state); + + path.unshift(node); + traverse(node.body, path, state); + path.shift(); + utils.catchup(node.body.range[1], state); + + if (methodNode.key.name !== 'constructor') { + if (isGetter || isSetter || !state.g.opts.es3) { + utils.append('})', state); + } + utils.append(';', state); + } + return false; +} +visitClassFunctionExpression.test = function(node, path, state) { + return node.type === Syntax.FunctionExpression + && path[0].type === Syntax.MethodDefinition; +}; + +function visitClassMethodParam(traverse, node, path, state) { + var paramName = node.name; + if (_shouldMungeIdentifier(node, state)) { + paramName = _getMungedName(node.name, state); + } + utils.append(paramName, state); + utils.move(node.range[1], state); +} +visitClassMethodParam.test = function(node, path, state) { + if (!path[0] || !path[1]) { + return; + } + + var parentFuncExpr = path[0]; + var parentClassMethod = path[1]; + + return parentFuncExpr.type === Syntax.FunctionExpression + && parentClassMethod.type === Syntax.MethodDefinition + && node.type === Syntax.Identifier; +}; + +/** + * @param {function} traverse + * @param {object} node + * @param {array} path + * @param {object} state + */ +function _renderClassBody(traverse, node, path, state) { + var className = state.className; + var superClass = state.superClass; + + // Set up prototype of constructor on same line as `extends` for line-number + // preservation. This relies on function-hoisting if a constructor function is + // defined in the class body. + if (superClass.name) { + // If the super class is an expression, we need to memoize the output of the + // expression into the generated class name variable and use that to refer + // to the super class going forward. Example: + // + // class Foo extends mixin(Bar, Baz) {} + // --transforms to-- + // function Foo() {} var ____Class0Blah = mixin(Bar, Baz); + if (superClass.expression !== null) { + utils.append( + 'var ' + superClass.name + '=' + superClass.expression + ';', + state + ); + } + + var keyName = superClass.name + '____Key'; + var keyNameDeclarator = ''; + if (!utils.identWithinLexicalScope(keyName, state)) { + keyNameDeclarator = 'var '; + declareIdentInLocalScope(keyName, initScopeMetadata(node), state); + } + utils.append( + 'for(' + keyNameDeclarator + keyName + ' in ' + superClass.name + '){' + + 'if(' + superClass.name + '.hasOwnProperty(' + keyName + ')){' + + className + '[' + keyName + ']=' + + superClass.name + '[' + keyName + '];' + + '}' + + '}', + state + ); + + var superProtoIdentStr = SUPER_PROTO_IDENT_PREFIX + superClass.name; + if (!utils.identWithinLexicalScope(superProtoIdentStr, state)) { + utils.append( + 'var ' + superProtoIdentStr + '=' + superClass.name + '===null?' + + 'null:' + superClass.name + '.prototype;', + state + ); + declareIdentInLocalScope(superProtoIdentStr, initScopeMetadata(node), state); + } + + utils.append( + className + '.prototype=Object.create(' + superProtoIdentStr + ');', + state + ); + utils.append( + className + '.prototype.constructor=' + className + ';', + state + ); + utils.append( + className + '.__superConstructor__=' + superClass.name + ';', + state + ); + } + + // If there's no constructor method specified in the class body, create an + // empty constructor function at the top (same line as the class keyword) + if (!node.body.body.filter(_isConstructorMethod).pop()) { + utils.append('function ' + className + '(){', state); + if (!state.scopeIsStrict) { + utils.append('"use strict";', state); + } + if (superClass.name) { + utils.append( + 'if(' + superClass.name + '!==null){' + + superClass.name + '.apply(this,arguments);}', + state + ); + } + utils.append('}', state); + } + + utils.move(node.body.range[0] + '{'.length, state); + traverse(node.body, path, state); + utils.catchupWhiteSpace(node.range[1], state); +} + +/** + * @param {function} traverse + * @param {object} node + * @param {array} path + * @param {object} state + */ +function visitClassDeclaration(traverse, node, path, state) { + var className = node.id.name; + var superClass = _getSuperClassInfo(node, state); + + state = utils.updateState(state, { + mungeNamespace: className, + className: className, + superClass: superClass + }); + + _renderClassBody(traverse, node, path, state); + + return false; +} +visitClassDeclaration.test = function(node, path, state) { + return node.type === Syntax.ClassDeclaration; +}; + +/** + * @param {function} traverse + * @param {object} node + * @param {array} path + * @param {object} state + */ +function visitClassExpression(traverse, node, path, state) { + var className = node.id && node.id.name || _generateAnonymousClassName(state); + var superClass = _getSuperClassInfo(node, state); + + utils.append('(function(){', state); + + state = utils.updateState(state, { + mungeNamespace: className, + className: className, + superClass: superClass + }); + + _renderClassBody(traverse, node, path, state); + + utils.append('return ' + className + ';})()', state); + return false; +} +visitClassExpression.test = function(node, path, state) { + return node.type === Syntax.ClassExpression; +}; + +/** + * @param {function} traverse + * @param {object} node + * @param {array} path + * @param {object} state + */ +function visitPrivateIdentifier(traverse, node, path, state) { + utils.append(_getMungedName(node.name, state), state); + utils.move(node.range[1], state); +} +visitPrivateIdentifier.test = function(node, path, state) { + if (node.type === Syntax.Identifier && _shouldMungeIdentifier(node, state)) { + // Always munge non-computed properties of MemberExpressions + // (a la preventing access of properties of unowned objects) + if (path[0].type === Syntax.MemberExpression && path[0].object !== node + && path[0].computed === false) { + return true; + } + + // Always munge identifiers that were declared within the method function + // scope + if (utils.identWithinLexicalScope(node.name, state, state.methodFuncNode)) { + return true; + } + + // Always munge private keys on object literals defined within a method's + // scope. + if (path[0].type === Syntax.Property + && path[1].type === Syntax.ObjectExpression) { + return true; + } + + // Always munge function parameters + if (path[0].type === Syntax.FunctionExpression + || path[0].type === Syntax.FunctionDeclaration + || path[0].type === Syntax.ArrowFunctionExpression) { + for (var i = 0; i < path[0].params.length; i++) { + if (path[0].params[i] === node) { + return true; + } + } + } + } + return false; +}; + +/** + * @param {function} traverse + * @param {object} node + * @param {array} path + * @param {object} state + */ +function visitSuperCallExpression(traverse, node, path, state) { + var superClassName = state.superClass.name; + + if (node.callee.type === Syntax.Identifier) { + if (_isConstructorMethod(state.methodNode)) { + utils.append(superClassName + '.call(', state); + } else { + var protoProp = SUPER_PROTO_IDENT_PREFIX + superClassName; + if (state.methodNode.key.type === Syntax.Identifier) { + protoProp += '.' + state.methodNode.key.name; + } else if (state.methodNode.key.type === Syntax.Literal) { + protoProp += '[' + JSON.stringify(state.methodNode.key.value) + ']'; + } + utils.append(protoProp + ".call(", state); + } + utils.move(node.callee.range[1], state); + } else if (node.callee.type === Syntax.MemberExpression) { + utils.append(SUPER_PROTO_IDENT_PREFIX + superClassName, state); + utils.move(node.callee.object.range[1], state); + + if (node.callee.computed) { + // ["a" + "b"] + utils.catchup(node.callee.property.range[1] + ']'.length, state); + } else { + // .ab + utils.append('.' + node.callee.property.name, state); + } + + utils.append('.call(', state); + utils.move(node.callee.range[1], state); + } + + utils.append('this', state); + if (node.arguments.length > 0) { + utils.append(',', state); + utils.catchupWhiteSpace(node.arguments[0].range[0], state); + traverse(node.arguments, path, state); + } + + utils.catchupWhiteSpace(node.range[1], state); + utils.append(')', state); + return false; +} +visitSuperCallExpression.test = function(node, path, state) { + if (state.superClass && node.type === Syntax.CallExpression) { + var callee = node.callee; + if (callee.type === Syntax.Identifier && callee.name === 'super' + || callee.type == Syntax.MemberExpression + && callee.object.name === 'super') { + return true; + } + } + return false; +}; + +/** + * @param {function} traverse + * @param {object} node + * @param {array} path + * @param {object} state + */ +function visitSuperMemberExpression(traverse, node, path, state) { + var superClassName = state.superClass.name; + + utils.append(SUPER_PROTO_IDENT_PREFIX + superClassName, state); + utils.move(node.object.range[1], state); +} +visitSuperMemberExpression.test = function(node, path, state) { + return state.superClass + && node.type === Syntax.MemberExpression + && node.object.type === Syntax.Identifier + && node.object.name === 'super'; +}; + +exports.resetSymbols = resetSymbols; + +exports.visitorList = [ + visitClassDeclaration, + visitClassExpression, + visitClassFunctionExpression, + visitClassMethod, + visitClassMethodParam, + visitPrivateIdentifier, + visitSuperCallExpression, + visitSuperMemberExpression +]; + +},{"../src/utils":23,"./reserved-words-helper":34,"base62":10,"esprima-fb":9}],27:[function(_dereq_,module,exports){ +/** + * Copyright 2014 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*global exports:true*/ + +/** + * Implements ES6 destructuring assignment and pattern matchng. + * + * function init({port, ip, coords: [x, y]}) { + * return (x && y) ? {id, port} : {ip}; + * }; + * + * function init($__0) { + * var + * port = $__0.port, + * ip = $__0.ip, + * $__1 = $__0.coords, + * x = $__1[0], + * y = $__1[1]; + * return (x && y) ? {id, port} : {ip}; + * } + * + * var x, {ip, port} = init({ip, port}); + * + * var x, $__0 = init({ip, port}), ip = $__0.ip, port = $__0.port; + * + */ +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); + +var reservedWordsHelper = _dereq_('./reserved-words-helper'); +var restParamVisitors = _dereq_('./es6-rest-param-visitors'); +var restPropertyHelpers = _dereq_('./es7-rest-property-helpers'); + +// ------------------------------------------------------- +// 1. Structured variable declarations. +// +// var [a, b] = [b, a]; +// var {x, y} = {y, x}; +// ------------------------------------------------------- + +function visitStructuredVariable(traverse, node, path, state) { + // Allocate new temp for the pattern. + utils.append(utils.getTempVar(state.localScope.tempVarIndex) + '=', state); + // Skip the pattern and assign the init to the temp. + utils.catchupWhiteSpace(node.init.range[0], state); + traverse(node.init, path, state); + utils.catchup(node.init.range[1], state); + // Render the destructured data. + utils.append(',' + getDestructuredComponents(node.id, state), state); + state.localScope.tempVarIndex++; + return false; +} + +visitStructuredVariable.test = function(node, path, state) { + return node.type === Syntax.VariableDeclarator && + isStructuredPattern(node.id); +}; + +function isStructuredPattern(node) { + return node.type === Syntax.ObjectPattern || + node.type === Syntax.ArrayPattern; +} + +// Main function which does actual recursive destructuring +// of nested complex structures. +function getDestructuredComponents(node, state) { + var tmpIndex = state.localScope.tempVarIndex; + var components = []; + var patternItems = getPatternItems(node); + + for (var idx = 0; idx < patternItems.length; idx++) { + var item = patternItems[idx]; + if (!item) { + continue; + } + + if (item.type === Syntax.SpreadElement) { + // Spread/rest of an array. + // TODO(dmitrys): support spread in the middle of a pattern + // and also for function param patterns: [x, ...xs, y] + components.push(item.argument.name + + '=Array.prototype.slice.call(' + + utils.getTempVar(tmpIndex) + ',' + idx + ')' + ); + continue; + } + + if (item.type === Syntax.SpreadProperty) { + var restExpression = restPropertyHelpers.renderRestExpression( + utils.getTempVar(tmpIndex), + patternItems + ); + components.push(item.argument.name + '=' + restExpression); + continue; + } + + // Depending on pattern type (Array or Object), we get + // corresponding pattern item parts. + var accessor = getPatternItemAccessor(node, item, tmpIndex, idx); + var value = getPatternItemValue(node, item); + + // TODO(dmitrys): implement default values: {x, y=5} + if (value.type === Syntax.Identifier) { + // Simple pattern item. + components.push(value.name + '=' + accessor); + } else { + // Complex sub-structure. + components.push( + utils.getTempVar(++state.localScope.tempVarIndex) + '=' + accessor + + ',' + getDestructuredComponents(value, state) + ); + } + } + + return components.join(','); +} + +function getPatternItems(node) { + return node.properties || node.elements; +} + +function getPatternItemAccessor(node, patternItem, tmpIndex, idx) { + var tmpName = utils.getTempVar(tmpIndex); + if (node.type === Syntax.ObjectPattern) { + if (reservedWordsHelper.isReservedWord(patternItem.key.name)) { + return tmpName + '["' + patternItem.key.name + '"]'; + } else if (patternItem.key.type === Syntax.Literal) { + return tmpName + '[' + JSON.stringify(patternItem.key.value) + ']'; + } else if (patternItem.key.type === Syntax.Identifier) { + return tmpName + '.' + patternItem.key.name; + } + } else if (node.type === Syntax.ArrayPattern) { + return tmpName + '[' + idx + ']'; + } +} + +function getPatternItemValue(node, patternItem) { + return node.type === Syntax.ObjectPattern + ? patternItem.value + : patternItem; +} + +// ------------------------------------------------------- +// 2. Assignment expression. +// +// [a, b] = [b, a]; +// ({x, y} = {y, x}); +// ------------------------------------------------------- + +function visitStructuredAssignment(traverse, node, path, state) { + var exprNode = node.expression; + utils.append('var ' + utils.getTempVar(state.localScope.tempVarIndex) + '=', state); + + utils.catchupWhiteSpace(exprNode.right.range[0], state); + traverse(exprNode.right, path, state); + utils.catchup(exprNode.right.range[1], state); + + utils.append( + ';' + getDestructuredComponents(exprNode.left, state) + ';', + state + ); + + utils.catchupWhiteSpace(node.range[1], state); + state.localScope.tempVarIndex++; + return false; +} + +visitStructuredAssignment.test = function(node, path, state) { + // We consider the expression statement rather than just assignment + // expression to cover case with object patters which should be + // wrapped in grouping operator: ({x, y} = {y, x}); + return node.type === Syntax.ExpressionStatement && + node.expression.type === Syntax.AssignmentExpression && + isStructuredPattern(node.expression.left); +}; + +// ------------------------------------------------------- +// 3. Structured parameter. +// +// function foo({x, y}) { ... } +// ------------------------------------------------------- + +function visitStructuredParameter(traverse, node, path, state) { + utils.append(utils.getTempVar(getParamIndex(node, path)), state); + utils.catchupWhiteSpace(node.range[1], state); + return true; +} + +function getParamIndex(paramNode, path) { + var funcNode = path[0]; + var tmpIndex = 0; + for (var k = 0; k < funcNode.params.length; k++) { + var param = funcNode.params[k]; + if (param === paramNode) { + break; + } + if (isStructuredPattern(param)) { + tmpIndex++; + } + } + return tmpIndex; +} + +visitStructuredParameter.test = function(node, path, state) { + return isStructuredPattern(node) && isFunctionNode(path[0]); +}; + +function isFunctionNode(node) { + return (node.type == Syntax.FunctionDeclaration || + node.type == Syntax.FunctionExpression || + node.type == Syntax.MethodDefinition || + node.type == Syntax.ArrowFunctionExpression); +} + +// ------------------------------------------------------- +// 4. Function body for structured parameters. +// +// function foo({x, y}) { x; y; } +// ------------------------------------------------------- + +function visitFunctionBodyForStructuredParameter(traverse, node, path, state) { + var funcNode = path[0]; + + utils.catchup(funcNode.body.range[0] + 1, state); + renderDestructuredComponents(funcNode, state); + + if (funcNode.rest) { + utils.append( + restParamVisitors.renderRestParamSetup(funcNode, state), + state + ); + } + + return true; +} + +function renderDestructuredComponents(funcNode, state) { + var destructuredComponents = []; + + for (var k = 0; k < funcNode.params.length; k++) { + var param = funcNode.params[k]; + if (isStructuredPattern(param)) { + destructuredComponents.push( + getDestructuredComponents(param, state) + ); + state.localScope.tempVarIndex++; + } + } + + if (destructuredComponents.length) { + utils.append('var ' + destructuredComponents.join(',') + ';', state); + } +} + +visitFunctionBodyForStructuredParameter.test = function(node, path, state) { + return node.type === Syntax.BlockStatement && isFunctionNode(path[0]); +}; + +exports.visitorList = [ + visitStructuredVariable, + visitStructuredAssignment, + visitStructuredParameter, + visitFunctionBodyForStructuredParameter +]; + +exports.renderDestructuredComponents = renderDestructuredComponents; + + +},{"../src/utils":23,"./es6-rest-param-visitors":30,"./es7-rest-property-helpers":32,"./reserved-words-helper":34,"esprima-fb":9}],28:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*jslint node:true*/ + +/** + * Desugars concise methods of objects to function expressions. + * + * var foo = { + * method(x, y) { ... } + * }; + * + * var foo = { + * method: function(x, y) { ... } + * }; + * + */ + +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); +var reservedWordsHelper = _dereq_('./reserved-words-helper'); + +function visitObjectConciseMethod(traverse, node, path, state) { + var isGenerator = node.value.generator; + if (isGenerator) { + utils.catchupWhiteSpace(node.range[0] + 1, state); + } + if (node.computed) { // []() { ...} + utils.catchup(node.key.range[1] + 1, state); + } else if (reservedWordsHelper.isReservedWord(node.key.name)) { + utils.catchup(node.key.range[0], state); + utils.append('"', state); + utils.catchup(node.key.range[1], state); + utils.append('"', state); + } + + utils.catchup(node.key.range[1], state); + utils.append( + ':function' + (isGenerator ? '*' : ''), + state + ); + path.unshift(node); + traverse(node.value, path, state); + path.shift(); + return false; +} + +visitObjectConciseMethod.test = function(node, path, state) { + return node.type === Syntax.Property && + node.value.type === Syntax.FunctionExpression && + node.method === true; +}; + +exports.visitorList = [ + visitObjectConciseMethod +]; + +},{"../src/utils":23,"./reserved-words-helper":34,"esprima-fb":9}],29:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*jslint node: true*/ + +/** + * Desugars ES6 Object Literal short notations into ES3 full notation. + * + * // Easier return values. + * function foo(x, y) { + * return {x, y}; // {x: x, y: y} + * }; + * + * // Destructuring. + * function init({port, ip, coords: {x, y}}) { ... } + * + */ +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); + +/** + * @public + */ +function visitObjectLiteralShortNotation(traverse, node, path, state) { + utils.catchup(node.key.range[1], state); + utils.append(':' + node.key.name, state); + return false; +} + +visitObjectLiteralShortNotation.test = function(node, path, state) { + return node.type === Syntax.Property && + node.kind === 'init' && + node.shorthand === true && + path[0].type !== Syntax.ObjectPattern; +}; + +exports.visitorList = [ + visitObjectLiteralShortNotation +]; + + +},{"../src/utils":23,"esprima-fb":9}],30:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*jslint node:true*/ + +/** + * Desugars ES6 rest parameters into an ES3 arguments array. + * + * function printf(template, ...args) { + * args.forEach(...); + * } + * + * We could use `Array.prototype.slice.call`, but that usage of arguments causes + * functions to be deoptimized in V8, so instead we use a for-loop. + * + * function printf(template) { + * for (var args = [], $__0 = 1, $__1 = arguments.length; $__0 < $__1; $__0++) + * args.push(arguments[$__0]); + * args.forEach(...); + * } + * + */ +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); + + + +function _nodeIsFunctionWithRestParam(node) { + return (node.type === Syntax.FunctionDeclaration + || node.type === Syntax.FunctionExpression + || node.type === Syntax.ArrowFunctionExpression) + && node.rest; +} + +function visitFunctionParamsWithRestParam(traverse, node, path, state) { + if (node.parametricType) { + utils.catchup(node.parametricType.range[0], state); + path.unshift(node); + traverse(node.parametricType, path, state); + path.shift(); + } + + // Render params. + if (node.params.length) { + path.unshift(node); + traverse(node.params, path, state); + path.shift(); + } else { + // -3 is for ... of the rest. + utils.catchup(node.rest.range[0] - 3, state); + } + utils.catchupWhiteSpace(node.rest.range[1], state); + + path.unshift(node); + traverse(node.body, path, state); + path.shift(); + + return false; +} + +visitFunctionParamsWithRestParam.test = function(node, path, state) { + return _nodeIsFunctionWithRestParam(node); +}; + +function renderRestParamSetup(functionNode, state) { + var idx = state.localScope.tempVarIndex++; + var len = state.localScope.tempVarIndex++; + + return 'for (var ' + functionNode.rest.name + '=[],' + + utils.getTempVar(idx) + '=' + functionNode.params.length + ',' + + utils.getTempVar(len) + '=arguments.length;' + + utils.getTempVar(idx) + '<' + utils.getTempVar(len) + ';' + + utils.getTempVar(idx) + '++) ' + + functionNode.rest.name + '.push(arguments[' + utils.getTempVar(idx) + ']);'; +} + +function visitFunctionBodyWithRestParam(traverse, node, path, state) { + utils.catchup(node.range[0] + 1, state); + var parentNode = path[0]; + utils.append(renderRestParamSetup(parentNode, state), state); + return true; +} + +visitFunctionBodyWithRestParam.test = function(node, path, state) { + return node.type === Syntax.BlockStatement + && _nodeIsFunctionWithRestParam(path[0]); +}; + +exports.renderRestParamSetup = renderRestParamSetup; +exports.visitorList = [ + visitFunctionParamsWithRestParam, + visitFunctionBodyWithRestParam +]; + +},{"../src/utils":23,"esprima-fb":9}],31:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*jslint node:true*/ + +/** + * @typechecks + */ +'use strict'; + +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); + +/** + * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-12.1.9 + */ +function visitTemplateLiteral(traverse, node, path, state) { + var templateElements = node.quasis; + + utils.append('(', state); + for (var ii = 0; ii < templateElements.length; ii++) { + var templateElement = templateElements[ii]; + if (templateElement.value.raw !== '') { + utils.append(getCookedValue(templateElement), state); + if (!templateElement.tail) { + // + between element and substitution + utils.append(' + ', state); + } + // maintain line numbers + utils.move(templateElement.range[0], state); + utils.catchupNewlines(templateElement.range[1], state); + } else { // templateElement.value.raw === '' + // Concatenat adjacent substitutions, e.g. `${x}${y}`. Empty templates + // appear before the first and after the last element - nothing to add in + // those cases. + if (ii > 0 && !templateElement.tail) { + // + between substitution and substitution + utils.append(' + ', state); + } + } + + utils.move(templateElement.range[1], state); + if (!templateElement.tail) { + var substitution = node.expressions[ii]; + if (substitution.type === Syntax.Identifier || + substitution.type === Syntax.MemberExpression || + substitution.type === Syntax.CallExpression) { + utils.catchup(substitution.range[1], state); + } else { + utils.append('(', state); + traverse(substitution, path, state); + utils.catchup(substitution.range[1], state); + utils.append(')', state); + } + // if next templateElement isn't empty... + if (templateElements[ii + 1].value.cooked !== '') { + utils.append(' + ', state); + } + } + } + utils.move(node.range[1], state); + utils.append(')', state); + return false; +} + +visitTemplateLiteral.test = function(node, path, state) { + return node.type === Syntax.TemplateLiteral; +}; + +/** + * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-12.2.6 + */ +function visitTaggedTemplateExpression(traverse, node, path, state) { + var template = node.quasi; + var numQuasis = template.quasis.length; + + // print the tag + utils.move(node.tag.range[0], state); + traverse(node.tag, path, state); + utils.catchup(node.tag.range[1], state); + + // print array of template elements + utils.append('(function() { var siteObj = [', state); + for (var ii = 0; ii < numQuasis; ii++) { + utils.append(getCookedValue(template.quasis[ii]), state); + if (ii !== numQuasis - 1) { + utils.append(', ', state); + } + } + utils.append(']; siteObj.raw = [', state); + for (ii = 0; ii < numQuasis; ii++) { + utils.append(getRawValue(template.quasis[ii]), state); + if (ii !== numQuasis - 1) { + utils.append(', ', state); + } + } + utils.append( + ']; Object.freeze(siteObj.raw); Object.freeze(siteObj); return siteObj; }()', + state + ); + + // print substitutions + if (numQuasis > 1) { + for (ii = 0; ii < template.expressions.length; ii++) { + var expression = template.expressions[ii]; + utils.append(', ', state); + + // maintain line numbers by calling catchupWhiteSpace over the whole + // previous TemplateElement + utils.move(template.quasis[ii].range[0], state); + utils.catchupNewlines(template.quasis[ii].range[1], state); + + utils.move(expression.range[0], state); + traverse(expression, path, state); + utils.catchup(expression.range[1], state); + } + } + + // print blank lines to push the closing ) down to account for the final + // TemplateElement. + utils.catchupNewlines(node.range[1], state); + + utils.append(')', state); + + return false; +} + +visitTaggedTemplateExpression.test = function(node, path, state) { + return node.type === Syntax.TaggedTemplateExpression; +}; + +function getCookedValue(templateElement) { + return JSON.stringify(templateElement.value.cooked); +} + +function getRawValue(templateElement) { + return JSON.stringify(templateElement.value.raw); +} + +exports.visitorList = [ + visitTemplateLiteral, + visitTaggedTemplateExpression +]; + +},{"../src/utils":23,"esprima-fb":9}],32:[function(_dereq_,module,exports){ +/** + * Copyright 2013 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*jslint node:true*/ + +/** + * Desugars ES7 rest properties into ES5 object iteration. + */ + +var Syntax = _dereq_('esprima-fb').Syntax; + +// TODO: This is a pretty massive helper, it should only be defined once, in the +// transform's runtime environment. We don't currently have a runtime though. +var restFunction = + '(function(source, exclusion) {' + + 'var rest = {};' + + 'var hasOwn = Object.prototype.hasOwnProperty;' + + 'if (source == null) {' + + 'throw new TypeError();' + + '}' + + 'for (var key in source) {' + + 'if (hasOwn.call(source, key) && !hasOwn.call(exclusion, key)) {' + + 'rest[key] = source[key];' + + '}' + + '}' + + 'return rest;' + + '})'; + +function getPropertyNames(properties) { + var names = []; + for (var i = 0; i < properties.length; i++) { + var property = properties[i]; + if (property.type === Syntax.SpreadProperty) { + continue; + } + if (property.type === Syntax.Identifier) { + names.push(property.name); + } else { + names.push(property.key.name); + } + } + return names; +} + +function getRestFunctionCall(source, exclusion) { + return restFunction + '(' + source + ',' + exclusion + ')'; +} + +function getSimpleShallowCopy(accessorExpression) { + // This could be faster with 'Object.assign({}, ' + accessorExpression + ')' + // but to unify code paths and avoid a ES6 dependency we use the same + // helper as for the exclusion case. + return getRestFunctionCall(accessorExpression, '{}'); +} + +function renderRestExpression(accessorExpression, excludedProperties) { + var excludedNames = getPropertyNames(excludedProperties); + if (!excludedNames.length) { + return getSimpleShallowCopy(accessorExpression); + } + return getRestFunctionCall( + accessorExpression, + '{' + excludedNames.join(':1,') + ':1}' + ); +} + +exports.renderRestExpression = renderRestExpression; + +},{"esprima-fb":9}],33:[function(_dereq_,module,exports){ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + */ +/*global exports:true*/ + +/** + * Implements ES7 object spread property. + * https://gist.github.com/sebmarkbage/aa849c7973cb4452c547 + * + * { ...a, x: 1 } + * + * Object.assign({}, a, {x: 1 }) + * + */ + +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); + +function visitObjectLiteralSpread(traverse, node, path, state) { + utils.catchup(node.range[0], state); + + utils.append('Object.assign({', state); + + // Skip the original { + utils.move(node.range[0] + 1, state); + + var previousWasSpread = false; + + for (var i = 0; i < node.properties.length; i++) { + var property = node.properties[i]; + if (property.type === Syntax.SpreadProperty) { + + // Close the previous object or initial object + if (!previousWasSpread) { + utils.append('}', state); + } + + if (i === 0) { + // Normally there will be a comma when we catch up, but not before + // the first property. + utils.append(',', state); + } + + utils.catchup(property.range[0], state); + + // skip ... + utils.move(property.range[0] + 3, state); + + traverse(property.argument, path, state); + + utils.catchup(property.range[1], state); + + previousWasSpread = true; + + } else { + + utils.catchup(property.range[0], state); + + if (previousWasSpread) { + utils.append('{', state); + } + + traverse(property, path, state); + + utils.catchup(property.range[1], state); + + previousWasSpread = false; + + } + } + + // Strip any non-whitespace between the last item and the end. + // We only catch up on whitespace so that we ignore any trailing commas which + // are stripped out for IE8 support. Unfortunately, this also strips out any + // trailing comments. + utils.catchupWhiteSpace(node.range[1] - 1, state); + + // Skip the trailing } + utils.move(node.range[1], state); + + if (!previousWasSpread) { + utils.append('}', state); + } + + utils.append(')', state); + return false; +} + +visitObjectLiteralSpread.test = function(node, path, state) { + if (node.type !== Syntax.ObjectExpression) { + return false; + } + // Tight loop optimization + var hasAtLeastOneSpreadProperty = false; + for (var i = 0; i < node.properties.length; i++) { + var property = node.properties[i]; + if (property.type === Syntax.SpreadProperty) { + hasAtLeastOneSpreadProperty = true; + } else if (property.kind !== 'init') { + return false; + } + } + return hasAtLeastOneSpreadProperty; +}; + +exports.visitorList = [ + visitObjectLiteralSpread +]; + +},{"../src/utils":23,"esprima-fb":9}],34:[function(_dereq_,module,exports){ +/** + * Copyright 2014 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var KEYWORDS = [ + 'break', 'do', 'in', 'typeof', 'case', 'else', 'instanceof', 'var', 'catch', + 'export', 'new', 'void', 'class', 'extends', 'return', 'while', 'const', + 'finally', 'super', 'with', 'continue', 'for', 'switch', 'yield', 'debugger', + 'function', 'this', 'default', 'if', 'throw', 'delete', 'import', 'try' +]; + +var FUTURE_RESERVED_WORDS = [ + 'enum', 'await', 'implements', 'package', 'protected', 'static', 'interface', + 'private', 'public' +]; + +var LITERALS = [ + 'null', + 'true', + 'false' +]; + +// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-reserved-words +var RESERVED_WORDS = [].concat( + KEYWORDS, + FUTURE_RESERVED_WORDS, + LITERALS +); + +var reservedWordsMap = Object.create(null); +RESERVED_WORDS.forEach(function(k) { + reservedWordsMap[k] = true; +}); + +/** + * This list should not grow as new reserved words are introdued. This list is + * of words that need to be quoted because ES3-ish browsers do not allow their + * use as identifier names. + */ +var ES3_FUTURE_RESERVED_WORDS = [ + 'enum', 'implements', 'package', 'protected', 'static', 'interface', + 'private', 'public' +]; + +var ES3_RESERVED_WORDS = [].concat( + KEYWORDS, + ES3_FUTURE_RESERVED_WORDS, + LITERALS +); + +var es3ReservedWordsMap = Object.create(null); +ES3_RESERVED_WORDS.forEach(function(k) { + es3ReservedWordsMap[k] = true; +}); + +exports.isReservedWord = function(word) { + return !!reservedWordsMap[word]; +}; + +exports.isES3ReservedWord = function(word) { + return !!es3ReservedWordsMap[word]; +}; + +},{}],35:[function(_dereq_,module,exports){ +/** + * Copyright 2014 Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +/*global exports:true*/ + +var Syntax = _dereq_('esprima-fb').Syntax; +var utils = _dereq_('../src/utils'); +var reserverdWordsHelper = _dereq_('./reserved-words-helper'); + +/** + * Code adapted from https://github.com/spicyj/es3ify + * The MIT License (MIT) + * Copyright (c) 2014 Ben Alpert + */ + +function visitProperty(traverse, node, path, state) { + utils.catchup(node.key.range[0], state); + utils.append('"', state); + utils.catchup(node.key.range[1], state); + utils.append('"', state); + utils.catchup(node.value.range[0], state); + traverse(node.value, path, state); + return false; +} + +visitProperty.test = function(node) { + return node.type === Syntax.Property && + node.key.type === Syntax.Identifier && + !node.method && + !node.shorthand && + !node.computed && + reserverdWordsHelper.isES3ReservedWord(node.key.name); +}; + +function visitMemberExpression(traverse, node, path, state) { + traverse(node.object, path, state); + utils.catchup(node.property.range[0] - 1, state); + utils.append('[', state); + utils.catchupWhiteSpace(node.property.range[0], state); + utils.append('"', state); + utils.catchup(node.property.range[1], state); + utils.append('"]', state); + return false; +} + +visitMemberExpression.test = function(node) { + return node.type === Syntax.MemberExpression && + node.property.type === Syntax.Identifier && + reserverdWordsHelper.isES3ReservedWord(node.property.name); +}; + +exports.visitorList = [ + visitProperty, + visitMemberExpression +]; + +},{"../src/utils":23,"./reserved-words-helper":34,"esprima-fb":9}],36:[function(_dereq_,module,exports){ +var esprima = _dereq_('esprima-fb'); +var utils = _dereq_('../src/utils'); + +var Syntax = esprima.Syntax; + +function _isFunctionNode(node) { + return node.type === Syntax.FunctionDeclaration + || node.type === Syntax.FunctionExpression + || node.type === Syntax.ArrowFunctionExpression; +} + +function visitClassProperty(traverse, node, path, state) { + utils.catchup(node.range[0], state); + utils.catchupWhiteOut(node.range[1], state); + return false; +} +visitClassProperty.test = function(node, path, state) { + return node.type === Syntax.ClassProperty; +}; + +function visitTypeAlias(traverse, node, path, state) { + utils.catchupWhiteOut(node.range[1], state); + return false; +} +visitTypeAlias.test = function(node, path, state) { + return node.type === Syntax.TypeAlias; +}; + +function visitTypeCast(traverse, node, path, state) { + path.unshift(node); + traverse(node.expression, path, state); + path.shift(); + + utils.catchup(node.typeAnnotation.range[0], state); + utils.catchupWhiteOut(node.typeAnnotation.range[1], state); + return false; +} +visitTypeCast.test = function(node, path, state) { + return node.type === Syntax.TypeCastExpression; +}; + +function visitInterfaceDeclaration(traverse, node, path, state) { + utils.catchupWhiteOut(node.range[1], state); + return false; +} +visitInterfaceDeclaration.test = function(node, path, state) { + return node.type === Syntax.InterfaceDeclaration; +}; + +function visitDeclare(traverse, node, path, state) { + utils.catchupWhiteOut(node.range[1], state); + return false; +} +visitDeclare.test = function(node, path, state) { + switch (node.type) { + case Syntax.DeclareVariable: + case Syntax.DeclareFunction: + case Syntax.DeclareClass: + case Syntax.DeclareModule: + return true; + } + return false; +}; + +function visitFunctionParametricAnnotation(traverse, node, path, state) { + utils.catchup(node.range[0], state); + utils.catchupWhiteOut(node.range[1], state); + return false; +} +visitFunctionParametricAnnotation.test = function(node, path, state) { + return node.type === Syntax.TypeParameterDeclaration + && path[0] + && _isFunctionNode(path[0]) + && node === path[0].typeParameters; +}; + +function visitFunctionReturnAnnotation(traverse, node, path, state) { + utils.catchup(node.range[0], state); + utils.catchupWhiteOut(node.range[1], state); + return false; +} +visitFunctionReturnAnnotation.test = function(node, path, state) { + return path[0] && _isFunctionNode(path[0]) && node === path[0].returnType; +}; + +function visitOptionalFunctionParameterAnnotation(traverse, node, path, state) { + utils.catchup(node.range[0] + node.name.length, state); + utils.catchupWhiteOut(node.range[1], state); + return false; +} +visitOptionalFunctionParameterAnnotation.test = function(node, path, state) { + return node.type === Syntax.Identifier + && node.optional + && path[0] + && _isFunctionNode(path[0]); +}; + +function visitTypeAnnotatedIdentifier(traverse, node, path, state) { + utils.catchup(node.typeAnnotation.range[0], state); + utils.catchupWhiteOut(node.typeAnnotation.range[1], state); + return false; +} +visitTypeAnnotatedIdentifier.test = function(node, path, state) { + return node.type === Syntax.Identifier && node.typeAnnotation; +}; + +function visitTypeAnnotatedObjectOrArrayPattern(traverse, node, path, state) { + utils.catchup(node.typeAnnotation.range[0], state); + utils.catchupWhiteOut(node.typeAnnotation.range[1], state); + return false; +} +visitTypeAnnotatedObjectOrArrayPattern.test = function(node, path, state) { + var rightType = node.type === Syntax.ObjectPattern + || node.type === Syntax.ArrayPattern; + return rightType && node.typeAnnotation; +}; + +/** + * Methods cause trouble, since esprima parses them as a key/value pair, where + * the location of the value starts at the method body. For example + * { bar(x:number,...y:Array):number {} } + * is parsed as + * { bar: function(x: number, ...y:Array): number {} } + * except that the location of the FunctionExpression value is 40-something, + * which is the location of the function body. This means that by the time we + * visit the params, rest param, and return type organically, we've already + * catchup()'d passed them. + */ +function visitMethod(traverse, node, path, state) { + path.unshift(node); + traverse(node.key, path, state); + + path.unshift(node.value); + traverse(node.value.params, path, state); + node.value.rest && traverse(node.value.rest, path, state); + node.value.returnType && traverse(node.value.returnType, path, state); + traverse(node.value.body, path, state); + + path.shift(); + + path.shift(); + return false; +} + +visitMethod.test = function(node, path, state) { + return (node.type === "Property" && (node.method || node.kind === "set" || node.kind === "get")) + || (node.type === "MethodDefinition"); +}; + +function visitImportType(traverse, node, path, state) { + utils.catchupWhiteOut(node.range[1], state); + return false; +} +visitImportType.test = function(node, path, state) { + return node.type === 'ImportDeclaration' + && node.isType; +}; + +exports.visitorList = [ + visitClassProperty, + visitDeclare, + visitImportType, + visitInterfaceDeclaration, + visitFunctionParametricAnnotation, + visitFunctionReturnAnnotation, + visitMethod, + visitOptionalFunctionParameterAnnotation, + visitTypeAlias, + visitTypeCast, + visitTypeAnnotatedIdentifier, + visitTypeAnnotatedObjectOrArrayPattern +]; + +},{"../src/utils":23,"esprima-fb":9}],37:[function(_dereq_,module,exports){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +/*global exports:true*/ +'use strict'; +var Syntax = _dereq_('jstransform').Syntax; +var utils = _dereq_('jstransform/src/utils'); + +function renderJSXLiteral(object, isLast, state, start, end) { + var lines = object.value.split(/\r\n|\n|\r/); + + if (start) { + utils.append(start, state); + } + + var lastNonEmptyLine = 0; + + lines.forEach(function(line, index) { + if (line.match(/[^ \t]/)) { + lastNonEmptyLine = index; + } + }); + + lines.forEach(function(line, index) { + var isFirstLine = index === 0; + var isLastLine = index === lines.length - 1; + var isLastNonEmptyLine = index === lastNonEmptyLine; + + // replace rendered whitespace tabs with spaces + var trimmedLine = line.replace(/\t/g, ' '); + + // trim whitespace touching a newline + if (!isFirstLine) { + trimmedLine = trimmedLine.replace(/^[ ]+/, ''); + } + if (!isLastLine) { + trimmedLine = trimmedLine.replace(/[ ]+$/, ''); + } + + if (!isFirstLine) { + utils.append(line.match(/^[ \t]*/)[0], state); + } + + if (trimmedLine || isLastNonEmptyLine) { + utils.append( + JSON.stringify(trimmedLine) + + (!isLastNonEmptyLine ? ' + \' \' +' : ''), + state); + + if (isLastNonEmptyLine) { + if (end) { + utils.append(end, state); + } + if (!isLast) { + utils.append(', ', state); + } + } + + // only restore tail whitespace if line had literals + if (trimmedLine && !isLastLine) { + utils.append(line.match(/[ \t]*$/)[0], state); + } + } + + if (!isLastLine) { + utils.append('\n', state); + } + }); + + utils.move(object.range[1], state); +} + +function renderJSXExpressionContainer(traverse, object, isLast, path, state) { + // Plus 1 to skip `{`. + utils.move(object.range[0] + 1, state); + utils.catchup(object.expression.range[0], state); + traverse(object.expression, path, state); + + if (!isLast && object.expression.type !== Syntax.JSXEmptyExpression) { + // If we need to append a comma, make sure to do so after the expression. + utils.catchup(object.expression.range[1], state, trimLeft); + utils.append(', ', state); + } + + // Minus 1 to skip `}`. + utils.catchup(object.range[1] - 1, state, trimLeft); + utils.move(object.range[1], state); + return false; +} + +function quoteAttrName(attr) { + // Quote invalid JS identifiers. + if (!/^[a-z_$][a-z\d_$]*$/i.test(attr)) { + return '"' + attr + '"'; + } + return attr; +} + +function trimLeft(value) { + return value.replace(/^[ ]+/, ''); +} + +exports.renderJSXExpressionContainer = renderJSXExpressionContainer; +exports.renderJSXLiteral = renderJSXLiteral; +exports.quoteAttrName = quoteAttrName; +exports.trimLeft = trimLeft; + +},{"jstransform":22,"jstransform/src/utils":23}],38:[function(_dereq_,module,exports){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +/*global exports:true*/ +'use strict'; + +var Syntax = _dereq_('jstransform').Syntax; +var utils = _dereq_('jstransform/src/utils'); + +var renderJSXExpressionContainer = + _dereq_('./jsx').renderJSXExpressionContainer; +var renderJSXLiteral = _dereq_('./jsx').renderJSXLiteral; +var quoteAttrName = _dereq_('./jsx').quoteAttrName; + +var trimLeft = _dereq_('./jsx').trimLeft; + +/** + * Customized desugar processor for React JSX. Currently: + * + * => React.createElement(X, null) + * => React.createElement(X, {prop: '1'}, null) + * => React.createElement(X, {prop:'2'}, + * React.createElement(Y, null) + * ) + *
=> React.createElement("div", null) + */ + +/** + * Removes all non-whitespace/parenthesis characters + */ +var reNonWhiteParen = /([^\s\(\)])/g; +function stripNonWhiteParen(value) { + return value.replace(reNonWhiteParen, ''); +} + +var tagConvention = /^[a-z]|\-/; +function isTagName(name) { + return tagConvention.test(name); +} + +function visitReactTag(traverse, object, path, state) { + var openingElement = object.openingElement; + var nameObject = openingElement.name; + var attributesObject = openingElement.attributes; + + utils.catchup(openingElement.range[0], state, trimLeft); + + if (nameObject.type === Syntax.JSXNamespacedName && nameObject.namespace) { + throw new Error('Namespace tags are not supported. ReactJSX is not XML.'); + } + + // We assume that the React runtime is already in scope + utils.append('React.createElement(', state); + + if (nameObject.type === Syntax.JSXIdentifier && isTagName(nameObject.name)) { + utils.append('"' + nameObject.name + '"', state); + utils.move(nameObject.range[1], state); + } else { + // Use utils.catchup in this case so we can easily handle + // JSXMemberExpressions which look like Foo.Bar.Baz. This also handles + // JSXIdentifiers that aren't fallback tags. + utils.move(nameObject.range[0], state); + utils.catchup(nameObject.range[1], state); + } + + utils.append(', ', state); + + var hasAttributes = attributesObject.length; + + var hasAtLeastOneSpreadProperty = attributesObject.some(function(attr) { + return attr.type === Syntax.JSXSpreadAttribute; + }); + + // if we don't have any attributes, pass in null + if (hasAtLeastOneSpreadProperty) { + utils.append('React.__spread({', state); + } else if (hasAttributes) { + utils.append('{', state); + } else { + utils.append('null', state); + } + + // keep track of if the previous attribute was a spread attribute + var previousWasSpread = false; + + // write attributes + attributesObject.forEach(function(attr, index) { + var isLast = index === attributesObject.length - 1; + + if (attr.type === Syntax.JSXSpreadAttribute) { + // Close the previous object or initial object + if (!previousWasSpread) { + utils.append('}, ', state); + } + + // Move to the expression start, ignoring everything except parenthesis + // and whitespace. + utils.catchup(attr.range[0], state, stripNonWhiteParen); + // Plus 1 to skip `{`. + utils.move(attr.range[0] + 1, state); + utils.catchup(attr.argument.range[0], state, stripNonWhiteParen); + + traverse(attr.argument, path, state); + + utils.catchup(attr.argument.range[1], state); + + // Move to the end, ignoring parenthesis and the closing `}` + utils.catchup(attr.range[1] - 1, state, stripNonWhiteParen); + + if (!isLast) { + utils.append(', ', state); + } + + utils.move(attr.range[1], state); + + previousWasSpread = true; + + return; + } + + // If the next attribute is a spread, we're effective last in this object + if (!isLast) { + isLast = attributesObject[index + 1].type === Syntax.JSXSpreadAttribute; + } + + if (attr.name.namespace) { + throw new Error( + 'Namespace attributes are not supported. ReactJSX is not XML.'); + } + var name = attr.name.name; + + utils.catchup(attr.range[0], state, trimLeft); + + if (previousWasSpread) { + utils.append('{', state); + } + + utils.append(quoteAttrName(name), state); + utils.append(': ', state); + + if (!attr.value) { + state.g.buffer += 'true'; + state.g.position = attr.name.range[1]; + if (!isLast) { + utils.append(', ', state); + } + } else { + utils.move(attr.name.range[1], state); + // Use catchupNewlines to skip over the '=' in the attribute + utils.catchupNewlines(attr.value.range[0], state); + if (attr.value.type === Syntax.Literal) { + renderJSXLiteral(attr.value, isLast, state); + } else { + renderJSXExpressionContainer(traverse, attr.value, isLast, path, state); + } + } + + utils.catchup(attr.range[1], state, trimLeft); + + previousWasSpread = false; + + }); + + if (!openingElement.selfClosing) { + utils.catchup(openingElement.range[1] - 1, state, trimLeft); + utils.move(openingElement.range[1], state); + } + + if (hasAttributes && !previousWasSpread) { + utils.append('}', state); + } + + if (hasAtLeastOneSpreadProperty) { + utils.append(')', state); + } + + // filter out whitespace + var childrenToRender = object.children.filter(function(child) { + return !(child.type === Syntax.Literal + && typeof child.value === 'string' + && child.value.match(/^[ \t]*[\r\n][ \t\r\n]*$/)); + }); + if (childrenToRender.length > 0) { + var lastRenderableIndex; + + childrenToRender.forEach(function(child, index) { + if (child.type !== Syntax.JSXExpressionContainer || + child.expression.type !== Syntax.JSXEmptyExpression) { + lastRenderableIndex = index; + } + }); + + if (lastRenderableIndex !== undefined) { + utils.append(', ', state); + } + + childrenToRender.forEach(function(child, index) { + utils.catchup(child.range[0], state, trimLeft); + + var isLast = index >= lastRenderableIndex; + + if (child.type === Syntax.Literal) { + renderJSXLiteral(child, isLast, state); + } else if (child.type === Syntax.JSXExpressionContainer) { + renderJSXExpressionContainer(traverse, child, isLast, path, state); + } else { + traverse(child, path, state); + if (!isLast) { + utils.append(', ', state); + } + } + + utils.catchup(child.range[1], state, trimLeft); + }); + } + + if (openingElement.selfClosing) { + // everything up to /> + utils.catchup(openingElement.range[1] - 2, state, trimLeft); + utils.move(openingElement.range[1], state); + } else { + // everything up to + utils.catchup(object.closingElement.range[0], state, trimLeft); + utils.move(object.closingElement.range[1], state); + } + + utils.append(')', state); + return false; +} + +visitReactTag.test = function(object, path, state) { + return object.type === Syntax.JSXElement; +}; + +exports.visitorList = [ + visitReactTag +]; + +},{"./jsx":37,"jstransform":22,"jstransform/src/utils":23}],39:[function(_dereq_,module,exports){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +/*global exports:true*/ +'use strict'; + +var Syntax = _dereq_('jstransform').Syntax; +var utils = _dereq_('jstransform/src/utils'); + +function addDisplayName(displayName, object, state) { + if (object && + object.type === Syntax.CallExpression && + object.callee.type === Syntax.MemberExpression && + object.callee.object.type === Syntax.Identifier && + object.callee.object.name === 'React' && + object.callee.property.type === Syntax.Identifier && + object.callee.property.name === 'createClass' && + object.arguments.length === 1 && + object.arguments[0].type === Syntax.ObjectExpression) { + // Verify that the displayName property isn't already set + var properties = object.arguments[0].properties; + var safe = properties.every(function(property) { + var value = property.key.type === Syntax.Identifier ? + property.key.name : + property.key.value; + return value !== 'displayName'; + }); + + if (safe) { + utils.catchup(object.arguments[0].range[0] + 1, state); + utils.append('displayName: "' + displayName + '",', state); + } + } +} + +/** + * Transforms the following: + * + * var MyComponent = React.createClass({ + * render: ... + * }); + * + * into: + * + * var MyComponent = React.createClass({ + * displayName: 'MyComponent', + * render: ... + * }); + * + * Also catches: + * + * MyComponent = React.createClass(...); + * exports.MyComponent = React.createClass(...); + * module.exports = {MyComponent: React.createClass(...)}; + */ +function visitReactDisplayName(traverse, object, path, state) { + var left, right; + + if (object.type === Syntax.AssignmentExpression) { + left = object.left; + right = object.right; + } else if (object.type === Syntax.Property) { + left = object.key; + right = object.value; + } else if (object.type === Syntax.VariableDeclarator) { + left = object.id; + right = object.init; + } + + if (left && left.type === Syntax.MemberExpression) { + left = left.property; + } + if (left && left.type === Syntax.Identifier) { + addDisplayName(left.name, right, state); + } +} + +visitReactDisplayName.test = function(object, path, state) { + return ( + object.type === Syntax.AssignmentExpression || + object.type === Syntax.Property || + object.type === Syntax.VariableDeclarator + ); +}; + +exports.visitorList = [ + visitReactDisplayName +]; + +},{"jstransform":22,"jstransform/src/utils":23}],40:[function(_dereq_,module,exports){ +/*global exports:true*/ + +'use strict'; + +var es6ArrowFunctions = + _dereq_('jstransform/visitors/es6-arrow-function-visitors'); +var es6Classes = _dereq_('jstransform/visitors/es6-class-visitors'); +var es6Destructuring = + _dereq_('jstransform/visitors/es6-destructuring-visitors'); +var es6ObjectConciseMethod = + _dereq_('jstransform/visitors/es6-object-concise-method-visitors'); +var es6ObjectShortNotation = + _dereq_('jstransform/visitors/es6-object-short-notation-visitors'); +var es6RestParameters = _dereq_('jstransform/visitors/es6-rest-param-visitors'); +var es6Templates = _dereq_('jstransform/visitors/es6-template-visitors'); +var es6CallSpread = + _dereq_('jstransform/visitors/es6-call-spread-visitors'); +var es7SpreadProperty = + _dereq_('jstransform/visitors/es7-spread-property-visitors'); +var react = _dereq_('./transforms/react'); +var reactDisplayName = _dereq_('./transforms/reactDisplayName'); +var reservedWords = _dereq_('jstransform/visitors/reserved-words-visitors'); + +/** + * Map from transformName => orderedListOfVisitors. + */ +var transformVisitors = { + 'es6-arrow-functions': es6ArrowFunctions.visitorList, + 'es6-classes': es6Classes.visitorList, + 'es6-destructuring': es6Destructuring.visitorList, + 'es6-object-concise-method': es6ObjectConciseMethod.visitorList, + 'es6-object-short-notation': es6ObjectShortNotation.visitorList, + 'es6-rest-params': es6RestParameters.visitorList, + 'es6-templates': es6Templates.visitorList, + 'es6-call-spread': es6CallSpread.visitorList, + 'es7-spread-property': es7SpreadProperty.visitorList, + 'react': react.visitorList.concat(reactDisplayName.visitorList), + 'reserved-words': reservedWords.visitorList +}; + +var transformSets = { + 'harmony': [ + 'es6-arrow-functions', + 'es6-object-concise-method', + 'es6-object-short-notation', + 'es6-classes', + 'es6-rest-params', + 'es6-templates', + 'es6-destructuring', + 'es6-call-spread', + 'es7-spread-property' + ], + 'es3': [ + 'reserved-words' + ], + 'react': [ + 'react' + ] +}; + +/** + * Specifies the order in which each transform should run. + */ +var transformRunOrder = [ + 'reserved-words', + 'es6-arrow-functions', + 'es6-object-concise-method', + 'es6-object-short-notation', + 'es6-classes', + 'es6-rest-params', + 'es6-templates', + 'es6-destructuring', + 'es6-call-spread', + 'es7-spread-property', + 'react' +]; + +/** + * Given a list of transform names, return the ordered list of visitors to be + * passed to the transform() function. + * + * @param {array?} excludes + * @return {array} + */ +function getAllVisitors(excludes) { + var ret = []; + for (var i = 0, il = transformRunOrder.length; i < il; i++) { + if (!excludes || excludes.indexOf(transformRunOrder[i]) === -1) { + ret = ret.concat(transformVisitors[transformRunOrder[i]]); + } + } + return ret; +} + +/** + * Given a list of visitor set names, return the ordered list of visitors to be + * passed to jstransform. + * + * @param {array} + * @return {array} + */ +function getVisitorsBySet(sets) { + var visitorsToInclude = sets.reduce(function(visitors, set) { + if (!transformSets.hasOwnProperty(set)) { + throw new Error('Unknown visitor set: ' + set); + } + transformSets[set].forEach(function(visitor) { + visitors[visitor] = true; + }); + return visitors; + }, {}); + + var visitorList = []; + for (var i = 0; i < transformRunOrder.length; i++) { + if (visitorsToInclude.hasOwnProperty(transformRunOrder[i])) { + visitorList = visitorList.concat(transformVisitors[transformRunOrder[i]]); + } + } + + return visitorList; +} + +exports.getVisitorsBySet = getVisitorsBySet; +exports.getAllVisitors = getAllVisitors; +exports.transformVisitors = transformVisitors; + +},{"./transforms/react":38,"./transforms/reactDisplayName":39,"jstransform/visitors/es6-arrow-function-visitors":24,"jstransform/visitors/es6-call-spread-visitors":25,"jstransform/visitors/es6-class-visitors":26,"jstransform/visitors/es6-destructuring-visitors":27,"jstransform/visitors/es6-object-concise-method-visitors":28,"jstransform/visitors/es6-object-short-notation-visitors":29,"jstransform/visitors/es6-rest-param-visitors":30,"jstransform/visitors/es6-template-visitors":31,"jstransform/visitors/es7-spread-property-visitors":33,"jstransform/visitors/reserved-words-visitors":35}],41:[function(_dereq_,module,exports){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +'use strict'; +/*eslint-disable no-undef*/ +var Buffer = _dereq_('buffer').Buffer; + +function inlineSourceMap(sourceMap, sourceCode, sourceFilename) { + // This can be used with a sourcemap that has already has toJSON called on it. + // Check first. + var json = sourceMap; + if (typeof sourceMap.toJSON === 'function') { + json = sourceMap.toJSON(); + } + json.sources = [sourceFilename]; + json.sourcesContent = [sourceCode]; + var base64 = Buffer(JSON.stringify(json)).toString('base64'); + return '//# sourceMappingURL=data:application/json;base64,' + base64; +} + +module.exports = inlineSourceMap; + +},{"buffer":3}]},{},[1])(1) +}); \ No newline at end of file diff --git a/public/javascripts/wechat/browser.min.js b/public/javascripts/wechat/browser.min.js new file mode 100644 index 000000000..7566e1a59 --- /dev/null +++ b/public/javascripts/wechat/browser.min.js @@ -0,0 +1,44 @@ + +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.babel=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=0){var next_line=out.indexOf("\n",idx+1);out=out.substring(next_line+1)}this.stack=out}}};util.inherits(assert.AssertionError,Error);function replacer(key,value){if(util.isUndefined(value)){return""+value}if(util.isNumber(value)&&!isFinite(value)){return value.toString()}if(util.isFunction(value)||util.isRegExp(value)){return value.toString()}return value}function truncate(s,n){if(util.isString(s)){return s.length=0;i--){if(ka[i]!=kb[i])return false}for(i=ka.length-1;i>=0;i--){key=ka[i];if(!_deepEqual(a[key],b[key]))return false}return true}assert.notDeepEqual=function notDeepEqual(actual,expected,message){if(_deepEqual(actual,expected)){fail(actual,expected,message,"notDeepEqual",assert.notDeepEqual)}};assert.strictEqual=function strictEqual(actual,expected,message){if(actual!==expected){fail(actual,expected,message,"===",assert.strictEqual)}};assert.notStrictEqual=function notStrictEqual(actual,expected,message){if(actual===expected){fail(actual,expected,message,"!==",assert.notStrictEqual)}};function expectedException(actual,expected){if(!actual||!expected){return false}if(Object.prototype.toString.call(expected)=="[object RegExp]"){return expected.test(actual)}else if(actual instanceof expected){return true}else if(expected.call({},actual)===true){return true}return false}function _throws(shouldThrow,block,expected,message){var actual;if(util.isString(expected)){message=expected;expected=null}try{block()}catch(e){actual=e}message=(expected&&expected.name?" ("+expected.name+").":".")+(message?" "+message:".");if(shouldThrow&&!actual){fail(actual,expected,"Missing expected exception"+message)}if(!shouldThrow&&expectedException(actual,expected)){fail(actual,expected,"Got unwanted exception"+message)}if(shouldThrow&&actual&&expected&&!expectedException(actual,expected)||!shouldThrow&&actual){throw actual}}assert.throws=function(block,error,message){_throws.apply(this,[true].concat(pSlice.call(arguments)))};assert.doesNotThrow=function(block,message){_throws.apply(this,[false].concat(pSlice.call(arguments)))};assert.ifError=function(err){if(err){throw err}};var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj){if(hasOwn.call(obj,key))keys.push(key)}return keys}},{"util/":30}],3:[function(require,module,exports){arguments[4][1][0].apply(exports,arguments)},{dup:1}],4:[function(require,module,exports){var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("is-array");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=function(){function Bar(){}try{var arr=new Uint8Array(1);arr.foo=function(){return 42};arr.constructor=Bar;return arr.foo()===42&&arr.constructor===Bar&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}();function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Buffer(arg){if(!(this instanceof Buffer)){if(arguments.length>1)return new Buffer(arg,arguments[1]);return new Buffer(arg)}this.length=0;this.parent=undefined;if(typeof arg==="number"){return fromNumber(this,arg)}if(typeof arg==="string"){return fromString(this,arg,arguments.length>1?arguments[1]:"utf8")}return fromObject(this,arg)}function fromNumber(that,length){that=allocate(that,length<0?0:checked(length)|0);if(!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i>>1;if(fromPool)that.parent=rootParent;return that}function checked(length){if(length>=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(subject,encoding){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding);var buf=new Buffer(subject,encoding);delete buf.parent;return buf}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;var i=0;var len=Math.min(x,y);while(i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;function slowToString(encoding,start,end){var loweredCase=false;start=start|0;end=end===undefined||end===Infinity?this.length:end|0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype.toString=function toString(){var length=this.length|0;if(length===0)return"";if(arguments.length===0)return utf8Slice(this,0,length);return slowToString.apply(this,arguments)};Buffer.prototype.equals=function equals(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(this===b)return true;return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function inspect(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return""};Buffer.prototype.compare=function compare(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(this===b)return 0;return Buffer.compare(this,b)};Buffer.prototype.indexOf=function indexOf(val,byteOffset){if(byteOffset>2147483647)byteOffset=2147483647;else if(byteOffset<-2147483648)byteOffset=-2147483648;byteOffset>>=0;if(this.length===0)return-1;if(byteOffset>=this.length)return-1;if(byteOffset<0)byteOffset=Math.max(this.length+byteOffset,0);if(typeof val==="string"){if(val.length===0)return-1;return String.prototype.indexOf.call(this,val,byteOffset)}if(Buffer.isBuffer(val)){return arrayIndexOf(this,val,byteOffset)}if(typeof val==="number"){if(Buffer.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,val,byteOffset)}return arrayIndexOf(this,[val],byteOffset)}function arrayIndexOf(arr,val,byteOffset){var foundIndex=-1;for(var i=0;byteOffset+iremaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;iremaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"binary":return binaryWrite(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||valuebuf.length)throw new RangeError("index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1;var i=0;this[offset]=value&255;while(++i=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=value<0?1:0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=value<0?1:0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||valuebuf.length)throw new RangeError("index out of range");if(offset<0)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;i--){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("end out of bounds");var i;if(typeof value==="number"){for(i=start;i55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}},{"base64-js":5,ieee754:6,"is-array":7}],5:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);var PLUS_URL_SAFE="-".charCodeAt(0);var SLASH_URL_SAFE="_".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS||code===PLUS_URL_SAFE)return 62;if(code===SLASH||code===SLASH_URL_SAFE)return 63;if(code0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(typeof exports==="undefined"?this.base64js={}:exports)},{}],6:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],7:[function(require,module,exports){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},{}],8:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}throw TypeError('Uncaught, unspecified "error" event.')}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:len=arguments.length;args=new Array(len-1);for(i=1;i0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-->0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1)}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else{while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.listenerCount=function(emitter,type){var ret;if(!emitter._events||!emitter._events[type])ret=0;else if(isFunction(emitter._events[type]))ret=1;else ret=emitter._events[type].length;return ret};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],9:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],10:[function(require,module,exports){module.exports=Array.isArray||function(arr){return Object.prototype.toString.call(arr)=="[object Array]"}},{}],11:[function(require,module,exports){(function(process){function normalizeArray(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(filename){return splitPathRe.exec(filename).slice(1)};exports.resolve=function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:process.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){continue}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=normalizeArray(filter(resolvedPath.split("/"),function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."};exports.normalize=function(path){var isAbsolute=exports.isAbsolute(path),trailingSlash=substr(path,-1)==="/";path=normalizeArray(filter(path.split("/"),function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path};exports.isAbsolute=function(path){return path.charAt(0)==="/"};exports.join=function(){var paths=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(paths,function(p,index){if(typeof p!=="string"){throw new TypeError("Arguments to path.join must be strings")}return p}).join("/"))};exports.relative=function(from,to){from=exports.resolve(from).substr(1);to=exports.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i1){for(var i=1;i0){if(state.ended&&!addToFront){var e=new Error("stream.push() after EOF");stream.emit("error",e)}else if(state.endEmitted&&addToFront){var e=new Error("stream.unshift() after end event");stream.emit("error",e)}else{if(state.decoder&&!addToFront&&!encoding)chunk=state.decoder.write(chunk);if(!addToFront)state.reading=false;if(state.flowing&&state.length===0&&!state.sync){stream.emit("data",chunk);stream.read(0)}else{state.length+=state.objectMode?1:chunk.length;if(addToFront)state.buffer.unshift(chunk);else state.buffer.push(chunk);if(state.needReadable)emitReadable(stream)}maybeReadMore(stream,state)}}else if(!addToFront){state.reading=false}return needMoreData(state)}function needMoreData(state){return!state.ended&&(state.needReadable||state.length=MAX_HWM){n=MAX_HWM}else{n--;for(var p=1;p<32;p<<=1)n|=n>>p;n++}return n}function howMuchToRead(n,state){if(state.length===0&&state.ended)return 0;if(state.objectMode)return n===0?0:1;if(n===null||isNaN(n)){if(state.flowing&&state.buffer.length)return state.buffer[0].length;else return state.length}if(n<=0)return 0;if(n>state.highWaterMark)state.highWaterMark=roundUpToNextPowerOf2(n);if(n>state.length){if(!state.ended){state.needReadable=true;return 0}else{return state.length}}return n}Readable.prototype.read=function(n){debug("read",n);var state=this._readableState;var nOrig=n;if(typeof n!=="number"||n>0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){debug("read: emitReadable",state.length,state.ended);if(state.length===0&&state.ended)endReadable(this);else emitReadable(this);return null}n=howMuchToRead(n,state);if(n===0&&state.ended){if(state.length===0)endReadable(this);return null}var doRead=state.needReadable;debug("need readable",doRead);if(state.length===0||state.length-n0)ret=fromList(n,state);else ret=null;if(ret===null){state.needReadable=true;n=0}state.length-=n;if(state.length===0&&!state.ended)state.needReadable=true;if(nOrig!==n&&state.ended&&state.length===0)endReadable(this);if(ret!==null)this.emit("data",ret);return ret};function chunkInvalid(state,chunk){var er=null;if(!Buffer.isBuffer(chunk)&&typeof chunk!=="string"&&chunk!==null&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}return er}function onEofChunk(stream,state){if(state.ended)return;if(state.decoder){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;emitReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(!state.emittedReadable){debug("emitReadable",state.flowing);state.emittedReadable=true;if(state.sync)processNextTick(emitReadable_,stream);else emitReadable_(stream)}}function emitReadable_(stream){debug("emit readable");stream.emit("readable");flow(stream)}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state)}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length=length){if(stringMode)ret=list.join("");else ret=Buffer.concat(list,length);list.length=0}else{if(n0)throw new Error("endReadable called on non-empty stream");if(!state.endEmitted){state.ended=true;processNextTick(endReadableNT,state,stream)}}function endReadableNT(state,stream){if(!state.endEmitted&&state.length===0){state.endEmitted=true;stream.readable=false;stream.emit("end")}}function forEach(xs,f){for(var i=0,l=xs.length;i-1))throw new TypeError("Unknown encoding: "+encoding);this._writableState.defaultEncoding=encoding};function decodeChunk(state,chunk,encoding){if(!state.objectMode&&state.decodeStrings!==false&&typeof chunk==="string"){chunk=new Buffer(chunk,encoding)}return chunk}function writeOrBuffer(stream,state,chunk,encoding,cb){chunk=decodeChunk(state,chunk,encoding);if(Buffer.isBuffer(chunk))encoding="buffer";var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length=this.charLength-this.charReceived?this.charLength-this.charReceived:buffer.length;buffer.copy(this.charBuffer,this.charReceived,0,available);this.charReceived+=available;if(this.charReceived=55296&&charCode<=56319){this.charLength+=this.surrogateSize;charStr="";continue}this.charReceived=this.charLength=0;if(buffer.length===0){return charStr}break}this.detectIncompleteChar(buffer);var end=buffer.length;if(this.charLength){buffer.copy(this.charBuffer,0,buffer.length-this.charReceived,end);end-=this.charReceived}charStr+=buffer.toString(this.encoding,0,end);var end=charStr.length-1;var charCode=charStr.charCodeAt(end);if(charCode>=55296&&charCode<=56319){var size=this.surrogateSize;this.charLength+=size;this.charReceived+=size;this.charBuffer.copy(this.charBuffer,size,0,size);buffer.copy(this.charBuffer,0,0,size);return charStr.substring(0,end)}return charStr};StringDecoder.prototype.detectIncompleteChar=function(buffer){var i=buffer.length>=3?3:buffer.length;for(;i>0;i--){var c=buffer[buffer.length-i];if(i==1&&c>>5==6){this.charLength=2;break}if(i<=2&&c>>4==14){this.charLength=3;break}if(i<=3&&c>>3==30){this.charLength=4;break}}this.charReceived=i};StringDecoder.prototype.end=function(buffer){var res="";if(buffer&&buffer.length)res=this.write(buffer);if(this.charReceived){var cr=this.charReceived;var buf=this.charBuffer;var enc=this.encoding;res+=buf.slice(0,cr).toString(enc)}return res};function passThroughWrite(buffer){return buffer.toString(this.encoding)}function utf16DetectIncompleteChar(buffer){this.charReceived=buffer.length%2;this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(buffer){this.charReceived=buffer.length%3;this.charLength=this.charReceived?3:0}},{buffer:4}],28:[function(require,module,exports){exports.isatty=function(){return false};function ReadStream(){throw new Error("tty.ReadStream is not implemented")}exports.ReadStream=ReadStream;function WriteStream(){throw new Error("tty.ReadStream is not implemented")}exports.WriteStream=WriteStream},{}],29:[function(require,module,exports){module.exports=function isBuffer(arg){return arg&&typeof arg==="object"&&typeof arg.copy==="function"&&typeof arg.fill==="function"&&typeof arg.readUInt8==="function"}},{}],30:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){var objects=[];for(var i=0;i=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}});for(var x=args[i];i=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts)){ctx.showHidden=opts}else if(opts){exports._extend(ctx,opts)}if(isUndefined(ctx.showHidden))ctx.showHidden=false;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=false;if(isUndefined(ctx.customInspect))ctx.customInspect=true;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style){return"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m"}else{return str}}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};array.forEach(function(val,idx){hash[val]=true});return hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret)){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}var keys=Object.keys(value);var visibleKeys=arrayToHash(keys);if(ctx.showHidden){keys=Object.getOwnPropertyNames(value)}if(isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0)){return formatError(value)}if(keys.length===0){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){base=" "+formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i-1){if(array){str=str.split("\n").map(function(line){return" "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return" "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(isUndefined(name)){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date;var time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))};exports.inherits=require("inherits");exports._extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":29,_process:12,inherits:9}],31:[function(require,module,exports){(function(global){"use strict";require("./node");var transform=module.exports=require("../transformation");transform.options=require("../transformation/file/options");transform.version=require("../../package").version;transform.transform=transform;transform.run=function(code){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];opts.sourceMaps="inline";return new Function(transform(code,opts).code)()};transform.load=function(url,callback,opts,hold){if(opts===undefined)opts={};opts.filename=opts.filename||url;var xhr=global.ActiveXObject?new global.ActiveXObject("Microsoft.XMLHTTP"):new global.XMLHttpRequest;xhr.open("GET",url,true);if("overrideMimeType"in xhr)xhr.overrideMimeType("text/plain");xhr.onreadystatechange=function(){if(xhr.readyState!==4)return;var status=xhr.status;if(status===0||status===200){var param=[xhr.responseText,opts];if(!hold)transform.run.apply(transform,param);if(callback)callback(param)}else{throw new Error("Could not load "+url)}};xhr.send(null)};var runScripts=function runScripts(){var scripts=[];var types=["text/ecmascript-6","text/6to5","text/babel","module"];var index=0;var exec=function exec(){var param=scripts[index];if(param instanceof Array){transform.run.apply(transform,param);index++;exec()}};var run=function run(script,i){var opts={};if(script.src){transform.load(script.src,function(param){scripts[i]=param;exec()},opts,true)}else{opts.filename="embedded";scripts[i]=[script.innerHTML,opts]}};var _scripts=global.document.getElementsByTagName("script");for(var i=0;i<_scripts.length;++i){var _script=_scripts[i];if(types.indexOf(_script.type)>=0)scripts.push(_script)}for(i in scripts){run(scripts[i],i)}exec()};if(global.addEventListener){global.addEventListener("DOMContentLoaded",runScripts,false)}else if(global.attachEvent){global.attachEvent("onload",runScripts)}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"../../package":631,"../transformation":83,"../transformation/file/options":66,"./node":32}],32:[function(require,module,exports){"use strict";exports.__esModule=true;exports.register=register;exports.polyfill=polyfill;exports.transformFile=transformFile;exports.transformFileSync=transformFileSync;exports.parse=parse;function _interopRequire(obj){return obj&&obj.__esModule?obj["default"]:obj}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashLangIsFunction=require("lodash/lang/isFunction");var _lodashLangIsFunction2=_interopRequireDefault(_lodashLangIsFunction);var _transformation=require("../transformation");var _transformation2=_interopRequireDefault(_transformation);var _babylon=require("babylon");var babylon=_interopRequireWildcard(_babylon);var _util=require("../util");var util=_interopRequireWildcard(_util);var _fs=require("fs");var _fs2=_interopRequireDefault(_fs);var _types=require("../types");var t=_interopRequireWildcard(_types);exports.util=util;exports.acorn=babylon;exports.transform=_transformation2["default"];exports.pipeline=_transformation.pipeline;exports.canCompile=_util.canCompile;var _transformationFile=require("../transformation/file");exports.File=_interopRequire(_transformationFile);var _transformationFileOptionsConfig=require("../transformation/file/options/config");exports.options=_interopRequire(_transformationFileOptionsConfig);var _transformationPlugin=require("../transformation/plugin");exports.Plugin=_interopRequire(_transformationPlugin);var _transformationTransformer=require("../transformation/transformer");exports.Transformer=_interopRequire(_transformationTransformer);var _transformationPipeline=require("../transformation/pipeline");exports.Pipeline=_interopRequire(_transformationPipeline);var _traversal=require("../traversal");exports.traverse=_interopRequire(_traversal);var _toolsBuildExternalHelpers=require("../tools/build-external-helpers");exports.buildExternalHelpers=_interopRequire(_toolsBuildExternalHelpers);var _package=require("../../package");exports.version=_package.version; +exports.types=t;function register(opts){var callback=require("./register/node-polyfill");if(opts!=null)callback(opts);return callback}function polyfill(){require("../polyfill")}function transformFile(filename,opts,callback){if(_lodashLangIsFunction2["default"](opts)){callback=opts;opts={}}opts.filename=filename;_fs2["default"].readFile(filename,function(err,code){if(err)return callback(err);var result;try{result=_transformation2["default"](code,opts)}catch(err){return callback(err)}callback(null,result)})}function transformFileSync(filename){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];opts.filename=filename;return _transformation2["default"](_fs2["default"].readFileSync(filename,"utf8"),opts)}function parse(code){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];opts.allowHashBang=true;opts.sourceType="module";opts.ecmaVersion=Infinity;opts.plugins={jsx:true,flow:true};opts.features={};for(var key in _transformation2["default"].pipeline.transformers){opts.features[key]=true}var ast=babylon.parse(code,opts);if(opts.onToken){var _opts$onToken;(_opts$onToken=opts.onToken).push.apply(_opts$onToken,ast.tokens)}if(opts.onComment){var _opts$onComment;(_opts$onComment=opts.onComment).push.apply(_opts$onComment,ast.comments)}return ast.program}},{"../../package":631,"../polyfill":61,"../tools/build-external-helpers":62,"../transformation":83,"../transformation/file":63,"../transformation/file/options/config":65,"../transformation/pipeline":97,"../transformation/plugin":99,"../transformation/transformer":100,"../traversal":165,"../types":196,"../util":199,"./register/node-polyfill":34,babylon:633,fs:1,"lodash/lang/isFunction":526}],33:[function(require,module,exports){"use strict";exports.__esModule=true;require("../../polyfill");exports["default"]=function(){};module.exports=exports["default"]},{"../../polyfill":61}],34:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequire(obj){return obj&&obj.__esModule?obj["default"]:obj}require("../../polyfill");var _node=require("./node");exports["default"]=_interopRequire(_node);module.exports=exports["default"]},{"../../polyfill":61,"./node":33}],35:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _repeating=require("repeating");var _repeating2=_interopRequireDefault(_repeating);var _trimRight=require("trim-right");var _trimRight2=_interopRequireDefault(_trimRight);var _lodashLangIsBoolean=require("lodash/lang/isBoolean");var _lodashLangIsBoolean2=_interopRequireDefault(_lodashLangIsBoolean);var _lodashCollectionIncludes=require("lodash/collection/includes");var _lodashCollectionIncludes2=_interopRequireDefault(_lodashCollectionIncludes);var _lodashLangIsNumber=require("lodash/lang/isNumber");var _lodashLangIsNumber2=_interopRequireDefault(_lodashLangIsNumber);var Buffer=function(){function Buffer(position,format){_classCallCheck(this,Buffer);this.parenPushNewlineState=null;this.position=position;this._indent=format.indent.base;this.format=format;this.buf=""}Buffer.prototype.get=function get(){return _trimRight2["default"](this.buf)};Buffer.prototype.getIndent=function getIndent(){if(this.format.compact||this.format.concise){return""}else{return _repeating2["default"](this.format.indent.style,this._indent)}};Buffer.prototype.indentSize=function indentSize(){return this.getIndent().length};Buffer.prototype.indent=function indent(){this._indent++};Buffer.prototype.dedent=function dedent(){this._indent--};Buffer.prototype.semicolon=function semicolon(){this.push(";")};Buffer.prototype.ensureSemicolon=function ensureSemicolon(){if(!this.isLast(";"))this.semicolon()};Buffer.prototype.rightBrace=function rightBrace(){this.newline(true);this.push("}")};Buffer.prototype.keyword=function keyword(name){this.push(name);this.space()};Buffer.prototype.space=function space(force){if(!force&&this.format.compact)return;if(force||this.buf&&!this.isLast(" ")&&!this.isLast("\n")){this.push(" ")}};Buffer.prototype.removeLast=function removeLast(cha){if(this.format.compact)return;if(!this.isLast(cha))return;this.buf=this.buf.substr(0,this.buf.length-1);this.position.unshift(cha)};Buffer.prototype.startTerminatorless=function startTerminatorless(){return this.parenPushNewlineState={printed:false}};Buffer.prototype.endTerminatorless=function endTerminatorless(state){if(state.printed){this.dedent();this.newline();this.push(")")}};Buffer.prototype.newline=function newline(i,removeLast){if(this.format.compact||this.format.retainLines)return;if(this.format.concise){this.space();return}removeLast=removeLast||false;if(_lodashLangIsNumber2["default"](i)){i=Math.min(2,i);if(this.endsWith("{\n")||this.endsWith(":\n"))i--;if(i<=0)return;while(i>0){this._newline(removeLast);i--}return}if(_lodashLangIsBoolean2["default"](i)){removeLast=i}this._newline(removeLast)};Buffer.prototype._newline=function _newline(removeLast){if(this.endsWith("\n\n"))return;if(removeLast&&this.isLast("\n"))this.removeLast("\n");this.removeLast(" ");this._removeSpacesAfterLastNewline();this._push("\n")};Buffer.prototype._removeSpacesAfterLastNewline=function _removeSpacesAfterLastNewline(){var lastNewlineIndex=this.buf.lastIndexOf("\n");if(lastNewlineIndex===-1){return}var index=this.buf.length-1;while(index>lastNewlineIndex){if(this.buf[index]!==" "){break}index--}if(index===lastNewlineIndex){this.buf=this.buf.substring(0,index+1)}};Buffer.prototype.push=function push(str,noIndent){if(!this.format.compact&&this._indent&&!noIndent&&str!=="\n"){var indent=this.getIndent();str=str.replace(/\n/g,"\n"+indent);if(this.isLast("\n"))this._push(indent)}this._push(str)};Buffer.prototype._push=function _push(str){var parenPushNewlineState=this.parenPushNewlineState;if(parenPushNewlineState){for(var i=0;i")}this.space();print.plain(node.returnType)}function FunctionTypeParam(node,print){print.plain(node.name);if(node.optional)this.push("?");this.push(":");this.space();print.plain(node.typeAnnotation)}function InterfaceExtends(node,print){print.plain(node.id);print.plain(node.typeParameters)}exports.ClassImplements=InterfaceExtends;exports.GenericTypeAnnotation=InterfaceExtends;function _interfaceish(node,print){print.plain(node.id);print.plain(node.typeParameters);if(node["extends"].length){this.push(" extends ");print.join(node["extends"],{separator:", "})}this.space();print.plain(node.body)}function InterfaceDeclaration(node,print){this.push("interface ");this._interfaceish(node,print)}function IntersectionTypeAnnotation(node,print){print.join(node.types,{separator:" & "})}function MixedTypeAnnotation(){this.push("mixed")}function NullableTypeAnnotation(node,print){this.push("?");print.plain(node.typeAnnotation)}var _types2=require("./types");exports.NumberLiteralTypeAnnotation=_types2.Literal;function NumberTypeAnnotation(){this.push("number")}function StringLiteralTypeAnnotation(node){this.push(this._stringLiteral(node.value))}function StringTypeAnnotation(){this.push("string")}function TupleTypeAnnotation(node,print){this.push("[");print.join(node.types,{separator:", "});this.push("]")}function TypeofTypeAnnotation(node,print){this.push("typeof ");print.plain(node.argument)}function TypeAlias(node,print){this.push("type ");print.plain(node.id);print.plain(node.typeParameters);this.space();this.push("=");this.space();print.plain(node.right);this.semicolon()}function TypeAnnotation(node,print){this.push(":");this.space();if(node.optional)this.push("?");print.plain(node.typeAnnotation)}function TypeParameterInstantiation(node,print){this.push("<");print.join(node.params,{separator:", ",iterator:function iterator(node){print.plain(node.typeAnnotation)}});this.push(">")}exports.TypeParameterDeclaration=TypeParameterInstantiation;function ObjectTypeAnnotation(node,print){var _this=this;this.push("{");var props=node.properties.concat(node.callProperties,node.indexers);if(props.length){this.space();print.list(props,{separator:false,indent:true,iterator:function iterator(){if(props.length!==1){_this.semicolon();_this.space()}}});this.space()}this.push("}")}function ObjectTypeCallProperty(node,print){if(node["static"])this.push("static ");print.plain(node.value)}function ObjectTypeIndexer(node,print){if(node["static"])this.push("static ");this.push("[");print.plain(node.id);this.push(":");this.space();print.plain(node.key);this.push("]");this.push(":");this.space();print.plain(node.value)}function ObjectTypeProperty(node,print){if(node["static"])this.push("static ");print.plain(node.key);if(node.optional)this.push("?");if(!t.isFunctionTypeAnnotation(node.value)){this.push(":");this.space()}print.plain(node.value)}function QualifiedTypeIdentifier(node,print){print.plain(node.qualification);this.push(".");print.plain(node.id)}function UnionTypeAnnotation(node,print){print.join(node.types,{separator:" | "})}function TypeCastExpression(node,print){this.push("(");print.plain(node.expression);print.plain(node.typeAnnotation);this.push(")")}function VoidTypeAnnotation(){this.push("void")}},{"../../types":196,"./types":46}],41:[function(require,module,exports){"use strict";exports.__esModule=true;exports.JSXAttribute=JSXAttribute;exports.JSXIdentifier=JSXIdentifier;exports.JSXNamespacedName=JSXNamespacedName;exports.JSXMemberExpression=JSXMemberExpression;exports.JSXSpreadAttribute=JSXSpreadAttribute;exports.JSXExpressionContainer=JSXExpressionContainer;exports.JSXElement=JSXElement;exports.JSXOpeningElement=JSXOpeningElement;exports.JSXClosingElement=JSXClosingElement;exports.JSXEmptyExpression=JSXEmptyExpression;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);function JSXAttribute(node,print){print.plain(node.name);if(node.value){this.push("=");print.plain(node.value)}}function JSXIdentifier(node){this.push(node.name)}function JSXNamespacedName(node,print){print.plain(node.namespace);this.push(":");print.plain(node.name)}function JSXMemberExpression(node,print){print.plain(node.object);this.push(".");print.plain(node.property)}function JSXSpreadAttribute(node,print){this.push("{...");print.plain(node.argument);this.push("}")}function JSXExpressionContainer(node,print){this.push("{");print.plain(node.expression);this.push("}")}function JSXElement(node,print){var open=node.openingElement;print.plain(open);if(open.selfClosing)return;this.indent();var _arr=node.children;for(var _i=0;_i<_arr.length;_i++){var child=_arr[_i];if(t.isLiteral(child)){this.push(child.value,true)}else{print.plain(child)}}this.dedent();print.plain(node.closingElement)}function JSXOpeningElement(node,print){this.push("<");print.plain(node.name);if(node.attributes.length>0){this.push(" ");print.join(node.attributes,{separator:" "})}this.push(node.selfClosing?" />":">")}function JSXClosingElement(node,print){this.push("")}function JSXEmptyExpression(){}},{"../../types":196}],42:[function(require,module,exports){"use strict";exports.__esModule=true;exports._params=_params;exports._method=_method;exports.FunctionExpression=FunctionExpression;exports.ArrowFunctionExpression=ArrowFunctionExpression;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);function _params(node,print){var _this=this;print.plain(node.typeParameters);this.push("(");print.list(node.params,{iterator:function iterator(node){if(node.optional)_this.push("?");print.plain(node.typeAnnotation)}});this.push(")");if(node.returnType){print.plain(node.returnType)}}function _method(node,print){var value=node.value;var kind=node.kind;var key=node.key;if(kind==="method"||kind==="init"){if(value.generator){this.push("*")}}if(kind==="get"||kind==="set"){this.push(kind+" ")}if(value.async)this.push("async ");if(node.computed){this.push("[");print.plain(key);this.push("]")}else{print.plain(key)}this._params(value,print);this.space();print.plain(value.body)}function FunctionExpression(node,print){if(node.async)this.push("async ");this.push("function");if(node.generator)this.push("*");if(node.id){this.push(" ");print.plain(node.id)}else{this.space()}this._params(node,print);this.space();print.plain(node.body)}exports.FunctionDeclaration=FunctionExpression;function ArrowFunctionExpression(node,print){if(node.async)this.push("async ");if(node.params.length===1&&t.isIdentifier(node.params[0])){print.plain(node.params[0])}else{this._params(node,print)}this.push(" => ");var bodyNeedsParens=t.isObjectExpression(node.body);if(bodyNeedsParens){this.push("(")}print.plain(node.body);if(bodyNeedsParens){this.push(")")}}},{"../../types":196}],43:[function(require,module,exports){"use strict";exports.__esModule=true;exports.ImportSpecifier=ImportSpecifier;exports.ImportDefaultSpecifier=ImportDefaultSpecifier;exports.ExportDefaultSpecifier=ExportDefaultSpecifier;exports.ExportSpecifier=ExportSpecifier;exports.ExportNamespaceSpecifier=ExportNamespaceSpecifier;exports.ExportAllDeclaration=ExportAllDeclaration;exports.ExportNamedDeclaration=ExportNamedDeclaration;exports.ExportDefaultDeclaration=ExportDefaultDeclaration;exports.ImportDeclaration=ImportDeclaration;exports.ImportNamespaceSpecifier=ImportNamespaceSpecifier;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);function ImportSpecifier(node,print){print.plain(node.imported);if(node.local&&node.local.name!==node.imported.name){this.push(" as ");print.plain(node.local)}}function ImportDefaultSpecifier(node,print){print.plain(node.local)}function ExportDefaultSpecifier(node,print){print.plain(node.exported)}function ExportSpecifier(node,print){print.plain(node.local);if(node.exported&&node.local.name!==node.exported.name){this.push(" as ");print.plain(node.exported)}}function ExportNamespaceSpecifier(node,print){this.push("* as ");print.plain(node.exported)}function ExportAllDeclaration(node,print){this.push("export *");if(node.exported){this.push(" as ");print.plain(node.exported)}this.push(" from ");print.plain(node.source);this.semicolon()}function ExportNamedDeclaration(node,print){this.push("export ");ExportDeclaration.call(this,node,print)}function ExportDefaultDeclaration(node,print){this.push("export default ");ExportDeclaration.call(this,node,print)}function ExportDeclaration(node,print){var specifiers=node.specifiers;if(node.declaration){var declar=node.declaration;print.plain(declar);if(t.isStatement(declar)||t.isFunction(declar)||t.isClass(declar))return}else{if(node.exportKind==="type"){this.push("type ")}var first=specifiers[0];var hasSpecial=false;if(t.isExportDefaultSpecifier(first)||t.isExportNamespaceSpecifier(first)){hasSpecial=true;print.plain(specifiers.shift());if(specifiers.length){this.push(", ")}}if(specifiers.length||!specifiers.length&&!hasSpecial){this.push("{");if(specifiers.length){this.space();print.join(specifiers,{separator:", "});this.space()}this.push("}")}if(node.source){this.push(" from ");print.plain(node.source)}}this.ensureSemicolon()}function ImportDeclaration(node,print){this.push("import ");if(node.importKind==="type"||node.importKind==="typeof"){this.push(node.importKind+" ")}var specfiers=node.specifiers;if(specfiers&&specfiers.length){var first=node.specifiers[0];if(t.isImportDefaultSpecifier(first)||t.isImportNamespaceSpecifier(first)){print.plain(node.specifiers.shift());if(node.specifiers.length){this.push(", ")}}if(node.specifiers.length){this.push("{");this.space();print.join(node.specifiers,{separator:", "});this.space();this.push("}")}this.push(" from ")}print.plain(node.source);this.semicolon()}function ImportNamespaceSpecifier(node,print){this.push("* as ");print.plain(node.local)}},{"../../types":196}],44:[function(require,module,exports){"use strict";exports.__esModule=true;exports.WithStatement=WithStatement;exports.IfStatement=IfStatement;exports.ForStatement=ForStatement;exports.WhileStatement=WhileStatement;exports.DoWhileStatement=DoWhileStatement;exports.LabeledStatement=LabeledStatement;exports.TryStatement=TryStatement;exports.CatchClause=CatchClause;exports.SwitchStatement=SwitchStatement;exports.SwitchCase=SwitchCase;exports.DebuggerStatement=DebuggerStatement;exports.VariableDeclaration=VariableDeclaration;exports.VariableDeclarator=VariableDeclarator;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _repeating=require("repeating");var _repeating2=_interopRequireDefault(_repeating);var _types=require("../../types");var t=_interopRequireWildcard(_types);function WithStatement(node,print){this.keyword("with");this.push("(");print.plain(node.object);this.push(")");print.block(node.body)}function IfStatement(node,print){this.keyword("if");this.push("(");print.plain(node.test);this.push(")");this.space();print.indentOnComments(node.consequent);if(node.alternate){if(this.isLast("}"))this.space();this.push("else ");print.indentOnComments(node.alternate)}}function ForStatement(node,print){this.keyword("for");this.push("(");print.plain(node.init);this.push(";");if(node.test){this.space();print.plain(node.test)}this.push(";");if(node.update){this.space();print.plain(node.update)}this.push(")");print.block(node.body)}function WhileStatement(node,print){this.keyword("while");this.push("(");print.plain(node.test);this.push(")");print.block(node.body)}var buildForXStatement=function buildForXStatement(op){return function(node,print){this.keyword("for");this.push("(");print.plain(node.left);this.push(" "+op+" ");print.plain(node.right);this.push(")");print.block(node.body)}};var ForInStatement=buildForXStatement("in");exports.ForInStatement=ForInStatement;var ForOfStatement=buildForXStatement("of");exports.ForOfStatement=ForOfStatement;function DoWhileStatement(node,print){this.push("do ");print.plain(node.body);this.space();this.keyword("while");this.push("(");print.plain(node.test);this.push(");")}var buildLabelStatement=function buildLabelStatement(prefix){var key=arguments.length<=1||arguments[1]===undefined?"label":arguments[1];return function(node,print){this.push(prefix);var label=node[key];if(label){this.push(" ");var terminatorState=this.startTerminatorless();print.plain(label);this.endTerminatorless(terminatorState)}this.semicolon()}};var ContinueStatement=buildLabelStatement("continue");exports.ContinueStatement=ContinueStatement;var ReturnStatement=buildLabelStatement("return","argument");exports.ReturnStatement=ReturnStatement;var BreakStatement=buildLabelStatement("break");exports.BreakStatement=BreakStatement;var ThrowStatement=buildLabelStatement("throw","argument");exports.ThrowStatement=ThrowStatement;function LabeledStatement(node,print){print.plain(node.label);this.push(": ");print.plain(node.body)}function TryStatement(node,print){this.keyword("try");print.plain(node.block);this.space();if(node.handlers){print.plain(node.handlers[0])}else{print.plain(node.handler)}if(node.finalizer){this.space();this.push("finally ");print.plain(node.finalizer)}}function CatchClause(node,print){this.keyword("catch");this.push("(");print.plain(node.param);this.push(") ");print.plain(node.body)}function SwitchStatement(node,print){this.keyword("switch");this.push("(");print.plain(node.discriminant);this.push(")");this.space();this.push("{");print.sequence(node.cases,{indent:true,addNewlines:function addNewlines(leading,cas){if(!leading&&node.cases[node.cases.length-1]===cas)return-1}});this.push("}"); +}function SwitchCase(node,print){if(node.test){this.push("case ");print.plain(node.test);this.push(":")}else{this.push("default:")}if(node.consequent.length){this.newline();print.sequence(node.consequent,{indent:true})}}function DebuggerStatement(){this.push("debugger;")}function VariableDeclaration(node,print,parent){this.push(node.kind+" ");var hasInits=false;if(!t.isFor(parent)){var _arr=node.declarations;for(var _i=0;_i<_arr.length;_i++){var declar=_arr[_i];if(declar.init){hasInits=true}}}var sep;if(!this.format.compact&&!this.format.concise&&hasInits&&!this.format.retainLines){sep=",\n"+_repeating2["default"](" ",node.kind.length+1)}print.list(node.declarations,{separator:sep});if(t.isFor(parent)){if(parent.left===node||parent.init===node)return}this.semicolon()}function VariableDeclarator(node,print){print.plain(node.id);print.plain(node.id.typeAnnotation);if(node.init){this.space();this.push("=");this.space();print.plain(node.init)}}},{"../../types":196,repeating:611}],45:[function(require,module,exports){"use strict";exports.__esModule=true;exports.TaggedTemplateExpression=TaggedTemplateExpression;exports.TemplateElement=TemplateElement;exports.TemplateLiteral=TemplateLiteral;function TaggedTemplateExpression(node,print){print.plain(node.tag);print.plain(node.quasi)}function TemplateElement(node){this._push(node.value.raw)}function TemplateLiteral(node,print){this.push("`");var quasis=node.quasis;var len=quasis.length;for(var i=0;i0)this.space();print.plain(elem);if(i1e5;if(format.compact){console.error("[BABEL] "+messages.get("codeGeneratorDeopt",opts.filename,"100KB"))}}if(format.compact){format.indent.adjustMultilineComment=false}return format};CodeGenerator.findCommonStringDelimiter=function findCommonStringDelimiter(code,tokens){var occurences={single:0,"double":0};var checked=0;for(var i=0;i=3)break}if(occurences.single>occurences.double){return"single"}else{return"double"}};CodeGenerator.prototype.generate=function generate(){var ast=this.ast;this.print(ast);if(ast.comments){var comments=[];var _arr=ast.comments;for(var _i=0;_i<_arr.length;_i++){var comment=_arr[_i];if(!comment._displayed)comments.push(comment)}this._printComments(comments)}return{map:this.map.get(),code:this.buffer.get()}};CodeGenerator.prototype.buildPrint=function buildPrint(parent){return new _nodePrinter2["default"](this,parent)};CodeGenerator.prototype.catchUp=function catchUp(node){if(node.loc&&this.format.retainLines&&this.buffer.buf){while(this.position.line=0||comment.value.indexOf("@preserve")>=0){return true}else{return this.format.comments}}};CodeGenerator.prototype._printComments=function _printComments(comments){if(!comments||!comments.length)return;var _arr3=comments;for(var _i3=0;_i3<_arr3.length;_i3++){var comment=_arr3[_i3];if(!this.shouldPrintComment(comment))continue;if(comment._displayed)continue;comment._displayed=true;this.catchUp(comment);this.newline(this.whitespace.getNewlinesBefore(comment));var column=this.position.column;var val=this.generateComment(comment);if(column&&!this.isLast(["\n"," ","[","{"])){this._push(" ");column++}if(comment.type==="CommentBlock"&&this.format.indent.adjustMultilineComment){var offset=comment.loc&&comment.loc.start.column;if(offset){var newlineRegex=new RegExp("\\n\\s{1,"+offset+"}","g");val=val.replace(newlineRegex,"\n")}var indent=Math.max(this.indentSize(),column);val=val.replace(/\n/g,"\n"+_repeating2["default"](" ",indent))}if(column===0){val=this.getIndent()+val}if((this.format.compact||this.format.retainLines)&&comment.type==="CommentLine"){val+="\n"}this._push(val);this.newline(this.whitespace.getNewlinesAfter(comment))}};_createClass(CodeGenerator,null,[{key:"generators",value:{templateLiterals:require("./generators/template-literals"),comprehensions:require("./generators/comprehensions"),expressions:require("./generators/expressions"),statements:require("./generators/statements"),classes:require("./generators/classes"),methods:require("./generators/methods"),modules:require("./generators/modules"),types:require("./generators/types"),flow:require("./generators/flow"),base:require("./generators/base"),jsx:require("./generators/jsx")},enumerable:true}]);return CodeGenerator}();_lodashCollectionEach2["default"](_buffer2["default"].prototype,function(fn,key){CodeGenerator.prototype[key]=function(){return fn.apply(this.buffer,arguments)}});_lodashCollectionEach2["default"](CodeGenerator.generators,function(generator){_lodashObjectExtend2["default"](CodeGenerator.prototype,generator)});module.exports=function(ast,opts,code){var gen=new CodeGenerator(ast,opts,code);return gen.generate()};module.exports.CodeGenerator=CodeGenerator},{"../messages":60,"../types":196,"./buffer":35,"./generators/base":36,"./generators/classes":37,"./generators/comprehensions":38,"./generators/expressions":39,"./generators/flow":40,"./generators/jsx":41,"./generators/methods":42,"./generators/modules":43,"./generators/statements":44,"./generators/template-literals":45,"./generators/types":46,"./node":48,"./node/printer":50,"./position":52,"./source-map":53,"./whitespace":54,"detect-indent":409,"lodash/collection/each":437,"lodash/object/extend":537,repeating:611}],48:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _whitespace=require("./whitespace");var _whitespace2=_interopRequireDefault(_whitespace);var _parentheses=require("./parentheses");var parens=_interopRequireWildcard(_parentheses);var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _lodashCollectionSome=require("lodash/collection/some");var _lodashCollectionSome2=_interopRequireDefault(_lodashCollectionSome);var _types=require("../../types");var t=_interopRequireWildcard(_types);var find=function find(obj,node,parent){if(!obj)return;var result;var types=Object.keys(obj);for(var i=0;i","<=",">=","in","instanceof"],[">>","<<",">>>"],["+","-"],["*","/","%"],["**"]],function(tier,i){_lodashCollectionEach2["default"](tier,function(op){PRECEDENCE[op]=i})});function NullableTypeAnnotation(node,parent){return t.isArrayTypeAnnotation(parent)}exports.FunctionTypeAnnotation=NullableTypeAnnotation;function UpdateExpression(node,parent){if(t.isMemberExpression(parent)&&parent.object===node){return true}}function ObjectExpression(node,parent){if(t.isExpressionStatement(parent)){return true}if(t.isMemberExpression(parent)&&parent.object===node){return true}return false}function Binary(node,parent){if((t.isCallExpression(parent)||t.isNewExpression(parent))&&parent.callee===node){return true}if(t.isUnaryLike(parent)){return true}if(t.isMemberExpression(parent)&&parent.object===node){return true}if(t.isBinary(parent)){var parentOp=parent.operator;var parentPos=PRECEDENCE[parentOp];var nodeOp=node.operator;var nodePos=PRECEDENCE[nodeOp];if(parentPos>nodePos){return true}if(parentPos===nodePos&&parent.right===node){return true}}}function BinaryExpression(node,parent){if(node.operator==="in"){if(t.isVariableDeclarator(parent)){return true}if(t.isFor(parent)){return true}}}function SequenceExpression(node,parent){if(t.isForStatement(parent)){return false}if(t.isExpressionStatement(parent)&&parent.expression===node){return false}return true}function YieldExpression(node,parent){return t.isBinary(parent)||t.isUnaryLike(parent)||t.isCallExpression(parent)||t.isMemberExpression(parent)||t.isNewExpression(parent)||t.isConditionalExpression(parent)||t.isYieldExpression(parent)}function ClassExpression(node,parent){return t.isExpressionStatement(parent)}function UnaryLike(node,parent){return t.isMemberExpression(parent)&&parent.object===node}function FunctionExpression(node,parent){if(t.isExpressionStatement(parent)){return true}if(t.isMemberExpression(parent)&&parent.object===node){return true}if(t.isCallExpression(parent)&&parent.callee===node){return true}}function ConditionalExpression(node,parent){if(t.isUnaryLike(parent)){return true}if(t.isBinary(parent)){return true}if(t.isCallExpression(parent)||t.isNewExpression(parent)){if(parent.callee===node){return true}}if(t.isConditionalExpression(parent)&&parent.test===node){return true}if(t.isMemberExpression(parent)&&parent.object===node){return true}return false}function AssignmentExpression(node){if(t.isObjectPattern(node.left)){return true}else{return ConditionalExpression.apply(undefined,arguments)}}},{"../../types":196,"lodash/collection/each":437}],50:[function(require,module,exports){"use strict";exports.__esModule=true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var NodePrinter=function(){function NodePrinter(generator,parent){_classCallCheck(this,NodePrinter);this.generator=generator;this.parent=parent}NodePrinter.prototype.printInnerComments=function printInnerComments(){if(!this.parent.innerComments)return;var gen=this.generator;gen.indent();gen._printComments(this.parent.innerComments);gen.dedent()};NodePrinter.prototype.plain=function plain(node,opts){return this.generator.print(node,this.parent,opts)};NodePrinter.prototype.sequence=function sequence(nodes){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];opts.statement=true;return this.generator.printJoin(this,nodes,opts)};NodePrinter.prototype.join=function join(nodes,opts){return this.generator.printJoin(this,nodes,opts)};NodePrinter.prototype.list=function list(items){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];if(opts.separator==null){opts.separator=",";if(!this.generator.format.compact)opts.separator+=" "}return this.join(items,opts)};NodePrinter.prototype.block=function block(node){return this.generator.printBlock(this,node)};NodePrinter.prototype.indentOnComments=function indentOnComments(node){return this.generator.printAndIndentOnComments(this,node)};return NodePrinter}();exports["default"]=NodePrinter;module.exports=exports["default"]},{}],51:[function(require,module,exports){"use strict";function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashLangIsBoolean=require("lodash/lang/isBoolean");var _lodashLangIsBoolean2=_interopRequireDefault(_lodashLangIsBoolean);var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _lodashCollectionMap=require("lodash/collection/map");var _lodashCollectionMap2=_interopRequireDefault(_lodashCollectionMap);var _types=require("../../types");var t=_interopRequireWildcard(_types);function crawl(node){var state=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];if(t.isMemberExpression(node)){crawl(node.object,state);if(node.computed)crawl(node.property,state)}else if(t.isBinary(node)||t.isAssignmentExpression(node)){crawl(node.left,state);crawl(node.right,state)}else if(t.isCallExpression(node)){state.hasCall=true;crawl(node.callee,state)}else if(t.isFunction(node)){state.hasFunction=true}else if(t.isIdentifier(node)){state.hasHelper=state.hasHelper||isHelper(node.callee)}return state}function isHelper(node){if(t.isMemberExpression(node)){return isHelper(node.object)||isHelper(node.property)}else if(t.isIdentifier(node)){return node.name==="require"||node.name[0]==="_"}else if(t.isCallExpression(node)){return isHelper(node.callee)}else if(t.isBinary(node)||t.isAssignmentExpression(node)){return t.isIdentifier(node.left)&&isHelper(node.left)||isHelper(node.right)}else{return false}}function isType(node){return t.isLiteral(node)||t.isObjectExpression(node)||t.isArrayExpression(node)||t.isIdentifier(node)||t.isMemberExpression(node)}exports.nodes={AssignmentExpression:function AssignmentExpression(node){var state=crawl(node.right);if(state.hasCall&&state.hasHelper||state.hasFunction){return{before:state.hasFunction,after:true}}},SwitchCase:function SwitchCase(node,parent){return{before:node.consequent.length||parent.cases[0]===node}},LogicalExpression:function LogicalExpression(node){if(t.isFunction(node.left)||t.isFunction(node.right)){return{after:true}}},Literal:function Literal(node){if(node.value==="use strict"){return{after:true}}},CallExpression:function CallExpression(node){if(t.isFunction(node.callee)||isHelper(node)){return{before:true,after:true}}},VariableDeclaration:function VariableDeclaration(node){for(var i=0;i=max){i-=max}return i}var Whitespace=function(){function Whitespace(tokens){_classCallCheck(this,Whitespace);this.tokens=tokens;this.used={};this._lastFoundIndex=0}Whitespace.prototype.getNewlinesBefore=function getNewlinesBefore(node){var startToken;var endToken;var tokens=this.tokens;for(var j=0;j")}}).join("\n");if(highlighted){return _chalk2["default"].reset(frame)}else{return frame}};module.exports=exports["default"]},{chalk:217,esutils:413,"js-tokens":427,"line-numbers":429,repeating:611}],56:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashObjectMerge=require("lodash/object/merge");var _lodashObjectMerge2=_interopRequireDefault(_lodashObjectMerge);exports["default"]=function(dest,src){if(!dest||!src)return;return _lodashObjectMerge2["default"](dest,src,function(a,b){if(b&&Array.isArray(a)){var c=a.slice(0);for(var _iterator=b,_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;){var _ref;if(_isArray){if(_i>=_iterator.length)break;_ref=_iterator[_i++]}else{_i=_iterator.next();if(_i.done)break;_ref=_i.value}var v=_ref;if(a.indexOf(v)<0){c.push(v)}}return c}})};module.exports=exports["default"]},{"lodash/object/merge":541}],57:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../types");var t=_interopRequireWildcard(_types);exports["default"]=function(ast,comments,tokens){if(ast&&ast.type==="Program"){return t.file(ast,comments||[],tokens||[])}else{throw new Error("Not a valid ast?")}};module.exports=exports["default"]},{"../types":196}],58:[function(require,module,exports){"use strict";exports.__esModule=true;exports["default"]=function(){return Object.create(null)};module.exports=exports["default"]},{}],59:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _babylon=require("babylon");var babylon=_interopRequireWildcard(_babylon);exports["default"]=function(code){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];var parseOpts={allowImportExportEverywhere:opts.looseModules,allowReturnOutsideFunction:opts.looseModules,allowHashBang:true,ecmaVersion:6,strictMode:opts.strictMode,sourceType:opts.sourceType,locations:true,features:opts.features||{},plugins:opts.plugins||{}};if(opts.nonStandard){parseOpts.plugins.jsx=true;parseOpts.plugins.flow=true}return babylon.parse(code,parseOpts)};module.exports=exports["default"]},{babylon:633}],60:[function(require,module,exports){"use strict";exports.__esModule=true;exports.get=get;exports.parseArgs=parseArgs;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _util=require("util");var util=_interopRequireWildcard(_util);var MESSAGES={tailCallReassignmentDeopt:"Function reference has been reassigned, so it will probably be dereferenced, therefore we can't optimise this with confidence",JSXNamespacedTags:"Namespace tags are not supported. ReactJSX is not XML.",classesIllegalBareSuper:"Illegal use of bare super",classesIllegalSuperCall:"Direct super call is illegal in non-constructor, use super.$1() instead",scopeDuplicateDeclaration:"Duplicate declaration $1",settersNoRest:"Setters aren't allowed to have a rest",noAssignmentsInForHead:"No assignments allowed in for-in/of head",expectedMemberExpressionOrIdentifier:"Expected type MemberExpression or Identifier",invalidParentForThisNode:"We don't know how to handle this node within the current parent - please open an issue",readOnly:"$1 is read-only",unknownForHead:"Unknown node type $1 in ForStatement",didYouMean:"Did you mean $1?",codeGeneratorDeopt:"Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.",missingTemplatesDirectory:"no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues",unsupportedOutputType:"Unsupported output type $1",illegalMethodName:"Illegal method name $1",lostTrackNodePath:"We lost track of this node's position, likely because the AST was directly manipulated",modulesIllegalExportName:"Illegal export $1",modulesDuplicateDeclarations:"Duplicate module declarations with the same source but in different scopes",undeclaredVariable:"Reference to undeclared variable $1",undeclaredVariableType:"Referencing a type alias outside of a type annotation",undeclaredVariableSuggestion:"Reference to undeclared variable $1 - did you mean $2?",traverseNeedsParent:"You must pass a scope and parentPath unless traversing a Program/File got a $1 node",traverseVerifyRootFunction:"You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?",traverseVerifyVisitorProperty:"You passed `traverse()` a visitor object with the property $1 that has the invalid property $2",traverseVerifyNodeType:"You gave us a visitor for the node type $1 but it's not a valid type",pluginIllegalKind:"Illegal kind $1 for plugin $2",pluginIllegalPosition:"Illegal position $1 for plugin $2",pluginKeyCollision:"The plugin $1 collides with another of the same name",pluginNotTransformer:"The plugin $1 didn't export a Plugin instance",pluginUnknown:"Unknown plugin $1",pluginNotFile:"Plugin $1 is resolving to a different Babel version than what is performing the transformation.",pluginInvalidProperty:"Plugin $1 provided an invalid property of $2.",pluginInvalidPropertyVisitor:'Define your visitor methods inside a `visitor` property like so:\n\n new Plugin("foobar", {\n visitor: {\n // define your visitor methods here!\n }\n });\n'};exports.MESSAGES=MESSAGES;function get(key){for(var _len=arguments.length,args=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var msg=MESSAGES[key];if(!msg)throw new ReferenceError("Unknown message "+JSON.stringify(key));args=parseArgs(args);return msg.replace(/\$(\d+)/g,function(str,i){return args[--i]})}function parseArgs(args){return args.map(function(val){if(val!=null&&val.inspect){return val.inspect()}else{try{return JSON.stringify(val)||val+""}catch(e){return util.inspect(val)}}})}},{util:30}],61:[function(require,module,exports){(function(global){"use strict";require("core-js/shim");require("regenerator/runtime");if(global._babelPolyfill){throw new Error("only one instance of babel/polyfill is allowed")}global._babelPolyfill=true}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"core-js/shim":405,"regenerator/runtime":604}],62:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _generation=require("../generation");var _generation2=_interopRequireDefault(_generation);var _messages=require("../messages");var messages=_interopRequireWildcard(_messages);var _util=require("../util");var util=_interopRequireWildcard(_util);var _transformationFile=require("../transformation/file");var _transformationFile2=_interopRequireDefault(_transformationFile);var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _types=require("../types");var t=_interopRequireWildcard(_types);function buildGlobal(namespace,builder){var body=[];var container=t.functionExpression(null,[t.identifier("global")],t.blockStatement(body));var tree=t.program([t.expressionStatement(t.callExpression(container,[util.template("helper-self-global")]))]);body.push(t.variableDeclaration("var",[t.variableDeclarator(namespace,t.assignmentExpression("=",t.memberExpression(t.identifier("global"),namespace),t.objectExpression([])))]));builder(body);return tree}function buildUmd(namespace,builder){var body=[];body.push(t.variableDeclaration("var",[t.variableDeclarator(namespace,t.identifier("global"))]));builder(body);var container=util.template("umd-commonjs-strict",{FACTORY_PARAMETERS:t.identifier("global"),BROWSER_ARGUMENTS:t.assignmentExpression("=",t.memberExpression(t.identifier("root"),namespace),t.objectExpression({})),COMMON_ARGUMENTS:t.identifier("exports"),AMD_ARGUMENTS:t.arrayExpression([t.literal("exports")]),FACTORY_BODY:body,UMD_ROOT:t.identifier("this")});return t.program([container])}function buildVar(namespace,builder){var body=[];body.push(t.variableDeclaration("var",[t.variableDeclarator(namespace,t.objectExpression({}))]));builder(body);return t.program(body)}function buildHelpers(body,namespace,whitelist){_lodashCollectionEach2["default"](_transformationFile2["default"].helpers,function(name){if(whitelist&&whitelist.indexOf(name)===-1)return;var key=t.identifier(t.toIdentifier(name));body.push(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(namespace,key),util.template("helper-"+name))))})}exports["default"]=function(whitelist){var outputType=arguments.length<=1||arguments[1]===undefined?"global":arguments[1];var namespace=t.identifier("babelHelpers");var builder=function builder(body){return buildHelpers(body,namespace,whitelist)};var tree;var build={global:buildGlobal,umd:buildUmd,"var":buildVar}[outputType];if(build){tree=build(namespace,builder)}else{throw new Error(messages.get("unsupportedOutputType",outputType))}return _generation2["default"](tree).code};module.exports=exports["default"]},{"../generation":47,"../messages":60,"../transformation/file":63,"../types":196,"../util":199,"lodash/collection/each":437}],63:[function(require,module,exports){(function(process){"use strict";exports.__esModule=true;var _createClass=function(){function defineProperties(target,props){for(var i=0;i=0)continue;var group=pass.plugin.metadata.group;if(!pass.canTransform()||!group){stack.push(pass);continue}var mergeStack=[];var _arr4=_stack;for(var _i4=0;_i4<_arr4.length;_i4++){var _pass=_arr4[_i4];if(_pass.plugin.metadata.group===group){mergeStack.push(_pass);ignore.push(_pass)}}var visitors=[];var _arr5=mergeStack;for(var _i5=0;_i5<_arr5.length;_i5++){var _pass2=_arr5[_i5];visitors.push(_pass2.plugin.visitor)}var visitor=_traversal2["default"].visitors.merge(visitors);var mergePlugin=new _plugin2["default"](group,{visitor:visitor});stack.push(mergePlugin.buildPass(this))}return stack};File.prototype.set=function set(key,val){return this.data[key]=val};File.prototype.setDynamic=function setDynamic(key,fn){this.dynamicData[key]=fn};File.prototype.get=function get(key){var data=this.data[key];if(data){return data}else{var dynamic=this.dynamicData[key];if(dynamic){return this.set(key,dynamic())}}};File.prototype.resolveModuleSource=function resolveModuleSource(source){var resolveModuleSource=this.opts.resolveModuleSource;if(resolveModuleSource)source=resolveModuleSource(source,this.opts.filename);return source};File.prototype.addImport=function addImport(source,name,type){name=name||source;var id=this.dynamicImportIds[name];if(!id){source=this.resolveModuleSource(source);id=this.dynamicImportIds[name]=this.scope.generateUidIdentifier(name);var specifiers=[t.importDefaultSpecifier(id)];var declar=t.importDeclaration(specifiers,t.literal(source));declar._blockHoist=3;if(type){var modules=this.dynamicImportTypes[type]=this.dynamicImportTypes[type]||[];modules.push(declar)}if(this.transformers["es6.modules"].canTransform()){this.moduleFormatter.importSpecifier(specifiers[0],declar,this.dynamicImports,this.scope);this.moduleFormatter.hasLocalImports=true}else{this.dynamicImports.push(declar)}}return id};File.prototype.attachAuxiliaryComment=function attachAuxiliaryComment(node){var beforeComment=this.opts.auxiliaryCommentBefore;if(beforeComment){node.leadingComments=node.leadingComments||[];node.leadingComments.push({type:"CommentLine",value:" "+beforeComment})}var afterComment=this.opts.auxiliaryCommentAfter;if(afterComment){node.trailingComments=node.trailingComments||[];node.trailingComments.push({type:"CommentLine",value:" "+afterComment})}return node};File.prototype.addHelper=function addHelper(name){var isSolo=_lodashCollectionIncludes2["default"](File.soloHelpers,name);if(!isSolo&&!_lodashCollectionIncludes2["default"](File.helpers,name)){throw new ReferenceError("Unknown helper "+name)}var declar=this.declarations[name];if(declar)return declar;this.usedHelpers[name]=true;if(!isSolo){var generator=this.get("helperGenerator");var runtime=this.get("helpersNamespace");if(generator){return generator(name)}else if(runtime){var id=t.identifier(t.toIdentifier(name));return t.memberExpression(runtime,id)}}var ref=util.template("helper-"+name);var uid=this.declarations[name]=this.scope.generateUidIdentifier(name);if(t.isFunctionExpression(ref)&&!ref.id){ref.body._compact=true;ref._generated=true;ref.id=uid;ref.type="FunctionDeclaration";this.attachAuxiliaryComment(ref);this.path.unshiftContainer("body",ref)}else{ref._compact=true;this.scope.push({id:uid,init:ref,unique:true})}return uid};File.prototype.addTemplateObject=function addTemplateObject(helperName,strings,raw){var stringIds=raw.elements.map(function(string){return string.value});var name=helperName+"_"+raw.elements.length+"_"+stringIds.join(",");var declar=this.declarations[name];if(declar)return declar;var uid=this.declarations[name]=this.scope.generateUidIdentifier("templateObject");var helperId=this.addHelper(helperName);var init=t.callExpression(helperId,[strings,raw]);init._compact=true;this.scope.push({id:uid,init:init,_blockHoist:1.9});return uid};File.prototype.errorWithNode=function errorWithNode(node,msg){var Error=arguments.length<=2||arguments[2]===undefined?SyntaxError:arguments[2];var err;var loc=node&&(node.loc||node._loc);if(loc){err=new Error("Line "+loc.start.line+": "+msg);err.loc=loc.start}else{err=new Error("There's been an error on a dynamic node. This is almost certainly an internal error. Please report it.")}return err};File.prototype.mergeSourceMap=function mergeSourceMap(map){var opts=this.opts;var inputMap=opts.inputSourceMap;if(inputMap){map.sources[0]=inputMap.file;var inputMapConsumer=new _sourceMap2["default"].SourceMapConsumer(inputMap);var outputMapConsumer=new _sourceMap2["default"].SourceMapConsumer(map);var outputMapGenerator=_sourceMap2["default"].SourceMapGenerator.fromSourceMap(outputMapConsumer);outputMapGenerator.applySourceMap(inputMapConsumer);var mergedMap=outputMapGenerator.toJSON();mergedMap.sources=inputMap.sources;mergedMap.file=inputMap.file;return mergedMap}return map};File.prototype.getModuleFormatter=function getModuleFormatter(type){if(_lodashLangIsFunction2["default"](type)||!_modules2["default"][type]){this.log.deprecate("Custom module formatters are deprecated and will be removed in the next major. Please use Babel plugins instead.")}var ModuleFormatter=_lodashLangIsFunction2["default"](type)?type:_modules2["default"][type];if(!ModuleFormatter){var loc=_tryResolve2["default"].relative(type);if(loc)ModuleFormatter=require(loc)}if(!ModuleFormatter){throw new ReferenceError("Unknown module formatter type "+JSON.stringify(type))}return new ModuleFormatter(this)};File.prototype.parse=function parse(code){var opts=this.opts;var parseOpts={highlightCode:opts.highlightCode,nonStandard:opts.nonStandard,sourceType:opts.sourceType,filename:opts.filename,plugins:{}};var features=parseOpts.features={};for(var key in this.transformers){var transformer=this.transformers[key];features[key]=transformer.canTransform()}parseOpts.looseModules=this.isLoose("es6.modules");parseOpts.strictMode=features.strict;this.log.debug("Parse start");var ast=_helpersParse2["default"](code,parseOpts);this.log.debug("Parse stop");return ast};File.prototype._addAst=function _addAst(ast){this.path=_traversalPath2["default"].get({hub:this.hub,parentPath:null,parent:ast,container:ast,key:"program"}).setContext();this.scope=this.path.scope;this.ast=ast};File.prototype.addAst=function addAst(ast){this.log.debug("Start set AST");this._addAst(ast);this.log.debug("End set AST");this.log.debug("Start module formatter init");var modFormatter=this.moduleFormatter=this.getModuleFormatter(this.opts.modules);if(modFormatter.init&&this.transformers["es6.modules"].canTransform()){modFormatter.init()}this.log.debug("End module formatter init")};File.prototype.transform=function transform(){this.call("pre");var _arr6=this.transformerStack;for(var _i6=0;_i6<_arr6.length;_i6++){var pass=_arr6[_i6];pass.transform()}this.call("post");return this.generate()};File.prototype.wrap=function wrap(code,callback){code=code+"";try{if(this.shouldIgnore()){return this.makeResult({code:code,ignored:true})}else{return callback()}}catch(err){if(err._babel){throw err}else{err._babel=true}var message=err.message=this.opts.filename+": "+err.message;var loc=err.loc;if(loc){err.codeFrame=_helpersCodeFrame2["default"](code,loc.line,loc.column+1,this.opts);message+="\n"+err.codeFrame}if(process.browser){err.message=message}if(err.stack){var newStack=err.stack.replace(err.message,message);try{err.stack=newStack}catch(e){}}throw err}};File.prototype.addCode=function addCode(code){code=(code||"")+"";code=this.parseInputSourceMap(code);this.code=code};File.prototype.parseCode=function parseCode(){this.parseShebang();var ast=this.parse(this.code);this.addAst(ast)};File.prototype.shouldIgnore=function shouldIgnore(){var opts=this.opts;return util.shouldIgnore(opts.filename,opts.ignore,opts.only)};File.prototype.call=function call(key){var _arr7=this.uncollapsedTransformerStack;for(var _i7=0;_i7<_arr7.length;_i7++){var pass=_arr7[_i7];var fn=pass.plugin[key];if(fn)fn(this)}};File.prototype.parseInputSourceMap=function parseInputSourceMap(code){var opts=this.opts;if(opts.inputSourceMap!==false){var inputMap=_convertSourceMap2["default"].fromSource(code);if(inputMap){opts.inputSourceMap=inputMap.toObject();code=_convertSourceMap2["default"].removeComments(code)}}return code};File.prototype.parseShebang=function parseShebang(){var shebangMatch=_shebangRegex2["default"].exec(this.code);if(shebangMatch){this.shebang=shebangMatch[0];this.code=this.code.replace(_shebangRegex2["default"],"")}};File.prototype.makeResult=function makeResult(_ref){var code=_ref.code;var _ref$map=_ref.map;var map=_ref$map===undefined?null:_ref$map;var ast=_ref.ast;var ignored=_ref.ignored;var result={metadata:null,ignored:!!ignored,code:null,ast:null,map:map};if(this.opts.code){result.code=code}if(this.opts.ast){result.ast=ast}if(this.opts.metadata){result.metadata=this.metadata;result.metadata.usedHelpers=Object.keys(this.usedHelpers)}return result};File.prototype.generate=function generate(){var opts=this.opts;var ast=this.ast;var result={ast:ast};if(!opts.code)return this.makeResult(result);this.log.debug("Generation start");var _result=_generation2["default"](ast,opts,this.code);result.code=_result.code;result.map=_result.map;this.log.debug("Generation end");if(this.shebang){result.code=this.shebang+"\n"+result.code}if(result.map){result.map=this.mergeSourceMap(result.map)}if(opts.sourceMaps==="inline"||opts.sourceMaps==="both"){result.code+="\n"+_convertSourceMap2["default"].fromObject(result.map).toComment()}if(opts.sourceMaps==="inline"){result.map=null}return this.makeResult(result)};_createClass(File,null,[{key:"helpers",value:["inherits","defaults","create-class","create-decorated-class","create-decorated-object","define-decorated-property-descriptor","tagged-template-literal","tagged-template-literal-loose","to-array","to-consumable-array","sliced-to-array","sliced-to-array-loose","object-without-properties","has-own","slice","bind","define-property","async-to-generator","interop-export-wildcard","interop-require-wildcard","interop-require-default","typeof","extends","get","set","new-arrow-check","class-call-check","object-destructuring-empty","temporal-undefined","temporal-assert-defined","self-global","default-props","instanceof","interop-require"],enumerable:true},{key:"soloHelpers",value:[],enumerable:true}]);return File}();exports["default"]=File;module.exports=exports["default"]}).call(this,require("_process"))},{"../../generation":47,"../../helpers/code-frame":55,"../../helpers/parse":59,"../../traversal":165,"../../traversal/hub":164,"../../traversal/path":172,"../../types":196,"../../util":199,"../modules":91,"../plugin":99,"./logger":64,"./options/option-manager":67,"./plugin-manager":69,_process:12,"convert-source-map":225,"lodash/collection/includes":439,"lodash/lang/isFunction":526,"lodash/object/defaults":536,path:11,"shebang-regex":614,"source-map":616,"try-resolve":630}],64:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _debugNode=require("debug/node");var _debugNode2=_interopRequireDefault(_debugNode);var verboseDebug=_debugNode2["default"]("babel:verbose");var generalDebug=_debugNode2["default"]("babel");var seenDeprecatedMessages=[];var Logger=function(){function Logger(file,filename){_classCallCheck(this,Logger);this.filename=filename;this.file=file}Logger.prototype._buildMessage=function _buildMessage(msg){var parts="[BABEL] "+this.filename;if(msg)parts+=": "+msg;return parts};Logger.prototype.warn=function warn(msg){console.warn(this._buildMessage(msg))};Logger.prototype.error=function error(msg){var Constructor=arguments.length<=1||arguments[1]===undefined?Error:arguments[1];throw new Constructor(this._buildMessage(msg))};Logger.prototype.deprecate=function deprecate(msg){if(this.file.opts&&this.file.opts.suppressDeprecationMessages)return;msg=this._buildMessage(msg);if(seenDeprecatedMessages.indexOf(msg)>=0)return;seenDeprecatedMessages.push(msg);console.error(msg)};Logger.prototype.verbose=function verbose(msg){if(verboseDebug.enabled)verboseDebug(this._buildMessage(msg))};Logger.prototype.debug=function debug(msg){if(generalDebug.enabled)generalDebug(this._buildMessage(msg))};Logger.prototype.deopt=function deopt(node,msg){this.debug(msg)};return Logger}();exports["default"]=Logger;module.exports=exports["default"]},{"debug/node":407}],65:[function(require,module,exports){module.exports={filename:{type:"filename",description:"filename to use when reading from stdin - this will be used in source-maps, errors etc","default":"unknown",shorthand:"f"},filenameRelative:{hidden:true,type:"string"},inputSourceMap:{hidden:true},extra:{hidden:true,"default":{}},env:{hidden:true,"default":{}},moduleId:{description:"specify a custom name for module ids",type:"string"},getModuleId:{hidden:true},retainLines:{type:"boolean","default":false,description:"retain line numbers - will result in really ugly code"},nonStandard:{type:"boolean","default":true,description:"enable/disable support for JSX and Flow (on by default)"},experimental:{type:"boolean",description:"allow use of experimental transformers","default":false},highlightCode:{description:"enable/disable ANSI syntax highlighting of code frames (on by default)",type:"boolean","default":true},suppressDeprecationMessages:{type:"boolean","default":false,hidden:true},resolveModuleSource:{hidden:true},stage:{description:"ECMAScript proposal stage version to allow [0-4]",shorthand:"e",type:"number","default":2},blacklist:{type:"transformerList",description:"blacklist of transformers to NOT use",shorthand:"b","default":[]},whitelist:{type:"transformerList",optional:true,description:"whitelist of transformers to ONLY use",shorthand:"l"},optional:{type:"transformerList",description:"list of optional transformers to enable","default":[]},modules:{type:"string",description:"module formatter type to use [common]","default":"common",shorthand:"m"},moduleIds:{type:"boolean","default":false,shorthand:"M",description:"insert an explicit id for modules"},loose:{type:"transformerList",description:"list of transformers to enable loose mode ON",shorthand:"L"},jsxPragma:{type:"string",description:"custom pragma to use with JSX (same functionality as @jsx comments)", +"default":"React.createElement",shorthand:"P"},plugins:{type:"list",description:"","default":[]},ignore:{type:"list",description:"list of glob paths to **not** compile","default":[]},only:{type:"list",description:"list of glob paths to **only** compile"},code:{hidden:true,"default":true,type:"boolean"},metadata:{hidden:true,"default":true,type:"boolean"},ast:{hidden:true,"default":true,type:"boolean"},comments:{type:"boolean","default":true,description:"strip/output comments in generated output (on by default)"},shouldPrintComment:{hidden:true,description:"optional callback to control whether a comment should be inserted, when this is used the comments option is ignored"},compact:{type:"booleanString","default":"auto",description:"do not include superfluous whitespace characters and line terminators [true|false|auto]"},keepModuleIdExtensions:{type:"boolean",description:"keep extensions when generating module ids","default":false,shorthand:"k"},auxiliaryComment:{deprecated:"renamed to auxiliaryCommentBefore",shorthand:"a",alias:"auxiliaryCommentBefore"},auxiliaryCommentBefore:{type:"string","default":"",description:"attach a comment before all helper declarations and auxiliary code"},auxiliaryCommentAfter:{type:"string","default":"",description:"attach a comment after all helper declarations and auxiliary code"},externalHelpers:{type:"boolean","default":false,shorthand:"r",description:"uses a reference to `babelHelpers` instead of placing helpers at the top of your code."},metadataUsedHelpers:{deprecated:"Not required anymore as this is enabled by default",type:"boolean","default":false,hidden:true},sourceMap:{alias:"sourceMaps",hidden:true},sourceMaps:{type:"booleanString",description:"[true|false|inline]","default":false,shorthand:"s"},sourceMapName:{alias:"sourceMapTarget",description:"DEPRECATED - Please use sourceMapTarget"},sourceMapTarget:{type:"string",description:"set `file` on returned source map"},sourceFileName:{type:"string",description:"set `sources[0]` on returned source map"},sourceRoot:{type:"filename",description:"the root from which all sources are relative"},moduleRoot:{type:"filename",description:"optional prefix for the AMD module formatter that will be prepend to the filename on module definitions"},breakConfig:{type:"boolean","default":false,hidden:true,description:"stop trying to load .babelrc files"},babelrc:{description:"Specify a custom list of babelrc files to use",type:"list"},sourceType:{description:"","default":"module"}}},{}],66:[function(require,module,exports){"use strict";exports.__esModule=true;exports.validateOption=validateOption;exports.normaliseOptions=normaliseOptions;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _parsers=require("./parsers");var parsers=_interopRequireWildcard(_parsers);var _config=require("./config");var _config2=_interopRequireDefault(_config);exports.config=_config2["default"];function validateOption(key,val,pipeline){var opt=_config2["default"][key];var parser=opt&&parsers[opt.type];if(parser&&parser.validate){return parser.validate(key,val,pipeline)}else{return val}}function normaliseOptions(){var options=arguments.length<=0||arguments[0]===undefined?{}:arguments[0];for(var key in options){var val=options[key];if(val==null)continue;var opt=_config2["default"][key];if(!opt)continue;var parser=parsers[opt.type];if(parser)val=parser(val);options[key]=val}return options}},{"./config":65,"./parsers":68}],67:[function(require,module,exports){(function(process){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _index=require("./index");var _json5=require("json5");var _json52=_interopRequireDefault(_json5);var _pathIsAbsolute=require("path-is-absolute");var _pathIsAbsolute2=_interopRequireDefault(_pathIsAbsolute);var _pathExists=require("path-exists");var _pathExists2=_interopRequireDefault(_pathExists);var _lodashLangClone=require("lodash/lang/clone");var _lodashLangClone2=_interopRequireDefault(_lodashLangClone);var _helpersMerge=require("../../../helpers/merge");var _helpersMerge2=_interopRequireDefault(_helpersMerge);var _config=require("./config");var _config2=_interopRequireDefault(_config);var _path=require("path");var _path2=_interopRequireDefault(_path);var _fs=require("fs");var _fs2=_interopRequireDefault(_fs);var existsCache={};var jsonCache={};var BABELIGNORE_FILENAME=".babelignore";var BABELRC_FILENAME=".babelrc";var PACKAGE_FILENAME="package.json";function exists(filename){var cached=existsCache[filename];if(cached!=null){return cached}else{return existsCache[filename]=_pathExists2["default"].sync(filename)}}var OptionManager=function(){function OptionManager(log,pipeline){_classCallCheck(this,OptionManager);this.resolvedConfigs=[];this.options=OptionManager.createBareOptions();this.pipeline=pipeline;this.log=log}OptionManager.createBareOptions=function createBareOptions(){var opts={};for(var key in _config2["default"]){var opt=_config2["default"][key];opts[key]=_lodashLangClone2["default"](opt["default"])}return opts};OptionManager.prototype.addConfig=function addConfig(loc,key){var json=arguments.length<=2||arguments[2]===undefined?_json52["default"]:arguments[2];if(this.resolvedConfigs.indexOf(loc)>=0)return;var content=_fs2["default"].readFileSync(loc,"utf8");var opts;try{opts=jsonCache[content]=jsonCache[content]||json.parse(content);if(key)opts=opts[key]}catch(err){err.message=loc+": Error while parsing JSON - "+err.message;throw err}this.mergeOptions(opts,loc);this.resolvedConfigs.push(loc)};OptionManager.prototype.mergeOptions=function mergeOptions(opts){var alias=arguments.length<=1||arguments[1]===undefined?"foreign":arguments[1];if(!opts)return;for(var key in opts){if(key[0]==="_")continue;var option=_config2["default"][key];if(!option)this.log.error("Unknown option: "+alias+"."+key,ReferenceError)}_index.normaliseOptions(opts);_helpersMerge2["default"](this.options,opts)};OptionManager.prototype.addIgnoreConfig=function addIgnoreConfig(loc){var file=_fs2["default"].readFileSync(loc,"utf8");var lines=file.split("\n");lines=lines.map(function(line){return line.replace(/#(.*?)$/,"").trim()}).filter(function(line){return!!line});this.mergeOptions({ignore:lines},loc)};OptionManager.prototype.findConfigs=function findConfigs(loc){if(!loc)return;if(!_pathIsAbsolute2["default"](loc)){loc=_path2["default"].join(process.cwd(),loc)}while(loc!==(loc=_path2["default"].dirname(loc))){if(this.options.breakConfig)return;var configLoc=_path2["default"].join(loc,BABELRC_FILENAME);if(exists(configLoc))this.addConfig(configLoc);var pkgLoc=_path2["default"].join(loc,PACKAGE_FILENAME);if(exists(pkgLoc))this.addConfig(pkgLoc,"babel",JSON);var ignoreLoc=_path2["default"].join(loc,BABELIGNORE_FILENAME);if(exists(ignoreLoc))this.addIgnoreConfig(ignoreLoc)}};OptionManager.prototype.normaliseOptions=function normaliseOptions(){var opts=this.options;for(var key in _config2["default"]){var option=_config2["default"][key];var val=opts[key];if(!val&&option.optional)continue;if(this.log&&val&&option.deprecated){this.log.deprecate("Deprecated option "+key+": "+option.deprecated)}if(this.pipeline&&val){val=_index.validateOption(key,val,this.pipeline)}if(option.alias){opts[option.alias]=opts[option.alias]||val}else{opts[key]=val}}};OptionManager.prototype.init=function init(opts){this.mergeOptions(opts,"direct");if(opts.babelrc){var _arr=opts.babelrc;for(var _i=0;_i<_arr.length;_i++){var loc=_arr[_i];this.addConfig(loc)}}if(opts.babelrc!==false){this.findConfigs(opts.filename)}var envKey=process.env.BABEL_ENV||process.env.NODE_ENV||"development";if(this.options.env){this.mergeOptions(this.options.env[envKey],"direct.env."+envKey)}this.normaliseOptions(opts);return this.options};return OptionManager}();exports["default"]=OptionManager;module.exports=exports["default"]}).call(this,require("_process"))},{"../../../helpers/merge":56,"./config":65,"./index":66,_process:12,fs:1,json5:428,"lodash/lang/clone":520,path:11,"path-exists":552,"path-is-absolute":553}],68:[function(require,module,exports){"use strict";exports.__esModule=true;exports.transformerList=transformerList;exports.number=number;exports.boolean=boolean;exports.booleanString=booleanString;exports.list=list;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _slash=require("slash");var _slash2=_interopRequireDefault(_slash);var _util=require("../../../util");var util=_interopRequireWildcard(_util);function transformerList(val){return util.arrayify(val)}transformerList.validate=function(key,val,pipeline){if(val.indexOf("all")>=0||val.indexOf(true)>=0){val=Object.keys(pipeline.transformers)}return pipeline._ensureTransformerNames(key,val)};function number(val){return+val}var filename=_slash2["default"];exports.filename=filename;function boolean(val){return!!val}function booleanString(val){return util.booleanify(val)}function list(val){return util.list(val)}},{"../../../util":199,slash:615}],69:[function(require,module,exports){"use strict";exports.__esModule=true;var _createClass=function(){function defineProperties(target,props){for(var i=0;i=3){callExpr._prettyCall=true}return t.inherits(callExpr,node)}};return visitor};module.exports=exports["default"]},{"../../messages":60,"../../types":196,"./react":79,esutils:413,"lodash/lang/isString":532}],73:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);var visitor={enter:function enter(node,parent,scope,state){if(this.isThisExpression()||this.isReferencedIdentifier({name:"arguments"})){state.found=true;this.stop()}},Function:function Function(){this.skip()}};exports["default"]=function(node,scope){var container=t.functionExpression(null,[],node.body,node.generator,node.async);var callee=container;var args=[];var state={found:false};scope.traverse(node,visitor,state);if(state.found){callee=t.memberExpression(container,t.identifier("apply"));args=[t.thisExpression(),t.identifier("arguments")]}var call=t.callExpression(callee,args);if(node.generator)call=t.yieldExpression(call,true);return t.returnStatement(call)};module.exports=exports["default"]},{"../../types":196}],74:[function(require,module,exports){"use strict";exports.__esModule=true;exports.push=push;exports.hasComputed=hasComputed;exports.toComputedObjectFromClass=toComputedObjectFromClass;exports.toClassObject=toClassObject;exports.toDefineObject=toDefineObject;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _lodashObjectHas=require("lodash/object/has");var _lodashObjectHas2=_interopRequireDefault(_lodashObjectHas);var _types=require("../../types");var t=_interopRequireWildcard(_types);function push(mutatorMap,node,kind,file){var alias=t.toKeyAlias(node);var map={};if(_lodashObjectHas2["default"](mutatorMap,alias))map=mutatorMap[alias];mutatorMap[alias]=map;map._inherits=map._inherits||[];map._inherits.push(node);map._key=node.key;if(node.computed){map._computed=true}if(node.decorators){var decorators=map.decorators=map.decorators||t.arrayExpression([]);decorators.elements=decorators.elements.concat(node.decorators.map(function(dec){return dec.expression}).reverse())}if(map.value||map.initializer){throw file.errorWithNode(node,"Key conflict with sibling node")}if(node.value){if(node.kind==="init")kind="value";if(node.kind==="get")kind="get";if(node.kind==="set")kind="set";t.inheritsComments(node.value,node);map[kind]=node.value}return map}function hasComputed(mutatorMap){for(var key in mutatorMap){if(mutatorMap[key]._computed){return true}}return false}function toComputedObjectFromClass(obj){var objExpr=t.arrayExpression([]);for(var i=0;i=0}function pullFlag(node,flag){var flags=node.regex.flags.split("");if(node.regex.flags.indexOf(flag)<0)return;_lodashArrayPull2["default"](flags,flag);node.regex.flags=flags.join("")}},{"../../types":196,"lodash/array/pull":434}],81:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);var awaitVisitor={Function:function Function(){this.skip()},AwaitExpression:function AwaitExpression(node){node.type="YieldExpression";if(node.all){node.all=false;node.argument=t.callExpression(t.memberExpression(t.identifier("Promise"),t.identifier("all")),[node.argument])}}};var referenceVisitor={ReferencedIdentifier:function ReferencedIdentifier(node,parent,scope,state){var name=state.id.name;if(node.name===name&&scope.bindingIdentifierEquals(name,state.id)){return state.ref=state.ref||scope.generateUidIdentifier(name)}}};exports["default"]=function(path,callId){var node=path.node;node.async=false;node.generator=true;path.traverse(awaitVisitor,state);var call=t.callExpression(callId,[node]);var id=node.id;node.id=null;if(t.isFunctionDeclaration(node)){var declar=t.variableDeclaration("let",[t.variableDeclarator(id,call)]);declar._blockHoist=true;return declar}else{if(id){var state={id:id};path.traverse(referenceVisitor,state);if(state.ref){path.scope.parent.push({id:state.ref});return t.assignmentExpression("=",state.ref,call)}}return call}};module.exports=exports["default"]},{"../../types":196}],82:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _messages=require("../../messages");var messages=_interopRequireWildcard(_messages);var _types=require("../../types");var t=_interopRequireWildcard(_types);function isIllegalBareSuper(node,parent){if(!t.isSuper(node))return false;if(t.isMemberExpression(parent,{computed:false}))return false;if(t.isCallExpression(parent,{callee:node}))return false;return true}function isMemberExpressionSuper(node){return t.isMemberExpression(node)&&t.isSuper(node.object)}var visitor={enter:function enter(node,parent,scope,state){var topLevel=state.topLevel;var self=state.self;if(t.isFunction(node)&&!t.isArrowFunctionExpression(node)){self.traverseLevel(this,false);return this.skip()}if(t.isProperty(node,{method:true})||t.isMethodDefinition(node)){return this.skip()}var getThisReference=topLevel?t.thisExpression:self.getThisReference.bind(self);var callback=self.specHandle;if(self.isLoose)callback=self.looseHandle;var result=callback.call(self,this,getThisReference);if(result)this.hasSuper=true;if(result===true)return;return result}};var ReplaceSupers=function(){function ReplaceSupers(opts){var inClass=arguments.length<=1||arguments[1]===undefined?false:arguments[1];_classCallCheck(this,ReplaceSupers);this.topLevelThisReference=opts.topLevelThisReference;this.methodPath=opts.methodPath;this.methodNode=opts.methodNode;this.superRef=opts.superRef;this.isStatic=opts.isStatic;this.hasSuper=false;this.inClass=inClass;this.isLoose=opts.isLoose;this.scope=opts.scope;this.file=opts.file;this.opts=opts}ReplaceSupers.prototype.getObjectRef=function getObjectRef(){return this.opts.objectRef||this.opts.getObjectRef()};ReplaceSupers.prototype.setSuperProperty=function setSuperProperty(property,value,isComputed,thisExpression){return t.callExpression(this.file.addHelper("set"),[t.callExpression(t.memberExpression(t.identifier("Object"),t.identifier("getPrototypeOf")),[this.isStatic?this.getObjectRef():t.memberExpression(this.getObjectRef(),t.identifier("prototype"))]),isComputed?property:t.literal(property.name),value,thisExpression])};ReplaceSupers.prototype.getSuperProperty=function getSuperProperty(property,isComputed,thisExpression){return t.callExpression(this.file.addHelper("get"),[t.callExpression(t.memberExpression(t.identifier("Object"),t.identifier("getPrototypeOf")),[this.isStatic?this.getObjectRef():t.memberExpression(this.getObjectRef(),t.identifier("prototype"))]),isComputed?property:t.literal(property.name),thisExpression])};ReplaceSupers.prototype.replace=function replace(){this.traverseLevel(this.methodPath.get("value"),true)};ReplaceSupers.prototype.traverseLevel=function traverseLevel(path,topLevel){var state={self:this,topLevel:topLevel};path.traverse(visitor,state)};ReplaceSupers.prototype.getThisReference=function getThisReference(){if(this.topLevelThisReference){return this.topLevelThisReference}else{var ref=this.topLevelThisReference=this.scope.generateUidIdentifier("this");this.methodNode.value.body.body.unshift(t.variableDeclaration("var",[t.variableDeclarator(this.topLevelThisReference,t.thisExpression())]));return ref}};ReplaceSupers.prototype.getLooseSuperProperty=function getLooseSuperProperty(id,parent){var methodNode=this.methodNode;var methodName=methodNode.key;var superRef=this.superRef||t.identifier("Function");if(parent.property===id){return}else if(t.isCallExpression(parent,{callee:id})){parent.arguments.unshift(t.thisExpression());if(methodName.name==="constructor"){if(parent.arguments.length===2&&t.isSpreadElement(parent.arguments[1])&&t.isIdentifier(parent.arguments[1].argument,{name:"arguments"})){parent.arguments[1]=parent.arguments[1].argument;return t.memberExpression(superRef,t.identifier("apply"))}else{return t.memberExpression(superRef,t.identifier("call"))}}else{id=superRef;if(!methodNode["static"]){id=t.memberExpression(id,t.identifier("prototype"))}id=t.memberExpression(id,methodName,methodNode.computed);return t.memberExpression(id,t.identifier("call"))}}else if(t.isMemberExpression(parent)&&!methodNode["static"]){return t.memberExpression(superRef,t.identifier("prototype"))}else{return superRef}};ReplaceSupers.prototype.looseHandle=function looseHandle(path,getThisReference){var node=path.node;if(path.isSuper()){return this.getLooseSuperProperty(node,path.parent)}else if(path.isCallExpression()){var callee=node.callee;if(!t.isMemberExpression(callee))return;if(!t.isSuper(callee.object))return;t.appendToMemberExpression(callee,t.identifier("call"));node.arguments.unshift(getThisReference());return true}};ReplaceSupers.prototype.specHandleAssignmentExpression=function specHandleAssignmentExpression(ref,path,node,getThisReference){if(node.operator==="="){return this.setSuperProperty(node.left.property,node.right,node.left.computed,getThisReference())}else{ref=ref||path.scope.generateUidIdentifier("ref");return[t.variableDeclaration("var",[t.variableDeclarator(ref,node.left)]),t.expressionStatement(t.assignmentExpression("=",node.left,t.binaryExpression(node.operator[0],ref,node.right)))]}};ReplaceSupers.prototype.specHandle=function specHandle(path,getThisReference){var methodNode=this.methodNode;var property;var computed;var args;var thisReference;var parent=path.parent;var node=path.node;if(isIllegalBareSuper(node,parent)){throw path.errorWithNode(messages.get("classesIllegalBareSuper"))}if(t.isCallExpression(node)){var callee=node.callee;if(t.isSuper(callee)){property=methodNode.key;computed=methodNode.computed;args=node.arguments;if(methodNode.key.name!=="constructor"||!this.inClass){var methodName=methodNode.key.name||"METHOD_NAME";throw this.file.errorWithNode(node,messages.get("classesIllegalSuperCall",methodName))}}else if(isMemberExpressionSuper(callee)){property=callee.property;computed=callee.computed;args=node.arguments}}else if(t.isMemberExpression(node)&&t.isSuper(node.object)){property=node.property;computed=node.computed}else if(t.isUpdateExpression(node)&&isMemberExpressionSuper(node.argument)){var binary=t.binaryExpression(node.operator[0],node.argument,t.literal(1));if(node.prefix){return this.specHandleAssignmentExpression(null,path,binary,getThisReference)}else{var ref=path.scope.generateUidIdentifier("ref");return this.specHandleAssignmentExpression(ref,path,binary,getThisReference).concat(t.expressionStatement(ref))}}else if(t.isAssignmentExpression(node)&&isMemberExpressionSuper(node.left)){return this.specHandleAssignmentExpression(null,path,node,getThisReference)}if(!property)return;thisReference=getThisReference();var superProperty=this.getSuperProperty(property,computed,thisReference);if(args){if(args.length===1&&t.isSpreadElement(args[0])){return t.callExpression(t.memberExpression(superProperty,t.identifier("apply")),[thisReference,args[0].argument])}else{return t.callExpression(t.memberExpression(superProperty,t.identifier("call")),[thisReference].concat(args))}}else{return superProperty}};return ReplaceSupers}();exports["default"]=ReplaceSupers;module.exports=exports["default"]},{"../../messages":60,"../../types":196}],83:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _pipeline=require("./pipeline");var _pipeline2=_interopRequireDefault(_pipeline);var _transformers=require("./transformers");var _transformers2=_interopRequireDefault(_transformers);var _transformersDeprecated=require("./transformers/deprecated");var _transformersDeprecated2=_interopRequireDefault(_transformersDeprecated);var _transformersAliases=require("./transformers/aliases");var _transformersAliases2=_interopRequireDefault(_transformersAliases);var _transformersFilters=require("./transformers/filters");var filters=_interopRequireWildcard(_transformersFilters);var pipeline=new _pipeline2["default"];for(var key in _transformers2["default"]){var transformer=_transformers2["default"][key];if(typeof transformer==="object"){var metadata=transformer.metadata=transformer.metadata||{};metadata.group=metadata.group||"builtin-basic"}}pipeline.addTransformers(_transformers2["default"]);pipeline.addDeprecated(_transformersDeprecated2["default"]);pipeline.addAliases(_transformersAliases2["default"]);pipeline.addFilter(filters.internal);pipeline.addFilter(filters.blacklist);pipeline.addFilter(filters.whitelist);pipeline.addFilter(filters.stage);pipeline.addFilter(filters.optional);var transform=pipeline.transform.bind(pipeline);transform.fromAst=pipeline.transformFromAst.bind(pipeline);transform.pipeline=pipeline;exports["default"]=transform;module.exports=exports["default"]},{"./pipeline":97,"./transformers":143,"./transformers/aliases":101,"./transformers/deprecated":102,"./transformers/filters":142}],84:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _libMetadata=require("./lib/metadata");var metadataVisitor=_interopRequireWildcard(_libMetadata);var _messages=require("../../messages");var messages=_interopRequireWildcard(_messages);var _libRemaps=require("./lib/remaps");var _libRemaps2=_interopRequireDefault(_libRemaps);var _helpersObject=require("../../helpers/object");var _helpersObject2=_interopRequireDefault(_helpersObject);var _util=require("../../util");var util=_interopRequireWildcard(_util);var _types=require("../../types");var t=_interopRequireWildcard(_types);var DefaultFormatter=function(){function DefaultFormatter(file){_classCallCheck(this,DefaultFormatter);this.sourceScopes=_helpersObject2["default"]();this.defaultIds=_helpersObject2["default"]();this.ids=_helpersObject2["default"]();this.remaps=new _libRemaps2["default"](file,this);this.scope=file.scope;this.file=file;this.hasNonDefaultExports=false;this.hasLocalExports=false;this.hasLocalImports=false;this.localExports=_helpersObject2["default"]();this.localImports=_helpersObject2["default"]();this.metadata=file.metadata.modules;this.getMetadata()}DefaultFormatter.prototype.addScope=function addScope(path){var source=path.node.source&&path.node.source.value;if(!source)return;var existingScope=this.sourceScopes[source];if(existingScope&&existingScope!==path.scope){throw path.errorWithNode(messages.get("modulesDuplicateDeclarations"))}this.sourceScopes[source]=path.scope};DefaultFormatter.prototype.isModuleType=function isModuleType(node,type){var modules=this.file.dynamicImportTypes[type];return modules&&modules.indexOf(node)>=0};DefaultFormatter.prototype.transform=function transform(){this.remapAssignments()};DefaultFormatter.prototype.doDefaultExportInterop=function doDefaultExportInterop(node){return(t.isExportDefaultDeclaration(node)||t.isSpecifierDefault(node))&&!this.noInteropRequireExport&&!this.hasNonDefaultExports};DefaultFormatter.prototype.getMetadata=function getMetadata(){var has=false;var _arr=this.file.ast.program.body;for(var _i=0;_i<_arr.length;_i++){var node=_arr[_i];if(t.isModuleDeclaration(node)){has=true;break}}if(has||this.isLoose()){this.file.path.traverse(metadataVisitor,this)}};DefaultFormatter.prototype.remapAssignments=function remapAssignments(){if(this.hasLocalExports||this.hasLocalImports){this.remaps.run()}};DefaultFormatter.prototype.remapExportAssignment=function remapExportAssignment(node,exported){var assign=node;for(var i=0;i=0)continue;var msgType="pluginInvalidProperty";if(t.TYPES.indexOf(key)>=0)msgType="pluginInvalidPropertyVisitor";throw new Error(messages.get(msgType,name,key))}for(var key in plugin.metadata){if(VALID_METADATA_PROPERTES.indexOf(key)>=0)continue;throw new Error(messages.get("pluginInvalidProperty",name,"metadata."+key))}};Plugin.prototype.normalize=function normalize(visitor){_traversal2["default"].explode(visitor);return visitor};Plugin.prototype.buildPass=function buildPass(file){if(!(file instanceof _file2["default"])){throw new TypeError(messages.get("pluginNotFile",this.key))}return new _pluginPass2["default"](file,this)};return Plugin}();exports["default"]=Plugin;module.exports=exports["default"]},{"../messages":60,"../traversal":165,"../types":196,"./file":63,"./plugin-pass":98,"lodash/lang/clone":520,"lodash/object/assign":535}],100:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _plugin=require("./plugin");var _plugin2=_interopRequireDefault(_plugin);var Transformer=function Transformer(key,obj){_classCallCheck(this,Transformer);var plugin={};plugin.metadata=obj.metadata;delete obj.metadata;plugin.visitor=obj;return new _plugin2["default"](key,plugin)};exports["default"]=Transformer;module.exports=exports["default"]},{"./plugin":99}],101:[function(require,module,exports){module.exports={useStrict:"strict","es5.runtime":"runtime","es6.runtime":"runtime","minification.inlineExpressions":"minification.constantFolding"}},{}],102:[function(require,module,exports){module.exports={selfContained:"runtime","unicode-regex":"regex.unicode","spec.typeofSymbol":"es6.spec.symbols","es6.symbols":"es6.spec.symbols","es6.blockScopingTDZ":"es6.spec.blockScoping","utility.inlineExpressions":"minification.constantFolding","utility.deadCodeElimination":"minification.deadCodeElimination","utility.removeConsoleCalls":"minification.removeConsole","utility.removeDebugger":"minification.removeDebugger","es6.parameters.rest":"es6.parameters","es6.parameters.default":"es6.parameters"}},{}],103:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-trailing"};exports.metadata=metadata;var visitor={MemberExpression:{exit:function exit(node){var prop=node.property;if(!node.computed&&t.isIdentifier(prop)&&!t.isValidIdentifier(prop.name)){node.property=t.literal(prop.name);node.computed=true}}}};exports.visitor=visitor},{"../../../types":196}],104:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-trailing"};exports.metadata=metadata;var visitor={Property:{exit:function exit(node){var key=node.key;if(!node.computed&&t.isIdentifier(key)&&!t.isValidIdentifier(key.name)){node.key=t.literal(key.name)}}}};exports.visitor=visitor},{"../../../types":196}],105:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _helpersDefineMap=require("../../helpers/define-map");var defineMap=_interopRequireWildcard(_helpersDefineMap);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var visitor={ObjectExpression:function ObjectExpression(node,parent,scope,file){var hasAny=false;var _arr=node.properties;for(var _i=0;_i<_arr.length;_i++){var prop=_arr[_i];if(prop.kind==="get"||prop.kind==="set"){hasAny=true;break}}if(!hasAny)return;var mutatorMap={};node.properties=node.properties.filter(function(prop){if(prop.kind==="get"||prop.kind==="set"){defineMap.push(mutatorMap,prop,prop.kind,file);return false}else{return true}});return t.callExpression(t.memberExpression(t.identifier("Object"),t.identifier("defineProperties")),[node,defineMap.toDefineObject(mutatorMap)])}};exports.visitor=visitor},{"../../../types":196,"../../helpers/define-map":74}],106:[function(require,module,exports){"use strict";exports.__esModule=true;var visitor={ArrowFunctionExpression:function ArrowFunctionExpression(node){this.ensureBlock();node.expression=false;node.type="FunctionExpression";node.shadow=node.shadow||true}};exports.visitor=visitor; +},{}],107:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _traversal=require("../../../traversal");var _traversal2=_interopRequireDefault(_traversal);var _helpersObject=require("../../../helpers/object");var _helpersObject2=_interopRequireDefault(_helpersObject);var _util=require("../../../util");var util=_interopRequireWildcard(_util);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var _lodashObjectValues=require("lodash/object/values");var _lodashObjectValues2=_interopRequireDefault(_lodashObjectValues);var _lodashObjectExtend=require("lodash/object/extend");var _lodashObjectExtend2=_interopRequireDefault(_lodashObjectExtend);function isLet(node,parent){if(!t.isVariableDeclaration(node))return false;if(node._let)return true;if(node.kind!=="let")return false;if(isLetInitable(node,parent)){for(var i=0;i=0){return}loopText=loopText+"|"+node.label.name}else{if(state.ignoreLabeless)return;if(state.inSwitchCase)return;if(t.isBreakStatement(node)&&t.isSwitchCase(parent))return}state.hasBreakContinue=true;state.map[loopText]=node;replace=t.literal(loopText)}if(this.isReturnStatement()){state.hasReturn=true;replace=t.objectExpression([t.property("init",t.identifier("v"),node.argument||t.identifier("undefined"))])}if(replace){replace=t.returnStatement(replace);this.skip();return t.inherits(replace,node)}}};var BlockScoping=function(){function BlockScoping(loopPath,blockPath,parent,scope,file){_classCallCheck(this,BlockScoping);this.parent=parent;this.scope=scope;this.file=file;this.blockPath=blockPath;this.block=blockPath.node;this.outsideLetReferences=_helpersObject2["default"]();this.hasLetReferences=false;this.letReferences=this.block._letReferences=_helpersObject2["default"]();this.body=[];if(loopPath){this.loopParent=loopPath.parent;this.loopLabel=t.isLabeledStatement(this.loopParent)&&this.loopParent.label;this.loopPath=loopPath;this.loop=loopPath.node}}BlockScoping.prototype.run=function run(){var block=this.block;if(block._letDone)return;block._letDone=true;var needsClosure=this.getLetReferences();if(t.isFunction(this.parent)||t.isProgram(this.block))return;if(!this.hasLetReferences)return;if(needsClosure){this.wrapClosure()}else{this.remap()}if(this.loopLabel&&!t.isLabeledStatement(this.loopParent)){return t.labeledStatement(this.loopLabel,this.loop)}};BlockScoping.prototype.remap=function remap(){var hasRemaps=false;var letRefs=this.letReferences;var scope=this.scope;var remaps=_helpersObject2["default"]();for(var key in letRefs){var ref=letRefs[key];if(scope.parentHasBinding(key)||scope.hasGlobal(key)){var uid=scope.generateUidIdentifier(ref.name).name;ref.name=uid;hasRemaps=true;remaps[key]=remaps[uid]={binding:ref,uid:uid}}}if(!hasRemaps)return;var loop=this.loop;if(loop){traverseReplace(loop.right,loop,scope,remaps);traverseReplace(loop.test,loop,scope,remaps);traverseReplace(loop.update,loop,scope,remaps)}this.blockPath.traverse(replaceVisitor,remaps)};BlockScoping.prototype.wrapClosure=function wrapClosure(){var block=this.block;var outsideRefs=this.outsideLetReferences;if(this.loop){for(var name in outsideRefs){var id=outsideRefs[name];if(this.scope.hasGlobal(id.name)||this.scope.parentHasBinding(id.name)){delete outsideRefs[id.name];delete this.letReferences[id.name];this.scope.rename(id.name);this.letReferences[id.name]=id;outsideRefs[id.name]=id}}}this.has=this.checkLoop();this.hoistVarDeclarations();var params=_lodashObjectValues2["default"](outsideRefs);var args=_lodashObjectValues2["default"](outsideRefs);var fn=t.functionExpression(null,params,t.blockStatement(block.body));fn.shadow=true;this.addContinuations(fn);block.body=this.body;var ref=fn;if(this.loop){ref=this.scope.generateUidIdentifier("loop");this.loopPath.insertBefore(t.variableDeclaration("var",[t.variableDeclarator(ref,fn)]))}var call=t.callExpression(ref,args);var ret=this.scope.generateUidIdentifier("ret");var hasYield=_traversal2["default"].hasType(fn.body,this.scope,"YieldExpression",t.FUNCTION_TYPES);if(hasYield){fn.generator=true;call=t.yieldExpression(call,true)}var hasAsync=_traversal2["default"].hasType(fn.body,this.scope,"AwaitExpression",t.FUNCTION_TYPES);if(hasAsync){fn.async=true;call=t.awaitExpression(call)}this.buildClosure(ret,call)};BlockScoping.prototype.buildClosure=function buildClosure(ret,call){var has=this.has;if(has.hasReturn||has.hasBreakContinue){this.buildHas(ret,call)}else{this.body.push(t.expressionStatement(call))}};BlockScoping.prototype.addContinuations=function addContinuations(fn){var state={reassignments:{},outsideReferences:this.outsideLetReferences};this.scope.traverse(fn,continuationVisitor,state);for(var i=0;i=spreadPropIndex)break;if(t.isSpreadProperty(prop))continue;var key=prop.key;if(t.isIdentifier(key)&&!prop.computed)key=t.literal(prop.key.name);keys.push(key)}keys=t.arrayExpression(keys);var value=t.callExpression(this.file.addHelper("object-without-properties"),[objRef,keys]);this.nodes.push(this.buildVariableAssignment(spreadProp.argument,value))};DestructuringTransformer.prototype.pushObjectProperty=function pushObjectProperty(prop,propRef){if(t.isLiteral(prop.key))prop.computed=true;var pattern=prop.value;var objRef=t.memberExpression(propRef,prop.key,prop.computed);if(t.isPattern(pattern)){this.push(pattern,objRef)}else{this.nodes.push(this.buildVariableAssignment(pattern,objRef))}};DestructuringTransformer.prototype.pushObjectPattern=function pushObjectPattern(pattern,objRef){if(!pattern.properties.length){this.nodes.push(t.expressionStatement(t.callExpression(this.file.addHelper("object-destructuring-empty"),[objRef])))}if(pattern.properties.length>1&&!this.scope.isStatic(objRef)){var temp=this.scope.generateUidIdentifierBasedOnNode(objRef);this.nodes.push(this.buildVariableDeclaration(temp,objRef));objRef=temp}for(var i=0;iarr.elements.length)return;if(pattern.elements.length0){elemRef=t.callExpression(t.memberExpression(elemRef,t.identifier("slice")),[t.literal(i)])}elem=elem.argument}else{elemRef=t.memberExpression(arrayRef,t.literal(i),true)}this.push(elem,elemRef)}};DestructuringTransformer.prototype.init=function init(pattern,ref){if(!t.isArrayExpression(ref)&&!t.isMemberExpression(ref)){var memo=this.scope.maybeGenerateMemoised(ref,true);if(memo){this.nodes.push(this.buildVariableDeclaration(memo,ref));ref=memo}}this.push(pattern,ref);return this.nodes};return DestructuringTransformer}()},{"../../../messages":60,"../../../types":196}],113:[function(require,module,exports){"use strict";exports.__esModule=true;exports._ForOfStatementArray=_ForOfStatementArray;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _messages=require("../../../messages");var messages=_interopRequireWildcard(_messages);var _util=require("../../../util");var util=_interopRequireWildcard(_util);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var visitor={ForOfStatement:function ForOfStatement(node,parent,scope,file){if(this.get("right").isArrayExpression()){return _ForOfStatementArray.call(this,node,scope,file)}var callback=spec;if(file.isLoose("es6.forOf"))callback=loose;var build=callback(node,parent,scope,file);var declar=build.declar;var loop=build.loop;var block=loop.body;this.ensureBlock();if(declar){block.body.push(declar)}block.body=block.body.concat(node.body.body);t.inherits(loop,node);t.inherits(loop.body,node.body);if(build.replaceParent){this.parentPath.replaceWithMultiple(build.node);this.dangerouslyRemove()}else{return build.node}}};exports.visitor=visitor;function _ForOfStatementArray(node,scope){var nodes=[];var right=node.right;if(!t.isIdentifier(right)||!scope.hasBinding(right.name)){var uid=scope.generateUidIdentifier("arr");nodes.push(t.variableDeclaration("var",[t.variableDeclarator(uid,right)]));right=uid}var iterationKey=scope.generateUidIdentifier("i");var loop=util.template("for-of-array",{BODY:node.body,KEY:iterationKey,ARR:right});t.inherits(loop,node);t.ensureBlock(loop);var iterationValue=t.memberExpression(right,iterationKey,true);var left=node.left;if(t.isVariableDeclaration(left)){left.declarations[0].init=iterationValue;loop.body.body.unshift(left)}else{loop.body.body.unshift(t.expressionStatement(t.assignmentExpression("=",left,iterationValue)))}if(this.parentPath.isLabeledStatement()){loop=t.labeledStatement(this.parentPath.node.label,loop)}nodes.push(loop);return nodes}var loose=function loose(node,parent,scope,file){var left=node.left;var declar,id;if(t.isIdentifier(left)||t.isPattern(left)||t.isMemberExpression(left)){id=left}else if(t.isVariableDeclaration(left)){id=scope.generateUidIdentifier("ref");declar=t.variableDeclaration(left.kind,[t.variableDeclarator(left.declarations[0].id,id)])}else{throw file.errorWithNode(left,messages.get("unknownForHead",left.type))}var iteratorKey=scope.generateUidIdentifier("iterator");var isArrayKey=scope.generateUidIdentifier("isArray");var loop=util.template("for-of-loose",{LOOP_OBJECT:iteratorKey,IS_ARRAY:isArrayKey,OBJECT:node.right,INDEX:scope.generateUidIdentifier("i"),ID:id});if(!declar){loop.body.body.shift()}return{declar:declar,node:loop,loop:loop}};var spec=function spec(node,parent,scope,file){var left=node.left;var declar;var stepKey=scope.generateUidIdentifier("step");var stepValue=t.memberExpression(stepKey,t.identifier("value"));if(t.isIdentifier(left)||t.isPattern(left)||t.isMemberExpression(left)){declar=t.expressionStatement(t.assignmentExpression("=",left,stepValue))}else if(t.isVariableDeclaration(left)){declar=t.variableDeclaration(left.kind,[t.variableDeclarator(left.declarations[0].id,stepValue)])}else{throw file.errorWithNode(left,messages.get("unknownForHead",left.type))}var iteratorKey=scope.generateUidIdentifier("iterator");var template=util.template("for-of",{ITERATOR_HAD_ERROR_KEY:scope.generateUidIdentifier("didIteratorError"),ITERATOR_COMPLETION:scope.generateUidIdentifier("iteratorNormalCompletion"),ITERATOR_ERROR_KEY:scope.generateUidIdentifier("iteratorError"),ITERATOR_KEY:iteratorKey,STEP_KEY:stepKey,OBJECT:node.right,BODY:null});var isLabeledParent=t.isLabeledStatement(parent);var tryBody=template[3].block.body;var loop=tryBody[0];if(isLabeledParent){tryBody[0]=t.labeledStatement(parent.label,loop)}return{replaceParent:isLabeledParent,declar:declar,loop:loop,node:template}}},{"../../../messages":60,"../../../types":196,"../../../util":199}],114:[function(require,module,exports){"use strict";exports.__esModule=true;var metadata={group:"builtin-pre"};exports.metadata=metadata;var visitor={Literal:function Literal(node){if(typeof node.value==="number"&&/^0[ob]/i.test(node.raw)){node.raw=undefined}if(typeof node.value==="string"&&/\\[u]/gi.test(node.raw)){node.raw=undefined}}};exports.visitor=visitor},{}],115:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);function keepBlockHoist(node,nodes){if(node._blockHoist){for(var i=0;ilastNonDefaultParam}var lastNonDefaultParam=_helpersGetFunctionArity2["default"](node);var params=this.get("params");for(var i=0;i",len,start),t.binaryExpression("-",len,start),t.literal(0))}var loop=util.template("rest",{ARRAY_TYPE:restParam.typeAnnotation,ARGUMENTS:argsId,ARRAY_KEY:arrKey,ARRAY_LEN:arrLen,START:start,ARRAY:rest,KEY:key,LEN:len});if(state.deopted){loop._blockHoist=node.params.length+1;node.body.body.unshift(loop)}else{loop._blockHoist=1;var target=this.getEarliestCommonAncestorFrom(state.references).getStatementParent();var highestLoop;target.findParent(function(path){if(path.isLoop()){highestLoop=path}else if(path.isFunction()){return true}});if(highestLoop)target=highestLoop;target.insertBefore(loop)}}};exports.visitor=visitor},{"../../../../types":196,"../../../../util":199}],120:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);function loose(node,body,objId){var _arr=node.properties;for(var _i=0;_i<_arr.length;_i++){var prop=_arr[_i];body.push(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(objId,prop.key,prop.computed||t.isLiteral(prop.key)),prop.value)))}}function spec(node,body,objId,initProps,file){var _arr2=node.properties;for(var _i2=0;_i2<_arr2.length;_i2++){var prop=_arr2[_i2];if(t.isLiteral(t.toComputedKey(prop),{value:"__proto__"})){initProps.push(prop);continue}var key=prop.key;if(t.isIdentifier(key)&&!prop.computed){key=t.literal(key.name)}var bodyNode=t.callExpression(file.addHelper("define-property"),[objId,key,prop.value]);body.push(t.expressionStatement(bodyNode))}if(body.length===1){var first=body[0].expression;if(t.isCallExpression(first)){first.arguments[0]=t.objectExpression(initProps);return first}}}var visitor={ObjectExpression:{exit:function exit(node,parent,scope,file){var hasComputed=false;var _arr3=node.properties;for(var _i3=0;_i3<_arr3.length;_i3++){var prop=_arr3[_i3];hasComputed=t.isProperty(prop,{computed:true,kind:"init"});if(hasComputed)break}if(!hasComputed)return;var initProps=[];var stopInits=false;node.properties=node.properties.filter(function(prop){if(prop.computed){stopInits=true}if(prop.kind!=="init"||!stopInits){initProps.push(prop);return false}else{return true}});var objId=scope.generateUidIdentifierBasedOnNode(parent);var body=[];var callback=spec;if(file.isLoose("es6.properties.computed"))callback=loose;var result=callback(node,body,objId,initProps,file);if(result)return result;body.unshift(t.variableDeclaration("var",[t.variableDeclarator(objId,t.objectExpression(initProps))]));body.push(t.expressionStatement(objId));return body}}};exports.visitor=visitor},{"../../../types":196}],121:[function(require,module,exports){"use strict";exports.__esModule=true;var visitor={Property:function Property(node){if(node.method){node.method=false}if(node.shorthand){node.shorthand=false}}};exports.visitor=visitor},{}],122:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _helpersRegex=require("../../helpers/regex");var regex=_interopRequireWildcard(_helpersRegex);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var visitor={Literal:function Literal(node){if(!regex.is(node,"y"))return;return t.newExpression(t.identifier("RegExp"),[t.literal(node.regex.pattern),t.literal(node.regex.flags)])}};exports.visitor=visitor},{"../../../types":196,"../../helpers/regex":80}],123:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _regexpuRewritePattern=require("regexpu/rewrite-pattern");var _regexpuRewritePattern2=_interopRequireDefault(_regexpuRewritePattern);var _helpersRegex=require("../../helpers/regex");var regex=_interopRequireWildcard(_helpersRegex);var visitor={Literal:function Literal(node){if(!regex.is(node,"u"))return;node.regex.pattern=_regexpuRewritePattern2["default"](node.regex.pattern,node.regex.flags);regex.pullFlag(node,"u")}};exports.visitor=visitor},{"../../helpers/regex":80,"regexpu/rewrite-pattern":610}],124:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-pre",optional:true};exports.metadata=metadata;var visitor={ArrowFunctionExpression:function ArrowFunctionExpression(node,parent,scope,file){if(node.shadow)return;node.shadow={"this":false};var boundThis=t.thisExpression();boundThis._forceShadow=this;t.ensureBlock(node);this.get("body").unshiftContainer("body",t.expressionStatement(t.callExpression(file.addHelper("new-arrow-check"),[t.thisExpression(),boundThis])));return t.callExpression(t.memberExpression(node,t.identifier("bind")),[t.thisExpression()])}};exports.visitor=visitor},{"../../../types":196}],125:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);function buildAssert(node,file){return t.callExpression(file.addHelper("temporal-assert-defined"),[node,t.literal(node.name),file.addHelper("temporal-undefined")])}function references(node,scope,state){var declared=state.letRefs[node.name];if(!declared)return false;return scope.getBindingIdentifier(node.name)===declared}var refVisitor={ReferencedIdentifier:function ReferencedIdentifier(node,parent,scope,state){if(t.isFor(parent)&&parent.left===node)return;if(!references(node,scope,state))return;var assert=buildAssert(node,state.file);this.skip();if(t.isUpdateExpression(parent)){if(parent._ignoreBlockScopingTDZ)return;this.parentPath.replaceWith(t.sequenceExpression([assert,parent]))}else{return t.logicalExpression("&&",assert,node)}},AssignmentExpression:{exit:function exit(node,parent,scope,state){if(node._ignoreBlockScopingTDZ)return;var nodes=[];var ids=this.getBindingIdentifiers();for(var name in ids){var id=ids[name];if(references(id,scope,state)){nodes.push(buildAssert(id,state.file))}}if(nodes.length){node._ignoreBlockScopingTDZ=true;nodes.push(node);return nodes.map(t.expressionStatement)}}}};var metadata={optional:true,group:"builtin-advanced"};exports.metadata=metadata;var visitor={"Program|Loop|BlockStatement":{exit:function exit(node,parent,scope,file){var letRefs=node._letReferences;if(!letRefs)return;this.traverse(refVisitor,{letRefs:letRefs,file:file})}}};exports.visitor=visitor},{"../../../types":196}],126:[function(require,module,exports){"use strict";exports.__esModule=true; +function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-pre",optional:true};exports.metadata=metadata;var visitor={Program:function Program(){var id=this.scope.generateUidIdentifier("null");this.unshiftContainer("body",[t.variableDeclaration("var",[t.variableDeclarator(id,t.literal(null))]),t.exportNamedDeclaration(null,[t.exportSpecifier(id,t.identifier("__proto__"))])])}};exports.visitor=visitor},{"../../../types":196}],127:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={optional:true};exports.metadata=metadata;var visitor={UnaryExpression:function UnaryExpression(node,parent,scope,file){if(node._ignoreSpecSymbols)return;if(this.parentPath.isBinaryExpression()&&t.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator)>=0){var opposite=this.getOpposite();if(opposite.isLiteral()&&opposite.node.value!=="symbol"&&opposite.node.value!=="object")return}if(node.operator==="typeof"){var call=t.callExpression(file.addHelper("typeof"),[node.argument]);if(this.get("argument").isIdentifier()){var undefLiteral=t.literal("undefined");var unary=t.unaryExpression("typeof",node.argument);unary._ignoreSpecSymbols=true;return t.conditionalExpression(t.binaryExpression("===",unary,undefLiteral),undefLiteral,call)}else{return call}}},BinaryExpression:function BinaryExpression(node,parent,scope,file){if(node.operator==="instanceof"){return t.callExpression(file.addHelper("instanceof"),[node.left,node.right])}},"VariableDeclaration|FunctionDeclaration":function VariableDeclarationFunctionDeclaration(node){if(node._generated)this.skip()}};exports.visitor=visitor},{"../../../types":196}],128:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={optional:true,group:"builtin-pre"};exports.metadata=metadata;var visitor={TemplateLiteral:function TemplateLiteral(node,parent){if(t.isTaggedTemplateExpression(parent))return;for(var i=0;i0){var declarations=_lodashArrayFlatten2["default"](_lodashCollectionMap2["default"](this.vars,function(decl){return decl.declarations}));var assignment=_lodashCollectionReduceRight2["default"](declarations,function(expr,decl){return t.assignmentExpression("=",decl.id,expr)},t.identifier("undefined"));var statement=t.expressionStatement(assignment);statement._blockHoist=Infinity;body.unshift(statement)}var paramDecls=this.paramDecls;if(paramDecls.length>0){var paramDecl=t.variableDeclaration("var",paramDecls);paramDecl._blockHoist=Infinity;body.unshift(paramDecl)}body.unshift(t.expressionStatement(t.assignmentExpression("=",this.getAgainId(),t.literal(false))));node.body=util.template("tail-call-body",{FUNCTION_ID:this.getFunctionId(),AGAIN_ID:this.getAgainId(),BLOCK:node.body});var topVars=[];if(this.needsThis){var _arr=this.thisPaths;for(var _i=0;_i<_arr.length;_i++){var path=_arr[_i];path.replaceWith(this.getThisId())}topVars.push(t.variableDeclarator(this.getThisId(),t.thisExpression()))}if(this.needsArguments||this.setsArguments){var _arr2=this.argumentsPaths;for(var _i2=0;_i2<_arr2.length;_i2++){var _path=_arr2[_i2];_path.replaceWith(this.argumentsId)}var decl=t.variableDeclarator(this.argumentsId);if(this.argumentsId){decl.init=t.identifier("arguments");decl.init._shadowedFunctionLiteral=this.path}topVars.push(decl)}var leftId=this.leftId;if(leftId){topVars.push(t.variableDeclarator(leftId))}if(topVars.length>0){node.body.body.unshift(t.variableDeclaration("var",topVars))}};TailCallTransformer.prototype.subTransform=function subTransform(node){if(!node)return;var handler=this["subTransform"+node.type];if(handler)return handler.call(this,node)};TailCallTransformer.prototype.subTransformConditionalExpression=function subTransformConditionalExpression(node){var callConsequent=this.subTransform(node.consequent);var callAlternate=this.subTransform(node.alternate);if(!callConsequent&&!callAlternate){return}node.type="IfStatement";node.consequent=callConsequent?t.toBlock(callConsequent):returnBlock(node.consequent);if(callAlternate){node.alternate=t.isIfStatement(callAlternate)?callAlternate:t.toBlock(callAlternate)}else{node.alternate=returnBlock(node.alternate)}return[node]};TailCallTransformer.prototype.subTransformLogicalExpression=function subTransformLogicalExpression(node){var callRight=this.subTransform(node.right);if(!callRight)return;var leftId=this.getLeftId();var testExpr=t.assignmentExpression("=",leftId,node.left);if(node.operator==="&&"){testExpr=t.unaryExpression("!",testExpr)}return[t.ifStatement(testExpr,returnBlock(leftId))].concat(callRight)};TailCallTransformer.prototype.subTransformSequenceExpression=function subTransformSequenceExpression(node){var seq=node.expressions;var lastCall=this.subTransform(seq[seq.length-1]);if(!lastCall){return}if(--seq.length===1){node=seq[0]}return[t.expressionStatement(node)].concat(lastCall)};TailCallTransformer.prototype.subTransformCallExpression=function subTransformCallExpression(node){var callee=node.callee;var thisBinding,args;if(t.isMemberExpression(callee,{computed:false})&&t.isIdentifier(callee.property)){switch(callee.property.name){case"call":args=t.arrayExpression(node.arguments.slice(1));break;case"apply":args=node.arguments[1]||t.identifier("undefined");this.needsArguments=true;break;default:return}thisBinding=node.arguments[0];callee=callee.object}if(!t.isIdentifier(callee)||!this.scope.bindingIdentifierEquals(callee.name,this.ownerId)){return}this.hasTailRecursion=true;if(this.hasDeopt())return;var body=[];if(this.needsThis&&!t.isThisExpression(thisBinding)){body.push(t.expressionStatement(t.assignmentExpression("=",this.getThisId(),thisBinding||t.identifier("undefined"))))}if(!args){args=t.arrayExpression(node.arguments)}var argumentsId=this.getArgumentsId();var params=this.getParams();if(this.needsArguments){body.push(t.expressionStatement(t.assignmentExpression("=",argumentsId,args)))}if(t.isArrayExpression(args)){var elems=args.elements;while(elems.length1){var root=buildBinaryExpression(nodes.shift(),nodes.shift());var _arr3=nodes;for(var _i3=0;_i3<_arr3.length;_i3++){var _node=_arr3[_i3];root=buildBinaryExpression(root,_node)}this.replaceWith(root)}else{return nodes[0]}}};exports.visitor=visitor},{"../../../types":196}],132:[function(require,module,exports){"use strict";exports.__esModule=true;var metadata={stage:2};exports.metadata=metadata},{}],133:[function(require,module,exports){"use strict";exports.__esModule=true;var metadata={stage:0,dependencies:["es6.classes"]};exports.metadata=metadata},{}],134:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _helpersBuildComprehension=require("../../helpers/build-comprehension");var _helpersBuildComprehension2=_interopRequireDefault(_helpersBuildComprehension);var _traversal=require("../../../traversal");var _traversal2=_interopRequireDefault(_traversal);var _util=require("../../../util");var util=_interopRequireWildcard(_util);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={stage:0};exports.metadata=metadata;var visitor={ComprehensionExpression:function ComprehensionExpression(node,parent,scope){var callback=array;if(node.generator)callback=generator;return callback(node,parent,scope)}};exports.visitor=visitor;function generator(node){var body=[];var container=t.functionExpression(null,[],t.blockStatement(body),true);container.shadow=true;body.push(_helpersBuildComprehension2["default"](node,function(){return t.expressionStatement(t.yieldExpression(node.body))}));return t.callExpression(container,[])}function array(node,parent,scope){var uid=scope.generateUidIdentifierBasedOnNode(parent);var container=util.template("array-comprehension-container",{KEY:uid});container.callee.shadow=true;var block=container.callee.body;var body=block.body;if(_traversal2["default"].hasType(node,scope,"YieldExpression",t.FUNCTION_TYPES)){container.callee.generator=true;container=t.yieldExpression(container,true)}var returnStatement=body.pop();body.push(_helpersBuildComprehension2["default"](node,function(){return util.template("array-push",{STATEMENT:node.body,KEY:uid},true)}));body.push(returnStatement);return container}},{"../../../traversal":165,"../../../types":196,"../../../util":199,"../../helpers/build-comprehension":71}],135:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _helpersMemoiseDecorators=require("../../helpers/memoise-decorators");var _helpersMemoiseDecorators2=_interopRequireDefault(_helpersMemoiseDecorators);var _helpersDefineMap=require("../../helpers/define-map");var defineMap=_interopRequireWildcard(_helpersDefineMap);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={dependencies:["es6.classes"],optional:true,stage:1};exports.metadata=metadata;var visitor={ObjectExpression:function ObjectExpression(node,parent,scope,file){var hasDecorators=false;for(var i=0;i=1){nodes.push(node)}return nodes}};exports.visitor=visitor},{"../../../types":196}],139:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={optional:true,stage:0};exports.metadata=metadata;function getTempId(scope){var id=scope.path.getData("functionBind");if(id)return id;id=scope.generateDeclaredUidIdentifier("context");return scope.path.setData("functionBind",id)}function getStaticContext(bind,scope){var object=bind.object||bind.callee.object;return scope.isStatic(object)&&object}function inferBindContext(bind,scope){var staticContext=getStaticContext(bind,scope);if(staticContext)return staticContext;var tempId=getTempId(scope);if(bind.object){bind.callee=t.sequenceExpression([t.assignmentExpression("=",tempId,bind.object),bind.callee])}else{bind.callee.object=t.assignmentExpression("=",tempId,bind.callee.object)}return tempId}var visitor={CallExpression:function CallExpression(node,parent,scope){var bind=node.callee;if(!t.isBindExpression(bind))return;var context=inferBindContext(bind,scope);node.callee=t.memberExpression(bind.callee,t.identifier("call"));node.arguments.unshift(context)},BindExpression:function BindExpression(node,parent,scope){var context=inferBindContext(node,scope);return t.callExpression(t.memberExpression(node.callee,t.identifier("bind")),[context])}};exports.visitor=visitor},{"../../../types":196}],140:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={stage:2,dependencies:["es6.destructuring"]};exports.metadata=metadata;var hasSpread=function hasSpread(node){for(var i=0;i=opts.stage)return true}function optional(transformer,opts){if(transformer.metadata.optional&&!_lodashCollectionIncludes2["default"](opts.optional,transformer.key))return false}},{"lodash/collection/includes":439}],143:[function(require,module,exports){"use strict";exports.__esModule=true;exports["default"]={"minification.constantFolding":require("babel-plugin-constant-folding"),strict:require("./other/strict"),eval:require("babel-plugin-eval"),_validation:require("./internal/validation"),_hoistDirectives:require("./internal/hoist-directives"),"minification.removeDebugger":require("babel-plugin-remove-debugger"),"minification.removeConsole":require("babel-plugin-remove-console"),"utility.inlineEnvironmentVariables":require("babel-plugin-inline-environment-variables"),"minification.deadCodeElimination":require("babel-plugin-dead-code-elimination"),_modules:require("./internal/modules"),"react.displayName":require("babel-plugin-react-display-name"),"es6.spec.modules":require("./es6/spec.modules"),"es6.spec.arrowFunctions":require("./es6/spec.arrow-functions"),"es6.spec.templateLiterals":require("./es6/spec.template-literals"),"es6.templateLiterals":require("./es6/template-literals"),"es6.literals":require("./es6/literals"),"validation.undeclaredVariableCheck":require("babel-plugin-undeclared-variables-check"),"spec.functionName":require("./spec/function-name"),"es7.classProperties":require("./es7/class-properties"),"es7.trailingFunctionCommas":require("./es7/trailing-function-commas"),"es7.asyncFunctions":require("./es7/async-functions"),"es7.decorators":require("./es7/decorators"),"validation.react":require("./validation/react"),"es6.arrowFunctions":require("./es6/arrow-functions"),"spec.blockScopedFunctions":require("./spec/block-scoped-functions"),"optimisation.react.constantElements":require("babel-plugin-react-constant-elements"),"optimisation.react.inlineElements":require("./optimisation/react.inline-elements"),"es7.comprehensions":require("./es7/comprehensions"),"es6.classes":require("./es6/classes"),asyncToGenerator:require("./other/async-to-generator"),bluebirdCoroutines:require("./other/bluebird-coroutines"),"es6.objectSuper":require("./es6/object-super"),"es7.objectRestSpread":require("./es7/object-rest-spread"),"es7.exponentiationOperator":require("./es7/exponentiation-operator"),"es5.properties.mutators":require("./es5/properties.mutators"),"es6.properties.shorthand":require("./es6/properties.shorthand"),"es6.properties.computed":require("./es6/properties.computed"),"optimisation.flow.forOf":require("./optimisation/flow.for-of"),"es6.forOf":require("./es6/for-of"),"es6.regex.sticky":require("./es6/regex.sticky"),"es6.regex.unicode":require("./es6/regex.unicode"),"es6.constants":require("./es6/constants"),"es7.exportExtensions":require("./es7/export-extensions"),"spec.protoToAssign":require("babel-plugin-proto-to-assign"),"es7.doExpressions":require("./es7/do-expressions"),"es6.spec.symbols":require("./es6/spec.symbols"),"es7.functionBind":require("./es7/function-bind"),"spec.undefinedToVoid":require("babel-plugin-undefined-to-void"),"es6.spread":require("./es6/spread"),"es6.parameters":require("./es6/parameters"),"es6.destructuring":require("./es6/destructuring"),"es6.blockScoping":require("./es6/block-scoping"),"es6.spec.blockScoping":require("./es6/spec.block-scoping"),reactCompat:require("./other/react-compat"),react:require("./other/react"),regenerator:require("./other/regenerator"),runtime:require("babel-plugin-runtime"),"es6.modules":require("./es6/modules"),_moduleFormatter:require("./internal/module-formatter"), +"es6.tailCall":require("./es6/tail-call"),_shadowFunctions:require("./internal/shadow-functions"),"es3.propertyLiterals":require("./es3/property-literals"),"es3.memberExpressionLiterals":require("./es3/member-expression-literals"),"minification.memberExpressionLiterals":require("babel-plugin-member-expression-literals"),"minification.propertyLiterals":require("babel-plugin-property-literals"),_blockHoist:require("./internal/block-hoist"),jscript:require("babel-plugin-jscript"),flow:require("./other/flow"),"optimisation.modules.system":require("./optimisation/modules.system")};module.exports=exports["default"]},{"./es3/member-expression-literals":103,"./es3/property-literals":104,"./es5/properties.mutators":105,"./es6/arrow-functions":106,"./es6/block-scoping":107,"./es6/classes":108,"./es6/constants":111,"./es6/destructuring":112,"./es6/for-of":113,"./es6/literals":114,"./es6/modules":115,"./es6/object-super":116,"./es6/parameters":118,"./es6/properties.computed":120,"./es6/properties.shorthand":121,"./es6/regex.sticky":122,"./es6/regex.unicode":123,"./es6/spec.arrow-functions":124,"./es6/spec.block-scoping":125,"./es6/spec.modules":126,"./es6/spec.symbols":127,"./es6/spec.template-literals":128,"./es6/spread":129,"./es6/tail-call":130,"./es6/template-literals":131,"./es7/async-functions":132,"./es7/class-properties":133,"./es7/comprehensions":134,"./es7/decorators":135,"./es7/do-expressions":136,"./es7/exponentiation-operator":137,"./es7/export-extensions":138,"./es7/function-bind":139,"./es7/object-rest-spread":140,"./es7/trailing-function-commas":141,"./internal/block-hoist":144,"./internal/hoist-directives":145,"./internal/module-formatter":146,"./internal/modules":147,"./internal/shadow-functions":148,"./internal/validation":149,"./optimisation/flow.for-of":150,"./optimisation/modules.system":151,"./optimisation/react.inline-elements":152,"./other/async-to-generator":153,"./other/bluebird-coroutines":154,"./other/flow":155,"./other/react":157,"./other/react-compat":156,"./other/regenerator":158,"./other/strict":159,"./spec/block-scoped-functions":160,"./spec/function-name":161,"./validation/react":162,"babel-plugin-constant-folding":200,"babel-plugin-dead-code-elimination":201,"babel-plugin-eval":202,"babel-plugin-inline-environment-variables":203,"babel-plugin-jscript":204,"babel-plugin-member-expression-literals":205,"babel-plugin-property-literals":206,"babel-plugin-proto-to-assign":207,"babel-plugin-react-constant-elements":208,"babel-plugin-react-display-name":209,"babel-plugin-remove-console":210,"babel-plugin-remove-debugger":211,"babel-plugin-runtime":213,"babel-plugin-undeclared-variables-check":214,"babel-plugin-undefined-to-void":216}],144:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashCollectionSortBy=require("lodash/collection/sortBy");var _lodashCollectionSortBy2=_interopRequireDefault(_lodashCollectionSortBy);var metadata={group:"builtin-trailing"};exports.metadata=metadata;var visitor={Block:{exit:function exit(node){var hasChange=false;for(var i=0;i=0){comment.value=comment.value.replace(FLOW_DIRECTIVE,"");if(!comment.value.replace(/\*/g,"").trim())comment._displayed=true}}},Flow:function Flow(){this.dangerouslyRemove()},ClassProperty:function ClassProperty(node){node.typeAnnotation=null;if(!node.value)this.dangerouslyRemove()},Class:function Class(node){node["implements"]=null},Function:function Function(node){for(var i=0;i0){nodePath=nodePath.get(keysAlongPath.pop())}return nodePath}},{"../../../types":196,regenerator:561}],159:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-pre"};exports.metadata=metadata;var THIS_BREAK_KEYS=["FunctionExpression","FunctionDeclaration","ClassProperty"];function isUseStrict(node){if(!t.isLiteral(node))return false;if(node.raw&&node.rawValue===node.value){return node.rawValue==="use strict"}else{return node.value==="use strict"}}var visitor={Program:{enter:function enter(program){var first=program.body[0];var directive;if(t.isExpressionStatement(first)&&isUseStrict(first.expression)){directive=first}else{directive=t.expressionStatement(t.literal("use strict"));this.unshiftContainer("body",directive);if(first){directive.leadingComments=first.leadingComments;first.leadingComments=[]}}directive._blockHoist=Infinity}},ThisExpression:function ThisExpression(){if(!this.findParent(function(path){return!path.is("shadow")&&THIS_BREAK_KEYS.indexOf(path.type)>=0})){return t.identifier("undefined")}}};exports.visitor=visitor},{"../../../types":196}],160:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);function statementList(key,path){var paths=path.get(key);for(var i=0;i=0)continue;visited.push(path.node);if(path.visit()){stop=true;break}}var _arr3=queue;for(var _i3=0;_i3<_arr3.length;_i3++){var path=_arr3[_i3];path.shiftContext()}this.queue=null;return stop};TraversalContext.prototype.visitSingle=function visitSingle(node,key){if(this.shouldVisit(node[key])){var path=this.create(node,node,key);path.visit();path.shiftContext()}};TraversalContext.prototype.visit=function visit(node,key){var nodes=node[key];if(!nodes)return;if(Array.isArray(nodes)){return this.visitMultiple(nodes,node,key)}else{return this.visitSingle(node,key)}};return TraversalContext}();exports["default"]=TraversalContext;module.exports=exports["default"]},{"../types":196,"./path":172}],164:[function(require,module,exports){"use strict";exports.__esModule=true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Hub=function Hub(file){_classCallCheck(this,Hub);this.file=file};exports["default"]=Hub;module.exports=exports["default"]},{}],165:[function(require,module,exports){"use strict";exports.__esModule=true;exports["default"]=traverse;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _context=require("./context");var _context2=_interopRequireDefault(_context);var _visitors=require("./visitors");var visitors=_interopRequireWildcard(_visitors);var _messages=require("../messages");var messages=_interopRequireWildcard(_messages);var _lodashCollectionIncludes=require("lodash/collection/includes");var _lodashCollectionIncludes2=_interopRequireDefault(_lodashCollectionIncludes);var _types=require("../types");var t=_interopRequireWildcard(_types);function traverse(parent,opts,scope,state,parentPath){if(!parent)return;if(!opts)opts={};if(!opts.noScope&&!scope){if(parent.type!=="Program"&&parent.type!=="File"){throw new Error(messages.get("traverseNeedsParent",parent.type))}}visitors.explode(opts);if(Array.isArray(parent)){for(var i=0;icurrentKeyIndex){earliest=path}}return earliest})}function getDeepestCommonAncestorFrom(paths,filter){var _this=this;if(!paths.length){return this}if(paths.length===1){return paths[0]}var minDepth=Infinity;var lastCommonIndex,lastCommon;var ancestries=paths.map(function(path){var ancestry=[];do{ancestry.unshift(path)}while((path=path.parentPath)&&path!==_this);if(ancestry.length-1}function visit(){if(this.isBlacklisted())return false;if(this.opts.shouldSkip&&this.opts.shouldSkip(this))return false;this.call("enter");if(this.shouldSkip){return this.shouldStop}var node=this.node;var opts=this.opts;if(node){if(Array.isArray(node)){for(var i=0;i":return left>right;case"<=":return left<=right;case">=":return left>=right;case"==":return left==right;case"!=":return left!=right;case"===":return left===right;case"!==":return left!==right}}if(path.isCallExpression()){var callee=path.get("callee");var context;var func;if(callee.isIdentifier()&&!path.scope.getBinding(callee.node.name,true)&&VALID_CALLEES.indexOf(callee.node.name)>=0){func=global[node.callee.name]}if(callee.isMemberExpression()){var object=callee.get("object");var property=callee.get("property");if(object.isIdentifier()&&property.isIdentifier()&&VALID_CALLEES.indexOf(object.node.name)>=0){context=global[object.node.name];func=context[property.node.name]}if(object.isLiteral()&&property.isIdentifier()){var type=typeof object.node.value;if(type==="string"||type==="number"){context=object.node.value;func=context[property.node.name]}}}if(func){var args=path.get("arguments").map(evaluate);if(!confident)return;return func.apply(context,args)}}confident=false}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],171:[function(require,module,exports){"use strict";exports.__esModule=true;exports.getStatementParent=getStatementParent;exports.getOpposite=getOpposite;exports.getCompletionRecords=getCompletionRecords;exports.getSibling=getSibling;exports.get=get;exports._getKey=_getKey;exports._getPattern=_getPattern;exports.getBindingIdentifiers=getBindingIdentifiers;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _index=require("./index");var _index2=_interopRequireDefault(_index);var _types=require("../../types");var t=_interopRequireWildcard(_types);function getStatementParent(){var path=this;do{if(!path.parentPath||Array.isArray(path.container)&&path.isStatement()){break}else{path=path.parentPath}}while(path);if(path&&(path.isProgram()||path.isFile())){throw new Error("File/Program node, we can't possibly find a statement parent to this")}return path}function getOpposite(){if(this.key==="left"){return this.getSibling("right")}else if(this.key==="right"){return this.getSibling("left")}}function getCompletionRecords(){var paths=[];var add=function add(path){if(path)paths=paths.concat(path.getCompletionRecords())};if(this.isIfStatement()){add(this.get("consequent"));add(this.get("alternate"))}else if(this.isDoExpression()||this.isFor()||this.isWhile()){add(this.get("body"))}else if(this.isProgram()||this.isBlockStatement()){add(this.get("body").pop())}else if(this.isFunction()){return this.get("body").getCompletionRecords()}else if(this.isTryStatement()){add(this.get("block"));add(this.get("handler"));add(this.get("finalizer"))}else{paths.push(this)}return paths}function getSibling(key){return _index2["default"].get({parentPath:this.parentPath,parent:this.parent,container:this.container,listKey:this.listKey,key:key})}function get(key,context){if(context===true)context=this.context;var parts=key.split(".");if(parts.length===1){return this._getKey(key,context)}else{return this._getPattern(parts,context)}}function _getKey(key,context){var _this=this;var node=this.node;var container=node[key];if(Array.isArray(container)){return container.map(function(_,i){return _index2["default"].get({listKey:key,parentPath:_this,parent:node,container:container,key:i}).setContext(context)})}else{return _index2["default"].get({parentPath:this,parent:node,container:node,key:key}).setContext(context)}}function _getPattern(parts,context){var path=this;var _arr=parts;for(var _i=0;_i<_arr.length;_i++){var part=_arr[_i];if(part==="."){path=path.parentPath}else{if(Array.isArray(path)){path=path[part]}else{path=path.get(part,context)}}}return path}function getBindingIdentifiers(duplicates){return t.getBindingIdentifiers(this.node,duplicates)}},{"../../types":196,"./index":172}],172:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _libVirtualTypes=require("./lib/virtual-types");var virtualTypes=_interopRequireWildcard(_libVirtualTypes);var _index=require("../index");var _index2=_interopRequireDefault(_index);var _lodashObjectAssign=require("lodash/object/assign");var _lodashObjectAssign2=_interopRequireDefault(_lodashObjectAssign);var _scope=require("../scope");var _scope2=_interopRequireDefault(_scope);var _types=require("../../types");var t=_interopRequireWildcard(_types);var NodePath=function(){function NodePath(hub,parent){_classCallCheck(this,NodePath);this.contexts=[];this.parent=parent;this.data={};this.hub=hub;this.shouldSkip=false;this.shouldStop=false;this.removed=false;this.state=null;this.opts=null;this.skipKeys=null;this.parentPath=null;this.context=null;this.container=null;this.listKey=null;this.inList=false;this.parentKey=null;this.key=null;this.node=null;this.scope=null;this.type=null;this.typeAnnotation=null}NodePath.get=function get(_ref){var hub=_ref.hub;var parentPath=_ref.parentPath;var parent=_ref.parent;var container=_ref.container;var listKey=_ref.listKey;var key=_ref.key;if(!hub&&parentPath){hub=parentPath.hub}var targetNode=container[key];var paths=parent._paths=parent._paths||[];var path;for(var i=0;i=0)continue;visitedScopes.push(violationScope);constantViolations.push(violation);if(violationScope===path.scope){constantViolations=[violation];break}}constantViolations=constantViolations.concat(functionConstantViolations);var _arr2=constantViolations;for(var _i2=0;_i2<_arr2.length;_i2++){var violation=_arr2[_i2];types.push(violation.getTypeAnnotation())}}if(types.length){return t.createUnionTypeAnnotation(types)}}function getConstantViolationsBefore(binding,path,functions){var violations=binding.constantViolations.slice();violations.unshift(binding.path);return violations.filter(function(violation){violation=violation.resolve();var status=violation._guessExecutionStatusRelativeTo(path);if(functions&&status==="function")functions.push(violation);return status==="before"})}function inferAnnotationFromBinaryExpression(name,path){var operator=path.node.operator;var right=path.get("right").resolve();var left=path.get("left").resolve();var target;if(left.isIdentifier({name:name})){target=right}else if(right.isIdentifier({name:name})){target=left}if(target){if(operator==="==="){return target.getTypeAnnotation()}else if(t.BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator)>=0){return t.numberTypeAnnotation()}else{return}}else{if(operator!=="===")return}var typeofPath;var typePath;if(left.isUnaryExpression({operator:"typeof"})){typeofPath=left;typePath=right}else if(right.isUnaryExpression({operator:"typeof"})){typeofPath=right;typePath=left}if(!typePath&&!typeofPath)return;typePath=typePath.resolve();if(!typePath.isLiteral())return;var typeValue=typePath.node.value;if(typeof typeValue!=="string")return;if(!typeofPath.get("argument").isIdentifier({name:name}))return;return t.createTypeAnnotationBasedOnTypeof(typePath.node.value)}function getParentConditionalPath(path){var parentPath;while(parentPath=path.parentPath){if(parentPath.isIfStatement()||parentPath.isConditionalExpression()){if(path.key==="test"){return}else{return parentPath}}else{path=parentPath}}}function getConditionalAnnotation(path,name){var ifStatement=getParentConditionalPath(path);if(!ifStatement)return;var test=ifStatement.get("test");var paths=[test];var types=[];do{var _path=paths.shift().resolve();if(_path.isLogicalExpression()){paths.push(_path.get("left"));paths.push(_path.get("right"))}if(_path.isBinaryExpression()){var type=inferAnnotationFromBinaryExpression(name,_path);if(type)types.push(type)}}while(paths.length);if(types.length){return{typeAnnotation:t.createUnionTypeAnnotation(types),ifStatement:ifStatement}}else{return getConditionalAnnotation(ifStatement,name)}}module.exports=exports["default"]},{"../../../types":196}],175:[function(require,module,exports){"use strict";exports.__esModule=true;exports.VariableDeclarator=VariableDeclarator;exports.TypeCastExpression=TypeCastExpression;exports.NewExpression=NewExpression;exports.TemplateLiteral=TemplateLiteral;exports.UnaryExpression=UnaryExpression;exports.BinaryExpression=BinaryExpression;exports.LogicalExpression=LogicalExpression;exports.ConditionalExpression=ConditionalExpression;exports.SequenceExpression=SequenceExpression;exports.AssignmentExpression=AssignmentExpression;exports.UpdateExpression=UpdateExpression;exports.Literal=Literal;exports.ObjectExpression=ObjectExpression;exports.ArrayExpression=ArrayExpression;exports.RestElement=RestElement;exports.CallExpression=CallExpression;exports.TaggedTemplateExpression=TaggedTemplateExpression;function _interopRequire(obj){return obj&&obj.__esModule?obj["default"]:obj}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var _infererReference=require("./inferer-reference");exports.Identifier=_interopRequire(_infererReference);function VariableDeclarator(){var id=this.get("id");if(id.isIdentifier()){return this.get("init").getTypeAnnotation()}else{return}}function TypeCastExpression(node){return node.typeAnnotation}TypeCastExpression.validParent=true;function NewExpression(node){if(this.get("callee").isIdentifier()){return t.genericTypeAnnotation(node.callee)}}function TemplateLiteral(){return t.stringTypeAnnotation()}function UnaryExpression(node){var operator=node.operator;if(operator==="void"){return t.voidTypeAnnotation()}else if(t.NUMBER_UNARY_OPERATORS.indexOf(operator)>=0){return t.numberTypeAnnotation()}else if(t.STRING_UNARY_OPERATORS.indexOf(operator)>=0){return t.stringTypeAnnotation()}else if(t.BOOLEAN_UNARY_OPERATORS.indexOf(operator)>=0){return t.booleanTypeAnnotation()}}function BinaryExpression(node){var operator=node.operator;if(t.NUMBER_BINARY_OPERATORS.indexOf(operator)>=0){return t.numberTypeAnnotation()}else if(t.BOOLEAN_BINARY_OPERATORS.indexOf(operator)>=0){return t.booleanTypeAnnotation()}else if(operator==="+"){var right=this.get("right");var left=this.get("left");if(left.isBaseType("number")&&right.isBaseType("number")){return t.numberTypeAnnotation()}else if(left.isBaseType("string")||right.isBaseType("string")){return t.stringTypeAnnotation()}return t.unionTypeAnnotation([t.stringTypeAnnotation(),t.numberTypeAnnotation()])}}function LogicalExpression(){return t.createUnionTypeAnnotation([this.get("left").getTypeAnnotation(),this.get("right").getTypeAnnotation()])}function ConditionalExpression(){return t.createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(),this.get("alternate").getTypeAnnotation()])}function SequenceExpression(){return this.get("expressions").pop().getTypeAnnotation()}function AssignmentExpression(){return this.get("right").getTypeAnnotation()}function UpdateExpression(node){var operator=node.operator;if(operator==="++"||operator==="--"){return t.numberTypeAnnotation()}}function Literal(node){var value=node.value;if(typeof value==="string")return t.stringTypeAnnotation();if(typeof value==="number")return t.numberTypeAnnotation();if(typeof value==="boolean")return t.booleanTypeAnnotation();if(value===null)return t.voidTypeAnnotation();if(node.regex)return t.genericTypeAnnotation(t.identifier("RegExp"))}function ObjectExpression(){return t.genericTypeAnnotation(t.identifier("Object"))}function ArrayExpression(){return t.genericTypeAnnotation(t.identifier("Array"))}function RestElement(){return ArrayExpression()}RestElement.validParent=true;function Func(){return t.genericTypeAnnotation(t.identifier("Function"))}exports.Function=Func;exports.Class=Func;function CallExpression(){return resolveCall(this.get("callee"))}function TaggedTemplateExpression(){return resolveCall(this.get("tag"))}function resolveCall(callee){callee=callee.resolve();if(callee.isFunction()){if(callee.is("async")){if(callee.is("generator")){return t.genericTypeAnnotation(t.identifier("AsyncIterator"))}else{return t.genericTypeAnnotation(t.identifier("Promise"))}}else{if(callee.node.returnType){return callee.node.returnType}else{}}}}},{"../../../types":196,"./inferer-reference":174}],176:[function(require,module,exports){"use strict";exports.__esModule=true;exports.matchesPattern=matchesPattern;exports.has=has;exports.isnt=isnt;exports.equals=equals;exports.isNodeType=isNodeType;exports.canHaveVariableDeclarationOrExpression=canHaveVariableDeclarationOrExpression;exports.isCompletionRecord=isCompletionRecord;exports.isStatementOrBlock=isStatementOrBlock;exports.referencesImport=referencesImport;exports.getSource=getSource;exports.willIMaybeExecuteBefore=willIMaybeExecuteBefore;exports._guessExecutionStatusRelativeTo=_guessExecutionStatusRelativeTo;exports.resolve=resolve;exports._resolve=_resolve;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashCollectionIncludes=require("lodash/collection/includes");var _lodashCollectionIncludes2=_interopRequireDefault(_lodashCollectionIncludes);var _types=require("../../types");var t=_interopRequireWildcard(_types); +function matchesPattern(pattern,allowPartial){if(!this.isMemberExpression())return false;var parts=pattern.split(".");var search=[this.node];var i=0;function matches(name){var part=parts[i];return part==="*"||name===part}while(search.length){var node=search.shift();if(allowPartial&&i===parts.length){return true}if(t.isIdentifier(node)){if(!matches(node.name))return false}else if(t.isLiteral(node)){if(!matches(node.value))return false}else if(t.isMemberExpression(node)){if(node.computed&&!t.isLiteral(node.property)){return false}else{search.unshift(node.property);search.unshift(node.object);continue}}else if(t.isThisExpression(node)){if(!matches("this"))return false}else{return false}if(++i>parts.length){return false}}return i===parts.length}function has(key){var val=this.node[key];if(val&&Array.isArray(val)){return!!val.length}else{return!!val}}var is=has;exports.is=is;function isnt(key){return!this.has(key)}function equals(key,value){return this.node[key]===value}function isNodeType(type){return t.isType(this.type,type)}function canHaveVariableDeclarationOrExpression(){return(this.key==="init"||this.key==="left")&&this.parentPath.isFor()}function isCompletionRecord(allowInsideFunction){var path=this;var first=true;do{var container=path.container;if(path.isFunction()&&!first){return!!allowInsideFunction}first=false;if(Array.isArray(container)&&path.key!==container.length-1){return false}}while((path=path.parentPath)&&!path.isProgram());return true}function isStatementOrBlock(){if(this.parentPath.isLabeledStatement()||t.isBlockStatement(this.container)){return false}else{return _lodashCollectionIncludes2["default"](t.STATEMENT_OR_BLOCK_KEYS,this.key)}}function referencesImport(moduleSource,importName){if(!this.isReferencedIdentifier())return false;var binding=this.scope.getBinding(this.node.name);if(!binding||binding.kind!=="module")return false;var path=binding.path;var parent=path.parentPath;if(!parent.isImportDeclaration())return false;if(parent.node.source.value===moduleSource){if(!importName)return true}else{return false}if(path.isImportDefaultSpecifier()&&importName==="default"){return true}if(path.isImportNamespaceSpecifier()&&importName==="*"){return true}if(path.isImportSpecifier()&&path.node.imported.name===importName){return true}return false}function getSource(){var node=this.node;if(node.end){return this.hub.file.code.slice(node.start,node.end)}else{return""}}function willIMaybeExecuteBefore(target){return this._guessExecutionStatusRelativeTo(target)!=="after"}function _guessExecutionStatusRelativeTo(target){var targetFuncParent=target.scope.getFunctionParent();var selfFuncParent=this.scope.getFunctionParent();if(targetFuncParent!==selfFuncParent){return"function"}var targetPaths=target.getAncestry();var selfPaths=this.getAncestry();var commonPath;var targetIndex;var selfIndex;for(selfIndex=0;selfIndex=0){commonPath=selfPath;break}}if(!commonPath){return"before"}var targetRelationship=targetPaths[targetIndex-1];var selfRelationship=selfPaths[selfIndex-1];if(!targetRelationship||!selfRelationship){return"before"}if(targetRelationship.listKey&&targetRelationship.container===selfRelationship.container){return targetRelationship.key>selfRelationship.key?"before":"after"}var targetKeyPosition=t.VISITOR_KEYS[targetRelationship.type].indexOf(targetRelationship.key);var selfKeyPosition=t.VISITOR_KEYS[selfRelationship.type].indexOf(selfRelationship.key);return targetKeyPosition>selfKeyPosition?"before":"after"}function resolve(dangerous,resolved){return this._resolve(dangerous,resolved)||this}function _resolve(dangerous,resolved){if(resolved&&resolved.indexOf(this)>=0)return;resolved=resolved||[];resolved.push(this);if(this.isVariableDeclarator()){if(this.get("id").isIdentifier()){return this.get("init").resolve(dangerous,resolved)}else{}}else if(this.isReferencedIdentifier()){var binding=this.scope.getBinding(this.node.name);if(!binding)return;if(!binding.constant)return;if(binding.kind==="module")return;if(binding.path!==this){return binding.path.resolve(dangerous,resolved)}}else if(this.isTypeCastExpression()){return this.get("expression").resolve(dangerous,resolved)}else if(dangerous&&this.isMemberExpression()){var targetKey=this.toComputedKey();if(!t.isLiteral(targetKey))return;var targetName=targetKey.value;var target=this.get("object").resolve(dangerous,resolved);if(target.isObjectExpression()){var props=target.get("properties");var _arr=props;for(var _i=0;_i<_arr.length;_i++){var prop=_arr[_i];if(!prop.isProperty())continue;var key=prop.get("key");var match=prop.isnt("computed")&&key.isIdentifier({name:targetName});match=match||key.isLiteral({value:targetName});if(match)return prop.get("value").resolve(dangerous,resolved)}}else if(target.isArrayExpression()&&!isNaN(+targetName)){var elems=target.get("elements");var elem=elems[targetName];if(elem)return elem.resolve(dangerous,resolved)}}}},{"../../types":196,"lodash/collection/includes":439}],177:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _transformationHelpersReact=require("../../../transformation/helpers/react");var react=_interopRequireWildcard(_transformationHelpersReact);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var referenceVisitor={ReferencedIdentifier:function ReferencedIdentifier(node,parent,scope,state){if(this.isJSXIdentifier()&&react.isCompatTag(node.name)){return}var binding=scope.getBinding(node.name);if(!binding)return;if(binding!==state.scope.getBinding(node.name))return;if(binding.constant){state.bindings[node.name]=binding}else{var _arr=binding.constantViolations;for(var _i=0;_i<_arr.length;_i++){var violationPath=_arr[_i];state.breakOnScopePaths=state.breakOnScopePaths.concat(violationPath.getAncestry())}}}};var PathHoister=function(){function PathHoister(path,scope){_classCallCheck(this,PathHoister);this.breakOnScopePaths=[];this.bindings={};this.scopes=[];this.scope=scope;this.path=path}PathHoister.prototype.isCompatibleScope=function isCompatibleScope(scope){for(var key in this.bindings){var binding=this.bindings[key];if(!scope.bindingIdentifierEquals(key,binding.identifier)){return false}}return true};PathHoister.prototype.getCompatibleScopes=function getCompatibleScopes(){var scope=this.path.scope;do{if(this.isCompatibleScope(scope)){this.scopes.push(scope)}else{break}if(this.breakOnScopePaths.indexOf(scope.path)>=0){break}}while(scope=scope.parent)};PathHoister.prototype.getAttachmentPath=function getAttachmentPath(){var scopes=this.scopes;var scope=scopes.pop();if(!scope)return;if(scope.path.isFunction()){if(this.hasOwnParamBindings(scope)){if(this.scope===scope)return;return scope.path.get("body").get("body")[0]}else{return this.getNextScopeStatementParent()}}else if(scope.path.isProgram()){return this.getNextScopeStatementParent()}};PathHoister.prototype.getNextScopeStatementParent=function getNextScopeStatementParent(){var scope=this.scopes.pop();if(scope)return scope.path.getStatementParent()};PathHoister.prototype.hasOwnParamBindings=function hasOwnParamBindings(scope){for(var name in this.bindings){if(!scope.hasOwnBinding(name))continue;var binding=this.bindings[name];if(binding.kind==="param")return true}return false};PathHoister.prototype.run=function run(){var node=this.path.node;if(node._hoisted)return;node._hoisted=true;this.path.traverse(referenceVisitor,this);this.getCompatibleScopes();var attachTo=this.getAttachmentPath();if(!attachTo)return;if(attachTo.getFunctionParent()===this.path.getFunctionParent())return;var uid=attachTo.scope.generateUidIdentifier("ref");attachTo.insertBefore([t.variableDeclaration("var",[t.variableDeclarator(uid,this.path.node)])]);var parent=this.path.parentPath;if(parent.isJSXElement()&&this.path.container===parent.node.children){uid=t.JSXExpressionContainer(uid)}this.path.replaceWith(uid)};return PathHoister}();exports["default"]=PathHoister;module.exports=exports["default"]},{"../../../transformation/helpers/react":79,"../../../types":196}],178:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var pre=[function(self){if(self.key==="body"&&(self.isBlockStatement()||self.isClassBody())){self.node.body=[];return true}},function(self,parent){var replace=false;replace=replace||self.key==="body"&&parent.isArrowFunctionExpression();replace=replace||self.key==="argument"&&parent.isThrowStatement();if(replace){self.replaceWith(t.identifier("undefined"));return true}}];exports.pre=pre;var post=[function(self,parent){var removeParent=false;removeParent=removeParent||self.key==="test"&&(parent.isWhile()||parent.isSwitchCase());removeParent=removeParent||self.key==="declaration"&&parent.isExportDeclaration();removeParent=removeParent||self.key==="body"&&parent.isLabeledStatement();removeParent=removeParent||self.listKey==="declarations"&&parent.isVariableDeclaration()&&parent.node.declarations.length===0;removeParent=removeParent||self.key==="expression"&&parent.isExpressionStatement();removeParent=removeParent||self.key==="test"&&parent.isIfStatement();if(removeParent){parent.dangerouslyRemove();return true}},function(self,parent){if(parent.isSequenceExpression()&&parent.node.expressions.length===1){parent.replaceWith(parent.node.expressions[0]);return true}},function(self,parent){if(parent.isBinary()){if(self.key==="left"){parent.replaceWith(parent.node.right)}else{parent.replaceWith(parent.node.left)}return true}}];exports.post=post},{"../../../types":196}],179:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _transformationHelpersReact=require("../../../transformation/helpers/react");var react=_interopRequireWildcard(_transformationHelpersReact);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var ReferencedIdentifier={types:["Identifier","JSXIdentifier"],checkPath:function checkPath(_ref,opts){var node=_ref.node;var parent=_ref.parent;if(!t.isIdentifier(node,opts)){if(t.isJSXIdentifier(node,opts)){if(react.isCompatTag(node.name))return false}else{return false}}return t.isReferenced(node,parent)}};exports.ReferencedIdentifier=ReferencedIdentifier;var BindingIdentifier={types:["Identifier"],checkPath:function checkPath(_ref2){var node=_ref2.node;var parent=_ref2.parent;return t.isBinding(node,parent)}};exports.BindingIdentifier=BindingIdentifier;var Statement={types:["Statement"],checkPath:function checkPath(_ref3){var node=_ref3.node;var parent=_ref3.parent;if(t.isStatement(node)){if(t.isVariableDeclaration(node)){if(t.isForXStatement(parent,{left:node}))return false;if(t.isForStatement(parent,{init:node}))return false}return true}else{return false}}};exports.Statement=Statement;var Expression={types:["Expression"],checkPath:function checkPath(path){if(path.isIdentifier()){return path.isReferencedIdentifier()}else{return t.isExpression(path.node)}}};exports.Expression=Expression;var Scope={types:["Scopable"],checkPath:function checkPath(path){return t.isScope(path.node,path.parent)}};exports.Scope=Scope;var Referenced={checkPath:function checkPath(path){return t.isReferenced(path.node,path.parent)}};exports.Referenced=Referenced;var BlockScoped={checkPath:function checkPath(path){return t.isBlockScoped(path.node)}};exports.BlockScoped=BlockScoped;var Var={types:["VariableDeclaration"],checkPath:function checkPath(path){return t.isVar(path.node)}};exports.Var=Var;var DirectiveLiteral={types:["Literal"],checkPath:function checkPath(path){return path.isLiteral()&&path.parentPath.isExpressionStatement()}};exports.DirectiveLiteral=DirectiveLiteral;var Directive={types:["ExpressionStatement"],checkPath:function checkPath(path){return path.get("expression").isLiteral()}};exports.Directive=Directive;var User={checkPath:function checkPath(path){return path.node&&!!path.node.loc}};exports.User=User;var Generated={checkPath:function checkPath(path){return!path.isUser()}};exports.Generated=Generated;var Flow={types:["Flow","ImportDeclaration","ExportDeclaration"],checkPath:function checkPath(_ref4){var node=_ref4.node;if(t.isFlow(node)){return true}else if(t.isImportDeclaration(node)){return node.importKind==="type"||node.importKind==="typeof"}else if(t.isExportDeclaration(node)){return node.exportKind==="type"}else{return false}}};exports.Flow=Flow},{"../../../transformation/helpers/react":79,"../../../types":196}],180:[function(require,module,exports){"use strict";exports.__esModule=true;exports.insertBefore=insertBefore;exports._containerInsert=_containerInsert;exports._containerInsertBefore=_containerInsertBefore;exports._containerInsertAfter=_containerInsertAfter;exports._maybePopFromStatements=_maybePopFromStatements;exports.insertAfter=insertAfter;exports.updateSiblingKeys=updateSiblingKeys;exports._verifyNodeList=_verifyNodeList;exports.unshiftContainer=unshiftContainer;exports.pushContainer=pushContainer;exports.hoist=hoist;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _libHoister=require("./lib/hoister");var _libHoister2=_interopRequireDefault(_libHoister);var _index=require("./index");var _index2=_interopRequireDefault(_index);var _types=require("../../types");var t=_interopRequireWildcard(_types);function insertBefore(nodes){this._assertUnremoved();nodes=this._verifyNodeList(nodes);if(this.parentPath.isExpressionStatement()||this.parentPath.isLabeledStatement()){return this.parentPath.insertBefore(nodes)}else if(this.isNodeType("Expression")||this.parentPath.isForStatement()&&this.key==="init"){if(this.node)nodes.push(this.node);this.replaceExpressionWithStatements(nodes)}else{this._maybePopFromStatements(nodes);if(Array.isArray(this.container)){return this._containerInsertBefore(nodes)}else if(this.isStatementOrBlock()){if(this.node)nodes.push(this.node);this.node=this.container[this.key]=t.blockStatement(nodes)}else{throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?")}}return[this]}function _containerInsert(from,nodes){this.updateSiblingKeys(from,nodes.length);var paths=[];for(var i=0;i=fromIndex){path.key+=incrementBy}}}function _verifyNodeList(nodes){if(nodes.constructor!==Array){nodes=[nodes]}for(var i=0;i1)id+=i;return"_"+id};Scope.prototype.generateUidIdentifierBasedOnNode=function generateUidIdentifierBasedOnNode(parent,defaultName){var node=parent;if(t.isAssignmentExpression(parent)){node=parent.left}else if(t.isVariableDeclarator(parent)){node=parent.id}else if(t.isProperty(node)){node=node.key}var parts=[];var add=function add(node){if(t.isModuleDeclaration(node)){if(node.source){add(node.source)}else if(node.specifiers&&node.specifiers.length){var _arr4=node.specifiers;for(var _i4=0;_i4<_arr4.length;_i4++){var specifier=_arr4[_i4];add(specifier)}}else if(node.declaration){add(node.declaration)}}else if(t.isModuleSpecifier(node)){add(node.local)}else if(t.isMemberExpression(node)){add(node.object);add(node.property)}else if(t.isIdentifier(node)){parts.push(node.name)}else if(t.isLiteral(node)){parts.push(node.value)}else if(t.isCallExpression(node)){add(node.callee)}else if(t.isObjectExpression(node)||t.isObjectPattern(node)){var _arr5=node.properties;for(var _i5=0;_i5<_arr5.length;_i5++){var prop=_arr5[_i5];add(prop.key||prop.argument)}}};add(node);var id=parts.join("$");id=id.replace(/^_/,"")||defaultName||"ref";return this.generateUidIdentifier(id)};Scope.prototype.isStatic=function isStatic(node){if(t.isThisExpression(node)||t.isSuper(node)){return true}if(t.isIdentifier(node)){var binding=this.getBinding(node.name);if(binding){return binding.constant}else{return this.hasBinding(node.name)}}return false};Scope.prototype.maybeGenerateMemoised=function maybeGenerateMemoised(node,dontPush){if(this.isStatic(node)){return null}else{var id=this.generateUidIdentifierBasedOnNode(node);if(!dontPush)this.push({id:id});return id}};Scope.prototype.checkBlockScopedCollisions=function checkBlockScopedCollisions(local,kind,name,id){if(kind==="param")return;if(kind==="hoisted"&&local.kind==="let")return;var duplicate=false;if(!duplicate)duplicate=kind==="let"||local.kind==="let"||local.kind==="const"||local.kind==="module";if(!duplicate)duplicate=local.kind==="param"&&(kind==="let"||kind==="const");if(duplicate){throw this.hub.file.errorWithNode(id,messages.get("scopeDuplicateDeclaration",name),TypeError)}};Scope.prototype.rename=function rename(oldName,newName,block){newName=newName||this.generateUidIdentifier(oldName).name;var info=this.getBinding(oldName);if(!info)return;var state={newName:newName,oldName:oldName,binding:info.identifier,info:info};var scope=info.scope;scope.traverse(block||scope.block,renameVisitor,state);if(!block){scope.removeOwnBinding(oldName);scope.bindings[newName]=info;state.binding.name=newName}var file=this.hub.file;if(file){this._renameFromMap(file.moduleFormatter.localImports,oldName,newName,state.binding)}};Scope.prototype._renameFromMap=function _renameFromMap(map,oldName,newName,value){if(map[oldName]){map[newName]=value;map[oldName]=null}};Scope.prototype.dump=function dump(){var sep=_repeating2["default"]("-",60);console.log(sep);var scope=this;do{console.log("#",scope.block.type);for(var name in scope.bindings){var binding=scope.bindings[name];console.log(" -",name,{constant:binding.constant,references:binding.references,kind:binding.kind})}}while(scope=scope.parent);console.log(sep)};Scope.prototype.toArray=function toArray(node,i){var file=this.hub.file;if(t.isIdentifier(node)){var binding=this.getBinding(node.name);if(binding&&binding.constant&&binding.path.isGenericType("Array"))return node}if(t.isArrayExpression(node)){return node}if(t.isIdentifier(node,{name:"arguments"})){return t.callExpression(t.memberExpression(file.addHelper("slice"),t.identifier("call")),[node])}var helperName="to-array";var args=[node];if(i===true){helperName="to-consumable-array"}else if(i){args.push(t.literal(i));helperName="sliced-to-array";if(this.hub.file.isLoose("es6.forOf"))helperName+="-loose"}return t.callExpression(file.addHelper(helperName),args)};Scope.prototype.registerDeclaration=function registerDeclaration(path){if(path.isLabeledStatement()){this.registerBinding("label",path)}else if(path.isFunctionDeclaration()){this.registerBinding("hoisted",path)}else if(path.isVariableDeclaration()){var declarations=path.get("declarations");var _arr6=declarations;for(var _i6=0;_i6<_arr6.length;_i6++){var declar=_arr6[_i6];this.registerBinding(path.node.kind,declar)}}else if(path.isClassDeclaration()){this.registerBinding("let",path)}else if(path.isImportDeclaration()){var specifiers=path.get("specifiers");var _arr7=specifiers;for(var _i7=0;_i7<_arr7.length;_i7++){var specifier=_arr7[_i7];this.registerBinding("module",specifier)}}else if(path.isExportDeclaration()){var declar=path.get("declaration");if(declar.isClassDeclaration()||declar.isFunctionDeclaration()||declar.isVariableDeclaration()){this.registerDeclaration(declar)}}else{this.registerBinding("unknown",path)}};Scope.prototype.registerConstantViolation=function registerConstantViolation(root,left,right){var ids=left.getBindingIdentifiers();for(var name in ids){var binding=this.getBinding(name);if(binding)binding.reassign(root,left,right)}};Scope.prototype.registerBinding=function registerBinding(kind,path){if(!kind)throw new ReferenceError("no `kind`");if(path.isVariableDeclaration()){var declarators=path.get("declarations");var _arr8=declarators;for(var _i8=0;_i8<_arr8.length;_i8++){var declar=_arr8[_i8];this.registerBinding(kind,declar)}return}var parent=this.getProgramParent();var ids=path.getBindingIdentifiers(true);for(var name in ids){var _arr9=ids[name];for(var _i9=0;_i9<_arr9.length;_i9++){var id=_arr9[_i9];var local=this.getOwnBinding(name);if(local){if(local.identifier===id)continue;this.checkBlockScopedCollisions(local,kind,name,id)}parent.references[name]=true;this.bindings[name]=new _binding2["default"]({identifier:id,existing:local,scope:this,path:path,kind:kind})}}};Scope.prototype.addGlobal=function addGlobal(node){this.globals[node.name]=node};Scope.prototype.hasUid=function hasUid(name){var scope=this;do{if(scope.uids[name])return true}while(scope=scope.parent);return false};Scope.prototype.hasGlobal=function hasGlobal(name){var scope=this;do{if(scope.globals[name])return true}while(scope=scope.parent);return false};Scope.prototype.hasReference=function hasReference(name){var scope=this;do{if(scope.references[name])return true}while(scope=scope.parent);return false};Scope.prototype.isPure=function isPure(node,constantsOnly){if(t.isIdentifier(node)){var binding=this.getBinding(node.name);if(!binding)return false;if(constantsOnly)return binding.constant;return true}else if(t.isClass(node)){return!node.superClass||this.isPure(node.superClass,constantsOnly)}else if(t.isBinary(node)){return this.isPure(node.left,constantsOnly)&&this.isPure(node.right,constantsOnly)}else if(t.isArrayExpression(node)){var _arr10=node.elements;for(var _i10=0;_i10<_arr10.length;_i10++){var elem=_arr10[_i10];if(!this.isPure(elem,constantsOnly))return false}return true}else if(t.isObjectExpression(node)){var _arr11=node.properties;for(var _i11=0;_i11<_arr11.length;_i11++){var prop=_arr11[_i11];if(!this.isPure(prop,constantsOnly))return false}return true}else if(t.isProperty(node)){if(node.computed&&!this.isPure(node.key,constantsOnly))return false;return this.isPure(node.value,constantsOnly)}else{return t.isPure(node)}};Scope.prototype.setData=function setData(key,val){return this.data[key]=val};Scope.prototype.getData=function getData(key){var scope=this;do{var data=scope.data[key];if(data!=null)return data}while(scope=scope.parent)};Scope.prototype.removeData=function removeData(key){var scope=this;do{var data=scope.data[key];if(data!=null)scope.data[key]=null}while(scope=scope.parent)};Scope.prototype.init=function init(){if(!this.references)this.crawl()};Scope.prototype.crawl=function crawl(){var path=this.path;var info=this.block._scopeInfo;if(info)return _lodashObjectExtend2["default"](this,info);info=this.block._scopeInfo={references:_helpersObject2["default"](),bindings:_helpersObject2["default"](),globals:_helpersObject2["default"](),uids:_helpersObject2["default"](),data:_helpersObject2["default"]()};_lodashObjectExtend2["default"](this,info);if(path.isLoop()){var _arr12=t.FOR_INIT_KEYS;for(var _i12=0;_i12<_arr12.length;_i12++){var key=_arr12[_i12];var node=path.get(key);if(node.isBlockScoped())this.registerBinding(node.node.kind,node)}}if(path.isFunctionExpression()&&path.has("id")){if(!t.isProperty(path.parent,{method:true})){this.registerBinding("var",path)}}if(path.isClassExpression()&&path.has("id")){this.registerBinding("var",path)}if(path.isFunction()){var params=path.get("params");var _arr13=params;for(var _i13=0;_i13<_arr13.length;_i13++){var param=_arr13[_i13];this.registerBinding("param",param)}}if(path.isCatchClause()){this.registerBinding("let",path)}if(path.isComprehensionExpression()){this.registerBinding("let",path)}var parent=this.getProgramParent();if(parent.crawling)return;this.crawling=true;path.traverse(collectorVisitor);this.crawling=false};Scope.prototype.push=function push(opts){var path=this.path;if(path.isSwitchStatement()){path=this.getFunctionParent().path}if(path.isLoop()||path.isCatchClause()||path.isFunction()){t.ensureBlock(path.node);path=path.get("body")}if(!path.isBlockStatement()&&!path.isProgram()){path=this.getBlockParent().path}var unique=opts.unique;var kind=opts.kind||"var";var blockHoist=opts._blockHoist==null?2:opts._blockHoist;var dataKey="declaration:"+kind+":"+blockHoist;var declarPath=!unique&&path.getData(dataKey);if(!declarPath){var declar=t.variableDeclaration(kind,[]);declar._generated=true;declar._blockHoist=blockHoist;this.hub.file.attachAuxiliaryComment(declar);var _path$unshiftContainer=path.unshiftContainer("body",[declar]);declarPath=_path$unshiftContainer[0];if(!unique)path.setData(dataKey,declarPath)}var declarator=t.variableDeclarator(opts.id,opts.init);declarPath.node.declarations.push(declarator);this.registerBinding(kind,declarPath.get("declarations").pop())};Scope.prototype.getProgramParent=function getProgramParent(){var scope=this;do{if(scope.path.isProgram()){return scope}}while(scope=scope.parent);throw new Error("We couldn't find a Function or Program...")};Scope.prototype.getFunctionParent=function getFunctionParent(){var scope=this;do{if(scope.path.isFunctionParent()){return scope}}while(scope=scope.parent);throw new Error("We couldn't find a Function or Program...")};Scope.prototype.getBlockParent=function getBlockParent(){var scope=this;do{if(scope.path.isBlockParent()){return scope}}while(scope=scope.parent);throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...")};Scope.prototype.getAllBindings=function getAllBindings(){var ids=_helpersObject2["default"]();var scope=this;do{_lodashObjectDefaults2["default"](ids,scope.bindings);scope=scope.parent}while(scope);return ids};Scope.prototype.getAllBindingsOfKind=function getAllBindingsOfKind(){var ids=_helpersObject2["default"]();var _arr14=arguments;for(var _i14=0;_i14<_arr14.length;_i14++){var kind=_arr14[_i14];var scope=this;do{for(var name in scope.bindings){var binding=scope.bindings[name];if(binding.kind===kind)ids[name]=binding}scope=scope.parent}while(scope)}return ids};Scope.prototype.bindingIdentifierEquals=function bindingIdentifierEquals(name,node){return this.getBindingIdentifier(name)===node};Scope.prototype.getBinding=function getBinding(name){var scope=this;do{var binding=scope.getOwnBinding(name);if(binding)return binding}while(scope=scope.parent)};Scope.prototype.getOwnBinding=function getOwnBinding(name){return this.bindings[name]};Scope.prototype.getBindingIdentifier=function getBindingIdentifier(name){var info=this.getBinding(name);return info&&info.identifier};Scope.prototype.getOwnBindingIdentifier=function getOwnBindingIdentifier(name){var binding=this.bindings[name];return binding&&binding.identifier};Scope.prototype.hasOwnBinding=function hasOwnBinding(name){return!!this.getOwnBinding(name)};Scope.prototype.hasBinding=function hasBinding(name,noGlobals){if(!name)return false;if(this.hasOwnBinding(name))return true;if(this.parentHasBinding(name,noGlobals))return true;if(this.hasUid(name))return true;if(!noGlobals&&_lodashCollectionIncludes2["default"](Scope.globals,name))return true;if(!noGlobals&&_lodashCollectionIncludes2["default"](Scope.contextVariables,name))return true;return false};Scope.prototype.parentHasBinding=function parentHasBinding(name,noGlobals){return this.parent&&this.parent.hasBinding(name,noGlobals)};Scope.prototype.moveBindingTo=function moveBindingTo(name,scope){var info=this.getBinding(name);if(info){info.scope.removeOwnBinding(name);info.scope=scope;scope.bindings[name]=info}};Scope.prototype.removeOwnBinding=function removeOwnBinding(name){delete this.bindings[name]};Scope.prototype.removeBinding=function removeBinding(name){var info=this.getBinding(name);if(info){info.scope.removeOwnBinding(name)}var scope=this;do{if(scope.uids[name]){scope.uids[name]=false}}while(scope=scope.parent)};_createClass(Scope,null,[{key:"globals",value:_lodashArrayFlatten2["default"]([_globals2["default"].builtin,_globals2["default"].browser,_globals2["default"].node].map(Object.keys)),enumerable:true},{key:"contextVariables",value:["arguments","undefined","Infinity","NaN"],enumerable:true}]);return Scope}();exports["default"]=Scope;module.exports=exports["default"]},{"../../helpers/object":58,"../../messages":60,"../../types":196,"../index":165,"./binding":183,globals:415,"lodash/array/flatten":432,"lodash/collection/includes":439,"lodash/object/defaults":536,"lodash/object/extend":537,repeating:611}],185:[function(require,module,exports){"use strict";exports.__esModule=true;exports.explode=explode;exports.verify=verify;exports.merge=merge;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _pathLibVirtualTypes=require("./path/lib/virtual-types");var virtualTypes=_interopRequireWildcard(_pathLibVirtualTypes);var _messages=require("../messages");var messages=_interopRequireWildcard(_messages);var _types=require("../types");var t=_interopRequireWildcard(_types);var _lodashLangClone=require("lodash/lang/clone");var _lodashLangClone2=_interopRequireDefault(_lodashLangClone);function explode(visitor){if(visitor._exploded)return visitor;visitor._exploded=true;for(var nodeType in visitor){if(shouldIgnoreKey(nodeType))continue;var parts=nodeType.split("|");if(parts.length===1)continue;var fns=visitor[nodeType];delete visitor[nodeType];var _arr=parts;for(var _i=0;_i<_arr.length;_i++){var part=_arr[_i];visitor[part]=fns}}verify(visitor);delete visitor.__esModule;ensureEntranceObjects(visitor);ensureCallbackArrays(visitor);var _arr2=Object.keys(visitor);for(var _i2=0;_i2<_arr2.length;_i2++){var nodeType=_arr2[_i2];if(shouldIgnoreKey(nodeType))continue;var wrapper=virtualTypes[nodeType];if(!wrapper)continue;var fns=visitor[nodeType];for(var type in fns){fns[type]=wrapCheck(wrapper,fns[type])}delete visitor[nodeType];if(wrapper.types){var _arr4=wrapper.types;for(var _i4=0;_i4<_arr4.length;_i4++){var type=_arr4[_i4];if(visitor[type]){mergePair(visitor[type],fns)}else{visitor[type]=fns}}}else{mergePair(visitor,fns)}}for(var nodeType in visitor){if(shouldIgnoreKey(nodeType))continue;var fns=visitor[nodeType];var aliases=t.FLIPPED_ALIAS_KEYS[nodeType];if(!aliases)continue;delete visitor[nodeType];var _arr3=aliases;for(var _i3=0;_i3<_arr3.length;_i3++){var alias=_arr3[_i3];var existing=visitor[alias];if(existing){mergePair(existing,fns)}else{visitor[alias]=_lodashLangClone2["default"](fns)}}}for(var nodeType in visitor){if(shouldIgnoreKey(nodeType))continue;ensureCallbackArrays(visitor[nodeType])}return visitor}function verify(visitor){if(visitor._verified)return;if(typeof visitor==="function"){throw new Error(messages.get("traverseVerifyRootFunction"))}for(var nodeType in visitor){if(shouldIgnoreKey(nodeType))continue;if(t.TYPES.indexOf(nodeType)<0){throw new Error(messages.get("traverseVerifyNodeType",nodeType))}var visitors=visitor[nodeType];if(typeof visitors==="object"){for(var visitorKey in visitors){if(visitorKey==="enter"||visitorKey==="exit")continue;throw new Error(messages.get("traverseVerifyVisitorProperty",nodeType,visitorKey))}}}visitor._verified=true}function merge(visitors){var rootVisitor={};var _arr5=visitors;for(var _i5=0;_i5<_arr5.length;_i5++){var visitor=_arr5[_i5];explode(visitor);for(var type in visitor){var nodeVisitor=rootVisitor[type]=rootVisitor[type]||{};mergePair(nodeVisitor,visitor[type])}}return rootVisitor}function ensureEntranceObjects(obj){for(var key in obj){if(shouldIgnoreKey(key))continue;var fns=obj[key];if(typeof fns==="function"){obj[key]={enter:fns}}}}function ensureCallbackArrays(obj){if(obj.enter&&!Array.isArray(obj.enter))obj.enter=[obj.enter];if(obj.exit&&!Array.isArray(obj.exit))obj.exit=[obj.exit]}function wrapCheck(wrapper,fn){return function(){if(wrapper.checkPath(this)){return fn.apply(this,arguments)}}}function shouldIgnoreKey(key){if(key[0]==="_")return true;if(key==="enter"||key==="exit"||key==="shouldSkip")return true;if(key==="blacklist"||key==="noScope"||key==="skipKeys")return true;return false}function mergePair(dest,src){for(var key in src){dest[key]=[].concat(dest[key]||[],src[key])}}},{"../messages":60,"../types":196,"./path/lib/virtual-types":179,"lodash/lang/clone":520}],186:[function(require,module,exports){"use strict";exports.__esModule=true;exports.toComputedKey=toComputedKey;exports.toSequenceExpression=toSequenceExpression;exports.toKeyAlias=toKeyAlias;exports.toIdentifier=toIdentifier;exports.toBindingIdentifierName=toBindingIdentifierName;exports.toStatement=toStatement;exports.toExpression=toExpression;exports.toBlock=toBlock;exports.valueToNode=valueToNode;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashLangIsPlainObject=require("lodash/lang/isPlainObject");var _lodashLangIsPlainObject2=_interopRequireDefault(_lodashLangIsPlainObject);var _lodashLangIsNumber=require("lodash/lang/isNumber");var _lodashLangIsNumber2=_interopRequireDefault(_lodashLangIsNumber);var _lodashLangIsRegExp=require("lodash/lang/isRegExp");var _lodashLangIsRegExp2=_interopRequireDefault(_lodashLangIsRegExp);var _lodashLangIsString=require("lodash/lang/isString");var _lodashLangIsString2=_interopRequireDefault(_lodashLangIsString);var _traversal=require("../traversal");var _traversal2=_interopRequireDefault(_traversal);var _index=require("./index");var t=_interopRequireWildcard(_index);function toComputedKey(node){var key=arguments.length<=1||arguments[1]===undefined?node.key||node.property:arguments[1];return function(){if(!node.computed){if(t.isIdentifier(key))key=t.literal(key.name)}return key}()}function toSequenceExpression(nodes,scope){var declars=[];var bailed=false;var result=convert(nodes);if(bailed)return;for(var i=0;i=0){continue}if(t.isAnyTypeAnnotation(node)){return[node]}if(t.isFlowBaseAnnotation(node)){bases[node.type]=node;continue}if(t.isUnionTypeAnnotation(node)){if(typeGroups.indexOf(node.types)<0){nodes=nodes.concat(node.types);typeGroups.push(node.types)}continue}if(t.isGenericTypeAnnotation(node)){var _name=node.id.name;if(generics[_name]){var existing=generics[_name];if(existing.typeParameters){if(node.typeParameters){existing.typeParameters.params=removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params))}}else{existing=node.typeParameters}}else{generics[_name]=node}continue}types.push(node)}for(var type in bases){types.push(bases[type])}for(var _name2 in generics){types.push(generics[_name2])}return types}function createTypeAnnotationBasedOnTypeof(type){if(type==="string"){return t.stringTypeAnnotation()}else if(type==="number"){return t.numberTypeAnnotation()}else if(type==="undefined"){return t.voidTypeAnnotation()}else if(type==="boolean"){return t.booleanTypeAnnotation()}else if(type==="function"){return t.genericTypeAnnotation(t.identifier("Function"))}else if(type==="object"){return t.genericTypeAnnotation(t.identifier("Object"))}else if(type==="symbol"){return t.genericTypeAnnotation(t.identifier("Symbol"))}else{throw new Error("Invalid typeof value")}}},{"./index":196}],196:[function(require,module,exports){"use strict";exports.__esModule=true;exports.is=is;exports.isType=isType;exports.shallowEqual=shallowEqual;exports.appendToMemberExpression=appendToMemberExpression;exports.prependToMemberExpression=prependToMemberExpression;exports.ensureBlock=ensureBlock;exports.clone=clone;exports.cloneDeep=cloneDeep;exports.buildMatchMemberExpression=buildMatchMemberExpression;exports.removeComments=removeComments;exports.inheritsComments=inheritsComments;exports.inheritTrailingComments=inheritTrailingComments;exports.inheritLeadingComments=inheritLeadingComments;exports.inheritInnerComments=inheritInnerComments;exports.inherits=inherits;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _toFastProperties=require("to-fast-properties");var _toFastProperties2=_interopRequireDefault(_toFastProperties);var _lodashArrayCompact=require("lodash/array/compact");var _lodashArrayCompact2=_interopRequireDefault(_lodashArrayCompact);var _lodashObjectAssign=require("lodash/object/assign");var _lodashObjectAssign2=_interopRequireDefault(_lodashObjectAssign);var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _lodashArrayUniq=require("lodash/array/uniq");var _lodashArrayUniq2=_interopRequireDefault(_lodashArrayUniq);require("./definitions/init");var _definitions=require("./definitions");var t=exports;function registerType(type,skipAliasCheck){var is=t["is"+type]=function(node,opts){return t.is(type,node,opts,skipAliasCheck)};t["assert"+type]=function(node,opts){opts=opts||{};if(!is(node,opts)){throw new Error("Expected type "+JSON.stringify(type)+" with option "+JSON.stringify(opts))}}}var STATEMENT_OR_BLOCK_KEYS=["consequent","body","alternate"];exports.STATEMENT_OR_BLOCK_KEYS=STATEMENT_OR_BLOCK_KEYS;var FLATTENABLE_KEYS=["body","expressions"];exports.FLATTENABLE_KEYS=FLATTENABLE_KEYS;var FOR_INIT_KEYS=["left","init"];exports.FOR_INIT_KEYS=FOR_INIT_KEYS;var COMMENT_KEYS=["leadingComments","trailingComments","innerComments"];exports.COMMENT_KEYS=COMMENT_KEYS;var INHERIT_KEYS={optional:["typeAnnotation","typeParameters","returnType"],force:["_scopeInfo","_paths","start","loc","end"]};exports.INHERIT_KEYS=INHERIT_KEYS;var BOOLEAN_NUMBER_BINARY_OPERATORS=[">","<",">=","<="];exports.BOOLEAN_NUMBER_BINARY_OPERATORS=BOOLEAN_NUMBER_BINARY_OPERATORS;var EQUALITY_BINARY_OPERATORS=["==","===","!=","!=="];exports.EQUALITY_BINARY_OPERATORS=EQUALITY_BINARY_OPERATORS;var COMPARISON_BINARY_OPERATORS=EQUALITY_BINARY_OPERATORS.concat(["in","instanceof"]);exports.COMPARISON_BINARY_OPERATORS=COMPARISON_BINARY_OPERATORS;var BOOLEAN_BINARY_OPERATORS=[].concat(COMPARISON_BINARY_OPERATORS,BOOLEAN_NUMBER_BINARY_OPERATORS);exports.BOOLEAN_BINARY_OPERATORS=BOOLEAN_BINARY_OPERATORS;var NUMBER_BINARY_OPERATORS=["-","/","*","**","&","|",">>",">>>","<<","^"];exports.NUMBER_BINARY_OPERATORS=NUMBER_BINARY_OPERATORS;var BOOLEAN_UNARY_OPERATORS=["delete","!"];exports.BOOLEAN_UNARY_OPERATORS=BOOLEAN_UNARY_OPERATORS;var NUMBER_UNARY_OPERATORS=["+","-","++","--","~"];exports.NUMBER_UNARY_OPERATORS=NUMBER_UNARY_OPERATORS;var STRING_UNARY_OPERATORS=["typeof"];exports.STRING_UNARY_OPERATORS=STRING_UNARY_OPERATORS;exports.VISITOR_KEYS=_definitions.VISITOR_KEYS;exports.BUILDER_KEYS=_definitions.BUILDER_KEYS;exports.ALIAS_KEYS=_definitions.ALIAS_KEYS;_lodashCollectionEach2["default"](t.VISITOR_KEYS,function(keys,type){registerType(type,true)});t.FLIPPED_ALIAS_KEYS={};_lodashCollectionEach2["default"](t.ALIAS_KEYS,function(aliases,type){_lodashCollectionEach2["default"](aliases,function(alias){var types=t.FLIPPED_ALIAS_KEYS[alias]=t.FLIPPED_ALIAS_KEYS[alias]||[];types.push(type)})});_lodashCollectionEach2["default"](t.FLIPPED_ALIAS_KEYS,function(types,type){t[type.toUpperCase()+"_TYPES"]=types;registerType(type,false)});var TYPES=Object.keys(t.VISITOR_KEYS).concat(Object.keys(t.FLIPPED_ALIAS_KEYS));exports.TYPES=TYPES;function is(type,node,opts,skipAliasCheck){if(!node)return false;var matches=isType(node.type,type);if(!matches)return false;if(typeof opts==="undefined"){return true}else{return t.shallowEqual(node,opts)}}function isType(nodeType,targetType){if(nodeType===targetType)return true;var aliases=t.FLIPPED_ALIAS_KEYS[targetType];if(aliases){if(aliases[0]===nodeType)return true;var _arr=aliases;for(var _i=0;_i<_arr.length;_i++){var alias=_arr[_i];if(nodeType===alias)return true}}return false}_lodashCollectionEach2["default"](t.VISITOR_KEYS,function(keys,type){if(t.BUILDER_KEYS[type])return;var defs={};_lodashCollectionEach2["default"](keys,function(key){defs[key]=null});t.BUILDER_KEYS[type]=defs});_lodashCollectionEach2["default"](t.BUILDER_KEYS,function(keys,type){var builder=function builder(){var node={};node.type=type;var i=0;for(var key in keys){var arg=arguments[i++];if(arg===undefined)arg=keys[key];node[key]=arg}return node};t[type]=builder;t[type[0].toLowerCase()+type.slice(1)]=builder});function shallowEqual(actual,expected){var keys=Object.keys(expected);var _arr2=keys;for(var _i2=0;_i2<_arr2.length;_i2++){var key=_arr2[_i2];if(actual[key]!==expected[key]){return false}}return true}function appendToMemberExpression(member,append,computed){member.object=t.memberExpression(member.object,member.property,member.computed);member.property=append;member.computed=!!computed;return member}function prependToMemberExpression(member,prepend){member.object=t.memberExpression(prepend,member.object);return member}function ensureBlock(node){var key=arguments.length<=1||arguments[1]===undefined?"body":arguments[1];return node[key]=t.toBlock(node[key],node)}function clone(node){var newNode={};for(var key in node){if(key[0]==="_")continue;newNode[key]=node[key]}return newNode}function cloneDeep(node){var newNode={};for(var key in node){if(key[0]==="_")continue;var val=node[key];if(val){if(val.type){val=t.cloneDeep(val)}else if(Array.isArray(val)){val=val.map(t.cloneDeep)}}newNode[key]=val}return newNode}function buildMatchMemberExpression(match,allowPartial){var parts=match.split(".");return function(member){if(!t.isMemberExpression(member))return false;var search=[member];var i=0;while(search.length){var node=search.shift();if(allowPartial&&i===parts.length){return true}if(t.isIdentifier(node)){if(parts[i]!==node.name)return false}else if(t.isLiteral(node)){if(parts[i]!==node.value)return false}else if(t.isMemberExpression(node)){if(node.computed&&!t.isLiteral(node.property)){return false}else{search.push(node.object);search.push(node.property);continue}}else{return false}if(++i>parts.length){return false}}return true}}function removeComments(node){var _arr3=COMMENT_KEYS;for(var _i3=0;_i3<_arr3.length;_i3++){var key=_arr3[_i3];delete node[key]}return node}function inheritsComments(child,parent){inheritTrailingComments(child,parent);inheritLeadingComments(child,parent);inheritInnerComments(child,parent);return child}function inheritTrailingComments(child,parent){_inheritComments("trailingComments",child,parent)}function inheritLeadingComments(child,parent){_inheritComments("leadingComments",child,parent)}function inheritInnerComments(child,parent){_inheritComments("innerComments",child,parent)}function _inheritComments(key,child,parent){if(child&&parent){child[key]=_lodashArrayUniq2["default"](_lodashArrayCompact2["default"]([].concat(child[key],parent[key])))}}function inherits(child,parent){if(!child||!parent)return child;var _arr4=t.INHERIT_KEYS.optional;for(var _i4=0;_i4<_arr4.length;_i4++){var key=_arr4[_i4];if(child[key]==null){child[key]=parent[key]}}var _arr5=t.INHERIT_KEYS.force;for(var _i5=0;_i5<_arr5.length;_i5++){var key=_arr5[_i5];child[key]=parent[key]}t.inheritsComments(child,parent);return child}_toFastProperties2["default"](t);_toFastProperties2["default"](t.VISITOR_KEYS);_lodashObjectAssign2["default"](t,require("./retrievers"));_lodashObjectAssign2["default"](t,require("./validators"));_lodashObjectAssign2["default"](t,require("./converters"));_lodashObjectAssign2["default"](t,require("./flow"))},{"./converters":186,"./definitions":191,"./definitions/init":192,"./flow":195,"./retrievers":197,"./validators":198,"lodash/array/compact":431,"lodash/array/uniq":435,"lodash/collection/each":437,"lodash/object/assign":535,"to-fast-properties":628}],197:[function(require,module,exports){"use strict";exports.__esModule=true;exports.getBindingIdentifiers=getBindingIdentifiers;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _helpersObject=require("../helpers/object");var _helpersObject2=_interopRequireDefault(_helpersObject);var _index=require("./index");var t=_interopRequireWildcard(_index);function getBindingIdentifiers(node,duplicates){var search=[].concat(node);var ids=_helpersObject2["default"]();while(search.length){var id=search.shift();if(!id)continue;var key=t.getBindingIdentifiers.keys[id.type];if(t.isIdentifier(id)){if(duplicates){var _ids=ids[id.name]=ids[id.name]||[];_ids.push(id)}else{ids[id.name]=id}}else if(t.isExportDeclaration(id)){if(t.isDeclaration(node.declaration)){search.push(node.declaration)}}else if(key&&id[key]){search=search.concat(id[key])}}return ids}getBindingIdentifiers.keys={DeclareClass:"id",DeclareFunction:"id",DeclareModule:"id",DeclareVariable:"id",InterfaceDeclaration:"id",TypeAlias:"id",ComprehensionExpression:"blocks",ComprehensionBlock:"left",CatchClause:"param",LabeledStatement:"label",UnaryExpression:"argument",AssignmentExpression:"left",ImportSpecifier:"local",ImportNamespaceSpecifier:"local",ImportDefaultSpecifier:"local",ImportDeclaration:"specifiers",FunctionDeclaration:"id",FunctionExpression:"id",ClassDeclaration:"id",ClassExpression:"id",RestElement:"argument",UpdateExpression:"argument",SpreadProperty:"argument",Property:"value",AssignmentPattern:"left",ArrayPattern:"elements",ObjectPattern:"properties",VariableDeclaration:"declarations",VariableDeclarator:"id"}},{"../helpers/object":58,"./index":196}],198:[function(require,module,exports){"use strict";exports.__esModule=true;exports.isBinding=isBinding;exports.isReferenced=isReferenced;exports.isValidIdentifier=isValidIdentifier;exports.isLet=isLet;exports.isBlockScoped=isBlockScoped;exports.isVar=isVar;exports.isSpecifierDefault=isSpecifierDefault;exports.isScope=isScope;exports.isImmutable=isImmutable;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _retrievers=require("./retrievers");var _esutils=require("esutils");var _esutils2=_interopRequireDefault(_esutils);var _index=require("./index");var t=_interopRequireWildcard(_index);function isBinding(node,parent){var bindingKey=_retrievers.getBindingIdentifiers.keys[parent.type];if(bindingKey){return parent[bindingKey]===node}else{return false}}function isReferenced(node,parent){switch(parent.type){case"MemberExpression":case"JSXMemberExpression":if(parent.property===node&&parent.computed){return true}else if(parent.object===node){return true}else{return false}case"MetaProperty":return false;case"Property":if(parent.key===node){return parent.computed}case"VariableDeclarator":return parent.id!==node;case"ArrowFunctionExpression":case"FunctionDeclaration":case"FunctionExpression":var _arr=parent.params;for(var _i=0;_i<_arr.length;_i++){var param=_arr[_i];if(param===node)return false}return parent.id!==node;case"ExportSpecifier":if(parent.source){return false}else{return parent.local===node}case"JSXAttribute":return parent.name!==node;case"ClassProperty":return parent.value===node;case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":case"ImportSpecifier":return false;case"ClassDeclaration":case"ClassExpression":return parent.id!==node;case"MethodDefinition":return parent.key===node&&parent.computed;case"LabeledStatement":return false;case"CatchClause":return parent.param!==node;case"RestElement":return false;case"AssignmentExpression":return parent.right===node;case"AssignmentPattern":return false;case"ObjectPattern":case"ArrayPattern":return false}return true}function isValidIdentifier(name){if(typeof name!=="string"||_esutils2["default"].keyword.isReservedWordES6(name,true)){return false}else{return _esutils2["default"].keyword.isIdentifierNameES6(name)}}function isLet(node){return t.isVariableDeclaration(node)&&(node.kind!=="var"||node._let)}function isBlockScoped(node){return t.isFunctionDeclaration(node)||t.isClassDeclaration(node)||t.isLet(node)}function isVar(node){return t.isVariableDeclaration(node,{kind:"var"})&&!node._let}function isSpecifierDefault(specifier){return t.isImportDefaultSpecifier(specifier)||t.isIdentifier(specifier.imported||specifier.exported,{name:"default"})}function isScope(node,parent){if(t.isBlockStatement(node)&&t.isFunction(parent,{body:node})){return false}return t.isScopable(node)}function isImmutable(node){if(t.isType(node.type,"Immutable"))return true;if(t.isLiteral(node)){if(node.regex){return false}else{return true}}else if(t.isIdentifier(node)){if(node.name==="undefined"){return true}else{return false}}return false}},{"./index":196,"./retrievers":197,esutils:413}],199:[function(require,module,exports){(function(__dirname){"use strict";exports.__esModule=true;exports.canCompile=canCompile;exports.list=list;exports.regexify=regexify;exports.arrayify=arrayify;exports.booleanify=booleanify;exports.shouldIgnore=shouldIgnore;exports.template=template;exports.parseTemplate=parseTemplate;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashStringEscapeRegExp=require("lodash/string/escapeRegExp");var _lodashStringEscapeRegExp2=_interopRequireDefault(_lodashStringEscapeRegExp);var _lodashStringStartsWith=require("lodash/string/startsWith");var _lodashStringStartsWith2=_interopRequireDefault(_lodashStringStartsWith);var _lodashLangCloneDeep=require("lodash/lang/cloneDeep");var _lodashLangCloneDeep2=_interopRequireDefault(_lodashLangCloneDeep);var _lodashLangIsBoolean=require("lodash/lang/isBoolean");var _lodashLangIsBoolean2=_interopRequireDefault(_lodashLangIsBoolean);var _messages=require("./messages");var messages=_interopRequireWildcard(_messages);var _minimatch=require("minimatch");var _minimatch2=_interopRequireDefault(_minimatch);var _lodashCollectionContains=require("lodash/collection/contains");var _lodashCollectionContains2=_interopRequireDefault(_lodashCollectionContains);var _traversal=require("./traversal");var _traversal2=_interopRequireDefault(_traversal);var _lodashLangIsString=require("lodash/lang/isString");var _lodashLangIsString2=_interopRequireDefault(_lodashLangIsString);var _lodashLangIsRegExp=require("lodash/lang/isRegExp");var _lodashLangIsRegExp2=_interopRequireDefault(_lodashLangIsRegExp);var _lodashLangIsEmpty=require("lodash/lang/isEmpty");var _lodashLangIsEmpty2=_interopRequireDefault(_lodashLangIsEmpty);var _helpersParse=require("./helpers/parse");var _helpersParse2=_interopRequireDefault(_helpersParse);var _path=require("path");var _path2=_interopRequireDefault(_path);var _lodashObjectHas=require("lodash/object/has");var _lodashObjectHas2=_interopRequireDefault(_lodashObjectHas);var _fs=require("fs");var _fs2=_interopRequireDefault(_fs);var _types=require("./types");var t=_interopRequireWildcard(_types);var _slash=require("slash");var _slash2=_interopRequireDefault(_slash);var _pathExists=require("path-exists");var _pathExists2=_interopRequireDefault(_pathExists);var _util=require("util");exports.inherits=_util.inherits;exports.inspect=_util.inspect;function canCompile(filename,altExts){var exts=altExts||canCompile.EXTENSIONS;var ext=_path2["default"].extname(filename);return _lodashCollectionContains2["default"](exts,ext)}canCompile.EXTENSIONS=[".js",".jsx",".es6",".es"];function list(val){if(!val){return[]}else if(Array.isArray(val)){return val}else if(typeof val==="string"){return val.split(",")}else{return[val]}}function regexify(val){if(!val)return new RegExp(/.^/);if(Array.isArray(val))val=new RegExp(val.map(_lodashStringEscapeRegExp2["default"]).join("|"),"i");if(_lodashLangIsString2["default"](val)){val=_slash2["default"](val);if(_lodashStringStartsWith2["default"](val,"./")||_lodashStringStartsWith2["default"](val,"*/"))val=val.slice(2);if(_lodashStringStartsWith2["default"](val,"**/"))val=val.slice(3);var regex=_minimatch2["default"].makeRe(val,{nocase:true});return new RegExp(regex.source.slice(1,-1),"i")}if(_lodashLangIsRegExp2["default"](val))return val;throw new TypeError("illegal type for regexify")}function arrayify(val,mapFn){if(!val)return[];if(_lodashLangIsBoolean2["default"](val))return arrayify([val],mapFn);if(_lodashLangIsString2["default"](val))return arrayify(list(val),mapFn);if(Array.isArray(val)){if(mapFn)val=val.map(mapFn);return val}return[val]}function booleanify(val){if(val==="true")return true;if(val==="false")return false;return val}function shouldIgnore(filename,ignore,only){filename=_slash2["default"](filename);if(only){var _arr=only;for(var _i=0;_i<_arr.length;_i++){var pattern=_arr[_i];if(_shouldIgnore(pattern,filename))return false}return true}else if(ignore.length){var _arr2=ignore;for(var _i2=0;_i2<_arr2.length;_i2++){var pattern=_arr2[_i2];if(_shouldIgnore(pattern,filename))return true}}return false}function _shouldIgnore(pattern,filename){if(typeof pattern==="function"){return pattern(filename)}else{return pattern.test(filename)}}var templateVisitor={noScope:true,enter:function enter(node,parent,scope,nodes){if(t.isExpressionStatement(node)){node=node.expression}if(t.isIdentifier(node)&&_lodashObjectHas2["default"](nodes,node.name)){this.skip();this.replaceInline(nodes[node.name])}},exit:function exit(node){_traversal2["default"].clearNode(node)}};function template(name,nodes,keepExpression){var ast=exports.templates[name];if(!ast)throw new ReferenceError("unknown template "+name);if(nodes===true){keepExpression=true;nodes=null}ast=_lodashLangCloneDeep2["default"](ast);if(!_lodashLangIsEmpty2["default"](nodes)){_traversal2["default"](ast,templateVisitor,null,nodes)}if(ast.body.length>1)return ast.body;var node=ast.body[0];if(!keepExpression&&t.isExpressionStatement(node)){return node.expression}else{return node}}function parseTemplate(loc,code){var ast=_helpersParse2["default"](code,{filename:loc,looseModules:true}).program;ast=_traversal2["default"].removeProperties(ast);return ast}function loadTemplates(){var templates={};var templatesLoc=_path2["default"].join(__dirname,"transformation/templates");if(!_pathExists2["default"].sync(templatesLoc)){throw new ReferenceError(messages.get("missingTemplatesDirectory"))}var _arr3=_fs2["default"].readdirSync(templatesLoc);for(var _i3=0;_i3<_arr3.length;_i3++){var name=_arr3[_i3];if(name[0]===".")return;var key=_path2["default"].basename(name,_path2["default"].extname(name));var loc=_path2["default"].join(templatesLoc,name);var code=_fs2["default"].readFileSync(loc,"utf8");templates[key]=parseTemplate(loc,code)}return templates}try{exports.templates=require("../templates.json")}catch(err){if(err.code!=="MODULE_NOT_FOUND")throw err;exports.templates=loadTemplates()}}).call(this,"/lib")},{"../templates.json":632,"./helpers/parse":59,"./messages":60,"./traversal":165,"./types":196,fs:1,"lodash/collection/contains":436,"lodash/lang/cloneDeep":521,"lodash/lang/isBoolean":524,"lodash/lang/isEmpty":525,"lodash/lang/isRegExp":531,"lodash/lang/isString":532,"lodash/object/has":538,"lodash/string/escapeRegExp":544,"lodash/string/startsWith":545,minimatch:548,path:11,"path-exists":552,slash:615,util:30}],200:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=function(_ref){var Plugin=_ref.Plugin;var t=_ref.types;return new Plugin("constant-folding",{metadata:{group:"builtin-prepass",experimental:true},visitor:{AssignmentExpression:function AssignmentExpression(){var left=this.get("left");if(!left.isIdentifier())return;var binding=this.scope.getBinding(left.node.name);if(!binding||binding.hasDeoptValue)return;var evaluated=this.get("right").evaluate();if(evaluated.confident){binding.setValue(evaluated.value)}else{binding.deoptValue()}},IfStatement:function IfStatement(){var evaluated=this.get("test").evaluate();if(!evaluated.confident){return this.skip()}if(evaluated.value){this.skipKey("alternate")}else{this.skipKey("consequent")}},Scopable:{enter:function enter(){var funcScope=this.scope.getFunctionParent();for(var name in this.scope.bindings){var binding=this.scope.bindings[name];var deopt=false;var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=binding.constantViolations[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var path=_step.value;var funcViolationScope=path.scope.getFunctionParent();if(funcViolationScope!==funcScope){deopt=true;break}}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}if(deopt)binding.deoptValue()}},exit:function exit(){for(var name in this.scope.bindings){var binding=this.scope.bindings[name];binding.clearValue()}}},Expression:{exit:function exit(){var res=this.evaluate();if(res.confident)return t.valueToNode(res.value)}}}})};module.exports=exports["default"]},{}],201:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=function(_ref){var Plugin=_ref.Plugin;var t=_ref.types;function toStatements(node){ +if(t.isBlockStatement(node)){var hasBlockScoped=false;for(var i=0;i1||!binding.constant)return;if(binding.kind==="param"||binding.kind==="module")return;var replacement=binding.path.node;if(t.isVariableDeclarator(replacement)){replacement=replacement.init}if(!replacement)return;if(!scope.isPure(replacement,true))return;if(t.isClass(replacement)||t.isFunction(replacement)){if(binding.path.scope.parent!==scope)return}if(this.findParent(function(path){return path.node===replacement})){return}t.toExpression(replacement);scope.removeBinding(node.name);binding.path.dangerouslyRemove();return replacement},"ClassDeclaration|FunctionDeclaration":function ClassDeclarationFunctionDeclaration(node,parent,scope){var binding=scope.getBinding(node.id.name);if(binding&&!binding.referenced){this.dangerouslyRemove()}},VariableDeclarator:function VariableDeclarator(node,parent,scope){if(!t.isIdentifier(node.id)||!scope.isPure(node.init,true))return;visitor["ClassDeclaration|FunctionDeclaration"].apply(this,arguments)},ConditionalExpression:function ConditionalExpression(node){var evaluateTest=this.get("test").evaluateTruthy();if(evaluateTest===true){return node.consequent}else if(evaluateTest===false){return node.alternate}},BlockStatement:function BlockStatement(){var paths=this.get("body");var purge=false;for(var i=0;i3)continue;if(distance<=shortest)continue;closest=name;shortest=distance}var msg;if(closest){msg=messages.get("undeclaredVariableSuggestion",node.name,closest)}else{msg=messages.get("undeclaredVariable",node.name)}throw this.errorWithNode(msg,ReferenceError)}}})};module.exports=exports["default"]},{leven:215}],215:[function(require,module,exports){"use strict";var arr=[];var charCodeCache=[];module.exports=function(a,b){if(a===b){return 0}var aLen=a.length;var bLen=b.length;if(aLen===0){return bLen}if(bLen===0){return aLen}var bCharCode;var ret;var tmp;var tmp2;var i=0;var j=0;while(iret?tmp2>ret?ret+1:tmp2:tmp2>tmp?tmp+1:tmp2}}return ret}},{}],216:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=function(_ref){var Plugin=_ref.Plugin;var t=_ref.types;return new Plugin("undefined-to-void",{metadata:{group:"builtin-basic"},visitor:{ReferencedIdentifier:function ReferencedIdentifier(node,parent){if(node.name==="undefined"){return t.unaryExpression("void",t.literal(0),true)}}}})};module.exports=exports["default"]},{}],217:[function(require,module,exports){(function(process){"use strict";var escapeStringRegexp=require("escape-string-regexp");var ansiStyles=require("ansi-styles");var stripAnsi=require("strip-ansi");var hasAnsi=require("has-ansi");var supportsColor=require("supports-color");var defineProps=Object.defineProperties;var isSimpleWindowsTerm=process.platform==="win32"&&!/^xterm/i.test(process.env.TERM);function Chalk(options){this.enabled=!options||options.enabled===undefined?supportsColor:options.enabled}if(isSimpleWindowsTerm){ansiStyles.blue.open=""}var styles=function(){var ret={};Object.keys(ansiStyles).forEach(function(key){ansiStyles[key].closeRe=new RegExp(escapeStringRegexp(ansiStyles[key].close),"g");ret[key]={get:function(){return build.call(this,this._styles.concat(key))}}});return ret}();var proto=defineProps(function chalk(){},styles);function build(_styles){var builder=function(){return applyStyle.apply(builder,arguments)};builder._styles=_styles;builder.enabled=this.enabled;builder.__proto__=proto;return builder}function applyStyle(){var args=arguments;var argsLen=args.length;var str=argsLen!==0&&String(arguments[0]);if(argsLen>1){for(var a=1;a<]/g}},{}],222:[function(require,module,exports){"use strict";var ansiRegex=require("ansi-regex")();module.exports=function(str){return typeof str==="string"?str.replace(ansiRegex,""):str}},{"ansi-regex":223}],223:[function(require,module,exports){arguments[4][221][0].apply(exports,arguments)},{dup:221}],224:[function(require,module,exports){(function(process){"use strict";var argv=process.argv;var terminator=argv.indexOf("--");var hasFlag=function(flag){flag="--"+flag;var pos=argv.indexOf(flag);return pos!==-1&&(terminator!==-1?pos0;i--){line=lines[i];if(~line.indexOf("sourceMappingURL=data:"))return exports.fromComment(line)}}Converter.prototype.toJSON=function(space){return JSON.stringify(this.sourcemap,null,space)};Converter.prototype.toBase64=function(){var json=this.toJSON();return new Buffer(json).toString("base64")};Converter.prototype.toComment=function(options){var base64=this.toBase64();var data="sourceMappingURL=data:application/json;base64,"+base64;return options&&options.multiline?"/*# "+data+" */":"//# "+data};Converter.prototype.toObject=function(){return JSON.parse(this.toJSON())};Converter.prototype.addProperty=function(key,value){if(this.sourcemap.hasOwnProperty(key))throw new Error("property %s already exists on the sourcemap, use set property instead");return this.setProperty(key,value)};Converter.prototype.setProperty=function(key,value){this.sourcemap[key]=value;return this};Converter.prototype.getProperty=function(key){return this.sourcemap[key]};exports.fromObject=function(obj){return new Converter(obj)};exports.fromJSON=function(json){return new Converter(json,{isJSON:true})};exports.fromBase64=function(base64){return new Converter(base64,{isEncoded:true})};exports.fromComment=function(comment){comment=comment.replace(/^\/\*/g,"//").replace(/\*\/$/g,"");return new Converter(comment,{isEncoded:true,hasComment:true})};exports.fromMapFileComment=function(comment,dir){return new Converter(comment,{commentFileDir:dir,isFileComment:true,isJSON:true})};exports.fromSource=function(content,largeSource){if(largeSource)return convertFromLargeSource(content);var m=content.match(commentRx);commentRx.lastIndex=0;return m?exports.fromComment(m.pop()):null};exports.fromMapFileSource=function(content,dir){var m=content.match(mapFileCommentRx);mapFileCommentRx.lastIndex=0;return m?exports.fromMapFileComment(m.pop(),dir):null};exports.removeComments=function(src){commentRx.lastIndex=0;return src.replace(commentRx,"")};exports.removeMapFileComments=function(src){mapFileCommentRx.lastIndex=0;return src.replace(mapFileCommentRx,"")};Object.defineProperty(exports,"commentRegex",{get:function getCommentRegex(){commentRx.lastIndex=0;return commentRx}});Object.defineProperty(exports,"mapFileCommentRegex",{get:function getMapFileCommentRegex(){mapFileCommentRx.lastIndex=0;return mapFileCommentRx}})}).call(this,require("buffer").Buffer)},{buffer:4,fs:1,path:11}],226:[function(require,module,exports){module.exports=function(it){if(typeof it!="function")throw TypeError(it+" is not a function!");return it}},{}],227:[function(require,module,exports){var isObject=require("./$.is-object");module.exports=function(it){if(!isObject(it))throw TypeError(it+" is not an object!");return it}},{"./$.is-object":257}],228:[function(require,module,exports){var toIObject=require("./$.to-iobject"),toLength=require("./$.to-length"),toIndex=require("./$.to-index");module.exports=function(IS_INCLUDES){return function($this,el,fromIndex){var O=toIObject($this),length=toLength(O.length),index=toIndex(fromIndex,length),value;if(IS_INCLUDES&&el!=el)while(length>index){value=O[index++];if(value!=value)return true}else for(;length>index;index++)if(IS_INCLUDES||index in O){if(O[index]===el)return IS_INCLUDES||index}return!IS_INCLUDES&&-1}}},{"./$.to-index":293,"./$.to-iobject":295,"./$.to-length":296}],229:[function(require,module,exports){var ctx=require("./$.ctx"),IObject=require("./$.iobject"),toObject=require("./$.to-object"),toLength=require("./$.to-length");module.exports=function(TYPE){var IS_MAP=TYPE==1,IS_FILTER=TYPE==2,IS_SOME=TYPE==3,IS_EVERY=TYPE==4,IS_FIND_INDEX=TYPE==6,NO_HOLES=TYPE==5||IS_FIND_INDEX;return function($this,callbackfn,that){var O=toObject($this),self=IObject(O),f=ctx(callbackfn,that,3),length=toLength(self.length),index=0,result=IS_MAP?Array(length):IS_FILTER?[]:undefined,val,res;for(;length>index;index++)if(NO_HOLES||index in self){val=self[index];res=f(val,index,O);if(TYPE){if(IS_MAP)result[index]=res;else if(res)switch(TYPE){case 3:return true;case 5:return val;case 6:return index;case 2:result.push(val)}else if(IS_EVERY)return false}}return IS_FIND_INDEX?-1:IS_SOME||IS_EVERY?IS_EVERY:result}}},{"./$.ctx":238,"./$.iobject":254,"./$.to-length":296,"./$.to-object":297}],230:[function(require,module,exports){var toObject=require("./$.to-object"),IObject=require("./$.iobject"),enumKeys=require("./$.enum-keys");module.exports=Object.assign||function assign(target,source){var T=toObject(target),l=arguments.length,i=1;while(l>i){var S=IObject(arguments[i++]),keys=enumKeys(S),length=keys.length,j=0,key;while(length>j)T[key=keys[j++]]=S[key]}return T}},{"./$.enum-keys":242,"./$.iobject":254,"./$.to-object":297}],231:[function(require,module,exports){var cof=require("./$.cof"),TAG=require("./$.wks")("toStringTag"),ARG=cof(function(){return arguments}())=="Arguments";module.exports=function(it){var O,T,B;return it===undefined?"Undefined":it===null?"Null":typeof(T=(O=Object(it))[TAG])=="string"?T:ARG?cof(O):(B=cof(O))=="Object"&&typeof O.callee=="function"?"Arguments":B}},{"./$.cof":232,"./$.wks":300}],232:[function(require,module,exports){var toString={}.toString;module.exports=function(it){return toString.call(it).slice(8,-1)}},{}],233:[function(require,module,exports){"use strict";var $=require("./$"),hide=require("./$.hide"),ctx=require("./$.ctx"),species=require("./$.species"),strictNew=require("./$.strict-new"),defined=require("./$.defined"),forOf=require("./$.for-of"),step=require("./$.iter-step"),ID=require("./$.uid")("id"),$has=require("./$.has"),isObject=require("./$.is-object"),isExtensible=Object.isExtensible||isObject,SUPPORT_DESC=require("./$.support-desc"),SIZE=SUPPORT_DESC?"_s":"size",id=0;var fastKey=function(it,create){if(!isObject(it))return typeof it=="symbol"?it:(typeof it=="string"?"S":"P")+it;if(!$has(it,ID)){if(!isExtensible(it))return"F";if(!create)return"E";hide(it,ID,++id)}return"O"+it[ID]};var getEntry=function(that,key){var index=fastKey(key),entry;if(index!=="F")return that._i[index];for(entry=that._f;entry;entry=entry.n){if(entry.k==key)return entry}};module.exports={getConstructor:function(wrapper,NAME,IS_MAP,ADDER){var C=wrapper(function(that,iterable){strictNew(that,C,NAME);that._i=$.create(null);that._f=undefined;that._l=undefined;that[SIZE]=0;if(iterable!=undefined)forOf(iterable,IS_MAP,that[ADDER],that)});require("./$.mix")(C.prototype,{clear:function clear(){for(var that=this,data=that._i,entry=that._f;entry;entry=entry.n){entry.r=true;if(entry.p)entry.p=entry.p.n=undefined; +delete data[entry.i]}that._f=that._l=undefined;that[SIZE]=0},"delete":function(key){var that=this,entry=getEntry(that,key);if(entry){var next=entry.n,prev=entry.p;delete that._i[entry.i];entry.r=true;if(prev)prev.n=next;if(next)next.p=prev;if(that._f==entry)that._f=next;if(that._l==entry)that._l=prev;that[SIZE]--}return!!entry},forEach:function forEach(callbackfn){var f=ctx(callbackfn,arguments[1],3),entry;while(entry=entry?entry.n:this._f){f(entry.v,entry.k,this);while(entry&&entry.r)entry=entry.p}},has:function has(key){return!!getEntry(this,key)}});if(SUPPORT_DESC)$.setDesc(C.prototype,"size",{get:function(){return defined(this[SIZE])}});return C},def:function(that,key,value){var entry=getEntry(that,key),prev,index;if(entry){entry.v=value}else{that._l=entry={i:index=fastKey(key,true),k:key,v:value,p:prev=that._l,n:undefined,r:false};if(!that._f)that._f=entry;if(prev)prev.n=entry;that[SIZE]++;if(index!=="F")that._i[index]=entry}return that},getEntry:getEntry,setStrong:function(C,NAME,IS_MAP){require("./$.iter-define")(C,NAME,function(iterated,kind){this._t=iterated;this._k=kind;this._l=undefined},function(){var that=this,kind=that._k,entry=that._l;while(entry&&entry.r)entry=entry.p;if(!that._t||!(that._l=entry=entry?entry.n:that._t._f)){that._t=undefined;return step(1)}if(kind=="keys")return step(0,entry.k);if(kind=="values")return step(0,entry.v);return step(0,[entry.k,entry.v])},IS_MAP?"entries":"values",!IS_MAP,true);species(C);species(require("./$.core")[NAME])}}},{"./$":265,"./$.core":237,"./$.ctx":238,"./$.defined":240,"./$.for-of":247,"./$.has":250,"./$.hide":251,"./$.is-object":257,"./$.iter-define":261,"./$.iter-step":263,"./$.mix":270,"./$.species":283,"./$.strict-new":284,"./$.support-desc":290,"./$.uid":298}],234:[function(require,module,exports){var forOf=require("./$.for-of"),classof=require("./$.classof");module.exports=function(NAME){return function toJSON(){if(classof(this)!=NAME)throw TypeError(NAME+"#toJSON isn't generic");var arr=[];forOf(this,false,arr.push,arr);return arr}}},{"./$.classof":231,"./$.for-of":247}],235:[function(require,module,exports){"use strict";var hide=require("./$.hide"),anObject=require("./$.an-object"),strictNew=require("./$.strict-new"),forOf=require("./$.for-of"),method=require("./$.array-methods"),WEAK=require("./$.uid")("weak"),isObject=require("./$.is-object"),$has=require("./$.has"),isExtensible=Object.isExtensible||isObject,find=method(5),findIndex=method(6),id=0;var frozenStore=function(that){return that._l||(that._l=new FrozenStore)};var FrozenStore=function(){this.a=[]};var findFrozen=function(store,key){return find(store.a,function(it){return it[0]===key})};FrozenStore.prototype={get:function(key){var entry=findFrozen(this,key);if(entry)return entry[1]},has:function(key){return!!findFrozen(this,key)},set:function(key,value){var entry=findFrozen(this,key);if(entry)entry[1]=value;else this.a.push([key,value])},"delete":function(key){var index=findIndex(this.a,function(it){return it[0]===key});if(~index)this.a.splice(index,1);return!!~index}};module.exports={getConstructor:function(wrapper,NAME,IS_MAP,ADDER){var C=wrapper(function(that,iterable){strictNew(that,C,NAME);that._i=id++;that._l=undefined;if(iterable!=undefined)forOf(iterable,IS_MAP,that[ADDER],that)});require("./$.mix")(C.prototype,{"delete":function(key){if(!isObject(key))return false;if(!isExtensible(key))return frozenStore(this)["delete"](key);return $has(key,WEAK)&&$has(key[WEAK],this._i)&&delete key[WEAK][this._i]},has:function has(key){if(!isObject(key))return false;if(!isExtensible(key))return frozenStore(this).has(key);return $has(key,WEAK)&&$has(key[WEAK],this._i)}});return C},def:function(that,key,value){if(!isExtensible(anObject(key))){frozenStore(that).set(key,value)}else{$has(key,WEAK)||hide(key,WEAK,{});key[WEAK][that._i]=value}return that},frozenStore:frozenStore,WEAK:WEAK}},{"./$.an-object":227,"./$.array-methods":229,"./$.for-of":247,"./$.has":250,"./$.hide":251,"./$.is-object":257,"./$.mix":270,"./$.strict-new":284,"./$.uid":298}],236:[function(require,module,exports){"use strict";var global=require("./$.global"),$def=require("./$.def"),BUGGY=require("./$.iter-buggy"),forOf=require("./$.for-of"),strictNew=require("./$.strict-new");module.exports=function(NAME,wrapper,methods,common,IS_MAP,IS_WEAK){var Base=global[NAME],C=Base,ADDER=IS_MAP?"set":"add",proto=C&&C.prototype,O={};var fixMethod=function(KEY){var fn=proto[KEY];require("./$.redef")(proto,KEY,KEY=="delete"?function(a){return fn.call(this,a===0?0:a)}:KEY=="has"?function has(a){return fn.call(this,a===0?0:a)}:KEY=="get"?function get(a){return fn.call(this,a===0?0:a)}:KEY=="add"?function add(a){fn.call(this,a===0?0:a);return this}:function set(a,b){fn.call(this,a===0?0:a,b);return this})};if(typeof C!="function"||!(IS_WEAK||!BUGGY&&proto.forEach&&proto.entries)){C=common.getConstructor(wrapper,NAME,IS_MAP,ADDER);require("./$.mix")(C.prototype,methods)}else{var inst=new C,chain=inst[ADDER](IS_WEAK?{}:-0,1),buggyZero;if(!require("./$.iter-detect")(function(iter){new C(iter)})){C=wrapper(function(target,iterable){strictNew(target,C,NAME);var that=new Base;if(iterable!=undefined)forOf(iterable,IS_MAP,that[ADDER],that);return that});C.prototype=proto;proto.constructor=C}IS_WEAK||inst.forEach(function(val,key){buggyZero=1/key===-Infinity});if(buggyZero){fixMethod("delete");fixMethod("has");IS_MAP&&fixMethod("get")}if(buggyZero||chain!==inst)fixMethod(ADDER);if(IS_WEAK&&proto.clear)delete proto.clear}require("./$.tag")(C,NAME);O[NAME]=C;$def($def.G+$def.W+$def.F*(C!=Base),O);if(!IS_WEAK)common.setStrong(C,NAME,IS_MAP);return C}},{"./$.def":239,"./$.for-of":247,"./$.global":249,"./$.iter-buggy":258,"./$.iter-detect":262,"./$.mix":270,"./$.redef":277,"./$.strict-new":284,"./$.tag":291}],237:[function(require,module,exports){var core=module.exports={};if(typeof __e=="number")__e=core},{}],238:[function(require,module,exports){var aFunction=require("./$.a-function");module.exports=function(fn,that,length){aFunction(fn);if(that===undefined)return fn;switch(length){case 1:return function(a){return fn.call(that,a)};case 2:return function(a,b){return fn.call(that,a,b)};case 3:return function(a,b,c){return fn.call(that,a,b,c)}}return function(){return fn.apply(that,arguments)}}},{"./$.a-function":226}],239:[function(require,module,exports){var global=require("./$.global"),core=require("./$.core"),hide=require("./$.hide"),$redef=require("./$.redef"),PROTOTYPE="prototype";var ctx=function(fn,that){return function(){return fn.apply(that,arguments)}};var $def=function(type,name,source){var key,own,out,exp,isGlobal=type&$def.G,isProto=type&$def.P,target=isGlobal?global:type&$def.S?global[name]||(global[name]={}):(global[name]||{})[PROTOTYPE],exports=isGlobal?core:core[name]||(core[name]={});if(isGlobal)source=name;for(key in source){own=!(type&$def.F)&&target&&key in target;out=(own?target:source)[key];if(type&$def.B&&own)exp=ctx(out,global);else exp=isProto&&typeof out=="function"?ctx(Function.call,out):out;if(target&&!own)$redef(target,key,out);if(exports[key]!=out)hide(exports,key,exp);if(isProto)(exports[PROTOTYPE]||(exports[PROTOTYPE]={}))[key]=out}};global.core=core;$def.F=1;$def.G=2;$def.S=4;$def.P=8;$def.B=16;$def.W=32;module.exports=$def},{"./$.core":237,"./$.global":249,"./$.hide":251,"./$.redef":277}],240:[function(require,module,exports){module.exports=function(it){if(it==undefined)throw TypeError("Can't call method on "+it);return it}},{}],241:[function(require,module,exports){var isObject=require("./$.is-object"),document=require("./$.global").document,is=isObject(document)&&isObject(document.createElement);module.exports=function(it){return is?document.createElement(it):{}}},{"./$.global":249,"./$.is-object":257}],242:[function(require,module,exports){var $=require("./$");module.exports=function(it){var keys=$.getKeys(it),getSymbols=$.getSymbols;if(getSymbols){var symbols=getSymbols(it),isEnum=$.isEnum,i=0,key;while(symbols.length>i)if(isEnum.call(it,key=symbols[i++]))keys.push(key)}return keys}},{"./$":265}],243:[function(require,module,exports){module.exports=Math.expm1||function expm1(x){return(x=+x)==0?x:x>-1e-6&&x<1e-6?x+x*x/2:Math.exp(x)-1}},{}],244:[function(require,module,exports){module.exports=function(exec){try{return!!exec()}catch(e){return true}}},{}],245:[function(require,module,exports){"use strict";module.exports=function(KEY,length,exec){var defined=require("./$.defined"),SYMBOL=require("./$.wks")(KEY),original=""[KEY];if(require("./$.fails")(function(){var O={};O[SYMBOL]=function(){return 7};return""[KEY](O)!=7})){require("./$.redef")(String.prototype,KEY,exec(defined,SYMBOL,original));require("./$.hide")(RegExp.prototype,SYMBOL,length==2?function(string,arg){return original.call(string,this,arg)}:function(string){return original.call(string,this)})}}},{"./$.defined":240,"./$.fails":244,"./$.hide":251,"./$.redef":277,"./$.wks":300}],246:[function(require,module,exports){"use strict";var anObject=require("./$.an-object");module.exports=function(){var that=anObject(this),result="";if(that.global)result+="g";if(that.ignoreCase)result+="i";if(that.multiline)result+="m";if(that.unicode)result+="u";if(that.sticky)result+="y";return result}},{"./$.an-object":227}],247:[function(require,module,exports){var ctx=require("./$.ctx"),call=require("./$.iter-call"),isArrayIter=require("./$.is-array-iter"),anObject=require("./$.an-object"),toLength=require("./$.to-length"),getIterFn=require("./core.get-iterator-method");module.exports=function(iterable,entries,fn,that){var iterFn=getIterFn(iterable),f=ctx(fn,that,entries?2:1),index=0,length,step,iterator;if(typeof iterFn!="function")throw TypeError(iterable+" is not iterable!");if(isArrayIter(iterFn))for(length=toLength(iterable.length);length>index;index++){entries?f(anObject(step=iterable[index])[0],step[1]):f(iterable[index])}else for(iterator=iterFn.call(iterable);!(step=iterator.next()).done;){call(iterator,f,step.value,entries)}}},{"./$.an-object":227,"./$.ctx":238,"./$.is-array-iter":255,"./$.iter-call":259,"./$.to-length":296,"./core.get-iterator-method":301}],248:[function(require,module,exports){var toString={}.toString,toIObject=require("./$.to-iobject"),getNames=require("./$").getNames;var windowNames=typeof window=="object"&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];var getWindowNames=function(it){try{return getNames(it)}catch(e){return windowNames.slice()}};module.exports.get=function getOwnPropertyNames(it){if(windowNames&&toString.call(it)=="[object Window]")return getWindowNames(it);return getNames(toIObject(it))}},{"./$":265,"./$.to-iobject":295}],249:[function(require,module,exports){var global=typeof self!="undefined"&&self.Math==Math?self:Function("return this")();module.exports=global;if(typeof __g=="number")__g=global},{}],250:[function(require,module,exports){var hasOwnProperty={}.hasOwnProperty;module.exports=function(it,key){return hasOwnProperty.call(it,key)}},{}],251:[function(require,module,exports){var $=require("./$"),createDesc=require("./$.property-desc");module.exports=require("./$.support-desc")?function(object,key,value){return $.setDesc(object,key,createDesc(1,value))}:function(object,key,value){object[key]=value;return object}},{"./$":265,"./$.property-desc":276,"./$.support-desc":290}],252:[function(require,module,exports){module.exports=require("./$.global").document&&document.documentElement},{"./$.global":249}],253:[function(require,module,exports){module.exports=function(fn,args,that){var un=that===undefined;switch(args.length){case 0:return un?fn():fn.call(that);case 1:return un?fn(args[0]):fn.call(that,args[0]);case 2:return un?fn(args[0],args[1]):fn.call(that,args[0],args[1]);case 3:return un?fn(args[0],args[1],args[2]):fn.call(that,args[0],args[1],args[2]);case 4:return un?fn(args[0],args[1],args[2],args[3]):fn.call(that,args[0],args[1],args[2],args[3])}return fn.apply(that,args)}},{}],254:[function(require,module,exports){var cof=require("./$.cof");module.exports=0 in Object("z")?Object:function(it){return cof(it)=="String"?it.split(""):Object(it)}},{"./$.cof":232}],255:[function(require,module,exports){var Iterators=require("./$.iterators"),ITERATOR=require("./$.wks")("iterator");module.exports=function(it){return(Iterators.Array||Array.prototype[ITERATOR])===it}},{"./$.iterators":264,"./$.wks":300}],256:[function(require,module,exports){var isObject=require("./$.is-object"),floor=Math.floor;module.exports=function isInteger(it){return!isObject(it)&&isFinite(it)&&floor(it)===it}},{"./$.is-object":257}],257:[function(require,module,exports){module.exports=function(it){return it!==null&&(typeof it=="object"||typeof it=="function")}},{}],258:[function(require,module,exports){module.exports="keys"in[]&&!("next"in[].keys())},{}],259:[function(require,module,exports){var anObject=require("./$.an-object");module.exports=function(iterator,fn,value,entries){try{return entries?fn(anObject(value)[0],value[1]):fn(value)}catch(e){var ret=iterator["return"];if(ret!==undefined)anObject(ret.call(iterator));throw e}}},{"./$.an-object":227}],260:[function(require,module,exports){"use strict";var $=require("./$"),IteratorPrototype={};require("./$.hide")(IteratorPrototype,require("./$.wks")("iterator"),function(){return this});module.exports=function(Constructor,NAME,next){Constructor.prototype=$.create(IteratorPrototype,{next:require("./$.property-desc")(1,next)});require("./$.tag")(Constructor,NAME+" Iterator")}},{"./$":265,"./$.hide":251,"./$.property-desc":276,"./$.tag":291,"./$.wks":300}],261:[function(require,module,exports){"use strict";var LIBRARY=require("./$.library"),$def=require("./$.def"),$redef=require("./$.redef"),hide=require("./$.hide"),has=require("./$.has"),SYMBOL_ITERATOR=require("./$.wks")("iterator"),Iterators=require("./$.iterators"),FF_ITERATOR="@@iterator",KEYS="keys",VALUES="values";var returnThis=function(){return this};module.exports=function(Base,NAME,Constructor,next,DEFAULT,IS_SET,FORCE){require("./$.iter-create")(Constructor,NAME,next);var createMethod=function(kind){switch(kind){case KEYS:return function keys(){return new Constructor(this,kind)};case VALUES:return function values(){return new Constructor(this,kind)}}return function entries(){return new Constructor(this,kind)}};var TAG=NAME+" Iterator",proto=Base.prototype,_native=proto[SYMBOL_ITERATOR]||proto[FF_ITERATOR]||DEFAULT&&proto[DEFAULT],_default=_native||createMethod(DEFAULT),methods,key;if(_native){var IteratorPrototype=require("./$").getProto(_default.call(new Base));require("./$.tag")(IteratorPrototype,TAG,true);if(!LIBRARY&&has(proto,FF_ITERATOR))hide(IteratorPrototype,SYMBOL_ITERATOR,returnThis)}if(!LIBRARY||FORCE)hide(proto,SYMBOL_ITERATOR,_default);Iterators[NAME]=_default;Iterators[TAG]=returnThis;if(DEFAULT){methods={keys:IS_SET?_default:createMethod(KEYS),values:DEFAULT==VALUES?_default:createMethod(VALUES),entries:DEFAULT!=VALUES?_default:createMethod("entries")};if(FORCE)for(key in methods){if(!(key in proto))$redef(proto,key,methods[key])}else $def($def.P+$def.F*require("./$.iter-buggy"),NAME,methods)}}},{"./$":265,"./$.def":239,"./$.has":250,"./$.hide":251,"./$.iter-buggy":258,"./$.iter-create":260,"./$.iterators":264,"./$.library":267,"./$.redef":277,"./$.tag":291,"./$.wks":300}],262:[function(require,module,exports){var SYMBOL_ITERATOR=require("./$.wks")("iterator"),SAFE_CLOSING=false;try{var riter=[7][SYMBOL_ITERATOR]();riter["return"]=function(){SAFE_CLOSING=true};Array.from(riter,function(){throw 2})}catch(e){}module.exports=function(exec){if(!SAFE_CLOSING)return false;var safe=false;try{var arr=[7],iter=arr[SYMBOL_ITERATOR]();iter.next=function(){safe=true};arr[SYMBOL_ITERATOR]=function(){return iter};exec(arr)}catch(e){}return safe}},{"./$.wks":300}],263:[function(require,module,exports){module.exports=function(done,value){return{value:value,done:!!done}}},{}],264:[function(require,module,exports){module.exports={}},{}],265:[function(require,module,exports){var $Object=Object;module.exports={create:$Object.create,getProto:$Object.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:$Object.getOwnPropertyDescriptor,setDesc:$Object.defineProperty,setDescs:$Object.defineProperties,getKeys:$Object.keys,getNames:$Object.getOwnPropertyNames,getSymbols:$Object.getOwnPropertySymbols,each:[].forEach}},{}],266:[function(require,module,exports){var $=require("./$"),toIObject=require("./$.to-iobject");module.exports=function(object,el){var O=toIObject(object),keys=$.getKeys(O),length=keys.length,index=0,key;while(length>index)if(O[key=keys[index++]]===el)return key}},{"./$":265,"./$.to-iobject":295}],267:[function(require,module,exports){module.exports=false},{}],268:[function(require,module,exports){module.exports=Math.log1p||function log1p(x){return(x=+x)>-1e-8&&x<1e-8?x-x*x/2:Math.log(1+x)}},{}],269:[function(require,module,exports){var global=require("./$.global"),macrotask=require("./$.task").set,Observer=global.MutationObserver||global.WebKitMutationObserver,process=global.process,head,last,notify;function flush(){while(head){head.fn.call();head=head.next}last=undefined}if(require("./$.cof")(process)=="process"){notify=function(){process.nextTick(flush)}}else if(Observer){var toggle=1,node=document.createTextNode("");new Observer(flush).observe(node,{characterData:true});notify=function(){node.data=toggle=-toggle}}else{notify=function(){macrotask.call(global,flush)}}module.exports=function asap(fn){var task={fn:fn,next:undefined};if(last)last.next=task;if(!head){head=task;notify()}last=task}},{"./$.cof":232,"./$.global":249,"./$.task":292}],270:[function(require,module,exports){var $redef=require("./$.redef");module.exports=function(target,src){for(var key in src)$redef(target,key,src[key]);return target}},{"./$.redef":277}],271:[function(require,module,exports){module.exports=function(KEY,exec){var $def=require("./$.def"),fn=(require("./$.core").Object||{})[KEY]||Object[KEY],exp={};exp[KEY]=exec(fn);$def($def.S+$def.F*require("./$.fails")(function(){fn(1)}),"Object",exp)}},{"./$.core":237,"./$.def":239,"./$.fails":244}],272:[function(require,module,exports){var $=require("./$"),toIObject=require("./$.to-iobject");module.exports=function(isEntries){return function(it){var O=toIObject(it),keys=$.getKeys(O),length=keys.length,i=0,result=Array(length),key;if(isEntries)while(length>i)result[i]=[key=keys[i++],O[key]];else while(length>i)result[i]=O[keys[i++]];return result}}},{"./$":265,"./$.to-iobject":295}],273:[function(require,module,exports){var $=require("./$"),anObject=require("./$.an-object");module.exports=function ownKeys(it){var keys=$.getNames(anObject(it)),getSymbols=$.getSymbols;return getSymbols?keys.concat(getSymbols(it)):keys}},{"./$":265,"./$.an-object":227}],274:[function(require,module,exports){"use strict";var path=require("./$.path"),invoke=require("./$.invoke"),aFunction=require("./$.a-function");module.exports=function(){var fn=aFunction(this),length=arguments.length,pargs=Array(length),i=0,_=path._,holder=false;while(length>i)if((pargs[i]=arguments[i++])===_)holder=true;return function(){var that=this,_length=arguments.length,j=0,k=0,args;if(!holder&&!_length)return invoke(fn,pargs,that);args=pargs.slice();if(holder)for(;length>j;j++)if(args[j]===_)args[j]=arguments[k++];while(_length>k)args.push(arguments[k++]);return invoke(fn,args,that)}}},{"./$.a-function":226,"./$.invoke":253,"./$.path":275}],275:[function(require,module,exports){module.exports=require("./$.global")},{"./$.global":249}],276:[function(require,module,exports){module.exports=function(bitmap,value){return{enumerable:!(bitmap&1),configurable:!(bitmap&2),writable:!(bitmap&4),value:value}}},{}],277:[function(require,module,exports){var global=require("./$.global"),hide=require("./$.hide"),SRC=require("./$.uid")("src"),TO_STRING="toString",$toString=Function[TO_STRING],TPL=(""+$toString).split(TO_STRING);require("./$.core").inspectSource=function(it){return $toString.call(it)};(module.exports=function(O,key,val,safe){if(typeof val=="function"){hide(val,SRC,O[key]?""+O[key]:TPL.join(String(key)));if(!("name"in val))val.name=key}if(O===global){O[key]=val}else{if(!safe)delete O[key];hide(O,key,val)}})(Function.prototype,TO_STRING,function toString(){return typeof this=="function"&&this[SRC]||$toString.call(this)})},{"./$.core":237,"./$.global":249,"./$.hide":251,"./$.uid":298}],278:[function(require,module,exports){module.exports=function(regExp,replace){var replacer=replace===Object(replace)?function(part){return replace[part]}:replace;return function(it){return String(it).replace(regExp,replacer)}}},{}],279:[function(require,module,exports){module.exports=Object.is||function is(x,y){return x===y?x!==0||1/x===1/y:x!=x&&y!=y}},{}],280:[function(require,module,exports){var getDesc=require("./$").getDesc,isObject=require("./$.is-object"),anObject=require("./$.an-object");var check=function(O,proto){anObject(O);if(!isObject(proto)&&proto!==null)throw TypeError(proto+": can't set as prototype!")};module.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(buggy,set){try{set=require("./$.ctx")(Function.call,getDesc(Object.prototype,"__proto__").set,2);set({},[])}catch(e){buggy=true}return function setPrototypeOf(O,proto){check(O,proto);if(buggy)O.__proto__=proto;else set(O,proto);return O}}():undefined),check:check}},{"./$":265,"./$.an-object":227,"./$.ctx":238,"./$.is-object":257}],281:[function(require,module,exports){var global=require("./$.global"),SHARED="__core-js_shared__",store=global[SHARED]||(global[SHARED]={});module.exports=function(key){return store[key]||(store[key]={})}},{"./$.global":249}],282:[function(require,module,exports){module.exports=Math.sign||function sign(x){return(x=+x)==0||x!=x?x:x<0?-1:1}},{}],283:[function(require,module,exports){"use strict";var $=require("./$"),SPECIES=require("./$.wks")("species");module.exports=function(C){if(require("./$.support-desc")&&!(SPECIES in C))$.setDesc(C,SPECIES,{configurable:true,get:function(){return this}})}},{"./$":265,"./$.support-desc":290,"./$.wks":300}],284:[function(require,module,exports){module.exports=function(it,Constructor,name){if(!(it instanceof Constructor))throw TypeError(name+": use the 'new' operator!");return it}},{}],285:[function(require,module,exports){var toInteger=require("./$.to-integer"),defined=require("./$.defined");module.exports=function(TO_STRING){return function(that,pos){var s=String(defined(that)),i=toInteger(pos),l=s.length,a,b;if(i<0||i>=l)return TO_STRING?"":undefined;a=s.charCodeAt(i);return a<55296||a>56319||i+1===l||(b=s.charCodeAt(i+1))<56320||b>57343?TO_STRING?s.charAt(i):a:TO_STRING?s.slice(i,i+2):(a-55296<<10)+(b-56320)+65536}}},{"./$.defined":240,"./$.to-integer":294}],286:[function(require,module,exports){var defined=require("./$.defined"),cof=require("./$.cof");module.exports=function(that,searchString,NAME){if(cof(searchString)=="RegExp")throw TypeError("String#"+NAME+" doesn't accept regex!");return String(defined(that))}},{"./$.cof":232,"./$.defined":240}],287:[function(require,module,exports){var toLength=require("./$.to-length"),repeat=require("./$.string-repeat"),defined=require("./$.defined");module.exports=function(that,maxLength,fillString,left){var S=String(defined(that)),stringLength=S.length,fillStr=fillString===undefined?" ":String(fillString),intMaxLength=toLength(maxLength);if(intMaxLength<=stringLength)return S;if(fillStr=="")fillStr=" ";var fillLen=intMaxLength-stringLength,stringFiller=repeat.call(fillStr,Math.ceil(fillLen/fillStr.length));if(stringFiller.length>fillLen)stringFiller=left?stringFiller.slice(stringFiller.length-fillLen):stringFiller.slice(0,fillLen);return left?stringFiller+S:S+stringFiller}},{"./$.defined":240,"./$.string-repeat":288,"./$.to-length":296}],288:[function(require,module,exports){"use strict";var toInteger=require("./$.to-integer"),defined=require("./$.defined");module.exports=function repeat(count){var str=String(defined(this)),res="",n=toInteger(count);if(n<0||n==Infinity)throw RangeError("Count can't be negative");for(;n>0;(n>>>=1)&&(str+=str))if(n&1)res+=str;return res}},{"./$.defined":240,"./$.to-integer":294}],289:[function(require,module,exports){var trim=function(string,TYPE){string=String(defined(string));if(TYPE&1)string=string.replace(ltrim,"");if(TYPE&2)string=string.replace(rtrim,"");return string};var $def=require("./$.def"),defined=require("./$.defined"),spaces=" \n \f\r   ᠎    "+"          \u2028\u2029\ufeff",space="["+spaces+"]",non="​…",ltrim=RegExp("^"+space+space+"*"),rtrim=RegExp(space+space+"*$");module.exports=function(KEY,exec){var exp={};exp[KEY]=exec(trim);$def($def.P+$def.F*require("./$.fails")(function(){return!!spaces[KEY]()||non[KEY]()!=non}),"String",exp)}},{"./$.def":239,"./$.defined":240,"./$.fails":244}],290:[function(require,module,exports){module.exports=!require("./$.fails")(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},{"./$.fails":244}],291:[function(require,module,exports){var has=require("./$.has"),hide=require("./$.hide"),TAG=require("./$.wks")("toStringTag");module.exports=function(it,tag,stat){if(it&&!has(it=stat?it:it.prototype,TAG))hide(it,TAG,tag)}},{"./$.has":250,"./$.hide":251,"./$.wks":300}],292:[function(require,module,exports){"use strict";var ctx=require("./$.ctx"),invoke=require("./$.invoke"),html=require("./$.html"),cel=require("./$.dom-create"),global=require("./$.global"),process=global.process,setTask=global.setImmediate,clearTask=global.clearImmediate,MessageChannel=global.MessageChannel,counter=0,queue={},ONREADYSTATECHANGE="onreadystatechange",defer,channel,port;var run=function(){var id=+this;if(queue.hasOwnProperty(id)){var fn=queue[id];delete queue[id];fn()}};var listner=function(event){run.call(event.data)};if(!setTask||!clearTask){setTask=function setImmediate(fn){var args=[],i=1;while(arguments.length>i)args.push(arguments[i++]);queue[++counter]=function(){invoke(typeof fn=="function"?fn:Function(fn),args)};defer(counter);return counter};clearTask=function clearImmediate(id){delete queue[id]};if(require("./$.cof")(process)=="process"){defer=function(id){process.nextTick(ctx(run,id,1))}}else if(MessageChannel){channel=new MessageChannel;port=channel.port2;channel.port1.onmessage=listner;defer=ctx(port.postMessage,port,1)}else if(global.addEventListener&&typeof postMessage=="function"&&!global.importScript){defer=function(id){global.postMessage(id+"","*")};global.addEventListener("message",listner,false)}else if(ONREADYSTATECHANGE in cel("script")){defer=function(id){html.appendChild(cel("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this);run.call(id)}}}else{defer=function(id){setTimeout(ctx(run,id,1),0)}}}module.exports={set:setTask,clear:clearTask}},{"./$.cof":232,"./$.ctx":238,"./$.dom-create":241,"./$.global":249,"./$.html":252,"./$.invoke":253}],293:[function(require,module,exports){var toInteger=require("./$.to-integer"),max=Math.max,min=Math.min;module.exports=function(index,length){index=toInteger(index);return index<0?max(index+length,0):min(index,length)}},{"./$.to-integer":294}],294:[function(require,module,exports){var ceil=Math.ceil,floor=Math.floor;module.exports=function(it){return isNaN(it=+it)?0:(it>0?floor:ceil)(it)}},{}],295:[function(require,module,exports){var IObject=require("./$.iobject"),defined=require("./$.defined");module.exports=function(it){return IObject(defined(it))}},{"./$.defined":240,"./$.iobject":254}],296:[function(require,module,exports){var toInteger=require("./$.to-integer"),min=Math.min;module.exports=function(it){return it>0?min(toInteger(it),9007199254740991):0}},{"./$.to-integer":294}],297:[function(require,module,exports){var defined=require("./$.defined");module.exports=function(it){return Object(defined(it))}},{"./$.defined":240}],298:[function(require,module,exports){var id=0,px=Math.random();module.exports=function(key){return"Symbol(".concat(key===undefined?"":key,")_",(++id+px).toString(36))}},{}],299:[function(require,module,exports){var UNSCOPABLES=require("./$.wks")("unscopables");if(!(UNSCOPABLES in[]))require("./$.hide")(Array.prototype,UNSCOPABLES,{});module.exports=function(key){[][UNSCOPABLES][key]=true}},{"./$.hide":251,"./$.wks":300}],300:[function(require,module,exports){var store=require("./$.shared")("wks"),Symbol=require("./$.global").Symbol;module.exports=function(name){return store[name]||(store[name]=Symbol&&Symbol[name]||(Symbol||require("./$.uid"))("Symbol."+name))}},{"./$.global":249,"./$.shared":281,"./$.uid":298}],301:[function(require,module,exports){var classof=require("./$.classof"),ITERATOR=require("./$.wks")("iterator"),Iterators=require("./$.iterators");module.exports=require("./$.core").getIteratorMethod=function(it){if(it!=undefined)return it[ITERATOR]||it["@@iterator"]||Iterators[classof(it)]}},{"./$.classof":231,"./$.core":237,"./$.iterators":264,"./$.wks":300}],302:[function(require,module,exports){"use strict";var $=require("./$"),SUPPORT_DESC=require("./$.support-desc"),createDesc=require("./$.property-desc"),html=require("./$.html"),cel=require("./$.dom-create"),has=require("./$.has"),cof=require("./$.cof"),$def=require("./$.def"),invoke=require("./$.invoke"),arrayMethod=require("./$.array-methods"),IE_PROTO=require("./$.uid")("__proto__"),isObject=require("./$.is-object"),anObject=require("./$.an-object"),aFunction=require("./$.a-function"),toObject=require("./$.to-object"),toIObject=require("./$.to-iobject"),toInteger=require("./$.to-integer"),toIndex=require("./$.to-index"),toLength=require("./$.to-length"),IObject=require("./$.iobject"),fails=require("./$.fails"),ObjectProto=Object.prototype,A=[],_slice=A.slice,_join=A.join,defineProperty=$.setDesc,getOwnDescriptor=$.getDesc,defineProperties=$.setDescs,$indexOf=require("./$.array-includes")(false),factories={},IE8_DOM_DEFINE;if(!SUPPORT_DESC){IE8_DOM_DEFINE=!fails(function(){return defineProperty(cel("div"),"a",{get:function(){return 7}}).a!=7});$.setDesc=function(O,P,Attributes){if(IE8_DOM_DEFINE)try{return defineProperty(O,P,Attributes)}catch(e){}if("get"in Attributes||"set"in Attributes)throw TypeError("Accessors not supported!");if("value"in Attributes)anObject(O)[P]=Attributes.value;return O};$.getDesc=function(O,P){if(IE8_DOM_DEFINE)try{return getOwnDescriptor(O,P)}catch(e){}if(has(O,P))return createDesc(!ObjectProto.propertyIsEnumerable.call(O,P),O[P])};$.setDescs=defineProperties=function(O,Properties){anObject(O);var keys=$.getKeys(Properties),length=keys.length,i=0,P;while(length>i)$.setDesc(O,P=keys[i++],Properties[P]);return O}}$def($def.S+$def.F*!SUPPORT_DESC,"Object",{getOwnPropertyDescriptor:$.getDesc,defineProperty:$.setDesc,defineProperties:defineProperties});var keys1=("constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,"+"toLocaleString,toString,valueOf").split(","),keys2=keys1.concat("length","prototype"),keysLen1=keys1.length;var createDict=function(){var iframe=cel("iframe"),i=keysLen1,gt=">",iframeDocument;iframe.style.display="none";html.appendChild(iframe);iframe.src="javascript:";iframeDocument=iframe.contentWindow.document;iframeDocument.open();iframeDocument.write(" + + + \ No newline at end of file diff --git a/public/plugin_assets/redmine_code_review/stylesheets/window_js/darkX.css b/public/plugin_assets/redmine_code_review/stylesheets/window_js/darkX.css index e3df3e0a4..2f83cfd46 100644 --- a/public/plugin_assets/redmine_code_review/stylesheets/window_js/darkX.css +++ b/public/plugin_assets/redmine_code_review/stylesheets/window_js/darkX.css @@ -1,121 +1,121 @@ -.overlay_darkX { - background-color: #85BBEF; - filter:alpha(opacity=60); - -moz-opacity: 0.6; - opacity: 0.6; -} - -.darkX_nw { - background: transparent url(darkX/titlebar-left-focused.png) no-repeat 0 0; - width:6px; - height:21px; -} -.darkX_n { - background: transparent url(darkX/titlebar-mid-focused.png) repeat-x 0 0; - height:21px; -} -.darkX_ne { - background: transparent url(darkX/titlebar-right-focused.png) no-repeat 0 0; - width:6px; - height:21px; -} -.darkX_w { - background: transparent url(darkX/frame-left-focused.png) repeat-y top left; - width:3px; -} - -.darkX_e { - background: transparent url(darkX/frame-right-focused.png) repeat-y top right; - width:3px; -} - -.darkX_sw { - background: transparent url(darkX/frame-bottom-left-focused.png) no-repeat 0 0; - width:5px; - height:3px; -} -.darkX_s { - background: transparent url(darkX/frame-bottom-mid-focused.png) repeat-x 0 0; - height:3px; -} -.darkX_se, .darkX_sizer { - background: transparent url(darkX/frame-bottom-right-focused.png) no-repeat 0 0; - width:5px; - height:3px; -} - -.darkX_sizer { - cursor:se-resize; -} - -.darkX_close { - width: 21px; - height: 21px; - background: transparent url(darkX/button-close-focused.png) no-repeat 0 0; - position:absolute; - top:0px; - right:5px; - cursor:pointer; - z-index:1000; -} - -.darkX_minimize { - width: 21px; - height: 21px; - background: transparent url(darkX/button-minimize-focused.png) no-repeat 0 0; - position:absolute; - top:0px; - right:26px; - cursor:pointer; - z-index:1000; -} - -.darkX_maximize { - width: 21px; - height: 21px; - background: transparent url(darkX/button-maximize-focused.png) no-repeat 0 0; - position:absolute; - top:0px; - right:47px; - cursor:pointer; - z-index:1000; -} - - -.darkX_title { - float:left; - height:14px; - font-size:12px; - text-align:center; - margin-top:2px; - width:100%; - color:#FFF; -} - -.darkX_content { - overflow:auto; - color: #E6DF2A; - font-family: Tahoma, Arial, sans-serif; - font-size: 14px; - background:#5E5148; -} - - -/* FOR IE */ -* html .darkX_minimize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-minimize-focused.png", sizingMethod="crop"); -} - -* html .darkX_maximize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-maximize-focused.png", sizingMethod="scale"); -} - -* html .darkX_close { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-close-focused.png", sizingMethod="crop"); -} +.overlay_darkX { + background-color: #85BBEF; + filter:alpha(opacity=60); + -moz-opacity: 0.6; + opacity: 0.6; +} + +.darkX_nw { + background: transparent url(darkX/titlebar-left-focused.png) no-repeat 0 0; + width:6px; + height:21px; +} +.darkX_n { + background: transparent url(darkX/titlebar-mid-focused.png) repeat-x 0 0; + height:21px; +} +.darkX_ne { + background: transparent url(darkX/titlebar-right-focused.png) no-repeat 0 0; + width:6px; + height:21px; +} +.darkX_w { + background: transparent url(darkX/frame-left-focused.png) repeat-y top left; + width:3px; +} + +.darkX_e { + background: transparent url(darkX/frame-right-focused.png) repeat-y top right; + width:3px; +} + +.darkX_sw { + background: transparent url(darkX/frame-bottom-left-focused.png) no-repeat 0 0; + width:5px; + height:3px; +} +.darkX_s { + background: transparent url(darkX/frame-bottom-mid-focused.png) repeat-x 0 0; + height:3px; +} +.darkX_se, .darkX_sizer { + background: transparent url(darkX/frame-bottom-right-focused.png) no-repeat 0 0; + width:5px; + height:3px; +} + +.darkX_sizer { + cursor:se-resize; +} + +.darkX_close { + width: 21px; + height: 21px; + background: transparent url(darkX/button-close-focused.png) no-repeat 0 0; + position:absolute; + top:0px; + right:5px; + cursor:pointer; + z-index:1000; +} + +.darkX_minimize { + width: 21px; + height: 21px; + background: transparent url(darkX/button-minimize-focused.png) no-repeat 0 0; + position:absolute; + top:0px; + right:26px; + cursor:pointer; + z-index:1000; +} + +.darkX_maximize { + width: 21px; + height: 21px; + background: transparent url(darkX/button-maximize-focused.png) no-repeat 0 0; + position:absolute; + top:0px; + right:47px; + cursor:pointer; + z-index:1000; +} + + +.darkX_title { + float:left; + height:14px; + font-size:12px; + text-align:center; + margin-top:2px; + width:100%; + color:#FFF; +} + +.darkX_content { + overflow:auto; + color: #E6DF2A; + font-family: Tahoma, Arial, sans-serif; + font-size: 14px; + background:#5E5148; +} + + +/* FOR IE */ +* html .darkX_minimize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-minimize-focused.png", sizingMethod="crop"); +} + +* html .darkX_maximize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-maximize-focused.png", sizingMethod="scale"); +} + +* html .darkX_close { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-close-focused.png", sizingMethod="crop"); +} diff --git a/public/plugin_assets/redmine_code_review/stylesheets/window_js/debug.css b/public/plugin_assets/redmine_code_review/stylesheets/window_js/debug.css index d7981e9ca..69e3b7fc2 100644 --- a/public/plugin_assets/redmine_code_review/stylesheets/window_js/debug.css +++ b/public/plugin_assets/redmine_code_review/stylesheets/window_js/debug.css @@ -1,25 +1,25 @@ -div.inspector div.inspectable { - padding: 0.25em 0 0.25em 1em; - background-color: Gray; - color: white; - border: outset 2px white; - cursor: pointer; -} - -div.inspector div.child { - margin: 0 0 0 1em; -} - -#debug_window_content { /* DIV container for debug sizing*/ - width:250px; - height:100px; - background-color:#000; -} - -#debug { /* DIV container for debug contents*/ - padding:3px; - color:#0f0; - font-family:monaco, Tahoma, Verdana, Arial, Helvetica, sans-serif; - font-size:10px; -} - +div.inspector div.inspectable { + padding: 0.25em 0 0.25em 1em; + background-color: Gray; + color: white; + border: outset 2px white; + cursor: pointer; +} + +div.inspector div.child { + margin: 0 0 0 1em; +} + +#debug_window_content { /* DIV container for debug sizing*/ + width:250px; + height:100px; + background-color:#000; +} + +#debug { /* DIV container for debug contents*/ + padding:3px; + color:#0f0; + font-family:monaco, Tahoma, Verdana, Arial, Helvetica, sans-serif; + font-size:10px; +} + diff --git a/public/plugin_assets/redmine_code_review/stylesheets/window_js/default.css b/public/plugin_assets/redmine_code_review/stylesheets/window_js/default.css index 591451723..6ab13789d 100644 --- a/public/plugin_assets/redmine_code_review/stylesheets/window_js/default.css +++ b/public/plugin_assets/redmine_code_review/stylesheets/window_js/default.css @@ -1,155 +1,155 @@ -.overlay_dialog { - background-color: #666666; - filter:alpha(opacity=60); - -moz-opacity: 0.6; - opacity: 0.6; -} - -.overlay___invisible__ { - background-color: #666666; - filter:alpha(opacity=0); - -moz-opacity: 0; - opacity: 0; -} - -.dialog_nw { - width: 9px; - height: 23px; - background: transparent url(default/top_left.gif) no-repeat 0 0; -} - -.dialog_n { - background: transparent url(default/top_mid.gif) repeat-x 0 0; - height: 23px; -} - -.dialog_ne { - width: 9px; - height: 23px; - background: transparent url(default/top_right.gif) no-repeat 0 0; -} - -.dialog_e { - width: 2px; - background: transparent url(default/center_right.gif) repeat-y 0 0; -} - -.dialog_w { - width: 2px; - background: transparent url(default/center_left.gif) repeat-y 0 0; -} - -.dialog_sw { - width: 9px; - height: 19px; - background: transparent url(default/bottom_left.gif) no-repeat 0 0; -} - -.dialog_s { - background: transparent url(default/bottom_mid.gif) repeat-x 0 0; - height: 19px; -} - -.dialog_se { - width: 9px; - height: 19px; - background: transparent url(default/bottom_right.gif) no-repeat 0 0; -} - -.dialog_sizer { - width: 9px; - height: 19px; - background: transparent url(default/sizer.gif) no-repeat 0 0; - cursor:se-resize; -} - -.dialog_close { - width: 14px; - height: 14px; - background: transparent url(default/close.gif) no-repeat 0 0; - position:absolute; - top:5px; - left:8px; - cursor:pointer; - z-index:2000; -} - -.dialog_minimize { - width: 14px; - height: 15px; - background: transparent url(default/minimize.gif) no-repeat 0 0; - position:absolute; - top:5px; - left:28px; - cursor:pointer; - z-index:2000; -} - -.dialog_maximize { - width: 14px; - height: 15px; - background: transparent url(default/maximize.gif) no-repeat 0 0; - position:absolute; - top:5px; - left:49px; - cursor:pointer; - z-index:2000; -} - -.dialog_title { - float:left; - height:14px; - font-family: Tahoma, Arial, sans-serif; - font-size:12px; - text-align:center; - width:100%; - color:#000; -} - -.dialog_content { - overflow:auto; - color: #DDD; - font-family: Tahoma, Arial, sans-serif; - font-size: 10px; - background-color:#123; -} - -.top_draggable, .bottom_draggable { - cursor:move; -} - -.status_bar { - font-size:12px; -} -.status_bar input{ - font-size:12px; -} - -.wired_frame { - display: block; - position: absolute; - border: 1px #000 dashed; -} - -/* DO NOT CHANGE THESE VALUES*/ -.dialog { - display: block; - position: absolute; -} - -.dialog table.table_window { - border-collapse: collapse; - border-spacing: 0; - width: 100%; - margin: 0px; - padding:0px; -} - -.dialog table.table_window td , .dialog table.table_window th { - padding: 0; -} - -.dialog .title_window { - -moz-user-select:none; -} - +.overlay_dialog { + background-color: #666666; + filter:alpha(opacity=60); + -moz-opacity: 0.6; + opacity: 0.6; +} + +.overlay___invisible__ { + background-color: #666666; + filter:alpha(opacity=0); + -moz-opacity: 0; + opacity: 0; +} + +.dialog_nw { + width: 9px; + height: 23px; + background: transparent url(default/top_left.gif) no-repeat 0 0; +} + +.dialog_n { + background: transparent url(default/top_mid.gif) repeat-x 0 0; + height: 23px; +} + +.dialog_ne { + width: 9px; + height: 23px; + background: transparent url(default/top_right.gif) no-repeat 0 0; +} + +.dialog_e { + width: 2px; + background: transparent url(default/center_right.gif) repeat-y 0 0; +} + +.dialog_w { + width: 2px; + background: transparent url(default/center_left.gif) repeat-y 0 0; +} + +.dialog_sw { + width: 9px; + height: 19px; + background: transparent url(default/bottom_left.gif) no-repeat 0 0; +} + +.dialog_s { + background: transparent url(default/bottom_mid.gif) repeat-x 0 0; + height: 19px; +} + +.dialog_se { + width: 9px; + height: 19px; + background: transparent url(default/bottom_right.gif) no-repeat 0 0; +} + +.dialog_sizer { + width: 9px; + height: 19px; + background: transparent url(default/sizer.gif) no-repeat 0 0; + cursor:se-resize; +} + +.dialog_close { + width: 14px; + height: 14px; + background: transparent url(default/close.gif) no-repeat 0 0; + position:absolute; + top:5px; + left:8px; + cursor:pointer; + z-index:2000; +} + +.dialog_minimize { + width: 14px; + height: 15px; + background: transparent url(default/minimize.gif) no-repeat 0 0; + position:absolute; + top:5px; + left:28px; + cursor:pointer; + z-index:2000; +} + +.dialog_maximize { + width: 14px; + height: 15px; + background: transparent url(default/maximize.gif) no-repeat 0 0; + position:absolute; + top:5px; + left:49px; + cursor:pointer; + z-index:2000; +} + +.dialog_title { + float:left; + height:14px; + font-family: Tahoma, Arial, sans-serif; + font-size:12px; + text-align:center; + width:100%; + color:#000; +} + +.dialog_content { + overflow:auto; + color: #DDD; + font-family: Tahoma, Arial, sans-serif; + font-size: 10px; + background-color:#123; +} + +.top_draggable, .bottom_draggable { + cursor:move; +} + +.status_bar { + font-size:12px; +} +.status_bar input{ + font-size:12px; +} + +.wired_frame { + display: block; + position: absolute; + border: 1px #000 dashed; +} + +/* DO NOT CHANGE THESE VALUES*/ +.dialog { + display: block; + position: absolute; +} + +.dialog table.table_window { + border-collapse: collapse; + border-spacing: 0; + width: 100%; + margin: 0px; + padding:0px; +} + +.dialog table.table_window td , .dialog table.table_window th { + padding: 0; +} + +.dialog .title_window { + -moz-user-select:none; +} + diff --git a/public/plugin_assets/redmine_code_review/stylesheets/window_js/iefix/iepngfix.css b/public/plugin_assets/redmine_code_review/stylesheets/window_js/iefix/iepngfix.css index 249388be5..257a1b1e3 100644 --- a/public/plugin_assets/redmine_code_review/stylesheets/window_js/iefix/iepngfix.css +++ b/public/plugin_assets/redmine_code_review/stylesheets/window_js/iefix/iepngfix.css @@ -1,3 +1,3 @@ -/* PNG fix for all themes that uses PNG images on IE */ -td, div { behavior: url(../themes/iefix/iepngfix.htc) } - +/* PNG fix for all themes that uses PNG images on IE */ +td, div { behavior: url(../themes/iefix/iepngfix.htc) } + diff --git a/public/plugin_assets/redmine_code_review/stylesheets/window_js/iefix/iepngfix.htc b/public/plugin_assets/redmine_code_review/stylesheets/window_js/iefix/iepngfix.htc index 9a13f32bf..a6c683b9f 100644 --- a/public/plugin_assets/redmine_code_review/stylesheets/window_js/iefix/iepngfix.htc +++ b/public/plugin_assets/redmine_code_review/stylesheets/window_js/iefix/iepngfix.htc @@ -1,54 +1,54 @@ - - - - + + + + \ No newline at end of file diff --git a/public/plugin_assets/redmine_code_review/stylesheets/window_js/lighting.css b/public/plugin_assets/redmine_code_review/stylesheets/window_js/lighting.css index 0d955c3d7..95ec287a9 100644 --- a/public/plugin_assets/redmine_code_review/stylesheets/window_js/lighting.css +++ b/public/plugin_assets/redmine_code_review/stylesheets/window_js/lighting.css @@ -1,960 +1,960 @@ -.overlay___invisible__ { - background-color: #666; - filter:alpha(opacity=0); - -moz-opacity: 0; - opacity: 0; -} - -.top_draggable, .bottom_draggable { - cursor:move; -} - -.status_bar { - font-size:12px; -} -.status_bar input{ - font-size:12px; -} - -.wired_frame { - display:block; - position:absolute; - border:1px #000 dashed; -} - - - -.overlay_bluelighting { - background-color:#FFF; - filter:alpha(opacity=60); - -moz-opacity:0.6; - opacity:0.6; -} - -.bluelighting_wired_frame { - background:#FFF; - filter:alpha(opacity=60); - -moz-opacity:0.6; - opacity:0.6; -} - -.bluelighting_nw { - background:transparent url(lighting/top-left-blue.png) no-repeat 0 0; - width:9px; - height:28px; -} - -.bluelighting_n { - background:transparent url(lighting/top-middle-blue.png) repeat-x 0 0; - height:28px; -} - -.bluelighting_ne { - background:transparent url(lighting/top-right-blue.png) no-repeat 0 0; - width:15px; - height:28px; -} - -.bluelighting_w { - background:transparent url(lighting/left-blue.png) repeat-y top left; - width:9px; -} - -.bluelighting_e { - background:transparent url(lighting/right-blue.png) repeat-y top right; - width:15px; -} - -.bluelighting_sw { - background:transparent url(lighting/bottom-left-blue.png) no-repeat 0 0; - width:9px; - height:15px; -} - -.bluelighting_s { - background:transparent url(lighting/bottom-middle-blue.png) repeat-x 0 0; - height:15px; -} - -.bluelighting_se, .bluelighting_sizer { - background:transparent url(lighting/bottom-right-blue.png) no-repeat 0 0; - width:15px; - height:15px; -} - -.bluelighting_sizer { - cursor:se-resize; -} - -.bluelighting_close { - width:15px; - height:9px; - background:transparent url(lighting/button-close-blue.png) no-repeat 0 0; - position:absolute; - top:11px; - right:10px; - cursor:pointer; - z-index:1000; -} - -.bluelighting_maximize { - width:15px; - height:9px; - background:transparent url(lighting/button-maximize-blue.png) no-repeat 0 0; - position:absolute; - top:11px; - right:25px; - cursor:pointer; - z-index:1000; -} - -.bluelighting_minimize { - width:15px; - height:9px; - background:transparent url(lighting/button-minimize-blue.png) no-repeat 0 0; - position:absolute; - top:11px; - right:40px; - cursor:pointer; - z-index:1000; -} - -.bluelighting_title { - float:left; - height:14px; - font-size:14px; - font-weight:bold; - font-family:Verdana, Arial, sans-serif; - text-align:center; - margin-top:2px; - width:100%; - color:#17385B; -} - -.bluelighting_content { - overflow:auto; - color:#000; - font-family:Verdana, Arial, sans-serif; - font-size:12px; - background:#BFDBFF; -} - -/* For alert/confirm dialog */ -.bluelighting_window { - border:1px solid #F00; - background:#FFF; - padding:20px; - margin-left:auto; - margin-right:auto; - width:400px; -} - -.bluelighting_message { - font-size:12px; - text-align:center; - width:100%; - padding-bottom:10px; -} - -.bluelighting_buttons { - text-align:center; - width:100%; -} - -.bluelighting_buttons input { - border:1px solid #999; - border-top-color:#CCC; - border-left-color:#CCC; - padding:2px; - background-color:#FFF; - color:#333; - background-image:url(lighting/background_buttons.gif); - background-repeat:repeat-x; - font-family:Verdana, Arial, sans-serif; - font-size:10px; - font-weight:bold; - text-align:center; -} - -.bluelighting_progress { - float:left; - margin:auto; - text-align:center; - width:100%; - height:16px; - background:transparent url('lighting/spinner.gif') no-repeat center center -} - -/* FOR IE */ -* html .bluelighting_nw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-left-blue.png", sizingMethod="crop"); -} - -* html .bluelighting_n { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-middle-blue.png", sizingMethod="scale"); -} - -* html .bluelighting_ne { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-right-blue.png", sizingMethod="crop"); -} - -* html .bluelighting_w { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/left-blue.png", sizingMethod="scale"); -} - -* html .bluelighting_e { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/right-blue.png", sizingMethod="scale"); -} - -* html .bluelighting_sw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-left-blue.png", sizingMethod="crop"); -} - -* html .bluelighting_s { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-middle-blue.png", sizingMethod="scale"); -} - -* html .bluelighting_se, * html .bluelighting_sizer { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-right-blue.png", sizingMethod="crop"); -} - -* html .bluelighting_close { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-close-blue.png", sizingMethod="crop"); -} - -* html .bluelighting_minimize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-minimize-blue.png", sizingMethod="crop"); -} - -* html .bluelighting_maximize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-maximize-blue.png", sizingMethod="crop"); -} - -* html .bluelighting_content { - background:#B8D7FF; -} - - - -.overlay_greylighting { - background-color:#FFF; - filter:alpha(opacity=60); - -moz-opacity:0.6; - opacity:0.6; -} - -.greylighting_wired_frame { - background:#FFF; - filter:alpha(opacity=60); - -moz-opacity:0.6; - opacity:0.6; -} - -.greylighting_nw { - background:transparent url(lighting/top-left-grey.png) no-repeat 0 0; - width:9px; - height:28px; -} - -.greylighting_n { - background:transparent url(lighting/top-middle-grey.png) repeat-x 0 0; - height:28px; -} - -.greylighting_ne { - background:transparent url(lighting/top-right-grey.png) no-repeat 0 0; - width:15px; - height:28px; -} - -.greylighting_w { - background:transparent url(lighting/left-grey.png) repeat-y top left; - width:9px; -} - -.greylighting_e { - background:transparent url(lighting/right-grey.png) repeat-y top right; - width:15px; -} - -.greylighting_sw { - background:transparent url(lighting/bottom-left-grey.png) no-repeat 0 0; - width:9px; - height:15px; -} - -.greylighting_s { - background:transparent url(lighting/bottom-middle-grey.png) repeat-x 0 0; - height:15px; -} - -.greylighting_se, .greylighting_sizer { - background:transparent url(lighting/bottom-right-grey.png) no-repeat 0 0; - width:15px; - height:15px; -} - -.greylighting_sizer { - cursor:se-resize; -} - -.greylighting_close { - width:15px; - height:9px; - background:transparent url(lighting/button-close-grey.png) no-repeat 0 0; - position:absolute; - top:11px; - right:10px; - cursor:pointer; - z-index:1000; -} - -.greylighting_maximize { - width:15px; - height:9px; - background:transparent url(lighting/button-maximize-grey.png) no-repeat 0 0; - position:absolute; - top:11px; - right:25px; - cursor:pointer; - z-index:1000; -} - -.greylighting_minimize { - width:15px; - height:9px; - background:transparent url(lighting/button-minimize-grey.png) no-repeat 0 0; - position:absolute; - top:11px; - right:40px; - cursor:pointer; - z-index:1000; -} - -.greylighting_title { - float:left; - height:14px; - font-size:14px; - font-weight:bold; - font-family:Verdana, Arial, sans-serif; - text-align:center; - margin-top:2px; - width:100%; - color:#525252; -} - -.greylighting_content { - overflow:auto; - color:#000; - font-family:Verdana, Arial, sans-serif; - font-size:12px; - background:#CDCDCD; -} - -/* For alert/confirm dialog */ -.greylighting_window { - border:1px solid #F00; - background:#FFF; - padding:20px; - margin-left:auto; - margin-right:auto; - width:400px; -} - -.greylighting_message { - font-size:12px; - text-align:center; - width:100%; - padding-bottom:10px; -} - -.greylighting_buttons { - text-align:center; - width:100%; -} - -.greylighting_buttons input { - border:1px solid #999; - border-top-color:#CCC; - border-left-color:#CCC; - padding:2px; - background-color:#FFF; - color:#333; - background-image:url(lighting/background_buttons.gif); - background-repeat:repeat-x; - font-family:Verdana, Arial, sans-serif; - font-size:10px; - font-weight:bold; - text-align:center; -} - -.greylighting_progress { - float:left; - margin:auto; - text-align:center; - width:100%; - height:16px; - background:transparent url('lighting/spinner.gif') no-repeat center center -} - -/* FOR IE */ -* html .greylighting_nw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-left-grey.png", sizingMethod="crop"); -} - -* html .greylighting_n { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-middle-grey.png", sizingMethod="scale"); -} - -* html .greylighting_ne { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-right-grey.png", sizingMethod="crop"); -} - -* html .greylighting_w { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/left-grey.png", sizingMethod="scale"); -} - -* html .greylighting_e { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/right-grey.png", sizingMethod="scale"); -} - -* html .greylighting_sw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-left-grey.png", sizingMethod="crop"); -} - -* html .greylighting_s { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-middle-grey.png", sizingMethod="scale"); -} - -* html greylighting_se, * html .greylighting_sizer { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-right-grey.png", sizingMethod="crop"); -} - -* html .greylighting_close { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-close-grey.png", sizingMethod="crop"); -} - -* html .greylighting_minimize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-minimize-grey.png", sizingMethod="crop"); -} - -* html .greylighting_maximize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-maximize-grey.png", sizingMethod="crop"); -} - -* html .greylighting_content { - background:#C7C7C7; -} - - - -.overlay_greenlighting { - background-color:#FFF; - filter:alpha(opacity=60); - -moz-opacity:0.6; - opacity:0.6; -} - -.greenlighting_wired_frame { - background:#FFF; - filter:alpha(opacity=60); - -moz-opacity:0.6; - opacity:0.6; -} - -.greenlighting_nw { - background:transparent url(lighting/top-left-green.png) no-repeat 0 0; - width:9px; - height:28px; -} - -.greenlighting_n { - background:transparent url(lighting/top-middle-green.png) repeat-x 0 0; - height:28px; -} - -.greenlighting_ne { - background:transparent url(lighting/top-right-green.png) no-repeat 0 0; - width:15px; - height:28px; -} - -.greenlighting_w { - background:transparent url(lighting/left-green.png) repeat-y top left; - width:9px; -} - -.greenlighting_e { - background:transparent url(lighting/right-green.png) repeat-y top right; - width:15px; -} - -.greenlighting_sw { - background:transparent url(lighting/bottom-left-green.png) no-repeat 0 0; - width:9px; - height:15px; -} - -.greenlighting_s { - background:transparent url(lighting/bottom-middle-green.png) repeat-x 0 0; - height:15px; -} - -.greenlighting_se, .greenlighting_sizer { - background:transparent url(lighting/bottom-right-green.png) no-repeat 0 0; - width:15px; - height:15px; -} - -.greenlighting_sizer { - cursor:se-resize; -} - -.greenlighting_close { - width:15px; - height:9px; - background:transparent url(lighting/button-close-green.png) no-repeat 0 0; - position:absolute; - top:11px; - right:10px; - cursor:pointer; - z-index:1000; -} - -.greenlighting_maximize { - width:15px; - height:9px; - background:transparent url(lighting/button-maximize-green.png) no-repeat 0 0; - position:absolute; - top:11px; - right:25px; - cursor:pointer; - z-index:1000; -} - -.greenlighting_minimize { - width:15px; - height:9px; - background:transparent url(lighting/button-minimize-green.png) no-repeat 0 0; - position:absolute; - top:11px; - right:40px; - cursor:pointer; - z-index:1000; -} - -.greenlighting_title { - float:left; - height:14px; - font-size:14px; - font-weight:bold; - font-family:Verdana, Arial, sans-serif; - text-align:center; - margin-top:2px; - width:100%; - color:#2A6002; -} - -.greenlighting_content { - overflow:auto; - color:#000; - font-family:Verdana, Arial, sans-serif; - font-size:12px; - background:#ACFCAF; -} - -/* For alert/confirm dialog */ -.greenlighting_window { - border:1px solid #F00; - background:#FFF; - padding:20px; - margin-left:auto; - margin-right:auto; - width:400px; -} - -.greenlighting_message { - font-size:12px; - text-align:center; - width:100%; - padding-bottom:10px; -} - -.greenlighting_buttons { - text-align:center; - width:100%; -} - -.greenlighting_buttons input { - border:1px solid #999; - border-top-color:#CCC; - border-left-color:#CCC; - padding:2px; - background-color:#FFF; - color:#333; - background-image:url(lighting/background_buttons.gif); - background-repeat:repeat-x; - font-family:Verdana, Arial, sans-serif; - font-size:10px; - font-weight:bold; - text-align:center; -} - -.greenlighting_progress { - float:left; - margin:auto; - text-align:center; - width:100%; - height:16px; - background:transparent url('lighting/spinner.gif') no-repeat center center -} - -/* FOR IE */ -* html .greenlighting_nw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-left-green.png", sizingMethod="crop"); -} - -* html .greenlighting_n { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-middle-green.png", sizingMethod="scale"); -} - -* html .greenlighting_ne { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-right-green.png", sizingMethod="crop"); -} - -* html .greenlighting_w { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/left-green.png", sizingMethod="scale"); -} - -* html .greenlighting_e { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/right-green.png", sizingMethod="scale"); -} - -* html .greenlighting_sw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-left-green.png", sizingMethod="crop"); -} - -* html .greenlighting_s { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-middle-green.png", sizingMethod="scale"); -} - -* html greenlighting_se, * html .greenlighting_sizer { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-right-green.png", sizingMethod="crop"); -} - -* html .greenlighting_close { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-close-green.png", sizingMethod="crop"); -} - -* html .greenlighting_minimize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-minimize-green.png", sizingMethod="crop"); -} - -* html .greenlighting_maximize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-maximize-green.png", sizingMethod="crop"); -} - -* html .greenlighting_content { - background:#A4FCA7; -} - - - -.overlay_darkbluelighting { - background-color:#FFF; - filter:alpha(opacity=60); - -moz-opacity:0.6; - opacity:0.6; -} - -.darkbluelighting_wired_frame { - background:#FFF; - filter:alpha(opacity=60); - -moz-opacity:0.6; - opacity:0.6; -} - -.darkbluelighting_nw { - background:transparent url(lighting/top-left-darkblue.png) no-repeat 0 0; - width:9px; - height:28px; -} - -.darkbluelighting_n { - background:transparent url(lighting/top-middle-darkblue.png) repeat-x 0 0; - height:28px; -} - -.darkbluelighting_ne { - background:transparent url(lighting/top-right-darkblue.png) no-repeat 0 0; - width:15px; - height:28px; -} - -.darkbluelighting_w { - background:transparent url(lighting/left-darkblue.png) repeat-y top left; - width:9px; -} - -.darkbluelighting_e { - background:transparent url(lighting/right-darkblue.png) repeat-y top right; - width:15px; -} - -.darkbluelighting_sw { - background:transparent url(lighting/bottom-left-darkblue.png) no-repeat 0 0; - width:9px; - height:15px; -} - -.darkbluelighting_s { - background:transparent url(lighting/bottom-middle-darkblue.png) repeat-x 0 0; - height:15px; -} - -.darkbluelighting_se, .darkbluelighting_sizer { - background:transparent url(lighting/bottom-right-darkblue.png) no-repeat 0 0; - width:15px; - height:15px; -} - -.darkbluelighting_sizer { - cursor:se-resize; -} - -.darkbluelighting_close { - width:15px; - height:9px; - background:transparent url(lighting/button-close-darkblue.png) no-repeat 0 0; - position:absolute; - top:11px; - right:10px; - cursor:pointer; - z-index:1000; -} - -.darkbluelighting_maximize { - width:15px; - height:9px; - background:transparent url(lighting/button-maximize-darkblue.png) no-repeat 0 0; - position:absolute; - top:11px; - right:25px; - cursor:pointer; - z-index:1000; -} - -.darkbluelighting_minimize { - width:15px; - height:9px; - background:transparent url(lighting/button-minimize-darkblue.png) no-repeat 0 0; - position:absolute; - top:11px; - right:40px; - cursor:pointer; - z-index:1000; -} - -.darkbluelighting_title { - float:left; - height:14px; - font-size:14px; - font-weight:bold; - font-family:Verdana, Arial, sans-serif; - text-align:center; - margin-top:2px; - width:100%; - color:#E4EFFD; -} - -.darkbluelighting_content { - overflow:auto; - color:#FFF; - font-family:Verdana, Arial, sans-serif; - font-size:12px; - background:#0413C0; -} - -/* For alert/confirm dialog */ -.darkbluelighting_window { - border:1px solid #F00; - background:#FFF; - padding:20px; - margin-left:auto; - margin-right:auto; - width:400px; -} - -.darkbluelighting_message { - font-size:12px; - text-align:center; - width:100%; - padding-bottom:10px; -} - -.darkbluelighting_buttons { - text-align:center; - width:100%; -} - -.darkbluelighting_buttons input { - border:1px solid #999; - border-top-color:#CCC; - border-left-color:#CCC; - padding:2px; - background-color:#FFF; - color:#333; - background-image:url(lighting/background_buttons.gif); - background-repeat:repeat-x; - font-family:Verdana, Arial, sans-serif; - font-size:10px; - font-weight:bold; - text-align:center; -} - -.darkbluelighting_progress { - float:left; - margin:auto; - text-align:center; - width:100%; - height:16px; - background:transparent url('lighting/spinner.gif') no-repeat center center -} - -/* FOR IE */ -* html .darkbluelighting_nw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-left-darkblue.png", sizingMethod="crop"); -} - -* html .darkbluelighting_n { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-middle-darkblue.png", sizingMethod="scale"); -} - -* html .darkbluelighting_ne { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-right-darkblue.png", sizingMethod="crop"); -} - -* html .darkbluelighting_w { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/left-darkblue.png", sizingMethod="scale"); -} - -* html .darkbluelighting_e { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/right-darkblue.png", sizingMethod="scale"); -} - -* html .darkbluelighting_sw { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-left-darkblue.png", sizingMethod="crop"); -} - -* html .darkbluelighting_s { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-middle-darkblue.png", sizingMethod="scale"); -} - -* html darkbluelighting_se, * html .darkbluelighting_sizer { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-right-darkblue.png", sizingMethod="crop"); -} - -* html .darkbluelighting_close { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-close-darkblue.png", sizingMethod="crop"); -} - -* html .darkbluelighting_minimize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-minimize-darkblue.png", sizingMethod="crop"); -} - -* html .darkbluelighting_maximize { - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-maximize-darkblue.png", sizingMethod="crop"); -} - -* html .darkbluelighting_content { - background:#020EBA; -} - +.overlay___invisible__ { + background-color: #666; + filter:alpha(opacity=0); + -moz-opacity: 0; + opacity: 0; +} + +.top_draggable, .bottom_draggable { + cursor:move; +} + +.status_bar { + font-size:12px; +} +.status_bar input{ + font-size:12px; +} + +.wired_frame { + display:block; + position:absolute; + border:1px #000 dashed; +} + + + +.overlay_bluelighting { + background-color:#FFF; + filter:alpha(opacity=60); + -moz-opacity:0.6; + opacity:0.6; +} + +.bluelighting_wired_frame { + background:#FFF; + filter:alpha(opacity=60); + -moz-opacity:0.6; + opacity:0.6; +} + +.bluelighting_nw { + background:transparent url(lighting/top-left-blue.png) no-repeat 0 0; + width:9px; + height:28px; +} + +.bluelighting_n { + background:transparent url(lighting/top-middle-blue.png) repeat-x 0 0; + height:28px; +} + +.bluelighting_ne { + background:transparent url(lighting/top-right-blue.png) no-repeat 0 0; + width:15px; + height:28px; +} + +.bluelighting_w { + background:transparent url(lighting/left-blue.png) repeat-y top left; + width:9px; +} + +.bluelighting_e { + background:transparent url(lighting/right-blue.png) repeat-y top right; + width:15px; +} + +.bluelighting_sw { + background:transparent url(lighting/bottom-left-blue.png) no-repeat 0 0; + width:9px; + height:15px; +} + +.bluelighting_s { + background:transparent url(lighting/bottom-middle-blue.png) repeat-x 0 0; + height:15px; +} + +.bluelighting_se, .bluelighting_sizer { + background:transparent url(lighting/bottom-right-blue.png) no-repeat 0 0; + width:15px; + height:15px; +} + +.bluelighting_sizer { + cursor:se-resize; +} + +.bluelighting_close { + width:15px; + height:9px; + background:transparent url(lighting/button-close-blue.png) no-repeat 0 0; + position:absolute; + top:11px; + right:10px; + cursor:pointer; + z-index:1000; +} + +.bluelighting_maximize { + width:15px; + height:9px; + background:transparent url(lighting/button-maximize-blue.png) no-repeat 0 0; + position:absolute; + top:11px; + right:25px; + cursor:pointer; + z-index:1000; +} + +.bluelighting_minimize { + width:15px; + height:9px; + background:transparent url(lighting/button-minimize-blue.png) no-repeat 0 0; + position:absolute; + top:11px; + right:40px; + cursor:pointer; + z-index:1000; +} + +.bluelighting_title { + float:left; + height:14px; + font-size:14px; + font-weight:bold; + font-family:Verdana, Arial, sans-serif; + text-align:center; + margin-top:2px; + width:100%; + color:#17385B; +} + +.bluelighting_content { + overflow:auto; + color:#000; + font-family:Verdana, Arial, sans-serif; + font-size:12px; + background:#BFDBFF; +} + +/* For alert/confirm dialog */ +.bluelighting_window { + border:1px solid #F00; + background:#FFF; + padding:20px; + margin-left:auto; + margin-right:auto; + width:400px; +} + +.bluelighting_message { + font-size:12px; + text-align:center; + width:100%; + padding-bottom:10px; +} + +.bluelighting_buttons { + text-align:center; + width:100%; +} + +.bluelighting_buttons input { + border:1px solid #999; + border-top-color:#CCC; + border-left-color:#CCC; + padding:2px; + background-color:#FFF; + color:#333; + background-image:url(lighting/background_buttons.gif); + background-repeat:repeat-x; + font-family:Verdana, Arial, sans-serif; + font-size:10px; + font-weight:bold; + text-align:center; +} + +.bluelighting_progress { + float:left; + margin:auto; + text-align:center; + width:100%; + height:16px; + background:transparent url('lighting/spinner.gif') no-repeat center center +} + +/* FOR IE */ +* html .bluelighting_nw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-left-blue.png", sizingMethod="crop"); +} + +* html .bluelighting_n { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-middle-blue.png", sizingMethod="scale"); +} + +* html .bluelighting_ne { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-right-blue.png", sizingMethod="crop"); +} + +* html .bluelighting_w { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/left-blue.png", sizingMethod="scale"); +} + +* html .bluelighting_e { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/right-blue.png", sizingMethod="scale"); +} + +* html .bluelighting_sw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-left-blue.png", sizingMethod="crop"); +} + +* html .bluelighting_s { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-middle-blue.png", sizingMethod="scale"); +} + +* html .bluelighting_se, * html .bluelighting_sizer { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-right-blue.png", sizingMethod="crop"); +} + +* html .bluelighting_close { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-close-blue.png", sizingMethod="crop"); +} + +* html .bluelighting_minimize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-minimize-blue.png", sizingMethod="crop"); +} + +* html .bluelighting_maximize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-maximize-blue.png", sizingMethod="crop"); +} + +* html .bluelighting_content { + background:#B8D7FF; +} + + + +.overlay_greylighting { + background-color:#FFF; + filter:alpha(opacity=60); + -moz-opacity:0.6; + opacity:0.6; +} + +.greylighting_wired_frame { + background:#FFF; + filter:alpha(opacity=60); + -moz-opacity:0.6; + opacity:0.6; +} + +.greylighting_nw { + background:transparent url(lighting/top-left-grey.png) no-repeat 0 0; + width:9px; + height:28px; +} + +.greylighting_n { + background:transparent url(lighting/top-middle-grey.png) repeat-x 0 0; + height:28px; +} + +.greylighting_ne { + background:transparent url(lighting/top-right-grey.png) no-repeat 0 0; + width:15px; + height:28px; +} + +.greylighting_w { + background:transparent url(lighting/left-grey.png) repeat-y top left; + width:9px; +} + +.greylighting_e { + background:transparent url(lighting/right-grey.png) repeat-y top right; + width:15px; +} + +.greylighting_sw { + background:transparent url(lighting/bottom-left-grey.png) no-repeat 0 0; + width:9px; + height:15px; +} + +.greylighting_s { + background:transparent url(lighting/bottom-middle-grey.png) repeat-x 0 0; + height:15px; +} + +.greylighting_se, .greylighting_sizer { + background:transparent url(lighting/bottom-right-grey.png) no-repeat 0 0; + width:15px; + height:15px; +} + +.greylighting_sizer { + cursor:se-resize; +} + +.greylighting_close { + width:15px; + height:9px; + background:transparent url(lighting/button-close-grey.png) no-repeat 0 0; + position:absolute; + top:11px; + right:10px; + cursor:pointer; + z-index:1000; +} + +.greylighting_maximize { + width:15px; + height:9px; + background:transparent url(lighting/button-maximize-grey.png) no-repeat 0 0; + position:absolute; + top:11px; + right:25px; + cursor:pointer; + z-index:1000; +} + +.greylighting_minimize { + width:15px; + height:9px; + background:transparent url(lighting/button-minimize-grey.png) no-repeat 0 0; + position:absolute; + top:11px; + right:40px; + cursor:pointer; + z-index:1000; +} + +.greylighting_title { + float:left; + height:14px; + font-size:14px; + font-weight:bold; + font-family:Verdana, Arial, sans-serif; + text-align:center; + margin-top:2px; + width:100%; + color:#525252; +} + +.greylighting_content { + overflow:auto; + color:#000; + font-family:Verdana, Arial, sans-serif; + font-size:12px; + background:#CDCDCD; +} + +/* For alert/confirm dialog */ +.greylighting_window { + border:1px solid #F00; + background:#FFF; + padding:20px; + margin-left:auto; + margin-right:auto; + width:400px; +} + +.greylighting_message { + font-size:12px; + text-align:center; + width:100%; + padding-bottom:10px; +} + +.greylighting_buttons { + text-align:center; + width:100%; +} + +.greylighting_buttons input { + border:1px solid #999; + border-top-color:#CCC; + border-left-color:#CCC; + padding:2px; + background-color:#FFF; + color:#333; + background-image:url(lighting/background_buttons.gif); + background-repeat:repeat-x; + font-family:Verdana, Arial, sans-serif; + font-size:10px; + font-weight:bold; + text-align:center; +} + +.greylighting_progress { + float:left; + margin:auto; + text-align:center; + width:100%; + height:16px; + background:transparent url('lighting/spinner.gif') no-repeat center center +} + +/* FOR IE */ +* html .greylighting_nw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-left-grey.png", sizingMethod="crop"); +} + +* html .greylighting_n { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-middle-grey.png", sizingMethod="scale"); +} + +* html .greylighting_ne { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-right-grey.png", sizingMethod="crop"); +} + +* html .greylighting_w { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/left-grey.png", sizingMethod="scale"); +} + +* html .greylighting_e { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/right-grey.png", sizingMethod="scale"); +} + +* html .greylighting_sw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-left-grey.png", sizingMethod="crop"); +} + +* html .greylighting_s { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-middle-grey.png", sizingMethod="scale"); +} + +* html greylighting_se, * html .greylighting_sizer { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-right-grey.png", sizingMethod="crop"); +} + +* html .greylighting_close { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-close-grey.png", sizingMethod="crop"); +} + +* html .greylighting_minimize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-minimize-grey.png", sizingMethod="crop"); +} + +* html .greylighting_maximize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-maximize-grey.png", sizingMethod="crop"); +} + +* html .greylighting_content { + background:#C7C7C7; +} + + + +.overlay_greenlighting { + background-color:#FFF; + filter:alpha(opacity=60); + -moz-opacity:0.6; + opacity:0.6; +} + +.greenlighting_wired_frame { + background:#FFF; + filter:alpha(opacity=60); + -moz-opacity:0.6; + opacity:0.6; +} + +.greenlighting_nw { + background:transparent url(lighting/top-left-green.png) no-repeat 0 0; + width:9px; + height:28px; +} + +.greenlighting_n { + background:transparent url(lighting/top-middle-green.png) repeat-x 0 0; + height:28px; +} + +.greenlighting_ne { + background:transparent url(lighting/top-right-green.png) no-repeat 0 0; + width:15px; + height:28px; +} + +.greenlighting_w { + background:transparent url(lighting/left-green.png) repeat-y top left; + width:9px; +} + +.greenlighting_e { + background:transparent url(lighting/right-green.png) repeat-y top right; + width:15px; +} + +.greenlighting_sw { + background:transparent url(lighting/bottom-left-green.png) no-repeat 0 0; + width:9px; + height:15px; +} + +.greenlighting_s { + background:transparent url(lighting/bottom-middle-green.png) repeat-x 0 0; + height:15px; +} + +.greenlighting_se, .greenlighting_sizer { + background:transparent url(lighting/bottom-right-green.png) no-repeat 0 0; + width:15px; + height:15px; +} + +.greenlighting_sizer { + cursor:se-resize; +} + +.greenlighting_close { + width:15px; + height:9px; + background:transparent url(lighting/button-close-green.png) no-repeat 0 0; + position:absolute; + top:11px; + right:10px; + cursor:pointer; + z-index:1000; +} + +.greenlighting_maximize { + width:15px; + height:9px; + background:transparent url(lighting/button-maximize-green.png) no-repeat 0 0; + position:absolute; + top:11px; + right:25px; + cursor:pointer; + z-index:1000; +} + +.greenlighting_minimize { + width:15px; + height:9px; + background:transparent url(lighting/button-minimize-green.png) no-repeat 0 0; + position:absolute; + top:11px; + right:40px; + cursor:pointer; + z-index:1000; +} + +.greenlighting_title { + float:left; + height:14px; + font-size:14px; + font-weight:bold; + font-family:Verdana, Arial, sans-serif; + text-align:center; + margin-top:2px; + width:100%; + color:#2A6002; +} + +.greenlighting_content { + overflow:auto; + color:#000; + font-family:Verdana, Arial, sans-serif; + font-size:12px; + background:#ACFCAF; +} + +/* For alert/confirm dialog */ +.greenlighting_window { + border:1px solid #F00; + background:#FFF; + padding:20px; + margin-left:auto; + margin-right:auto; + width:400px; +} + +.greenlighting_message { + font-size:12px; + text-align:center; + width:100%; + padding-bottom:10px; +} + +.greenlighting_buttons { + text-align:center; + width:100%; +} + +.greenlighting_buttons input { + border:1px solid #999; + border-top-color:#CCC; + border-left-color:#CCC; + padding:2px; + background-color:#FFF; + color:#333; + background-image:url(lighting/background_buttons.gif); + background-repeat:repeat-x; + font-family:Verdana, Arial, sans-serif; + font-size:10px; + font-weight:bold; + text-align:center; +} + +.greenlighting_progress { + float:left; + margin:auto; + text-align:center; + width:100%; + height:16px; + background:transparent url('lighting/spinner.gif') no-repeat center center +} + +/* FOR IE */ +* html .greenlighting_nw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-left-green.png", sizingMethod="crop"); +} + +* html .greenlighting_n { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-middle-green.png", sizingMethod="scale"); +} + +* html .greenlighting_ne { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-right-green.png", sizingMethod="crop"); +} + +* html .greenlighting_w { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/left-green.png", sizingMethod="scale"); +} + +* html .greenlighting_e { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/right-green.png", sizingMethod="scale"); +} + +* html .greenlighting_sw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-left-green.png", sizingMethod="crop"); +} + +* html .greenlighting_s { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-middle-green.png", sizingMethod="scale"); +} + +* html greenlighting_se, * html .greenlighting_sizer { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-right-green.png", sizingMethod="crop"); +} + +* html .greenlighting_close { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-close-green.png", sizingMethod="crop"); +} + +* html .greenlighting_minimize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-minimize-green.png", sizingMethod="crop"); +} + +* html .greenlighting_maximize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-maximize-green.png", sizingMethod="crop"); +} + +* html .greenlighting_content { + background:#A4FCA7; +} + + + +.overlay_darkbluelighting { + background-color:#FFF; + filter:alpha(opacity=60); + -moz-opacity:0.6; + opacity:0.6; +} + +.darkbluelighting_wired_frame { + background:#FFF; + filter:alpha(opacity=60); + -moz-opacity:0.6; + opacity:0.6; +} + +.darkbluelighting_nw { + background:transparent url(lighting/top-left-darkblue.png) no-repeat 0 0; + width:9px; + height:28px; +} + +.darkbluelighting_n { + background:transparent url(lighting/top-middle-darkblue.png) repeat-x 0 0; + height:28px; +} + +.darkbluelighting_ne { + background:transparent url(lighting/top-right-darkblue.png) no-repeat 0 0; + width:15px; + height:28px; +} + +.darkbluelighting_w { + background:transparent url(lighting/left-darkblue.png) repeat-y top left; + width:9px; +} + +.darkbluelighting_e { + background:transparent url(lighting/right-darkblue.png) repeat-y top right; + width:15px; +} + +.darkbluelighting_sw { + background:transparent url(lighting/bottom-left-darkblue.png) no-repeat 0 0; + width:9px; + height:15px; +} + +.darkbluelighting_s { + background:transparent url(lighting/bottom-middle-darkblue.png) repeat-x 0 0; + height:15px; +} + +.darkbluelighting_se, .darkbluelighting_sizer { + background:transparent url(lighting/bottom-right-darkblue.png) no-repeat 0 0; + width:15px; + height:15px; +} + +.darkbluelighting_sizer { + cursor:se-resize; +} + +.darkbluelighting_close { + width:15px; + height:9px; + background:transparent url(lighting/button-close-darkblue.png) no-repeat 0 0; + position:absolute; + top:11px; + right:10px; + cursor:pointer; + z-index:1000; +} + +.darkbluelighting_maximize { + width:15px; + height:9px; + background:transparent url(lighting/button-maximize-darkblue.png) no-repeat 0 0; + position:absolute; + top:11px; + right:25px; + cursor:pointer; + z-index:1000; +} + +.darkbluelighting_minimize { + width:15px; + height:9px; + background:transparent url(lighting/button-minimize-darkblue.png) no-repeat 0 0; + position:absolute; + top:11px; + right:40px; + cursor:pointer; + z-index:1000; +} + +.darkbluelighting_title { + float:left; + height:14px; + font-size:14px; + font-weight:bold; + font-family:Verdana, Arial, sans-serif; + text-align:center; + margin-top:2px; + width:100%; + color:#E4EFFD; +} + +.darkbluelighting_content { + overflow:auto; + color:#FFF; + font-family:Verdana, Arial, sans-serif; + font-size:12px; + background:#0413C0; +} + +/* For alert/confirm dialog */ +.darkbluelighting_window { + border:1px solid #F00; + background:#FFF; + padding:20px; + margin-left:auto; + margin-right:auto; + width:400px; +} + +.darkbluelighting_message { + font-size:12px; + text-align:center; + width:100%; + padding-bottom:10px; +} + +.darkbluelighting_buttons { + text-align:center; + width:100%; +} + +.darkbluelighting_buttons input { + border:1px solid #999; + border-top-color:#CCC; + border-left-color:#CCC; + padding:2px; + background-color:#FFF; + color:#333; + background-image:url(lighting/background_buttons.gif); + background-repeat:repeat-x; + font-family:Verdana, Arial, sans-serif; + font-size:10px; + font-weight:bold; + text-align:center; +} + +.darkbluelighting_progress { + float:left; + margin:auto; + text-align:center; + width:100%; + height:16px; + background:transparent url('lighting/spinner.gif') no-repeat center center +} + +/* FOR IE */ +* html .darkbluelighting_nw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-left-darkblue.png", sizingMethod="crop"); +} + +* html .darkbluelighting_n { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-middle-darkblue.png", sizingMethod="scale"); +} + +* html .darkbluelighting_ne { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/top-right-darkblue.png", sizingMethod="crop"); +} + +* html .darkbluelighting_w { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/left-darkblue.png", sizingMethod="scale"); +} + +* html .darkbluelighting_e { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/right-darkblue.png", sizingMethod="scale"); +} + +* html .darkbluelighting_sw { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-left-darkblue.png", sizingMethod="crop"); +} + +* html .darkbluelighting_s { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-middle-darkblue.png", sizingMethod="scale"); +} + +* html darkbluelighting_se, * html .darkbluelighting_sizer { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/bottom-right-darkblue.png", sizingMethod="crop"); +} + +* html .darkbluelighting_close { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-close-darkblue.png", sizingMethod="crop"); +} + +* html .darkbluelighting_minimize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-minimize-darkblue.png", sizingMethod="crop"); +} + +* html .darkbluelighting_maximize { + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/lighting/button-maximize-darkblue.png", sizingMethod="crop"); +} + +* html .darkbluelighting_content { + background:#020EBA; +} + diff --git a/public/plugin_assets/redmine_code_review/stylesheets/window_js/lighting/pngbehavior.htc b/public/plugin_assets/redmine_code_review/stylesheets/window_js/lighting/pngbehavior.htc index 92248c665..36ea182e7 100644 --- a/public/plugin_assets/redmine_code_review/stylesheets/window_js/lighting/pngbehavior.htc +++ b/public/plugin_assets/redmine_code_review/stylesheets/window_js/lighting/pngbehavior.htc @@ -1,67 +1,67 @@ - - - - + + + + +
+ + + + \ No newline at end of file diff --git a/public/javascripts/wechat/ReactRouter.js b/public/javascripts/wechat/ReactRouter.js new file mode 100644 index 000000000..810fd7ddc --- /dev/null +++ b/public/javascripts/wechat/ReactRouter.js @@ -0,0 +1,5064 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("react")); + else if(typeof define === 'function' && define.amd) + define(["react"], factory); + else if(typeof exports === 'object') + exports["ReactRouter"] = factory(require("react")); + else + root["ReactRouter"] = factory(root["React"]); +})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + /* components */ + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _Router2 = __webpack_require__(37); + + var _Router3 = _interopRequireDefault(_Router2); + + exports.Router = _Router3['default']; + + var _Link2 = __webpack_require__(18); + + var _Link3 = _interopRequireDefault(_Link2); + + exports.Link = _Link3['default']; + + var _IndexLink2 = __webpack_require__(31); + + var _IndexLink3 = _interopRequireDefault(_IndexLink2); + + exports.IndexLink = _IndexLink3['default']; + + /* components (configuration) */ + + var _IndexRedirect2 = __webpack_require__(32); + + var _IndexRedirect3 = _interopRequireDefault(_IndexRedirect2); + + exports.IndexRedirect = _IndexRedirect3['default']; + + var _IndexRoute2 = __webpack_require__(33); + + var _IndexRoute3 = _interopRequireDefault(_IndexRoute2); + + exports.IndexRoute = _IndexRoute3['default']; + + var _Redirect2 = __webpack_require__(19); + + var _Redirect3 = _interopRequireDefault(_Redirect2); + + exports.Redirect = _Redirect3['default']; + + var _Route2 = __webpack_require__(35); + + var _Route3 = _interopRequireDefault(_Route2); + + exports.Route = _Route3['default']; + + /* mixins */ + + var _History2 = __webpack_require__(30); + + var _History3 = _interopRequireDefault(_History2); + + exports.History = _History3['default']; + + var _Lifecycle2 = __webpack_require__(34); + + var _Lifecycle3 = _interopRequireDefault(_Lifecycle2); + + exports.Lifecycle = _Lifecycle3['default']; + + var _RouteContext2 = __webpack_require__(36); + + var _RouteContext3 = _interopRequireDefault(_RouteContext2); + + exports.RouteContext = _RouteContext3['default']; + + /* utils */ + + var _useRoutes2 = __webpack_require__(48); + + var _useRoutes3 = _interopRequireDefault(_useRoutes2); + + exports.useRoutes = _useRoutes3['default']; + + var _RouteUtils = __webpack_require__(5); + + exports.createRoutes = _RouteUtils.createRoutes; + + var _RouterContext2 = __webpack_require__(13); + + var _RouterContext3 = _interopRequireDefault(_RouterContext2); + + exports.RouterContext = _RouterContext3['default']; + + var _RoutingContext2 = __webpack_require__(38); + + var _RoutingContext3 = _interopRequireDefault(_RoutingContext2); + + exports.RoutingContext = _RoutingContext3['default']; + + var _PropTypes2 = __webpack_require__(6); + + var _PropTypes3 = _interopRequireDefault(_PropTypes2); + + exports.PropTypes = _PropTypes3['default']; + + var _match2 = __webpack_require__(46); + + var _match3 = _interopRequireDefault(_match2); + + exports.match = _match3['default']; + + var _useRouterHistory2 = __webpack_require__(24); + + var _useRouterHistory3 = _interopRequireDefault(_useRouterHistory2); + + exports.useRouterHistory = _useRouterHistory3['default']; + + var _PatternUtils = __webpack_require__(8); + + exports.formatPattern = _PatternUtils.formatPattern; + + /* histories */ + + var _browserHistory2 = __webpack_require__(40); + + var _browserHistory3 = _interopRequireDefault(_browserHistory2); + + exports.browserHistory = _browserHistory3['default']; + + var _hashHistory2 = __webpack_require__(44); + + var _hashHistory3 = _interopRequireDefault(_hashHistory2); + + exports.hashHistory = _hashHistory3['default']; + + var _createMemoryHistory2 = __webpack_require__(21); + + var _createMemoryHistory3 = _interopRequireDefault(_createMemoryHistory2); + + exports.createMemoryHistory = _createMemoryHistory3['default']; + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + exports['default'] = routerWarning; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + function routerWarning(falseToWarn, message) { + message = '[react-router] ' + message; + + for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } + + false ? _warning2['default'].apply(undefined, [falseToWarn, message].concat(args)) : undefined; + } + + module.exports = exports['default']; + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_2__; + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + 'use strict'; + + /** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + + var invariant = function(condition, format, a, b, c, d, e, f) { + if (false) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + } + + if (!condition) { + var error; + if (format === undefined) { + error = new Error( + 'Minified exception occurred; use the non-minified dev environment ' + + 'for the full error message and additional helpful warnings.' + ); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error( + format.replace(/%s/g, function() { return args[argIndex++]; }) + ); + error.name = 'Invariant Violation'; + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } + }; + + module.exports = invariant; + + +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + 'use strict'; + + /** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + + var warning = function() {}; + + if (false) { + warning = function(condition, format, args) { + var len = arguments.length; + args = new Array(len > 2 ? len - 2 : 0); + for (var key = 2; key < len; key++) { + args[key - 2] = arguments[key]; + } + if (format === undefined) { + throw new Error( + '`warning(condition, format, ...args)` requires a warning ' + + 'message argument' + ); + } + + if (format.length < 10 || (/^[s\W]*$/).test(format)) { + throw new Error( + 'The warning format should be able to uniquely identify this ' + + 'warning. Please, use a more descriptive format than: ' + format + ); + } + + if (!condition) { + var argIndex = 0; + var message = 'Warning: ' + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch(x) {} + } + }; + } + + module.exports = warning; + + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + exports.isReactChildren = isReactChildren; + exports.createRouteFromReactElement = createRouteFromReactElement; + exports.createRoutesFromReactChildren = createRoutesFromReactChildren; + exports.createRoutes = createRoutes; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + function isValidChild(object) { + return object == null || _react2['default'].isValidElement(object); + } + + function isReactChildren(object) { + return isValidChild(object) || Array.isArray(object) && object.every(isValidChild); + } + + function checkPropTypes(componentName, propTypes, props) { + componentName = componentName || 'UnknownComponent'; + + for (var propName in propTypes) { + if (propTypes.hasOwnProperty(propName)) { + var error = propTypes[propName](props, propName, componentName); + + /* istanbul ignore if: error logging */ + if (error instanceof Error) false ? _routerWarning2['default'](false, error.message) : undefined; + } + } + } + + function createRoute(defaultProps, props) { + return _extends({}, defaultProps, props); + } + + function createRouteFromReactElement(element) { + var type = element.type; + var route = createRoute(type.defaultProps, element.props); + + if (type.propTypes) checkPropTypes(type.displayName || type.name, type.propTypes, route); + + if (route.children) { + var childRoutes = createRoutesFromReactChildren(route.children, route); + + if (childRoutes.length) route.childRoutes = childRoutes; + + delete route.children; + } + + return route; + } + + /** + * Creates and returns a routes object from the given ReactChildren. JSX + * provides a convenient way to visualize how routes in the hierarchy are + * nested. + * + * import { Route, createRoutesFromReactChildren } from 'react-router' + * + * const routes = createRoutesFromReactChildren( + * + * + * + * + * ) + * + * Note: This method is automatically used when you provide children + * to a component. + */ + + function createRoutesFromReactChildren(children, parentRoute) { + var routes = []; + + _react2['default'].Children.forEach(children, function (element) { + if (_react2['default'].isValidElement(element)) { + // Component classes may have a static create* method. + if (element.type.createRouteFromReactElement) { + var route = element.type.createRouteFromReactElement(element, parentRoute); + + if (route) routes.push(route); + } else { + routes.push(createRouteFromReactElement(element)); + } + } + }); + + return routes; + } + + /** + * Creates and returns an array of routes from the given object which + * may be a JSX route, a plain object route, or an array of either. + */ + + function createRoutes(routes) { + if (isReactChildren(routes)) { + routes = createRoutesFromReactChildren(routes); + } else if (routes && !Array.isArray(routes)) { + routes = [routes]; + } + + return routes; + } + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + exports.falsy = falsy; + + var _react = __webpack_require__(2); + + var func = _react.PropTypes.func; + var object = _react.PropTypes.object; + var arrayOf = _react.PropTypes.arrayOf; + var oneOfType = _react.PropTypes.oneOfType; + var element = _react.PropTypes.element; + var shape = _react.PropTypes.shape; + var string = _react.PropTypes.string; + + function falsy(props, propName, componentName) { + if (props[propName]) return new Error('<' + componentName + '> should not have a "' + propName + '" prop'); + } + + var history = shape({ + listen: func.isRequired, + pushState: func.isRequired, + replaceState: func.isRequired, + go: func.isRequired + }); + + exports.history = history; + var location = shape({ + pathname: string.isRequired, + search: string.isRequired, + state: object, + action: string.isRequired, + key: string + }); + + exports.location = location; + var component = oneOfType([func, string]); + exports.component = component; + var components = oneOfType([component, object]); + exports.components = components; + var route = oneOfType([object, element]); + exports.route = route; + var routes = oneOfType([route, arrayOf(route)]); + + exports.routes = routes; + exports['default'] = { + falsy: falsy, + history: history, + location: location, + component: component, + components: components, + route: route + }; + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + exports.extractPath = extractPath; + exports.parsePath = parsePath; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + function extractPath(string) { + var match = string.match(/^https?:\/\/[^\/]*/); + + if (match == null) return string; + + return string.substring(match[0].length); + } + + function parsePath(path) { + var pathname = extractPath(path); + var search = ''; + var hash = ''; + + false ? _warning2['default'](path === pathname, 'A path must be pathname + search + hash only, not a fully qualified URL like "%s"', path) : undefined; + + var hashIndex = pathname.indexOf('#'); + if (hashIndex !== -1) { + hash = pathname.substring(hashIndex); + pathname = pathname.substring(0, hashIndex); + } + + var searchIndex = pathname.indexOf('?'); + if (searchIndex !== -1) { + search = pathname.substring(searchIndex); + pathname = pathname.substring(0, searchIndex); + } + + if (pathname === '') pathname = '/'; + + return { + pathname: pathname, + search: search, + hash: hash + }; + } + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + exports.compilePattern = compilePattern; + exports.matchPattern = matchPattern; + exports.getParamNames = getParamNames; + exports.getParams = getParams; + exports.formatPattern = formatPattern; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + function escapeRegExp(string) { + return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + } + + function escapeSource(string) { + return escapeRegExp(string).replace(/\/+/g, '/+'); + } + + function _compilePattern(pattern) { + var regexpSource = ''; + var paramNames = []; + var tokens = []; + + var match = undefined, + lastIndex = 0, + matcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|\*\*|\*|\(|\)/g; + while (match = matcher.exec(pattern)) { + if (match.index !== lastIndex) { + tokens.push(pattern.slice(lastIndex, match.index)); + regexpSource += escapeSource(pattern.slice(lastIndex, match.index)); + } + + if (match[1]) { + regexpSource += '([^/?#]+)'; + paramNames.push(match[1]); + } else if (match[0] === '**') { + regexpSource += '([\\s\\S]*)'; + paramNames.push('splat'); + } else if (match[0] === '*') { + regexpSource += '([\\s\\S]*?)'; + paramNames.push('splat'); + } else if (match[0] === '(') { + regexpSource += '(?:'; + } else if (match[0] === ')') { + regexpSource += ')?'; + } + + tokens.push(match[0]); + + lastIndex = matcher.lastIndex; + } + + if (lastIndex !== pattern.length) { + tokens.push(pattern.slice(lastIndex, pattern.length)); + regexpSource += escapeSource(pattern.slice(lastIndex, pattern.length)); + } + + return { + pattern: pattern, + regexpSource: regexpSource, + paramNames: paramNames, + tokens: tokens + }; + } + + var CompiledPatternsCache = {}; + + function compilePattern(pattern) { + if (!(pattern in CompiledPatternsCache)) CompiledPatternsCache[pattern] = _compilePattern(pattern); + + return CompiledPatternsCache[pattern]; + } + + /** + * Attempts to match a pattern on the given pathname. Patterns may use + * the following special characters: + * + * - :paramName Matches a URL segment up to the next /, ?, or #. The + * captured string is considered a "param" + * - () Wraps a segment of the URL that is optional + * - * Consumes (non-greedy) all characters up to the next + * character in the pattern, or to the end of the URL if + * there is none + * - ** Consumes (greedy) all characters up to the next character + * in the pattern, or to the end of the URL if there is none + * + * The return value is an object with the following properties: + * + * - remainingPathname + * - paramNames + * - paramValues + */ + + function matchPattern(pattern, pathname) { + // Make leading slashes consistent between pattern and pathname. + if (pattern.charAt(0) !== '/') { + pattern = '/' + pattern; + } + if (pathname.charAt(0) !== '/') { + pathname = '/' + pathname; + } + + var _compilePattern2 = compilePattern(pattern); + + var regexpSource = _compilePattern2.regexpSource; + var paramNames = _compilePattern2.paramNames; + var tokens = _compilePattern2.tokens; + + regexpSource += '/*'; // Capture path separators + + // Special-case patterns like '*' for catch-all routes. + var captureRemaining = tokens[tokens.length - 1] !== '*'; + + if (captureRemaining) { + // This will match newlines in the remaining path. + regexpSource += '([\\s\\S]*?)'; + } + + var match = pathname.match(new RegExp('^' + regexpSource + '$', 'i')); + + var remainingPathname = undefined, + paramValues = undefined; + if (match != null) { + if (captureRemaining) { + remainingPathname = match.pop(); + var matchedPath = match[0].substr(0, match[0].length - remainingPathname.length); + + // If we didn't match the entire pathname, then make sure that the match + // we did get ends at a path separator (potentially the one we added + // above at the beginning of the path, if the actual match was empty). + if (remainingPathname && matchedPath.charAt(matchedPath.length - 1) !== '/') { + return { + remainingPathname: null, + paramNames: paramNames, + paramValues: null + }; + } + } else { + // If this matched at all, then the match was the entire pathname. + remainingPathname = ''; + } + + paramValues = match.slice(1).map(function (v) { + return v != null ? decodeURIComponent(v) : v; + }); + } else { + remainingPathname = paramValues = null; + } + + return { + remainingPathname: remainingPathname, + paramNames: paramNames, + paramValues: paramValues + }; + } + + function getParamNames(pattern) { + return compilePattern(pattern).paramNames; + } + + function getParams(pattern, pathname) { + var _matchPattern = matchPattern(pattern, pathname); + + var paramNames = _matchPattern.paramNames; + var paramValues = _matchPattern.paramValues; + + if (paramValues != null) { + return paramNames.reduce(function (memo, paramName, index) { + memo[paramName] = paramValues[index]; + return memo; + }, {}); + } + + return null; + } + + /** + * Returns a version of the given pattern with params interpolated. Throws + * if there is a dynamic segment of the pattern for which there is no param. + */ + + function formatPattern(pattern, params) { + params = params || {}; + + var _compilePattern3 = compilePattern(pattern); + + var tokens = _compilePattern3.tokens; + + var parenCount = 0, + pathname = '', + splatIndex = 0; + + var token = undefined, + paramName = undefined, + paramValue = undefined; + for (var i = 0, len = tokens.length; i < len; ++i) { + token = tokens[i]; + + if (token === '*' || token === '**') { + paramValue = Array.isArray(params.splat) ? params.splat[splatIndex++] : params.splat; + + !(paramValue != null || parenCount > 0) ? false ? _invariant2['default'](false, 'Missing splat #%s for path "%s"', splatIndex, pattern) : _invariant2['default'](false) : undefined; + + if (paramValue != null) pathname += encodeURI(paramValue); + } else if (token === '(') { + parenCount += 1; + } else if (token === ')') { + parenCount -= 1; + } else if (token.charAt(0) === ':') { + paramName = token.substring(1); + paramValue = params[paramName]; + + !(paramValue != null || parenCount > 0) ? false ? _invariant2['default'](false, 'Missing "%s" parameter for path "%s"', paramName, pattern) : _invariant2['default'](false) : undefined; + + if (paramValue != null) pathname += encodeURIComponent(paramValue); + } else { + pathname += token; + } + } + + return pathname.replace(/\/+/g, '/'); + } + +/***/ }, +/* 9 */ +/***/ function(module, exports) { + + /** + * Indicates that navigation was caused by a call to history.push. + */ + 'use strict'; + + exports.__esModule = true; + var PUSH = 'PUSH'; + + exports.PUSH = PUSH; + /** + * Indicates that navigation was caused by a call to history.replace. + */ + var REPLACE = 'REPLACE'; + + exports.REPLACE = REPLACE; + /** + * Indicates that navigation was caused by some other action such + * as using a browser's back/forward buttons and/or manually manipulating + * the URL in a browser's location bar. This is the default. + * + * See https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate + * for more information. + */ + var POP = 'POP'; + + exports.POP = POP; + exports['default'] = { + PUSH: PUSH, + REPLACE: REPLACE, + POP: POP + }; + +/***/ }, +/* 10 */ +/***/ function(module, exports) { + + 'use strict'; + + exports.__esModule = true; + var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); + exports.canUseDOM = canUseDOM; + +/***/ }, +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + var _queryString = __webpack_require__(56); + + var _runTransitionHook = __webpack_require__(17); + + var _runTransitionHook2 = _interopRequireDefault(_runTransitionHook); + + var _PathUtils = __webpack_require__(7); + + var _deprecate = __webpack_require__(16); + + var _deprecate2 = _interopRequireDefault(_deprecate); + + var SEARCH_BASE_KEY = '$searchBase'; + + function defaultStringifyQuery(query) { + return _queryString.stringify(query).replace(/%20/g, '+'); + } + + var defaultParseQueryString = _queryString.parse; + + function isNestedObject(object) { + for (var p in object) { + if (object.hasOwnProperty(p) && typeof object[p] === 'object' && !Array.isArray(object[p]) && object[p] !== null) return true; + }return false; + } + + /** + * Returns a new createHistory function that may be used to create + * history objects that know how to handle URL queries. + */ + function useQueries(createHistory) { + return function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + var stringifyQuery = options.stringifyQuery; + var parseQueryString = options.parseQueryString; + + var historyOptions = _objectWithoutProperties(options, ['stringifyQuery', 'parseQueryString']); + + var history = createHistory(historyOptions); + + if (typeof stringifyQuery !== 'function') stringifyQuery = defaultStringifyQuery; + + if (typeof parseQueryString !== 'function') parseQueryString = defaultParseQueryString; + + function addQuery(location) { + if (location.query == null) { + var search = location.search; + + location.query = parseQueryString(search.substring(1)); + location[SEARCH_BASE_KEY] = { search: search, searchBase: '' }; + } + + // TODO: Instead of all the book-keeping here, this should just strip the + // stringified query from the search. + + return location; + } + + function appendQuery(location, query) { + var _extends2; + + var searchBaseSpec = location[SEARCH_BASE_KEY]; + var queryString = query ? stringifyQuery(query) : ''; + if (!searchBaseSpec && !queryString) { + return location; + } + + false ? _warning2['default'](stringifyQuery !== defaultStringifyQuery || !isNestedObject(query), 'useQueries does not stringify nested query objects by default; ' + 'use a custom stringifyQuery function') : undefined; + + if (typeof location === 'string') location = _PathUtils.parsePath(location); + + var searchBase = undefined; + if (searchBaseSpec && location.search === searchBaseSpec.search) { + searchBase = searchBaseSpec.searchBase; + } else { + searchBase = location.search || ''; + } + + var search = searchBase; + if (queryString) { + search += (search ? '&' : '?') + queryString; + } + + return _extends({}, location, (_extends2 = { + search: search + }, _extends2[SEARCH_BASE_KEY] = { search: search, searchBase: searchBase }, _extends2)); + } + + // Override all read methods with query-aware versions. + function listenBefore(hook) { + return history.listenBefore(function (location, callback) { + _runTransitionHook2['default'](hook, addQuery(location), callback); + }); + } + + function listen(listener) { + return history.listen(function (location) { + listener(addQuery(location)); + }); + } + + // Override all write methods with query-aware versions. + function push(location) { + history.push(appendQuery(location, location.query)); + } + + function replace(location) { + history.replace(appendQuery(location, location.query)); + } + + function createPath(location, query) { + false ? _warning2['default'](!query, 'the query argument to createPath is deprecated; use a location descriptor instead') : undefined; + + return history.createPath(appendQuery(location, query || location.query)); + } + + function createHref(location, query) { + false ? _warning2['default'](!query, 'the query argument to createHref is deprecated; use a location descriptor instead') : undefined; + + return history.createHref(appendQuery(location, query || location.query)); + } + + function createLocation(location) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + var fullLocation = history.createLocation.apply(history, [appendQuery(location, location.query)].concat(args)); + if (location.query) { + fullLocation.query = location.query; + } + return addQuery(fullLocation); + } + + // deprecated + function pushState(state, path, query) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + push(_extends({ state: state }, path, { query: query })); + } + + // deprecated + function replaceState(state, path, query) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + replace(_extends({ state: state }, path, { query: query })); + } + + return _extends({}, history, { + listenBefore: listenBefore, + listen: listen, + push: push, + replace: replace, + createPath: createPath, + createHref: createHref, + createLocation: createLocation, + + pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'), + replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead') + }); + }; + } + + exports['default'] = useQueries; + module.exports = exports['default']; + +/***/ }, +/* 12 */ +/***/ function(module, exports) { + + "use strict"; + + exports.__esModule = true; + var _slice = Array.prototype.slice; + exports.loopAsync = loopAsync; + exports.mapAsync = mapAsync; + + function loopAsync(turns, work, callback) { + var currentTurn = 0, + isDone = false; + var sync = false, + hasNext = false, + doneArgs = undefined; + + function done() { + isDone = true; + if (sync) { + // Iterate instead of recursing if possible. + doneArgs = [].concat(_slice.call(arguments)); + return; + } + + callback.apply(this, arguments); + } + + function next() { + if (isDone) { + return; + } + + hasNext = true; + if (sync) { + // Iterate instead of recursing if possible. + return; + } + + sync = true; + + while (!isDone && currentTurn < turns && hasNext) { + hasNext = false; + work.call(this, currentTurn++, next, done); + } + + sync = false; + + if (isDone) { + // This means the loop finished synchronously. + callback.apply(this, doneArgs); + return; + } + + if (currentTurn >= turns && hasNext) { + isDone = true; + callback(); + } + } + + next(); + } + + function mapAsync(array, work, callback) { + var length = array.length; + var values = []; + + if (length === 0) return callback(null, values); + + var isDone = false, + doneCount = 0; + + function done(index, error, value) { + if (isDone) return; + + if (error) { + isDone = true; + callback(error); + } else { + values[index] = value; + + isDone = ++doneCount === length; + + if (isDone) callback(null, values); + } + } + + array.forEach(function (item, index) { + work(item, index, function (error, value) { + done(index, error, value); + }); + }); + } + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _deprecateObjectProperties = __webpack_require__(23); + + var _deprecateObjectProperties2 = _interopRequireDefault(_deprecateObjectProperties); + + var _getRouteParams = __webpack_require__(43); + + var _getRouteParams2 = _interopRequireDefault(_getRouteParams); + + var _RouteUtils = __webpack_require__(5); + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var _React$PropTypes = _react2['default'].PropTypes; + var array = _React$PropTypes.array; + var func = _React$PropTypes.func; + var object = _React$PropTypes.object; + + /** + * A renders the component tree for a given router state + * and sets the history object and the current location in context. + */ + var RouterContext = _react2['default'].createClass({ + displayName: 'RouterContext', + + propTypes: { + history: object, + router: object.isRequired, + location: object.isRequired, + routes: array.isRequired, + params: object.isRequired, + components: array.isRequired, + createElement: func.isRequired + }, + + getDefaultProps: function getDefaultProps() { + return { + createElement: _react2['default'].createElement + }; + }, + + childContextTypes: { + history: object, + location: object.isRequired, + router: object.isRequired + }, + + getChildContext: function getChildContext() { + var _props = this.props; + var router = _props.router; + var history = _props.history; + var location = _props.location; + + if (!router) { + false ? _routerWarning2['default'](false, '`` expects a `router` rather than a `history`') : undefined; + + router = _extends({}, history, { + setRouteLeaveHook: history.listenBeforeLeavingRoute + }); + delete router.listenBeforeLeavingRoute; + } + + if (false) { + location = _deprecateObjectProperties2['default'](location, '`context.location` is deprecated, please use a route component\'s `props.location` instead. http://tiny.cc/router-accessinglocation'); + } + + return { history: history, location: location, router: router }; + }, + + createElement: function createElement(component, props) { + return component == null ? null : this.props.createElement(component, props); + }, + + render: function render() { + var _this = this; + + var _props2 = this.props; + var history = _props2.history; + var location = _props2.location; + var routes = _props2.routes; + var params = _props2.params; + var components = _props2.components; + + var element = null; + + if (components) { + element = components.reduceRight(function (element, components, index) { + if (components == null) return element; // Don't create new children; use the grandchildren. + + var route = routes[index]; + var routeParams = _getRouteParams2['default'](route, params); + var props = { + history: history, + location: location, + params: params, + route: route, + routeParams: routeParams, + routes: routes + }; + + if (_RouteUtils.isReactChildren(element)) { + props.children = element; + } else if (element) { + for (var prop in element) { + if (element.hasOwnProperty(prop)) props[prop] = element[prop]; + } + } + + if (typeof components === 'object') { + var elements = {}; + + for (var key in components) { + if (components.hasOwnProperty(key)) { + // Pass through the key as a prop to createElement to allow + // custom createElement functions to know which named component + // they're rendering, for e.g. matching up to fetched data. + elements[key] = _this.createElement(components[key], _extends({ + key: key }, props)); + } + } + + return elements; + } + + return _this.createElement(components, props); + }, element); + } + + !(element === null || element === false || _react2['default'].isValidElement(element)) ? false ? _invariant2['default'](false, 'The root route must render a single element') : _invariant2['default'](false) : undefined; + + return element; + } + + }); + + exports['default'] = RouterContext; + module.exports = exports['default']; + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + exports['default'] = createTransitionManager; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var _historyLibActions = __webpack_require__(9); + + var _computeChangedRoutes2 = __webpack_require__(41); + + var _computeChangedRoutes3 = _interopRequireDefault(_computeChangedRoutes2); + + var _TransitionUtils = __webpack_require__(39); + + var _isActive2 = __webpack_require__(45); + + var _isActive3 = _interopRequireDefault(_isActive2); + + var _getComponents = __webpack_require__(42); + + var _getComponents2 = _interopRequireDefault(_getComponents); + + var _matchRoutes = __webpack_require__(47); + + var _matchRoutes2 = _interopRequireDefault(_matchRoutes); + + function hasAnyProperties(object) { + for (var p in object) { + if (object.hasOwnProperty(p)) return true; + }return false; + } + + function createTransitionManager(history, routes) { + var state = {}; + + // Signature should be (location, indexOnly), but needs to support (path, + // query, indexOnly) + function isActive(location) { + var indexOnlyOrDeprecatedQuery = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + var deprecatedIndexOnly = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + + var indexOnly = undefined; + if (indexOnlyOrDeprecatedQuery && indexOnlyOrDeprecatedQuery !== true || deprecatedIndexOnly !== null) { + false ? _routerWarning2['default'](false, '`isActive(pathname, query, indexOnly) is deprecated; use `isActive(location, indexOnly)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated') : undefined; + location = { pathname: location, query: indexOnlyOrDeprecatedQuery }; + indexOnly = deprecatedIndexOnly || false; + } else { + location = history.createLocation(location); + indexOnly = indexOnlyOrDeprecatedQuery; + } + + return _isActive3['default'](location, indexOnly, state.location, state.routes, state.params); + } + + function createLocationFromRedirectInfo(location) { + return history.createLocation(location, _historyLibActions.REPLACE); + } + + var partialNextState = undefined; + + function match(location, callback) { + if (partialNextState && partialNextState.location === location) { + // Continue from where we left off. + finishMatch(partialNextState, callback); + } else { + _matchRoutes2['default'](routes, location, function (error, nextState) { + if (error) { + callback(error); + } else if (nextState) { + finishMatch(_extends({}, nextState, { location: location }), callback); + } else { + callback(); + } + }); + } + } + + function finishMatch(nextState, callback) { + var _computeChangedRoutes = _computeChangedRoutes3['default'](state, nextState); + + var leaveRoutes = _computeChangedRoutes.leaveRoutes; + var enterRoutes = _computeChangedRoutes.enterRoutes; + + _TransitionUtils.runLeaveHooks(leaveRoutes); + + // Tear down confirmation hooks for left routes + leaveRoutes.filter(function (route) { + return enterRoutes.indexOf(route) === -1; + }).forEach(removeListenBeforeHooksForRoute); + + _TransitionUtils.runEnterHooks(enterRoutes, nextState, function (error, redirectInfo) { + if (error) { + callback(error); + } else if (redirectInfo) { + callback(null, createLocationFromRedirectInfo(redirectInfo)); + } else { + // TODO: Fetch components after state is updated. + _getComponents2['default'](nextState, function (error, components) { + if (error) { + callback(error); + } else { + // TODO: Make match a pure function and have some other API + // for "match and update state". + callback(null, null, state = _extends({}, nextState, { components: components })); + } + }); + } + }); + } + + var RouteGuid = 1; + + function getRouteID(route) { + var create = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; + + return route.__id__ || create && (route.__id__ = RouteGuid++); + } + + var RouteHooks = {}; + + function getRouteHooksForRoutes(routes) { + return routes.reduce(function (hooks, route) { + hooks.push.apply(hooks, RouteHooks[getRouteID(route)]); + return hooks; + }, []); + } + + function transitionHook(location, callback) { + _matchRoutes2['default'](routes, location, function (error, nextState) { + if (nextState == null) { + // TODO: We didn't actually match anything, but hang + // onto error/nextState so we don't have to matchRoutes + // again in the listen callback. + callback(); + return; + } + + // Cache some state here so we don't have to + // matchRoutes() again in the listen callback. + partialNextState = _extends({}, nextState, { location: location }); + + var hooks = getRouteHooksForRoutes(_computeChangedRoutes3['default'](state, partialNextState).leaveRoutes); + + var result = undefined; + for (var i = 0, len = hooks.length; result == null && i < len; ++i) { + // Passing the location arg here indicates to + // the user that this is a transition hook. + result = hooks[i](location); + } + + callback(result); + }); + } + + /* istanbul ignore next: untestable with Karma */ + function beforeUnloadHook() { + // Synchronously check to see if any route hooks want + // to prevent the current window/tab from closing. + if (state.routes) { + var hooks = getRouteHooksForRoutes(state.routes); + + var message = undefined; + for (var i = 0, len = hooks.length; typeof message !== 'string' && i < len; ++i) { + // Passing no args indicates to the user that this is a + // beforeunload hook. We don't know the next location. + message = hooks[i](); + } + + return message; + } + } + + var unlistenBefore = undefined, + unlistenBeforeUnload = undefined; + + function removeListenBeforeHooksForRoute(route) { + var routeID = getRouteID(route, false); + if (!routeID) { + return; + } + + delete RouteHooks[routeID]; + + if (!hasAnyProperties(RouteHooks)) { + // teardown transition & beforeunload hooks + if (unlistenBefore) { + unlistenBefore(); + unlistenBefore = null; + } + + if (unlistenBeforeUnload) { + unlistenBeforeUnload(); + unlistenBeforeUnload = null; + } + } + } + + /** + * Registers the given hook function to run before leaving the given route. + * + * During a normal transition, the hook function receives the next location + * as its only argument and must return either a) a prompt message to show + * the user, to make sure they want to leave the page or b) false, to prevent + * the transition. + * + * During the beforeunload event (in browsers) the hook receives no arguments. + * In this case it must return a prompt message to prevent the transition. + * + * Returns a function that may be used to unbind the listener. + */ + function listenBeforeLeavingRoute(route, hook) { + // TODO: Warn if they register for a route that isn't currently + // active. They're probably doing something wrong, like re-creating + // route objects on every location change. + var routeID = getRouteID(route); + var hooks = RouteHooks[routeID]; + + if (!hooks) { + var thereWereNoRouteHooks = !hasAnyProperties(RouteHooks); + + RouteHooks[routeID] = [hook]; + + if (thereWereNoRouteHooks) { + // setup transition & beforeunload hooks + unlistenBefore = history.listenBefore(transitionHook); + + if (history.listenBeforeUnload) unlistenBeforeUnload = history.listenBeforeUnload(beforeUnloadHook); + } + } else { + if (hooks.indexOf(hook) === -1) { + false ? _routerWarning2['default'](false, 'adding multiple leave hooks for the same route is deprecated; manage multiple confirmations in your own code instead') : undefined; + + hooks.push(hook); + } + } + + return function () { + var hooks = RouteHooks[routeID]; + + if (hooks) { + var newHooks = hooks.filter(function (item) { + return item !== hook; + }); + + if (newHooks.length === 0) { + removeListenBeforeHooksForRoute(route); + } else { + RouteHooks[routeID] = newHooks; + } + } + }; + } + + /** + * This is the API for stateful environments. As the location + * changes, we update state and call the listener. We can also + * gracefully handle errors and redirects. + */ + function listen(listener) { + // TODO: Only use a single history listener. Otherwise we'll + // end up with multiple concurrent calls to match. + return history.listen(function (location) { + if (state.location === location) { + listener(null, state); + } else { + match(location, function (error, redirectLocation, nextState) { + if (error) { + listener(error); + } else if (redirectLocation) { + history.transitionTo(redirectLocation); + } else if (nextState) { + listener(null, nextState); + } else { + false ? _routerWarning2['default'](false, 'Location "%s" did not match any routes', location.pathname + location.search + location.hash) : undefined; + } + }); + } + }); + } + + return { + isActive: isActive, + match: match, + listenBeforeLeavingRoute: listenBeforeLeavingRoute, + listen: listen + }; + } + + //export default useRoutes + module.exports = exports['default']; + +/***/ }, +/* 15 */ +/***/ function(module, exports) { + + 'use strict'; + + exports.__esModule = true; + exports.addEventListener = addEventListener; + exports.removeEventListener = removeEventListener; + exports.getHashPath = getHashPath; + exports.replaceHashPath = replaceHashPath; + exports.getWindowPath = getWindowPath; + exports.go = go; + exports.getUserConfirmation = getUserConfirmation; + exports.supportsHistory = supportsHistory; + exports.supportsGoWithoutReloadUsingHash = supportsGoWithoutReloadUsingHash; + + function addEventListener(node, event, listener) { + if (node.addEventListener) { + node.addEventListener(event, listener, false); + } else { + node.attachEvent('on' + event, listener); + } + } + + function removeEventListener(node, event, listener) { + if (node.removeEventListener) { + node.removeEventListener(event, listener, false); + } else { + node.detachEvent('on' + event, listener); + } + } + + function getHashPath() { + // We can't use window.location.hash here because it's not + // consistent across browsers - Firefox will pre-decode it! + return window.location.href.split('#')[1] || ''; + } + + function replaceHashPath(path) { + window.location.replace(window.location.pathname + window.location.search + '#' + path); + } + + function getWindowPath() { + return window.location.pathname + window.location.search + window.location.hash; + } + + function go(n) { + if (n) window.history.go(n); + } + + function getUserConfirmation(message, callback) { + callback(window.confirm(message)); + } + + /** + * Returns true if the HTML5 history API is supported. Taken from Modernizr. + * + * https://github.com/Modernizr/Modernizr/blob/master/LICENSE + * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + * changed to avoid false negatives for Windows Phones: https://github.com/rackt/react-router/issues/586 + */ + + function supportsHistory() { + var ua = navigator.userAgent; + if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) { + return false; + } + return window.history && 'pushState' in window.history; + } + + /** + * Returns false if using go(n) with hash history causes a full page reload. + */ + + function supportsGoWithoutReloadUsingHash() { + var ua = navigator.userAgent; + return ua.indexOf('Firefox') === -1; + } + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + function deprecate(fn, message) { + return function () { + false ? _warning2['default'](false, '[history] ' + message) : undefined; + return fn.apply(this, arguments); + }; + } + + exports['default'] = deprecate; + module.exports = exports['default']; + +/***/ }, +/* 17 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + function runTransitionHook(hook, location, callback) { + var result = hook(location, callback); + + if (hook.length < 2) { + // Assume the hook runs synchronously and automatically + // call the callback with the return value. + callback(result); + } else { + false ? _warning2['default'](result === undefined, 'You should not "return" in a transition hook with a callback argument; call the callback instead') : undefined; + } + } + + exports['default'] = runTransitionHook; + module.exports = exports['default']; + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var _React$PropTypes = _react2['default'].PropTypes; + var bool = _React$PropTypes.bool; + var object = _React$PropTypes.object; + var string = _React$PropTypes.string; + var func = _React$PropTypes.func; + var oneOfType = _React$PropTypes.oneOfType; + + function isLeftClickEvent(event) { + return event.button === 0; + } + + function isModifiedEvent(event) { + return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey); + } + + function isEmptyObject(object) { + for (var p in object) { + if (object.hasOwnProperty(p)) return false; + }return true; + } + + function createLocationDescriptor(to, _ref) { + var query = _ref.query; + var hash = _ref.hash; + var state = _ref.state; + + if (query || hash || state) { + return { pathname: to, query: query, hash: hash, state: state }; + } + + return to; + } + + /** + * A is used to create an element that links to a route. + * When that route is active, the link gets the value of its + * activeClassName prop. + * + * For example, assuming you have the following route: + * + * + * + * You could use the following component to link to that route: + * + * + * + * Links may pass along location state and/or query string parameters + * in the state/query props, respectively. + * + * + */ + var Link = _react2['default'].createClass({ + displayName: 'Link', + + contextTypes: { + router: object + }, + + propTypes: { + to: oneOfType([string, object]).isRequired, + query: object, + hash: string, + state: object, + activeStyle: object, + activeClassName: string, + onlyActiveOnIndex: bool.isRequired, + onClick: func + }, + + getDefaultProps: function getDefaultProps() { + return { + onlyActiveOnIndex: false, + className: '', + style: {} + }; + }, + + handleClick: function handleClick(event) { + var allowTransition = true; + + if (this.props.onClick) this.props.onClick(event); + + if (isModifiedEvent(event) || !isLeftClickEvent(event)) return; + + if (event.defaultPrevented === true) allowTransition = false; + + // If target prop is set (e.g. to "_blank") let browser handle link. + /* istanbul ignore if: untestable with Karma */ + if (this.props.target) { + if (!allowTransition) event.preventDefault(); + + return; + } + + event.preventDefault(); + + if (allowTransition) { + var _props = this.props; + var to = _props.to; + var query = _props.query; + var hash = _props.hash; + var state = _props.state; + + var _location = createLocationDescriptor(to, { query: query, hash: hash, state: state }); + + this.context.router.push(_location); + } + }, + + render: function render() { + var _props2 = this.props; + var to = _props2.to; + var query = _props2.query; + var hash = _props2.hash; + var state = _props2.state; + var activeClassName = _props2.activeClassName; + var activeStyle = _props2.activeStyle; + var onlyActiveOnIndex = _props2.onlyActiveOnIndex; + + var props = _objectWithoutProperties(_props2, ['to', 'query', 'hash', 'state', 'activeClassName', 'activeStyle', 'onlyActiveOnIndex']); + + false ? _routerWarning2['default'](!(query || hash || state), 'the `query`, `hash`, and `state` props on `` are deprecated, use `. http://tiny.cc/router-isActivedeprecated') : undefined; + + // Ignore if rendered outside the context of router, simplifies unit testing. + var router = this.context.router; + + if (router) { + var _location2 = createLocationDescriptor(to, { query: query, hash: hash, state: state }); + props.href = router.createHref(_location2); + + if (activeClassName || activeStyle != null && !isEmptyObject(activeStyle)) { + if (router.isActive(_location2, onlyActiveOnIndex)) { + if (activeClassName) props.className += props.className === '' ? activeClassName : ' ' + activeClassName; + + if (activeStyle) props.style = _extends({}, props.style, activeStyle); + } + } + } + + return _react2['default'].createElement('a', _extends({}, props, { onClick: this.handleClick })); + } + + }); + + exports['default'] = Link; + module.exports = exports['default']; + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _RouteUtils = __webpack_require__(5); + + var _PatternUtils = __webpack_require__(8); + + var _PropTypes = __webpack_require__(6); + + var _React$PropTypes = _react2['default'].PropTypes; + var string = _React$PropTypes.string; + var object = _React$PropTypes.object; + + /** + * A is used to declare another URL path a client should + * be sent to when they request a given URL. + * + * Redirects are placed alongside routes in the route configuration + * and are traversed in the same manner. + */ + var Redirect = _react2['default'].createClass({ + displayName: 'Redirect', + + statics: { + + createRouteFromReactElement: function createRouteFromReactElement(element) { + var route = _RouteUtils.createRouteFromReactElement(element); + + if (route.from) route.path = route.from; + + route.onEnter = function (nextState, replace) { + var location = nextState.location; + var params = nextState.params; + + var pathname = undefined; + if (route.to.charAt(0) === '/') { + pathname = _PatternUtils.formatPattern(route.to, params); + } else if (!route.to) { + pathname = location.pathname; + } else { + var routeIndex = nextState.routes.indexOf(route); + var parentPattern = Redirect.getRoutePattern(nextState.routes, routeIndex - 1); + var pattern = parentPattern.replace(/\/*$/, '/') + route.to; + pathname = _PatternUtils.formatPattern(pattern, params); + } + + replace({ + pathname: pathname, + query: route.query || location.query, + state: route.state || location.state + }); + }; + + return route; + }, + + getRoutePattern: function getRoutePattern(routes, routeIndex) { + var parentPattern = ''; + + for (var i = routeIndex; i >= 0; i--) { + var route = routes[i]; + var pattern = route.path || ''; + + parentPattern = pattern.replace(/\/*$/, '/') + parentPattern; + + if (pattern.indexOf('/') === 0) break; + } + + return '/' + parentPattern; + } + + }, + + propTypes: { + path: string, + from: string, // Alias for path + to: string.isRequired, + query: object, + state: object, + onEnter: _PropTypes.falsy, + children: _PropTypes.falsy + }, + + /* istanbul ignore next: sanity check */ + render: function render() { + true ? false ? _invariant2['default'](false, ' elements are for router configuration only and should not be rendered') : _invariant2['default'](false) : undefined; + } + + }); + + exports['default'] = Redirect; + module.exports = exports['default']; + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + exports.createRouterObject = createRouterObject; + exports.createRoutingHistory = createRoutingHistory; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _deprecateObjectProperties = __webpack_require__(23); + + var _deprecateObjectProperties2 = _interopRequireDefault(_deprecateObjectProperties); + + function createRouterObject(history, transitionManager) { + return _extends({}, history, { + setRouteLeaveHook: transitionManager.listenBeforeLeavingRoute, + isActive: transitionManager.isActive + }); + } + + // deprecated + + function createRoutingHistory(history, transitionManager) { + history = _extends({}, history, transitionManager); + + if (false) { + history = _deprecateObjectProperties2['default'](history, '`props.history` and `context.history` are deprecated. Please use `context.router`. http://tiny.cc/router-contextchanges'); + } + + return history; + } + +/***/ }, +/* 21 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + exports['default'] = createMemoryHistory; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _historyLibUseQueries = __webpack_require__(11); + + var _historyLibUseQueries2 = _interopRequireDefault(_historyLibUseQueries); + + var _historyLibUseBasename = __webpack_require__(29); + + var _historyLibUseBasename2 = _interopRequireDefault(_historyLibUseBasename); + + var _historyLibCreateMemoryHistory = __webpack_require__(55); + + var _historyLibCreateMemoryHistory2 = _interopRequireDefault(_historyLibCreateMemoryHistory); + + function createMemoryHistory(options) { + // signatures and type checking differ between `useRoutes` and + // `createMemoryHistory`, have to create `memoryHistory` first because + // `useQueries` doesn't understand the signature + var memoryHistory = _historyLibCreateMemoryHistory2['default'](options); + var createHistory = function createHistory() { + return memoryHistory; + }; + var history = _historyLibUseQueries2['default'](_historyLibUseBasename2['default'](createHistory))(options); + history.__v2_compatible__ = true; + return history; + } + + module.exports = exports['default']; + +/***/ }, +/* 22 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _useRouterHistory = __webpack_require__(24); + + var _useRouterHistory2 = _interopRequireDefault(_useRouterHistory); + + var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); + + exports['default'] = function (createHistory) { + var history = undefined; + if (canUseDOM) history = _useRouterHistory2['default'](createHistory)(); + return history; + }; + + module.exports = exports['default']; + +/***/ }, +/* 23 */ +/***/ function(module, exports, __webpack_require__) { + + /*eslint no-empty: 0*/ + 'use strict'; + + exports.__esModule = true; + exports['default'] = deprecateObjectProperties; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var useMembrane = false; + + if (false) { + try { + if (Object.defineProperty({}, 'x', { get: function get() { + return true; + } }).x) { + useMembrane = true; + } + } catch (e) {} + } + + // wraps an object in a membrane to warn about deprecated property access + + function deprecateObjectProperties(object, message) { + if (!useMembrane) return object; + + var membrane = {}; + + var _loop = function (prop) { + if (typeof object[prop] === 'function') { + membrane[prop] = function () { + false ? _routerWarning2['default'](false, message) : undefined; + return object[prop].apply(object, arguments); + }; + } else { + Object.defineProperty(membrane, prop, { + configurable: false, + enumerable: false, + get: function get() { + false ? _routerWarning2['default'](false, message) : undefined; + return object[prop]; + } + }); + } + }; + + for (var prop in object) { + _loop(prop); + } + + return membrane; + } + + module.exports = exports['default']; + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + exports['default'] = useRouterHistory; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _historyLibUseQueries = __webpack_require__(11); + + var _historyLibUseQueries2 = _interopRequireDefault(_historyLibUseQueries); + + var _historyLibUseBasename = __webpack_require__(29); + + var _historyLibUseBasename2 = _interopRequireDefault(_historyLibUseBasename); + + function useRouterHistory(createHistory) { + return function (options) { + var history = _historyLibUseQueries2['default'](_historyLibUseBasename2['default'](createHistory))(options); + history.__v2_compatible__ = true; + return history; + }; + } + + module.exports = exports['default']; + +/***/ }, +/* 25 */ +/***/ function(module, exports, __webpack_require__) { + + /*eslint-disable no-empty */ + 'use strict'; + + exports.__esModule = true; + exports.saveState = saveState; + exports.readState = readState; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + var KeyPrefix = '@@History/'; + var QuotaExceededErrors = ['QuotaExceededError', 'QUOTA_EXCEEDED_ERR']; + + var SecurityError = 'SecurityError'; + + function createKey(key) { + return KeyPrefix + key; + } + + function saveState(key, state) { + try { + if (state == null) { + window.sessionStorage.removeItem(createKey(key)); + } else { + window.sessionStorage.setItem(createKey(key), JSON.stringify(state)); + } + } catch (error) { + if (error.name === SecurityError) { + // Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any + // attempt to access window.sessionStorage. + false ? _warning2['default'](false, '[history] Unable to save state; sessionStorage is not available due to security settings') : undefined; + + return; + } + + if (QuotaExceededErrors.indexOf(error.name) >= 0 && window.sessionStorage.length === 0) { + // Safari "private mode" throws QuotaExceededError. + false ? _warning2['default'](false, '[history] Unable to save state; sessionStorage is not available in Safari private mode') : undefined; + + return; + } + + throw error; + } + } + + function readState(key) { + var json = undefined; + try { + json = window.sessionStorage.getItem(createKey(key)); + } catch (error) { + if (error.name === SecurityError) { + // Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any + // attempt to access window.sessionStorage. + false ? _warning2['default'](false, '[history] Unable to read state; sessionStorage is not available due to security settings') : undefined; + + return null; + } + } + + if (json) { + try { + return JSON.parse(json); + } catch (error) { + // Ignore invalid JSON. + } + } + + return null; + } + +/***/ }, +/* 26 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _ExecutionEnvironment = __webpack_require__(10); + + var _DOMUtils = __webpack_require__(15); + + var _createHistory = __webpack_require__(28); + + var _createHistory2 = _interopRequireDefault(_createHistory); + + function createDOMHistory(options) { + var history = _createHistory2['default'](_extends({ + getUserConfirmation: _DOMUtils.getUserConfirmation + }, options, { + go: _DOMUtils.go + })); + + function listen(listener) { + !_ExecutionEnvironment.canUseDOM ? false ? _invariant2['default'](false, 'DOM history needs a DOM') : _invariant2['default'](false) : undefined; + + return history.listen(listener); + } + + return _extends({}, history, { + listen: listen + }); + } + + exports['default'] = createDOMHistory; + module.exports = exports['default']; + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _Actions = __webpack_require__(9); + + var _PathUtils = __webpack_require__(7); + + var _ExecutionEnvironment = __webpack_require__(10); + + var _DOMUtils = __webpack_require__(15); + + var _DOMStateStorage = __webpack_require__(25); + + var _createDOMHistory = __webpack_require__(26); + + var _createDOMHistory2 = _interopRequireDefault(_createDOMHistory); + + function isAbsolutePath(path) { + return typeof path === 'string' && path.charAt(0) === '/'; + } + + function ensureSlash() { + var path = _DOMUtils.getHashPath(); + + if (isAbsolutePath(path)) return true; + + _DOMUtils.replaceHashPath('/' + path); + + return false; + } + + function addQueryStringValueToPath(path, key, value) { + return path + (path.indexOf('?') === -1 ? '?' : '&') + (key + '=' + value); + } + + function stripQueryStringValueFromPath(path, key) { + return path.replace(new RegExp('[?&]?' + key + '=[a-zA-Z0-9]+'), ''); + } + + function getQueryStringValueFromPath(path, key) { + var match = path.match(new RegExp('\\?.*?\\b' + key + '=(.+?)\\b')); + return match && match[1]; + } + + var DefaultQueryKey = '_k'; + + function createHashHistory() { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + !_ExecutionEnvironment.canUseDOM ? false ? _invariant2['default'](false, 'Hash history needs a DOM') : _invariant2['default'](false) : undefined; + + var queryKey = options.queryKey; + + if (queryKey === undefined || !!queryKey) queryKey = typeof queryKey === 'string' ? queryKey : DefaultQueryKey; + + function getCurrentLocation() { + var path = _DOMUtils.getHashPath(); + + var key = undefined, + state = undefined; + if (queryKey) { + key = getQueryStringValueFromPath(path, queryKey); + path = stripQueryStringValueFromPath(path, queryKey); + + if (key) { + state = _DOMStateStorage.readState(key); + } else { + state = null; + key = history.createKey(); + _DOMUtils.replaceHashPath(addQueryStringValueToPath(path, queryKey, key)); + } + } else { + key = state = null; + } + + var location = _PathUtils.parsePath(path); + + return history.createLocation(_extends({}, location, { state: state }), undefined, key); + } + + function startHashChangeListener(_ref) { + var transitionTo = _ref.transitionTo; + + function hashChangeListener() { + if (!ensureSlash()) return; // Always make sure hashes are preceeded with a /. + + transitionTo(getCurrentLocation()); + } + + ensureSlash(); + _DOMUtils.addEventListener(window, 'hashchange', hashChangeListener); + + return function () { + _DOMUtils.removeEventListener(window, 'hashchange', hashChangeListener); + }; + } + + function finishTransition(location) { + var basename = location.basename; + var pathname = location.pathname; + var search = location.search; + var state = location.state; + var action = location.action; + var key = location.key; + + if (action === _Actions.POP) return; // Nothing to do. + + var path = (basename || '') + pathname + search; + + if (queryKey) { + path = addQueryStringValueToPath(path, queryKey, key); + _DOMStateStorage.saveState(key, state); + } else { + // Drop key and state. + location.key = location.state = null; + } + + var currentHash = _DOMUtils.getHashPath(); + + if (action === _Actions.PUSH) { + if (currentHash !== path) { + window.location.hash = path; + } else { + false ? _warning2['default'](false, 'You cannot PUSH the same path using hash history') : undefined; + } + } else if (currentHash !== path) { + // REPLACE + _DOMUtils.replaceHashPath(path); + } + } + + var history = _createDOMHistory2['default'](_extends({}, options, { + getCurrentLocation: getCurrentLocation, + finishTransition: finishTransition, + saveState: _DOMStateStorage.saveState + })); + + var listenerCount = 0, + stopHashChangeListener = undefined; + + function listenBefore(listener) { + if (++listenerCount === 1) stopHashChangeListener = startHashChangeListener(history); + + var unlisten = history.listenBefore(listener); + + return function () { + unlisten(); + + if (--listenerCount === 0) stopHashChangeListener(); + }; + } + + function listen(listener) { + if (++listenerCount === 1) stopHashChangeListener = startHashChangeListener(history); + + var unlisten = history.listen(listener); + + return function () { + unlisten(); + + if (--listenerCount === 0) stopHashChangeListener(); + }; + } + + function push(location) { + false ? _warning2['default'](queryKey || location.state == null, 'You cannot use state without a queryKey it will be dropped') : undefined; + + history.push(location); + } + + function replace(location) { + false ? _warning2['default'](queryKey || location.state == null, 'You cannot use state without a queryKey it will be dropped') : undefined; + + history.replace(location); + } + + var goIsSupportedWithoutReload = _DOMUtils.supportsGoWithoutReloadUsingHash(); + + function go(n) { + false ? _warning2['default'](goIsSupportedWithoutReload, 'Hash history go(n) causes a full page reload in this browser') : undefined; + + history.go(n); + } + + function createHref(path) { + return '#' + history.createHref(path); + } + + // deprecated + function registerTransitionHook(hook) { + if (++listenerCount === 1) stopHashChangeListener = startHashChangeListener(history); + + history.registerTransitionHook(hook); + } + + // deprecated + function unregisterTransitionHook(hook) { + history.unregisterTransitionHook(hook); + + if (--listenerCount === 0) stopHashChangeListener(); + } + + // deprecated + function pushState(state, path) { + false ? _warning2['default'](queryKey || state == null, 'You cannot use state without a queryKey it will be dropped') : undefined; + + history.pushState(state, path); + } + + // deprecated + function replaceState(state, path) { + false ? _warning2['default'](queryKey || state == null, 'You cannot use state without a queryKey it will be dropped') : undefined; + + history.replaceState(state, path); + } + + return _extends({}, history, { + listenBefore: listenBefore, + listen: listen, + push: push, + replace: replace, + go: go, + createHref: createHref, + + registerTransitionHook: registerTransitionHook, // deprecated - warning is in createHistory + unregisterTransitionHook: unregisterTransitionHook, // deprecated - warning is in createHistory + pushState: pushState, // deprecated - warning is in createHistory + replaceState: replaceState // deprecated - warning is in createHistory + }); + } + + exports['default'] = createHashHistory; + module.exports = exports['default']; + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + var _deepEqual = __webpack_require__(49); + + var _deepEqual2 = _interopRequireDefault(_deepEqual); + + var _PathUtils = __webpack_require__(7); + + var _AsyncUtils = __webpack_require__(52); + + var _Actions = __webpack_require__(9); + + var _createLocation2 = __webpack_require__(54); + + var _createLocation3 = _interopRequireDefault(_createLocation2); + + var _runTransitionHook = __webpack_require__(17); + + var _runTransitionHook2 = _interopRequireDefault(_runTransitionHook); + + var _deprecate = __webpack_require__(16); + + var _deprecate2 = _interopRequireDefault(_deprecate); + + function createRandomKey(length) { + return Math.random().toString(36).substr(2, length); + } + + function locationsAreEqual(a, b) { + return a.pathname === b.pathname && a.search === b.search && + //a.action === b.action && // Different action !== location change. + a.key === b.key && _deepEqual2['default'](a.state, b.state); + } + + var DefaultKeyLength = 6; + + function createHistory() { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + var getCurrentLocation = options.getCurrentLocation; + var finishTransition = options.finishTransition; + var saveState = options.saveState; + var go = options.go; + var keyLength = options.keyLength; + var getUserConfirmation = options.getUserConfirmation; + + if (typeof keyLength !== 'number') keyLength = DefaultKeyLength; + + var transitionHooks = []; + + function listenBefore(hook) { + transitionHooks.push(hook); + + return function () { + transitionHooks = transitionHooks.filter(function (item) { + return item !== hook; + }); + }; + } + + var allKeys = []; + var changeListeners = []; + var location = undefined; + + function getCurrent() { + if (pendingLocation && pendingLocation.action === _Actions.POP) { + return allKeys.indexOf(pendingLocation.key); + } else if (location) { + return allKeys.indexOf(location.key); + } else { + return -1; + } + } + + function updateLocation(newLocation) { + var current = getCurrent(); + + location = newLocation; + + if (location.action === _Actions.PUSH) { + allKeys = [].concat(allKeys.slice(0, current + 1), [location.key]); + } else if (location.action === _Actions.REPLACE) { + allKeys[current] = location.key; + } + + changeListeners.forEach(function (listener) { + listener(location); + }); + } + + function listen(listener) { + changeListeners.push(listener); + + if (location) { + listener(location); + } else { + var _location = getCurrentLocation(); + allKeys = [_location.key]; + updateLocation(_location); + } + + return function () { + changeListeners = changeListeners.filter(function (item) { + return item !== listener; + }); + }; + } + + function confirmTransitionTo(location, callback) { + _AsyncUtils.loopAsync(transitionHooks.length, function (index, next, done) { + _runTransitionHook2['default'](transitionHooks[index], location, function (result) { + if (result != null) { + done(result); + } else { + next(); + } + }); + }, function (message) { + if (getUserConfirmation && typeof message === 'string') { + getUserConfirmation(message, function (ok) { + callback(ok !== false); + }); + } else { + callback(message !== false); + } + }); + } + + var pendingLocation = undefined; + + function transitionTo(nextLocation) { + if (location && locationsAreEqual(location, nextLocation)) return; // Nothing to do. + + pendingLocation = nextLocation; + + confirmTransitionTo(nextLocation, function (ok) { + if (pendingLocation !== nextLocation) return; // Transition was interrupted. + + if (ok) { + // treat PUSH to current path like REPLACE to be consistent with browsers + if (nextLocation.action === _Actions.PUSH) { + var prevPath = createPath(location); + var nextPath = createPath(nextLocation); + + if (nextPath === prevPath && _deepEqual2['default'](location.state, nextLocation.state)) nextLocation.action = _Actions.REPLACE; + } + + if (finishTransition(nextLocation) !== false) updateLocation(nextLocation); + } else if (location && nextLocation.action === _Actions.POP) { + var prevIndex = allKeys.indexOf(location.key); + var nextIndex = allKeys.indexOf(nextLocation.key); + + if (prevIndex !== -1 && nextIndex !== -1) go(prevIndex - nextIndex); // Restore the URL. + } + }); + } + + function push(location) { + transitionTo(createLocation(location, _Actions.PUSH, createKey())); + } + + function replace(location) { + transitionTo(createLocation(location, _Actions.REPLACE, createKey())); + } + + function goBack() { + go(-1); + } + + function goForward() { + go(1); + } + + function createKey() { + return createRandomKey(keyLength); + } + + function createPath(location) { + if (location == null || typeof location === 'string') return location; + + var pathname = location.pathname; + var search = location.search; + var hash = location.hash; + + var result = pathname; + + if (search) result += search; + + if (hash) result += hash; + + return result; + } + + function createHref(location) { + return createPath(location); + } + + function createLocation(location, action) { + var key = arguments.length <= 2 || arguments[2] === undefined ? createKey() : arguments[2]; + + if (typeof action === 'object') { + false ? _warning2['default'](false, 'The state (2nd) argument to history.createLocation is deprecated; use a ' + 'location descriptor instead') : undefined; + + if (typeof location === 'string') location = _PathUtils.parsePath(location); + + location = _extends({}, location, { state: action }); + + action = key; + key = arguments[3] || createKey(); + } + + return _createLocation3['default'](location, action, key); + } + + // deprecated + function setState(state) { + if (location) { + updateLocationState(location, state); + updateLocation(location); + } else { + updateLocationState(getCurrentLocation(), state); + } + } + + function updateLocationState(location, state) { + location.state = _extends({}, location.state, state); + saveState(location.key, location.state); + } + + // deprecated + function registerTransitionHook(hook) { + if (transitionHooks.indexOf(hook) === -1) transitionHooks.push(hook); + } + + // deprecated + function unregisterTransitionHook(hook) { + transitionHooks = transitionHooks.filter(function (item) { + return item !== hook; + }); + } + + // deprecated + function pushState(state, path) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + push(_extends({ state: state }, path)); + } + + // deprecated + function replaceState(state, path) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + replace(_extends({ state: state }, path)); + } + + return { + listenBefore: listenBefore, + listen: listen, + transitionTo: transitionTo, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + createKey: createKey, + createPath: createPath, + createHref: createHref, + createLocation: createLocation, + + setState: _deprecate2['default'](setState, 'setState is deprecated; use location.key to save state instead'), + registerTransitionHook: _deprecate2['default'](registerTransitionHook, 'registerTransitionHook is deprecated; use listenBefore instead'), + unregisterTransitionHook: _deprecate2['default'](unregisterTransitionHook, 'unregisterTransitionHook is deprecated; use the callback returned from listenBefore instead'), + pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'), + replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead') + }; + } + + exports['default'] = createHistory; + module.exports = exports['default']; + +/***/ }, +/* 29 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + + var _ExecutionEnvironment = __webpack_require__(10); + + var _PathUtils = __webpack_require__(7); + + var _runTransitionHook = __webpack_require__(17); + + var _runTransitionHook2 = _interopRequireDefault(_runTransitionHook); + + var _deprecate = __webpack_require__(16); + + var _deprecate2 = _interopRequireDefault(_deprecate); + + function useBasename(createHistory) { + return function () { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + var basename = options.basename; + + var historyOptions = _objectWithoutProperties(options, ['basename']); + + var history = createHistory(historyOptions); + + // Automatically use the value of in HTML + // documents as basename if it's not explicitly given. + if (basename == null && _ExecutionEnvironment.canUseDOM) { + var base = document.getElementsByTagName('base')[0]; + + if (base) basename = _PathUtils.extractPath(base.href); + } + + function addBasename(location) { + if (basename && location.basename == null) { + if (location.pathname.indexOf(basename) === 0) { + location.pathname = location.pathname.substring(basename.length); + location.basename = basename; + + if (location.pathname === '') location.pathname = '/'; + } else { + location.basename = ''; + } + } + + return location; + } + + function prependBasename(location) { + if (!basename) return location; + + if (typeof location === 'string') location = _PathUtils.parsePath(location); + + var pname = location.pathname; + var normalizedBasename = basename.slice(-1) === '/' ? basename : basename + '/'; + var normalizedPathname = pname.charAt(0) === '/' ? pname.slice(1) : pname; + var pathname = normalizedBasename + normalizedPathname; + + return _extends({}, location, { + pathname: pathname + }); + } + + // Override all read methods with basename-aware versions. + function listenBefore(hook) { + return history.listenBefore(function (location, callback) { + _runTransitionHook2['default'](hook, addBasename(location), callback); + }); + } + + function listen(listener) { + return history.listen(function (location) { + listener(addBasename(location)); + }); + } + + // Override all write methods with basename-aware versions. + function push(location) { + history.push(prependBasename(location)); + } + + function replace(location) { + history.replace(prependBasename(location)); + } + + function createPath(location) { + return history.createPath(prependBasename(location)); + } + + function createHref(location) { + return history.createHref(prependBasename(location)); + } + + function createLocation(location) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return addBasename(history.createLocation.apply(history, [prependBasename(location)].concat(args))); + } + + // deprecated + function pushState(state, path) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + push(_extends({ state: state }, path)); + } + + // deprecated + function replaceState(state, path) { + if (typeof path === 'string') path = _PathUtils.parsePath(path); + + replace(_extends({ state: state }, path)); + } + + return _extends({}, history, { + listenBefore: listenBefore, + listen: listen, + push: push, + replace: replace, + createPath: createPath, + createHref: createHref, + createLocation: createLocation, + + pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'), + replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead') + }); + }; + } + + exports['default'] = useBasename; + module.exports = exports['default']; + +/***/ }, +/* 30 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var _PropTypes = __webpack_require__(6); + + /** + * A mixin that adds the "history" instance variable to components. + */ + var History = { + + contextTypes: { + history: _PropTypes.history + }, + + componentWillMount: function componentWillMount() { + false ? _routerWarning2['default'](false, 'the `History` mixin is deprecated, please access `context.router` with your own `contextTypes`. http://tiny.cc/router-historymixin') : undefined; + this.history = this.context.history; + } + + }; + + exports['default'] = History; + module.exports = exports['default']; + +/***/ }, +/* 31 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _Link = __webpack_require__(18); + + var _Link2 = _interopRequireDefault(_Link); + + /** + * An is used to link to an . + */ + var IndexLink = _react2['default'].createClass({ + displayName: 'IndexLink', + + render: function render() { + return _react2['default'].createElement(_Link2['default'], _extends({}, this.props, { onlyActiveOnIndex: true })); + } + + }); + + exports['default'] = IndexLink; + module.exports = exports['default']; + +/***/ }, +/* 32 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _Redirect = __webpack_require__(19); + + var _Redirect2 = _interopRequireDefault(_Redirect); + + var _PropTypes = __webpack_require__(6); + + var _React$PropTypes = _react2['default'].PropTypes; + var string = _React$PropTypes.string; + var object = _React$PropTypes.object; + + /** + * An is used to redirect from an indexRoute. + */ + var IndexRedirect = _react2['default'].createClass({ + displayName: 'IndexRedirect', + + statics: { + + createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) { + /* istanbul ignore else: sanity check */ + if (parentRoute) { + parentRoute.indexRoute = _Redirect2['default'].createRouteFromReactElement(element); + } else { + false ? _routerWarning2['default'](false, 'An does not make sense at the root of your route config') : undefined; + } + } + + }, + + propTypes: { + to: string.isRequired, + query: object, + state: object, + onEnter: _PropTypes.falsy, + children: _PropTypes.falsy + }, + + /* istanbul ignore next: sanity check */ + render: function render() { + true ? false ? _invariant2['default'](false, ' elements are for router configuration only and should not be rendered') : _invariant2['default'](false) : undefined; + } + + }); + + exports['default'] = IndexRedirect; + module.exports = exports['default']; + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _RouteUtils = __webpack_require__(5); + + var _PropTypes = __webpack_require__(6); + + var func = _react2['default'].PropTypes.func; + + /** + * An is used to specify its parent's in + * a JSX route config. + */ + var IndexRoute = _react2['default'].createClass({ + displayName: 'IndexRoute', + + statics: { + + createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) { + /* istanbul ignore else: sanity check */ + if (parentRoute) { + parentRoute.indexRoute = _RouteUtils.createRouteFromReactElement(element); + } else { + false ? _routerWarning2['default'](false, 'An does not make sense at the root of your route config') : undefined; + } + } + + }, + + propTypes: { + path: _PropTypes.falsy, + component: _PropTypes.component, + components: _PropTypes.components, + getComponent: func, + getComponents: func + }, + + /* istanbul ignore next: sanity check */ + render: function render() { + true ? false ? _invariant2['default'](false, ' elements are for router configuration only and should not be rendered') : _invariant2['default'](false) : undefined; + } + + }); + + exports['default'] = IndexRoute; + module.exports = exports['default']; + +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var object = _react2['default'].PropTypes.object; + + /** + * The Lifecycle mixin adds the routerWillLeave lifecycle method to a + * component that may be used to cancel a transition or prompt the user + * for confirmation. + * + * On standard transitions, routerWillLeave receives a single argument: the + * location we're transitioning to. To cancel the transition, return false. + * To prompt the user for confirmation, return a prompt message (string). + * + * During the beforeunload event (assuming you're using the useBeforeUnload + * history enhancer), routerWillLeave does not receive a location object + * because it isn't possible for us to know the location we're transitioning + * to. In this case routerWillLeave must return a prompt message to prevent + * the user from closing the window/tab. + */ + var Lifecycle = { + + contextTypes: { + history: object.isRequired, + // Nested children receive the route as context, either + // set by the route component using the RouteContext mixin + // or by some other ancestor. + route: object + }, + + propTypes: { + // Route components receive the route object as a prop. + route: object + }, + + componentDidMount: function componentDidMount() { + false ? _routerWarning2['default'](false, 'the `Lifecycle` mixin is deprecated, please use `context.router.setRouteLeaveHook(route, hook)`. http://tiny.cc/router-lifecyclemixin') : undefined; + !this.routerWillLeave ? false ? _invariant2['default'](false, 'The Lifecycle mixin requires you to define a routerWillLeave method') : _invariant2['default'](false) : undefined; + + var route = this.props.route || this.context.route; + + !route ? false ? _invariant2['default'](false, 'The Lifecycle mixin must be used on either a) a or ' + 'b) a descendant of a that uses the RouteContext mixin') : _invariant2['default'](false) : undefined; + + this._unlistenBeforeLeavingRoute = this.context.history.listenBeforeLeavingRoute(route, this.routerWillLeave); + }, + + componentWillUnmount: function componentWillUnmount() { + if (this._unlistenBeforeLeavingRoute) this._unlistenBeforeLeavingRoute(); + } + + }; + + exports['default'] = Lifecycle; + module.exports = exports['default']; + +/***/ }, +/* 35 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _RouteUtils = __webpack_require__(5); + + var _PropTypes = __webpack_require__(6); + + var _React$PropTypes = _react2['default'].PropTypes; + var string = _React$PropTypes.string; + var func = _React$PropTypes.func; + + /** + * A is used to declare which components are rendered to the + * page when the URL matches a given pattern. + * + * Routes are arranged in a nested tree structure. When a new URL is + * requested, the tree is searched depth-first to find a route whose + * path matches the URL. When one is found, all routes in the tree + * that lead to it are considered "active" and their components are + * rendered into the DOM, nested in the same order as in the tree. + */ + var Route = _react2['default'].createClass({ + displayName: 'Route', + + statics: { + createRouteFromReactElement: _RouteUtils.createRouteFromReactElement + }, + + propTypes: { + path: string, + component: _PropTypes.component, + components: _PropTypes.components, + getComponent: func, + getComponents: func + }, + + /* istanbul ignore next: sanity check */ + render: function render() { + true ? false ? _invariant2['default'](false, ' elements are for router configuration only and should not be rendered') : _invariant2['default'](false) : undefined; + } + + }); + + exports['default'] = Route; + module.exports = exports['default']; + +/***/ }, +/* 36 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var object = _react2['default'].PropTypes.object; + + /** + * The RouteContext mixin provides a convenient way for route + * components to set the route in context. This is needed for + * routes that render elements that want to use the Lifecycle + * mixin to prevent transitions. + */ + var RouteContext = { + + propTypes: { + route: object.isRequired + }, + + childContextTypes: { + route: object.isRequired + }, + + getChildContext: function getChildContext() { + return { + route: this.props.route + }; + }, + + componentWillMount: function componentWillMount() { + false ? _routerWarning2['default'](false, 'The `RouteContext` mixin is deprecated. You can provide `this.props.route` on context with your own `contextTypes`. http://tiny.cc/router-routecontextmixin') : undefined; + } + + }; + + exports['default'] = RouteContext; + module.exports = exports['default']; + +/***/ }, +/* 37 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + + var _historyLibCreateHashHistory = __webpack_require__(27); + + var _historyLibCreateHashHistory2 = _interopRequireDefault(_historyLibCreateHashHistory); + + var _historyLibUseQueries = __webpack_require__(11); + + var _historyLibUseQueries2 = _interopRequireDefault(_historyLibUseQueries); + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _createTransitionManager = __webpack_require__(14); + + var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); + + var _PropTypes = __webpack_require__(6); + + var _RouterContext = __webpack_require__(13); + + var _RouterContext2 = _interopRequireDefault(_RouterContext); + + var _RouteUtils = __webpack_require__(5); + + var _RouterUtils = __webpack_require__(20); + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + function isDeprecatedHistory(history) { + return !history || !history.__v2_compatible__; + } + + var _React$PropTypes = _react2['default'].PropTypes; + var func = _React$PropTypes.func; + var object = _React$PropTypes.object; + + /** + * A is a high-level API for automatically setting up + * a router that renders a with all the props + * it needs each time the URL changes. + */ + var Router = _react2['default'].createClass({ + displayName: 'Router', + + propTypes: { + history: object, + children: _PropTypes.routes, + routes: _PropTypes.routes, // alias for children + render: func, + createElement: func, + onError: func, + onUpdate: func, + + // PRIVATE: For client-side rehydration of server match. + matchContext: object + }, + + getDefaultProps: function getDefaultProps() { + return { + render: function render(props) { + return _react2['default'].createElement(_RouterContext2['default'], props); + } + }; + }, + + getInitialState: function getInitialState() { + return { + location: null, + routes: null, + params: null, + components: null + }; + }, + + handleError: function handleError(error) { + if (this.props.onError) { + this.props.onError.call(this, error); + } else { + // Throw errors by default so we don't silently swallow them! + throw error; // This error probably occurred in getChildRoutes or getComponents. + } + }, + + componentWillMount: function componentWillMount() { + var _this = this; + + var _props = this.props; + var parseQueryString = _props.parseQueryString; + var stringifyQuery = _props.stringifyQuery; + + false ? _routerWarning2['default'](!(parseQueryString || stringifyQuery), '`parseQueryString` and `stringifyQuery` are deprecated. Please create a custom history. http://tiny.cc/router-customquerystring') : undefined; + + var _createRouterObjects = this.createRouterObjects(); + + var history = _createRouterObjects.history; + var transitionManager = _createRouterObjects.transitionManager; + var router = _createRouterObjects.router; + + this._unlisten = transitionManager.listen(function (error, state) { + if (error) { + _this.handleError(error); + } else { + _this.setState(state, _this.props.onUpdate); + } + }); + + this.history = history; + this.router = router; + }, + + createRouterObjects: function createRouterObjects() { + var matchContext = this.props.matchContext; + + if (matchContext) { + return matchContext; + } + + var history = this.props.history; + var _props2 = this.props; + var routes = _props2.routes; + var children = _props2.children; + + if (isDeprecatedHistory(history)) { + history = this.wrapDeprecatedHistory(history); + } + + var transitionManager = _createTransitionManager2['default'](history, _RouteUtils.createRoutes(routes || children)); + var router = _RouterUtils.createRouterObject(history, transitionManager); + var routingHistory = _RouterUtils.createRoutingHistory(history, transitionManager); + + return { history: routingHistory, transitionManager: transitionManager, router: router }; + }, + + wrapDeprecatedHistory: function wrapDeprecatedHistory(history) { + var _props3 = this.props; + var parseQueryString = _props3.parseQueryString; + var stringifyQuery = _props3.stringifyQuery; + + var createHistory = undefined; + if (history) { + false ? _routerWarning2['default'](false, 'It appears you have provided a deprecated history object to ``, please use a history provided by ' + 'React Router with `import { browserHistory } from \'react-router\'` or `import { hashHistory } from \'react-router\'`. ' + 'If you are using a custom history please create it with `useRouterHistory`, see http://tiny.cc/router-usinghistory for details.') : undefined; + createHistory = function () { + return history; + }; + } else { + false ? _routerWarning2['default'](false, '`Router` no longer defaults the history prop to hash history. Please use the `hashHistory` singleton instead. http://tiny.cc/router-defaulthistory') : undefined; + createHistory = _historyLibCreateHashHistory2['default']; + } + + return _historyLibUseQueries2['default'](createHistory)({ parseQueryString: parseQueryString, stringifyQuery: stringifyQuery }); + }, + + /* istanbul ignore next: sanity check */ + componentWillReceiveProps: function componentWillReceiveProps(nextProps) { + false ? _routerWarning2['default'](nextProps.history === this.props.history, 'You cannot change ; it will be ignored') : undefined; + + false ? _routerWarning2['default']((nextProps.routes || nextProps.children) === (this.props.routes || this.props.children), 'You cannot change ; it will be ignored') : undefined; + }, + + componentWillUnmount: function componentWillUnmount() { + if (this._unlisten) this._unlisten(); + }, + + render: function render() { + var _state = this.state; + var location = _state.location; + var routes = _state.routes; + var params = _state.params; + var components = _state.components; + var _props4 = this.props; + var createElement = _props4.createElement; + var render = _props4.render; + + var props = _objectWithoutProperties(_props4, ['createElement', 'render']); + + if (location == null) return null; // Async match + + // Only forward non-Router-specific props to routing context, as those are + // the only ones that might be custom routing context props. + Object.keys(Router.propTypes).forEach(function (propType) { + return delete props[propType]; + }); + + return render(_extends({}, props, { + history: this.history, + router: this.router, + location: location, + routes: routes, + params: params, + components: components, + createElement: createElement + })); + } + + }); + + exports['default'] = Router; + module.exports = exports['default']; + +/***/ }, +/* 38 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _react = __webpack_require__(2); + + var _react2 = _interopRequireDefault(_react); + + var _RouterContext = __webpack_require__(13); + + var _RouterContext2 = _interopRequireDefault(_RouterContext); + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var RoutingContext = _react2['default'].createClass({ + displayName: 'RoutingContext', + + componentWillMount: function componentWillMount() { + false ? _routerWarning2['default'](false, '`RoutingContext` has been renamed to `RouterContext`. Please use `import { RouterContext } from \'react-router\'`. http://tiny.cc/router-routercontext') : undefined; + }, + + render: function render() { + return _react2['default'].createElement(_RouterContext2['default'], this.props); + } + }); + + exports['default'] = RoutingContext; + module.exports = exports['default']; + +/***/ }, +/* 39 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + exports.runEnterHooks = runEnterHooks; + exports.runLeaveHooks = runLeaveHooks; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _AsyncUtils = __webpack_require__(12); + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + function createEnterHook(hook, route) { + return function (a, b, callback) { + hook.apply(route, arguments); + + if (hook.length < 3) { + // Assume hook executes synchronously and + // automatically call the callback. + callback(); + } + }; + } + + function getEnterHooks(routes) { + return routes.reduce(function (hooks, route) { + if (route.onEnter) hooks.push(createEnterHook(route.onEnter, route)); + + return hooks; + }, []); + } + + /** + * Runs all onEnter hooks in the given array of routes in order + * with onEnter(nextState, replace, callback) and calls + * callback(error, redirectInfo) when finished. The first hook + * to use replace short-circuits the loop. + * + * If a hook needs to run asynchronously, it may use the callback + * function. However, doing so will cause the transition to pause, + * which could lead to a non-responsive UI if the hook is slow. + */ + + function runEnterHooks(routes, nextState, callback) { + var hooks = getEnterHooks(routes); + + if (!hooks.length) { + callback(); + return; + } + + var redirectInfo = undefined; + function replace(location, deprecatedPathname, deprecatedQuery) { + if (deprecatedPathname) { + false ? _routerWarning2['default'](false, '`replaceState(state, pathname, query) is deprecated; use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated') : undefined; + redirectInfo = { + pathname: deprecatedPathname, + query: deprecatedQuery, + state: location + }; + + return; + } + + redirectInfo = location; + } + + _AsyncUtils.loopAsync(hooks.length, function (index, next, done) { + hooks[index](nextState, replace, function (error) { + if (error || redirectInfo) { + done(error, redirectInfo); // No need to continue. + } else { + next(); + } + }); + }, callback); + } + + /** + * Runs all onLeave hooks in the given array of routes in order. + */ + + function runLeaveHooks(routes) { + for (var i = 0, len = routes.length; i < len; ++i) { + if (routes[i].onLeave) routes[i].onLeave.call(routes[i]); + } + } + +/***/ }, +/* 40 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _historyLibCreateBrowserHistory = __webpack_require__(53); + + var _historyLibCreateBrowserHistory2 = _interopRequireDefault(_historyLibCreateBrowserHistory); + + var _createRouterHistory = __webpack_require__(22); + + var _createRouterHistory2 = _interopRequireDefault(_createRouterHistory); + + exports['default'] = _createRouterHistory2['default'](_historyLibCreateBrowserHistory2['default']); + module.exports = exports['default']; + +/***/ }, +/* 41 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _PatternUtils = __webpack_require__(8); + + function routeParamsChanged(route, prevState, nextState) { + if (!route.path) return false; + + var paramNames = _PatternUtils.getParamNames(route.path); + + return paramNames.some(function (paramName) { + return prevState.params[paramName] !== nextState.params[paramName]; + }); + } + + /** + * Returns an object of { leaveRoutes, enterRoutes } determined by + * the change from prevState to nextState. We leave routes if either + * 1) they are not in the next state or 2) they are in the next state + * but their params have changed (i.e. /users/123 => /users/456). + * + * leaveRoutes are ordered starting at the leaf route of the tree + * we're leaving up to the common parent route. enterRoutes are ordered + * from the top of the tree we're entering down to the leaf route. + */ + function computeChangedRoutes(prevState, nextState) { + var prevRoutes = prevState && prevState.routes; + var nextRoutes = nextState.routes; + + var leaveRoutes = undefined, + enterRoutes = undefined; + if (prevRoutes) { + (function () { + var parentIsLeaving = false; + leaveRoutes = prevRoutes.filter(function (route) { + if (parentIsLeaving) { + return true; + } else { + var isLeaving = nextRoutes.indexOf(route) === -1 || routeParamsChanged(route, prevState, nextState); + if (isLeaving) parentIsLeaving = true; + return isLeaving; + } + }); + + // onLeave hooks start at the leaf route. + leaveRoutes.reverse(); + + enterRoutes = nextRoutes.filter(function (route) { + return prevRoutes.indexOf(route) === -1 || leaveRoutes.indexOf(route) !== -1; + }); + })(); + } else { + leaveRoutes = []; + enterRoutes = nextRoutes; + } + + return { + leaveRoutes: leaveRoutes, + enterRoutes: enterRoutes + }; + } + + exports['default'] = computeChangedRoutes; + module.exports = exports['default']; + +/***/ }, +/* 42 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _AsyncUtils = __webpack_require__(12); + + function getComponentsForRoute(location, route, callback) { + if (route.component || route.components) { + callback(null, route.component || route.components); + } else if (route.getComponent) { + route.getComponent(location, callback); + } else if (route.getComponents) { + route.getComponents(location, callback); + } else { + callback(); + } + } + + /** + * Asynchronously fetches all components needed for the given router + * state and calls callback(error, components) when finished. + * + * Note: This operation may finish synchronously if no routes have an + * asynchronous getComponents method. + */ + function getComponents(nextState, callback) { + _AsyncUtils.mapAsync(nextState.routes, function (route, index, callback) { + getComponentsForRoute(nextState.location, route, callback); + }, callback); + } + + exports['default'] = getComponents; + module.exports = exports['default']; + +/***/ }, +/* 43 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _PatternUtils = __webpack_require__(8); + + /** + * Extracts an object of params the given route cares about from + * the given params object. + */ + function getRouteParams(route, params) { + var routeParams = {}; + + if (!route.path) return routeParams; + + var paramNames = _PatternUtils.getParamNames(route.path); + + for (var p in params) { + if (params.hasOwnProperty(p) && paramNames.indexOf(p) !== -1) routeParams[p] = params[p]; + }return routeParams; + } + + exports['default'] = getRouteParams; + module.exports = exports['default']; + +/***/ }, +/* 44 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _historyLibCreateHashHistory = __webpack_require__(27); + + var _historyLibCreateHashHistory2 = _interopRequireDefault(_historyLibCreateHashHistory); + + var _createRouterHistory = __webpack_require__(22); + + var _createRouterHistory2 = _interopRequireDefault(_createRouterHistory); + + exports['default'] = _createRouterHistory2['default'](_historyLibCreateHashHistory2['default']); + module.exports = exports['default']; + +/***/ }, +/* 45 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + exports['default'] = isActive; + + var _PatternUtils = __webpack_require__(8); + + function deepEqual(a, b) { + if (a == b) return true; + + if (a == null || b == null) return false; + + if (Array.isArray(a)) { + return Array.isArray(b) && a.length === b.length && a.every(function (item, index) { + return deepEqual(item, b[index]); + }); + } + + if (typeof a === 'object') { + for (var p in a) { + if (!a.hasOwnProperty(p)) { + continue; + } + + if (a[p] === undefined) { + if (b[p] !== undefined) { + return false; + } + } else if (!b.hasOwnProperty(p)) { + return false; + } else if (!deepEqual(a[p], b[p])) { + return false; + } + } + + return true; + } + + return String(a) === String(b); + } + + function paramsAreActive(paramNames, paramValues, activeParams) { + // FIXME: This doesn't work on repeated params in activeParams. + return paramNames.every(function (paramName, index) { + return String(paramValues[index]) === String(activeParams[paramName]); + }); + } + + function getMatchingRouteIndex(pathname, activeRoutes, activeParams) { + var remainingPathname = pathname, + paramNames = [], + paramValues = []; + + for (var i = 0, len = activeRoutes.length; i < len; ++i) { + var route = activeRoutes[i]; + var pattern = route.path || ''; + + if (pattern.charAt(0) === '/') { + remainingPathname = pathname; + paramNames = []; + paramValues = []; + } + + if (remainingPathname !== null) { + var matched = _PatternUtils.matchPattern(pattern, remainingPathname); + remainingPathname = matched.remainingPathname; + paramNames = [].concat(paramNames, matched.paramNames); + paramValues = [].concat(paramValues, matched.paramValues); + } + + if (remainingPathname === '' && route.path && paramsAreActive(paramNames, paramValues, activeParams)) return i; + } + + return null; + } + + /** + * Returns true if the given pathname matches the active routes + * and params. + */ + function routeIsActive(pathname, routes, params, indexOnly) { + var i = getMatchingRouteIndex(pathname, routes, params); + + if (i === null) { + // No match. + return false; + } else if (!indexOnly) { + // Any match is good enough. + return true; + } + + // If any remaining routes past the match index have paths, then we can't + // be on the index route. + return routes.slice(i + 1).every(function (route) { + return !route.path; + }); + } + + /** + * Returns true if all key/value pairs in the given query are + * currently active. + */ + function queryIsActive(query, activeQuery) { + if (activeQuery == null) return query == null; + + if (query == null) return true; + + return deepEqual(query, activeQuery); + } + + /** + * Returns true if a to the given pathname/query combination is + * currently active. + */ + + function isActive(_ref, indexOnly, currentLocation, routes, params) { + var pathname = _ref.pathname; + var query = _ref.query; + + if (currentLocation == null) return false; + + if (!routeIsActive(pathname, routes, params, indexOnly)) return false; + + return queryIsActive(query, currentLocation.query); + } + + module.exports = exports['default']; + +/***/ }, +/* 46 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _createMemoryHistory = __webpack_require__(21); + + var _createMemoryHistory2 = _interopRequireDefault(_createMemoryHistory); + + var _createTransitionManager = __webpack_require__(14); + + var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); + + var _RouteUtils = __webpack_require__(5); + + var _RouterUtils = __webpack_require__(20); + + /** + * A high-level API to be used for server-side rendering. + * + * This function matches a location to a set of routes and calls + * callback(error, redirectLocation, renderProps) when finished. + * + * Note: You probably don't want to use this in a browser unless you're using + * server-side rendering with async routes. + */ + function match(_ref, callback) { + var history = _ref.history; + var routes = _ref.routes; + var location = _ref.location; + + var options = _objectWithoutProperties(_ref, ['history', 'routes', 'location']); + + !(history || location) ? false ? _invariant2['default'](false, 'match needs a history or a location') : _invariant2['default'](false) : undefined; + + history = history ? history : _createMemoryHistory2['default'](options); + var transitionManager = _createTransitionManager2['default'](history, _RouteUtils.createRoutes(routes)); + + var unlisten = undefined; + + if (location) { + // Allow match({ location: '/the/path', ... }) + location = history.createLocation(location); + } else { + // Pick up the location from the history via synchronous history.listen + // call if needed. + unlisten = history.listen(function (historyLocation) { + location = historyLocation; + }); + } + + var router = _RouterUtils.createRouterObject(history, transitionManager); + history = _RouterUtils.createRoutingHistory(history, transitionManager); + + transitionManager.match(location, function (error, redirectLocation, nextState) { + callback(error, redirectLocation, nextState && _extends({}, nextState, { + history: history, + router: router, + matchContext: { history: history, transitionManager: transitionManager, router: router } + })); + + // Defer removing the listener to here to prevent DOM histories from having + // to unwind DOM event listeners unnecessarily, in case callback renders a + // and attaches another history listener. + if (unlisten) { + unlisten(); + } + }); + } + + exports['default'] = match; + module.exports = exports['default']; + +/***/ }, +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + var _AsyncUtils = __webpack_require__(12); + + var _PatternUtils = __webpack_require__(8); + + var _RouteUtils = __webpack_require__(5); + + function getChildRoutes(route, location, callback) { + if (route.childRoutes) { + return [null, route.childRoutes]; + } + if (!route.getChildRoutes) { + return []; + } + + var sync = true, + result = undefined; + + route.getChildRoutes(location, function (error, childRoutes) { + childRoutes = !error && _RouteUtils.createRoutes(childRoutes); + if (sync) { + result = [error, childRoutes]; + return; + } + + callback(error, childRoutes); + }); + + sync = false; + return result; // Might be undefined. + } + + function getIndexRoute(route, location, callback) { + if (route.indexRoute) { + callback(null, route.indexRoute); + } else if (route.getIndexRoute) { + route.getIndexRoute(location, function (error, indexRoute) { + callback(error, !error && _RouteUtils.createRoutes(indexRoute)[0]); + }); + } else if (route.childRoutes) { + (function () { + var pathless = route.childRoutes.filter(function (obj) { + return !obj.hasOwnProperty('path'); + }); + + _AsyncUtils.loopAsync(pathless.length, function (index, next, done) { + getIndexRoute(pathless[index], location, function (error, indexRoute) { + if (error || indexRoute) { + var routes = [pathless[index]].concat(Array.isArray(indexRoute) ? indexRoute : [indexRoute]); + done(error, routes); + } else { + next(); + } + }); + }, function (err, routes) { + callback(null, routes); + }); + })(); + } else { + callback(); + } + } + + function assignParams(params, paramNames, paramValues) { + return paramNames.reduce(function (params, paramName, index) { + var paramValue = paramValues && paramValues[index]; + + if (Array.isArray(params[paramName])) { + params[paramName].push(paramValue); + } else if (paramName in params) { + params[paramName] = [params[paramName], paramValue]; + } else { + params[paramName] = paramValue; + } + + return params; + }, params); + } + + function createParams(paramNames, paramValues) { + return assignParams({}, paramNames, paramValues); + } + + function matchRouteDeep(route, location, remainingPathname, paramNames, paramValues, callback) { + var pattern = route.path || ''; + + if (pattern.charAt(0) === '/') { + remainingPathname = location.pathname; + paramNames = []; + paramValues = []; + } + + if (remainingPathname !== null) { + var matched = _PatternUtils.matchPattern(pattern, remainingPathname); + remainingPathname = matched.remainingPathname; + paramNames = [].concat(paramNames, matched.paramNames); + paramValues = [].concat(paramValues, matched.paramValues); + + if (remainingPathname === '' && route.path) { + var _ret2 = (function () { + var match = { + routes: [route], + params: createParams(paramNames, paramValues) + }; + + getIndexRoute(route, location, function (error, indexRoute) { + if (error) { + callback(error); + } else { + if (Array.isArray(indexRoute)) { + var _match$routes; + + false ? _routerWarning2['default'](indexRoute.every(function (route) { + return !route.path; + }), 'Index routes should not have paths') : undefined; + (_match$routes = match.routes).push.apply(_match$routes, indexRoute); + } else if (indexRoute) { + false ? _routerWarning2['default'](!indexRoute.path, 'Index routes should not have paths') : undefined; + match.routes.push(indexRoute); + } + + callback(null, match); + } + }); + return { + v: undefined + }; + })(); + + if (typeof _ret2 === 'object') return _ret2.v; + } + } + + if (remainingPathname != null || route.childRoutes) { + // Either a) this route matched at least some of the path or b) + // we don't have to load this route's children asynchronously. In + // either case continue checking for matches in the subtree. + var onChildRoutes = function onChildRoutes(error, childRoutes) { + if (error) { + callback(error); + } else if (childRoutes) { + // Check the child routes to see if any of them match. + matchRoutes(childRoutes, location, function (error, match) { + if (error) { + callback(error); + } else if (match) { + // A child route matched! Augment the match and pass it up the stack. + match.routes.unshift(route); + callback(null, match); + } else { + callback(); + } + }, remainingPathname, paramNames, paramValues); + } else { + callback(); + } + }; + + var result = getChildRoutes(route, location, onChildRoutes); + if (result) { + onChildRoutes.apply(undefined, result); + } + } else { + callback(); + } + } + + /** + * Asynchronously matches the given location to a set of routes and calls + * callback(error, state) when finished. The state object will have the + * following properties: + * + * - routes An array of routes that matched, in hierarchical order + * - params An object of URL parameters + * + * Note: This operation may finish synchronously if no routes have an + * asynchronous getChildRoutes method. + */ + function matchRoutes(routes, location, callback) { + var remainingPathname = arguments.length <= 3 || arguments[3] === undefined ? location.pathname : arguments[3]; + var paramNames = arguments.length <= 4 || arguments[4] === undefined ? [] : arguments[4]; + var paramValues = arguments.length <= 5 || arguments[5] === undefined ? [] : arguments[5]; + return (function () { + _AsyncUtils.loopAsync(routes.length, function (index, next, done) { + matchRouteDeep(routes[index], location, remainingPathname, paramNames, paramValues, function (error, match) { + if (error || match) { + done(error, match); + } else { + next(); + } + }); + }, callback); + })(); + } + + exports['default'] = matchRoutes; + module.exports = exports['default']; + +/***/ }, +/* 48 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + + var _historyLibUseQueries = __webpack_require__(11); + + var _historyLibUseQueries2 = _interopRequireDefault(_historyLibUseQueries); + + var _createTransitionManager = __webpack_require__(14); + + var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); + + var _routerWarning = __webpack_require__(1); + + var _routerWarning2 = _interopRequireDefault(_routerWarning); + + /** + * Returns a new createHistory function that may be used to create + * history objects that know about routing. + * + * Enhances history objects with the following methods: + * + * - listen((error, nextState) => {}) + * - listenBeforeLeavingRoute(route, (nextLocation) => {}) + * - match(location, (error, redirectLocation, nextState) => {}) + * - isActive(pathname, query, indexOnly=false) + */ + function useRoutes(createHistory) { + false ? _routerWarning2['default'](false, '`useRoutes` is deprecated. Please use `createTransitionManager` instead.') : undefined; + + return function () { + var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + var routes = _ref.routes; + + var options = _objectWithoutProperties(_ref, ['routes']); + + var history = _historyLibUseQueries2['default'](createHistory)(options); + var transitionManager = _createTransitionManager2['default'](history, routes); + return _extends({}, history, transitionManager); + }; + } + + exports['default'] = useRoutes; + module.exports = exports['default']; + +/***/ }, +/* 49 */ +/***/ function(module, exports, __webpack_require__) { + + var pSlice = Array.prototype.slice; + var objectKeys = __webpack_require__(51); + var isArguments = __webpack_require__(50); + + var deepEqual = module.exports = function (actual, expected, opts) { + if (!opts) opts = {}; + // 7.1. All identical values are equivalent, as determined by ===. + if (actual === expected) { + return true; + + } else if (actual instanceof Date && expected instanceof Date) { + return actual.getTime() === expected.getTime(); + + // 7.3. Other pairs that do not both pass typeof value == 'object', + // equivalence is determined by ==. + } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') { + return opts.strict ? actual === expected : actual == expected; + + // 7.4. For all other Object pairs, including Array objects, equivalence is + // determined by having the same number of owned properties (as verified + // with Object.prototype.hasOwnProperty.call), the same set of keys + // (although not necessarily the same order), equivalent values for every + // corresponding key, and an identical 'prototype' property. Note: this + // accounts for both named and indexed properties on Arrays. + } else { + return objEquiv(actual, expected, opts); + } + } + + function isUndefinedOrNull(value) { + return value === null || value === undefined; + } + + function isBuffer (x) { + if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false; + if (typeof x.copy !== 'function' || typeof x.slice !== 'function') { + return false; + } + if (x.length > 0 && typeof x[0] !== 'number') return false; + return true; + } + + function objEquiv(a, b, opts) { + var i, key; + if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) + return false; + // an identical 'prototype' property. + if (a.prototype !== b.prototype) return false; + //~~~I've managed to break Object.keys through screwy arguments passing. + // Converting to array solves the problem. + if (isArguments(a)) { + if (!isArguments(b)) { + return false; + } + a = pSlice.call(a); + b = pSlice.call(b); + return deepEqual(a, b, opts); + } + if (isBuffer(a)) { + if (!isBuffer(b)) { + return false; + } + if (a.length !== b.length) return false; + for (i = 0; i < a.length; i++) { + if (a[i] !== b[i]) return false; + } + return true; + } + try { + var ka = objectKeys(a), + kb = objectKeys(b); + } catch (e) {//happens when one is a string literal and the other isn't + return false; + } + // having the same number of owned properties (keys incorporates + // hasOwnProperty) + if (ka.length != kb.length) + return false; + //the same set of keys (although not necessarily the same order), + ka.sort(); + kb.sort(); + //~~~cheap key test + for (i = ka.length - 1; i >= 0; i--) { + if (ka[i] != kb[i]) + return false; + } + //equivalent values for every corresponding key, and + //~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!deepEqual(a[key], b[key], opts)) return false; + } + return typeof a === typeof b; + } + + +/***/ }, +/* 50 */ +/***/ function(module, exports) { + + var supportsArgumentsClass = (function(){ + return Object.prototype.toString.call(arguments) + })() == '[object Arguments]'; + + exports = module.exports = supportsArgumentsClass ? supported : unsupported; + + exports.supported = supported; + function supported(object) { + return Object.prototype.toString.call(object) == '[object Arguments]'; + }; + + exports.unsupported = unsupported; + function unsupported(object){ + return object && + typeof object == 'object' && + typeof object.length == 'number' && + Object.prototype.hasOwnProperty.call(object, 'callee') && + !Object.prototype.propertyIsEnumerable.call(object, 'callee') || + false; + }; + + +/***/ }, +/* 51 */ +/***/ function(module, exports) { + + exports = module.exports = typeof Object.keys === 'function' + ? Object.keys : shim; + + exports.shim = shim; + function shim (obj) { + var keys = []; + for (var key in obj) keys.push(key); + return keys; + } + + +/***/ }, +/* 52 */ +/***/ function(module, exports) { + + "use strict"; + + exports.__esModule = true; + exports.loopAsync = loopAsync; + + function loopAsync(turns, work, callback) { + var currentTurn = 0; + var isDone = false; + + function done() { + isDone = true; + callback.apply(this, arguments); + } + + function next() { + if (isDone) return; + + if (currentTurn < turns) { + work.call(this, currentTurn++, next, done); + } else { + done.apply(this, arguments); + } + } + + next(); + } + +/***/ }, +/* 53 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _Actions = __webpack_require__(9); + + var _PathUtils = __webpack_require__(7); + + var _ExecutionEnvironment = __webpack_require__(10); + + var _DOMUtils = __webpack_require__(15); + + var _DOMStateStorage = __webpack_require__(25); + + var _createDOMHistory = __webpack_require__(26); + + var _createDOMHistory2 = _interopRequireDefault(_createDOMHistory); + + /** + * Creates and returns a history object that uses HTML5's history API + * (pushState, replaceState, and the popstate event) to manage history. + * This is the recommended method of managing history in browsers because + * it provides the cleanest URLs. + * + * Note: In browsers that do not support the HTML5 history API full + * page reloads will be used to preserve URLs. + */ + function createBrowserHistory() { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + !_ExecutionEnvironment.canUseDOM ? false ? _invariant2['default'](false, 'Browser history needs a DOM') : _invariant2['default'](false) : undefined; + + var forceRefresh = options.forceRefresh; + + var isSupported = _DOMUtils.supportsHistory(); + var useRefresh = !isSupported || forceRefresh; + + function getCurrentLocation(historyState) { + historyState = historyState || window.history.state || {}; + + var path = _DOMUtils.getWindowPath(); + var _historyState = historyState; + var key = _historyState.key; + + var state = undefined; + if (key) { + state = _DOMStateStorage.readState(key); + } else { + state = null; + key = history.createKey(); + + if (isSupported) window.history.replaceState(_extends({}, historyState, { key: key }), null, path); + } + + var location = _PathUtils.parsePath(path); + + return history.createLocation(_extends({}, location, { state: state }), undefined, key); + } + + function startPopStateListener(_ref) { + var transitionTo = _ref.transitionTo; + + function popStateListener(event) { + if (event.state === undefined) return; // Ignore extraneous popstate events in WebKit. + + transitionTo(getCurrentLocation(event.state)); + } + + _DOMUtils.addEventListener(window, 'popstate', popStateListener); + + return function () { + _DOMUtils.removeEventListener(window, 'popstate', popStateListener); + }; + } + + function finishTransition(location) { + var basename = location.basename; + var pathname = location.pathname; + var search = location.search; + var hash = location.hash; + var state = location.state; + var action = location.action; + var key = location.key; + + if (action === _Actions.POP) return; // Nothing to do. + + _DOMStateStorage.saveState(key, state); + + var path = (basename || '') + pathname + search + hash; + var historyState = { + key: key + }; + + if (action === _Actions.PUSH) { + if (useRefresh) { + window.location.href = path; + return false; // Prevent location update. + } else { + window.history.pushState(historyState, null, path); + } + } else { + // REPLACE + if (useRefresh) { + window.location.replace(path); + return false; // Prevent location update. + } else { + window.history.replaceState(historyState, null, path); + } + } + } + + var history = _createDOMHistory2['default'](_extends({}, options, { + getCurrentLocation: getCurrentLocation, + finishTransition: finishTransition, + saveState: _DOMStateStorage.saveState + })); + + var listenerCount = 0, + stopPopStateListener = undefined; + + function listenBefore(listener) { + if (++listenerCount === 1) stopPopStateListener = startPopStateListener(history); + + var unlisten = history.listenBefore(listener); + + return function () { + unlisten(); + + if (--listenerCount === 0) stopPopStateListener(); + }; + } + + function listen(listener) { + if (++listenerCount === 1) stopPopStateListener = startPopStateListener(history); + + var unlisten = history.listen(listener); + + return function () { + unlisten(); + + if (--listenerCount === 0) stopPopStateListener(); + }; + } + + // deprecated + function registerTransitionHook(hook) { + if (++listenerCount === 1) stopPopStateListener = startPopStateListener(history); + + history.registerTransitionHook(hook); + } + + // deprecated + function unregisterTransitionHook(hook) { + history.unregisterTransitionHook(hook); + + if (--listenerCount === 0) stopPopStateListener(); + } + + return _extends({}, history, { + listenBefore: listenBefore, + listen: listen, + registerTransitionHook: registerTransitionHook, + unregisterTransitionHook: unregisterTransitionHook + }); + } + + exports['default'] = createBrowserHistory; + module.exports = exports['default']; + +/***/ }, +/* 54 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + var _Actions = __webpack_require__(9); + + var _PathUtils = __webpack_require__(7); + + function createLocation() { + var location = arguments.length <= 0 || arguments[0] === undefined ? '/' : arguments[0]; + var action = arguments.length <= 1 || arguments[1] === undefined ? _Actions.POP : arguments[1]; + var key = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; + + var _fourthArg = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + + if (typeof location === 'string') location = _PathUtils.parsePath(location); + + if (typeof action === 'object') { + false ? _warning2['default'](false, 'The state (2nd) argument to createLocation is deprecated; use a ' + 'location descriptor instead') : undefined; + + location = _extends({}, location, { state: action }); + + action = key || _Actions.POP; + key = _fourthArg; + } + + var pathname = location.pathname || '/'; + var search = location.search || ''; + var hash = location.hash || ''; + var state = location.state || null; + + return { + pathname: pathname, + search: search, + hash: hash, + state: state, + action: action, + key: key + }; + } + + exports['default'] = createLocation; + module.exports = exports['default']; + +/***/ }, +/* 55 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _warning = __webpack_require__(4); + + var _warning2 = _interopRequireDefault(_warning); + + var _invariant = __webpack_require__(3); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _PathUtils = __webpack_require__(7); + + var _Actions = __webpack_require__(9); + + var _createHistory = __webpack_require__(28); + + var _createHistory2 = _interopRequireDefault(_createHistory); + + function createStateStorage(entries) { + return entries.filter(function (entry) { + return entry.state; + }).reduce(function (memo, entry) { + memo[entry.key] = entry.state; + return memo; + }, {}); + } + + function createMemoryHistory() { + var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + + if (Array.isArray(options)) { + options = { entries: options }; + } else if (typeof options === 'string') { + options = { entries: [options] }; + } + + var history = _createHistory2['default'](_extends({}, options, { + getCurrentLocation: getCurrentLocation, + finishTransition: finishTransition, + saveState: saveState, + go: go + })); + + var _options = options; + var entries = _options.entries; + var current = _options.current; + + if (typeof entries === 'string') { + entries = [entries]; + } else if (!Array.isArray(entries)) { + entries = ['/']; + } + + entries = entries.map(function (entry) { + var key = history.createKey(); + + if (typeof entry === 'string') return { pathname: entry, key: key }; + + if (typeof entry === 'object' && entry) return _extends({}, entry, { key: key }); + + true ? false ? _invariant2['default'](false, 'Unable to create history entry from %s', entry) : _invariant2['default'](false) : undefined; + }); + + if (current == null) { + current = entries.length - 1; + } else { + !(current >= 0 && current < entries.length) ? false ? _invariant2['default'](false, 'Current index must be >= 0 and < %s, was %s', entries.length, current) : _invariant2['default'](false) : undefined; + } + + var storage = createStateStorage(entries); + + function saveState(key, state) { + storage[key] = state; + } + + function readState(key) { + return storage[key]; + } + + function getCurrentLocation() { + var entry = entries[current]; + var key = entry.key; + var basename = entry.basename; + var pathname = entry.pathname; + var search = entry.search; + + var path = (basename || '') + pathname + (search || ''); + + var state = undefined; + if (key) { + state = readState(key); + } else { + state = null; + key = history.createKey(); + entry.key = key; + } + + var location = _PathUtils.parsePath(path); + + return history.createLocation(_extends({}, location, { state: state }), undefined, key); + } + + function canGo(n) { + var index = current + n; + return index >= 0 && index < entries.length; + } + + function go(n) { + if (n) { + if (!canGo(n)) { + false ? _warning2['default'](false, 'Cannot go(%s) there is not enough history', n) : undefined; + return; + } + + current += n; + + var currentLocation = getCurrentLocation(); + + // change action to POP + history.transitionTo(_extends({}, currentLocation, { action: _Actions.POP })); + } + } + + function finishTransition(location) { + switch (location.action) { + case _Actions.PUSH: + current += 1; + + // if we are not on the top of stack + // remove rest and push new + if (current < entries.length) entries.splice(current); + + entries.push(location); + saveState(location.key, location.state); + break; + case _Actions.REPLACE: + entries[current] = location; + saveState(location.key, location.state); + break; + } + } + + return history; + } + + exports['default'] = createMemoryHistory; + module.exports = exports['default']; + +/***/ }, +/* 56 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + var strictUriEncode = __webpack_require__(57); + + exports.extract = function (str) { + return str.split('?')[1] || ''; + }; + + exports.parse = function (str) { + if (typeof str !== 'string') { + return {}; + } + + str = str.trim().replace(/^(\?|#|&)/, ''); + + if (!str) { + return {}; + } + + return str.split('&').reduce(function (ret, param) { + var parts = param.replace(/\+/g, ' ').split('='); + // Firefox (pre 40) decodes `%3D` to `=` + // https://github.com/sindresorhus/query-string/pull/37 + var key = parts.shift(); + var val = parts.length > 0 ? parts.join('=') : undefined; + + key = decodeURIComponent(key); + + // missing `=` should be `null`: + // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters + val = val === undefined ? null : decodeURIComponent(val); + + if (!ret.hasOwnProperty(key)) { + ret[key] = val; + } else if (Array.isArray(ret[key])) { + ret[key].push(val); + } else { + ret[key] = [ret[key], val]; + } + + return ret; + }, {}); + }; + + exports.stringify = function (obj) { + return obj ? Object.keys(obj).sort().map(function (key) { + var val = obj[key]; + + if (val === undefined) { + return ''; + } + + if (val === null) { + return key; + } + + if (Array.isArray(val)) { + return val.sort().map(function (val2) { + return strictUriEncode(key) + '=' + strictUriEncode(val2); + }).join('&'); + } + + return strictUriEncode(key) + '=' + strictUriEncode(val); + }).filter(function (x) { + return x.length > 0; + }).join('&') : ''; + }; + + +/***/ }, +/* 57 */ +/***/ function(module, exports) { + + 'use strict'; + module.exports = function (str) { + return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { + return '%' + c.charCodeAt(0).toString(16).toUpperCase(); + }); + }; + + +/***/ } +/******/ ]) +}); +; \ No newline at end of file diff --git a/public/javascripts/wechat/ReactRouter.min.js b/public/javascripts/wechat/ReactRouter.min.js new file mode 100644 index 000000000..af370173e --- /dev/null +++ b/public/javascripts/wechat/ReactRouter.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactRouter=t(require("react")):e.ReactRouter=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(37),a=r(o);t.Router=a["default"];var u=n(18),i=r(u);t.Link=i["default"];var s=n(31),c=r(s);t.IndexLink=c["default"];var f=n(32),l=r(f);t.IndexRedirect=l["default"];var d=n(33),p=r(d);t.IndexRoute=p["default"];var h=n(19),v=r(h);t.Redirect=v["default"];var y=n(35),g=r(y);t.Route=g["default"];var m=n(30),_=r(m);t.History=_["default"];var P=n(34),O=r(P);t.Lifecycle=O["default"];var R=n(36),x=r(R);t.RouteContext=x["default"];var w=n(48),b=r(w);t.useRoutes=b["default"];var M=n(5);t.createRoutes=M.createRoutes;var E=n(13),j=r(E);t.RouterContext=j["default"];var S=n(38),A=r(S);t.RoutingContext=A["default"];var C=n(6),k=r(C);t.PropTypes=k["default"];var T=n(46),H=r(T);t.match=H["default"];var L=n(24),q=r(L);t.useRouterHistory=q["default"];var U=n(8);t.formatPattern=U.formatPattern;var N=n(40),B=r(N);t.browserHistory=B["default"];var I=n(44),D=r(I);t.hashHistory=D["default"];var F=n(21),W=r(F);t.createMemoryHistory=W["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){t="[react-router] "+t;for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o]}t.__esModule=!0,t["default"]=o;var a=n(4);r(a);e.exports=t["default"]},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=function(e,t,n,r,o,a,u,i){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,a,u,i],f=0;s=new Error(t.replace(/%s/g,function(){return c[f++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}};e.exports=r},function(e,t,n){"use strict";var r=function(){};e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return null==e||p["default"].isValidElement(e)}function a(e){return o(e)||Array.isArray(e)&&e.every(o)}function u(e,t,n){e=e||"UnknownComponent";for(var r in t)if(t.hasOwnProperty(r)){var o=t[r](n,r,e);o instanceof Error}}function i(e,t){return l({},e,t)}function s(e){var t=e.type,n=i(t.defaultProps,e.props);if(t.propTypes&&u(t.displayName||t.name,t.propTypes,n),n.children){var r=c(n.children,n);r.length&&(n.childRoutes=r),delete n.children}return n}function c(e,t){var n=[];return p["default"].Children.forEach(e,function(e){if(p["default"].isValidElement(e))if(e.type.createRouteFromReactElement){var r=e.type.createRouteFromReactElement(e,t);r&&n.push(r)}else n.push(s(e))}),n}function f(e){return a(e)?e=c(e):e&&!Array.isArray(e)&&(e=[e]),e}t.__esModule=!0;var l=Object.assign||function(e){for(var t=1;t should not have a "'+t+'" prop'):void 0}t.__esModule=!0,t.falsy=r;var o=n(2),a=o.PropTypes.func,u=o.PropTypes.object,i=o.PropTypes.arrayOf,s=o.PropTypes.oneOfType,c=o.PropTypes.element,f=o.PropTypes.shape,l=o.PropTypes.string,d=f({listen:a.isRequired,pushState:a.isRequired,replaceState:a.isRequired,go:a.isRequired});t.history=d;var p=f({pathname:l.isRequired,search:l.isRequired,state:u,action:l.isRequired,key:l});t.location=p;var h=s([a,l]);t.component=h;var v=s([h,u]);t.components=v;var y=s([u,c]);t.route=y;var g=s([y,i(y)]);t.routes=g,t["default"]={falsy:r,history:d,location:p,component:h,components:v,route:y}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=e.match(/^https?:\/\/[^\/]*/);return null==t?e:e.substring(t[0].length)}function a(e){var t=o(e),n="",r="",a=t.indexOf("#");-1!==a&&(r=t.substring(a),t=t.substring(0,a));var u=t.indexOf("?");return-1!==u&&(n=t.substring(u),t=t.substring(0,u)),""===t&&(t="/"),{pathname:t,search:n,hash:r}}t.__esModule=!0,t.extractPath=o,t.parsePath=a;var u=n(4);r(u)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function a(e){return o(e).replace(/\/+/g,"/+")}function u(e){for(var t="",n=[],r=[],o=void 0,u=0,i=/:([a-zA-Z_$][a-zA-Z0-9_$]*)|\*\*|\*|\(|\)/g;o=i.exec(e);)o.index!==u&&(r.push(e.slice(u,o.index)),t+=a(e.slice(u,o.index))),o[1]?(t+="([^/?#]+)",n.push(o[1])):"**"===o[0]?(t+="([\\s\\S]*)",n.push("splat")):"*"===o[0]?(t+="([\\s\\S]*?)",n.push("splat")):"("===o[0]?t+="(?:":")"===o[0]&&(t+=")?"),r.push(o[0]),u=i.lastIndex;return u!==e.length&&(r.push(e.slice(u,e.length)),t+=a(e.slice(u,e.length))),{pattern:e,regexpSource:t,paramNames:n,tokens:r}}function i(e){return e in h||(h[e]=u(e)),h[e]}function s(e,t){"/"!==e.charAt(0)&&(e="/"+e),"/"!==t.charAt(0)&&(t="/"+t);var n=i(e),r=n.regexpSource,o=n.paramNames,a=n.tokens;r+="/*";var u="*"!==a[a.length-1];u&&(r+="([\\s\\S]*?)");var s=t.match(new RegExp("^"+r+"$","i")),c=void 0,f=void 0;if(null!=s){if(u){c=s.pop();var l=s[0].substr(0,s[0].length-c.length);if(c&&"/"!==l.charAt(l.length-1))return{remainingPathname:null,paramNames:o,paramValues:null}}else c="";f=s.slice(1).map(function(e){return null!=e?decodeURIComponent(e):e})}else c=f=null;return{remainingPathname:c,paramNames:o,paramValues:f}}function c(e){return i(e).paramNames}function f(e,t){var n=s(e,t),r=n.paramNames,o=n.paramValues;return null!=o?r.reduce(function(e,t,n){return e[t]=o[n],e},{}):null}function l(e,t){t=t||{};for(var n=i(e),r=n.tokens,o=0,a="",u=0,s=void 0,c=void 0,f=void 0,l=0,d=r.length;d>l;++l)s=r[l],"*"===s||"**"===s?(f=Array.isArray(t.splat)?t.splat[u++]:t.splat,null!=f||o>0?void 0:p["default"](!1),null!=f&&(a+=encodeURI(f))):"("===s?o+=1:")"===s?o-=1:":"===s.charAt(0)?(c=s.substring(1),f=t[c],null!=f||o>0?void 0:p["default"](!1),null!=f&&(a+=encodeURIComponent(f))):a+=s;return a.replace(/\/+/g,"/")}t.__esModule=!0,t.compilePattern=i,t.matchPattern=s,t.getParamNames=c,t.getParams=f,t.formatPattern=l;var d=n(3),p=r(d),h={}},function(e,t){"use strict";t.__esModule=!0;var n="PUSH";t.PUSH=n;var r="REPLACE";t.REPLACE=r;var o="POP";t.POP=o,t["default"]={PUSH:n,REPLACE:r,POP:o}},function(e,t){"use strict";t.__esModule=!0;var n=!("undefined"==typeof window||!window.document||!window.document.createElement);t.canUseDOM=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return c.stringify(e).replace(/%20/g,"+")}function u(e){return function(){function t(e){if(null==e.query){var t=e.search;e.query=R(t.substring(1)),e[v]={search:t,searchBase:""}}return e}function n(e,t){var n,r=e[v],o=t?O(t):"";if(!r&&!o)return e;"string"==typeof e&&(e=d.parsePath(e));var a=void 0;a=r&&e.search===r.search?r.searchBase:e.search||"";var u=a;return o&&(u+=(u?"&":"?")+o),i({},e,(n={search:u},n[v]={search:u,searchBase:a},n))}function r(e){return w.listenBefore(function(n,r){l["default"](e,t(n),r)})}function u(e){return w.listen(function(n){e(t(n))})}function s(e){w.push(n(e,e.query))}function c(e){w.replace(n(e,e.query))}function f(e,t){return w.createPath(n(e,t||e.query))}function p(e,t){return w.createHref(n(e,t||e.query))}function g(e){for(var r=arguments.length,o=Array(r>1?r-1:0),a=1;r>a;a++)o[a-1]=arguments[a];var u=w.createLocation.apply(w,[n(e,e.query)].concat(o));return e.query&&(u.query=e.query),t(u)}function m(e,t,n){"string"==typeof t&&(t=d.parsePath(t)),s(i({state:e},t,{query:n}))}function _(e,t,n){"string"==typeof t&&(t=d.parsePath(t)),c(i({state:e},t,{query:n}))}var P=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],O=P.stringifyQuery,R=P.parseQueryString,x=o(P,["stringifyQuery","parseQueryString"]),w=e(x);return"function"!=typeof O&&(O=a),"function"!=typeof R&&(R=y),i({},w,{listenBefore:r,listen:u,push:s,replace:c,createPath:f,createHref:p,createLocation:g,pushState:h["default"](m,"pushState is deprecated; use push instead"),replaceState:h["default"](_,"replaceState is deprecated; use replace instead")})}}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;tu&&c;)c=!1,t.call(this,u++,a,r);return s=!1,i?void n.apply(this,f):void(u>=e&&c&&(i=!0,n()))}}var u=0,i=!1,s=!1,c=!1,f=void 0;a()}function r(e,t,n){function r(e,t,r){u||(t?(u=!0,n(t)):(a[e]=r,u=++i===o,u&&n(null,a)))}var o=e.length,a=[];if(0===o)return n(null,a);var u=!1,i=0;e.forEach(function(e,n){t(e,n,function(e,t){r(n,e,t)})})}t.__esModule=!0;var o=Array.prototype.slice;t.loopAsync=n,t.mapAsync=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=Object.assign||function(e){for(var t=1;ti;++i)a=o[i](e);n(a)})}function y(){if(O.routes){for(var e=d(O.routes),t=void 0,n=0,r=e.length;"string"!=typeof t&&r>n;++n)t=e[n]();return t}}function m(e){var t=c(e,!1);t&&(delete w[t],o(w)||(b&&(b(),b=null),M&&(M(),M=null)))}function _(t,n){var r=c(t),a=w[r];if(a)-1===a.indexOf(n)&&a.push(n);else{var u=!o(w);w[r]=[n],u&&(b=e.listenBefore(h),e.listenBeforeUnload&&(M=e.listenBeforeUnload(y)))}return function(){var e=w[r];if(e){var o=e.filter(function(e){return e!==n});0===o.length?m(t):w[r]=o}}}function P(t){return e.listen(function(n){O.location===n?t(null,O):a(n,function(n,r,o){n?t(n):r?e.transitionTo(r):o&&t(null,o)})})}var O={},R=void 0,x=1,w={},b=void 0,M=void 0;return{isActive:n,match:a,listenBeforeLeavingRoute:_,listen:P}}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return 0===e.button}function u(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function i(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}function s(e,t){var n=t.query,r=t.hash,o=t.state;return n||r||o?{pathname:e,query:n,hash:r,state:o}:e}t.__esModule=!0;var c=Object.assign||function(e){for(var t=1;t=0;r--){var o=e[r],a=o.path||"";if(n=a.replace(/\/*$/,"/")+n,0===a.indexOf("/"))break}return"/"+n}},propTypes:{path:d,from:d,to:d.isRequired,query:p,state:p,onEnter:f.falsy,children:f.falsy},render:function(){i["default"](!1)}});t["default"]=h,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){return u({},e,{setRouteLeaveHook:t.listenBeforeLeavingRoute,isActive:t.isActive})}function a(e,t){return e=u({},e,t)}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t=0&&0===window.sessionStorage.length)return;throw n}}function u(e){var t=void 0;try{t=window.sessionStorage.getItem(o(e))}catch(n){if(n.name===f)return null}if(t)try{return JSON.parse(t)}catch(n){}return null}t.__esModule=!0,t.saveState=a,t.readState=u;var i=n(4),s=(r(i),"@@History/"),c=["QuotaExceededError","QUOTA_EXCEEDED_ERR"],f="SecurityError"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){function t(e){return s.canUseDOM?void 0:i["default"](!1),n.listen(e)}var n=l["default"](a({getUserConfirmation:c.getUserConfirmation},e,{go:c.go}));return a({},n,{listen:t})}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return function(){function t(e){return _&&null==e.basename&&(0===e.pathname.indexOf(_)?(e.pathname=e.pathname.substring(_.length),e.basename=_,""===e.pathname&&(e.pathname="/")):e.basename=""),e}function n(e){if(!_)return e;"string"==typeof e&&(e=s.parsePath(e));var t=e.pathname,n="/"===_.slice(-1)?_:_+"/",r="/"===t.charAt(0)?t.slice(1):t,o=n+r;return u({},e,{pathname:o})}function r(e){return O.listenBefore(function(n,r){f["default"](e,t(n),r)})}function a(e){return O.listen(function(n){e(t(n))})}function c(e){O.push(n(e))}function l(e){O.replace(n(e))}function p(e){return O.createPath(n(e))}function h(e){return O.createHref(n(e))}function v(e){for(var r=arguments.length,o=Array(r>1?r-1:0),a=1;r>a;a++)o[a-1]=arguments[a];return t(O.createLocation.apply(O,[n(e)].concat(o)))}function y(e,t){"string"==typeof t&&(t=s.parsePath(t)),c(u({state:e},t))}function g(e,t){"string"==typeof t&&(t=s.parsePath(t)),l(u({state:e},t))}var m=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],_=m.basename,P=o(m,["basename"]),O=e(P);if(null==_&&i.canUseDOM){var R=document.getElementsByTagName("base")[0];R&&(_=s.extractPath(R.href))}return u({},O,{listenBefore:r,listen:a,push:c,replace:l,createPath:p,createHref:h,createLocation:v,pushState:d["default"](y,"pushState is deprecated; use push instead"),replaceState:d["default"](g,"replaceState is deprecated; use replace instead")})}}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return!e||!e.__v2_compatible__}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;tt;++t)e[t].onLeave&&e[t].onLeave.call(e[t])}t.__esModule=!0,t.runEnterHooks=u,t.runLeaveHooks=i;var s=n(12),c=n(1);r(c)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(53),a=r(o),u=n(22),i=r(u);t["default"]=i["default"](a["default"]),e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t,n){if(!e.path)return!1;var r=a.getParamNames(e.path);return r.some(function(e){return t.params[e]!==n.params[e]})}function o(e,t){var n=e&&e.routes,o=t.routes,a=void 0,u=void 0;return n?!function(){var i=!1;a=n.filter(function(n){if(i)return!0;var a=-1===o.indexOf(n)||r(n,e,t);return a&&(i=!0),a}),a.reverse(),u=o.filter(function(e){return-1===n.indexOf(e)||-1!==a.indexOf(e)})}():(a=[],u=o),{leaveRoutes:a,enterRoutes:u}}t.__esModule=!0;var a=n(8);t["default"]=o,e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t,n){t.component||t.components?n(null,t.component||t.components):t.getComponent?t.getComponent(e,n):t.getComponents?t.getComponents(e,n):n()}function o(e,t){a.mapAsync(e.routes,function(t,n,o){r(e.location,t,o)},t)}t.__esModule=!0;var a=n(12);t["default"]=o,e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t){var n={};if(!e.path)return n;var r=o.getParamNames(e.path);for(var a in t)t.hasOwnProperty(a)&&-1!==r.indexOf(a)&&(n[a]=t[a]);return n}t.__esModule=!0;var o=n(8);t["default"]=r,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(27),a=r(o),u=n(22),i=r(u);t["default"]=i["default"](a["default"]),e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t){if(e==t)return!0;if(null==e||null==t)return!1;if(Array.isArray(e))return Array.isArray(t)&&e.length===t.length&&e.every(function(e,n){return r(e,t[n])});if("object"==typeof e){for(var n in e)if(e.hasOwnProperty(n))if(void 0===e[n]){if(void 0!==t[n])return!1}else{if(!t.hasOwnProperty(n))return!1;if(!r(e[n],t[n]))return!1}return!0}return String(e)===String(t)}function o(e,t,n){return e.every(function(e,r){return String(t[r])===String(n[e])})}function a(e,t,n){for(var r=e,a=[],u=[],i=0,s=t.length;s>i;++i){var f=t[i],l=f.path||"";if("/"===l.charAt(0)&&(r=e,a=[],u=[]),null!==r){var d=c.matchPattern(l,r);r=d.remainingPathname,a=[].concat(a,d.paramNames),u=[].concat(u,d.paramValues)}if(""===r&&f.path&&o(a,u,n))return i}return null}function u(e,t,n,r){var o=a(e,t,n);return null===o?!1:r?t.slice(o+1).every(function(e){return!e.path}):!0}function i(e,t){return null==t?null==e:null==e?!0:r(e,t)}function s(e,t,n,r,o){var a=e.pathname,s=e.query;return null==n?!1:u(a,r,o,t)?i(s,n.query):!1}t.__esModule=!0,t["default"]=s;var c=n(8);e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e,t){var n=e.history,r=e.routes,a=e.location,i=o(e,["history","routes","location"]);n||a?void 0:s["default"](!1),n=n?n:f["default"](i);var c=d["default"](n,p.createRoutes(r)),l=void 0;a?a=n.createLocation(a):l=n.listen(function(e){a=e});var v=h.createRouterObject(n,c);n=h.createRoutingHistory(n,c),c.match(a,function(e,r,o){t(e,r,o&&u({},o,{history:n,router:v,matchContext:{history:n,transitionManager:c,router:v}})),l&&l()})}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=t.routes,r=o(t,["routes"]),a=s["default"](e)(r),i=f["default"](a,n);return u({},a,i)}}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t0&&"number"!=typeof e[0]?!1:!0:!1}function a(e,t,n){var a,f;if(r(e)||r(t))return!1;if(e.prototype!==t.prototype)return!1;if(s(e))return s(t)?(e=u.call(e),t=u.call(t),c(e,t,n)):!1;if(o(e)){if(!o(t))return!1;if(e.length!==t.length)return!1;for(a=0;a=0;a--)if(l[a]!=d[a])return!1;for(a=l.length-1;a>=0;a--)if(f=l[a],!c(e[f],t[f],n))return!1;return typeof e==typeof t}var u=Array.prototype.slice,i=n(51),s=n(50),c=e.exports=function(e,t,n){return n||(n={}),e===t?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():!e||!t||"object"!=typeof e&&"object"!=typeof t?n.strict?e===t:e==t:a(e,t,n)}},function(e,t){function n(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function r(e){return e&&"object"==typeof e&&"number"==typeof e.length&&Object.prototype.hasOwnProperty.call(e,"callee")&&!Object.prototype.propertyIsEnumerable.call(e,"callee")||!1}var o="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();t=e.exports=o?n:r,t.supported=n,t.unsupported=r},function(e,t){function n(e){var t=[];for(var n in e)t.push(n);return t}t=e.exports="function"==typeof Object.keys?Object.keys:n,t.shim=n},function(e,t){"use strict";function n(e,t,n){function r(){u=!0,n.apply(this,arguments)}function o(){u||(e>a?t.call(this,a++,o,r):r.apply(this,arguments))}var a=0,u=!1;o()}t.__esModule=!0,t.loopAsync=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){function e(e){e=e||window.history.state||{};var t=l.getWindowPath(),n=e,r=n.key,o=void 0;r?o=d.readState(r):(o=null,r=_.createKey(),g&&window.history.replaceState(a({},e,{key:r}),null,t));var u=c.parsePath(t);return _.createLocation(a({},u,{state:o}),void 0,r)}function t(t){function n(t){void 0!==t.state&&r(e(t.state))}var r=t.transitionTo;return l.addEventListener(window,"popstate",n),function(){l.removeEventListener(window,"popstate",n)}}function n(e){var t=e.basename,n=e.pathname,r=e.search,o=e.hash,a=e.state,u=e.action,i=e.key;if(u!==s.POP){d.saveState(i,a);var c=(t||"")+n+r+o,f={key:i};if(u===s.PUSH){if(m)return window.location.href=c,!1;window.history.pushState(f,null,c)}else{if(m)return window.location.replace(c),!1;window.history.replaceState(f,null,c)}}}function r(e){1===++P&&(O=t(_));var n=_.listenBefore(e);return function(){n(),0===--P&&O()}}function o(e){1===++P&&(O=t(_));var n=_.listen(e);return function(){n(),0===--P&&O()}}function u(e){1===++P&&(O=t(_)),_.registerTransitionHook(e)}function p(e){_.unregisterTransitionHook(e),0===--P&&O()}var v=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];f.canUseDOM?void 0:i["default"](!1);var y=v.forceRefresh,g=l.supportsHistory(),m=!g||y,_=h["default"](a({},v,{getCurrentLocation:e,finishTransition:n,saveState:d.saveState})),P=0,O=void 0;return a({},_,{listenBefore:r,listen:o,registerTransitionHook:u,unregisterTransitionHook:p})}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t=0&&t=0&&y Date: Mon, 21 Mar 2016 18:23:34 +0800 Subject: [PATCH 078/507] =?UTF-8?q?url=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/wechat.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/wechat.jsx b/public/javascripts/wechat/wechat.jsx index ce5d47d56..29a8da732 100644 --- a/public/javascripts/wechat/wechat.jsx +++ b/public/javascripts/wechat/wechat.jsx @@ -8,7 +8,7 @@ var Index = React.createClass({ } }); -var apiUrl = 'http://localhost:3000/api/v1/'; +var apiUrl = '/api/v1/'; var PostContainer = React.createClass({ loadDataFromServer: function(){ From aaa2a0dea7b7c60ac0434ea710ea383af7e05ffe Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 21 Mar 2016 18:26:35 +0800 Subject: [PATCH 079/507] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=A4=B4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/app.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/app.html b/public/app.html index 708859714..5ebcdc286 100644 --- a/public/app.html +++ b/public/app.html @@ -2,6 +2,13 @@ react js + + + + + + + From 4f7d698076b9b51cd68b559ca6fc20d9e84db6d4 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 26 Mar 2016 14:45:57 +0800 Subject: [PATCH 080/507] wechat init --- config/menu.yml | 17 ++++--- public/assets/wechat/issue.html | 52 +++++++++++++++++++++ public/javascripts/wechat/wechat-dev.js | 54 ++++++++++++++++++++++ public/javascripts/wechat/wechat.jsx | 60 ++++++++++++++++--------- 4 files changed, 156 insertions(+), 27 deletions(-) create mode 100644 public/assets/wechat/issue.html create mode 100644 public/javascripts/wechat/wechat-dev.js diff --git a/config/menu.yml b/config/menu.yml index c88e94ec4..711b087d1 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -1,13 +1,20 @@ button: - - type: "click" + type: "view" name: "最新动态" - key: "MY_NEWS" + url: "http://wechat.trustie.net/assets/wechat/issue.html" - type: "click" name: "意见返馈" key: "FEEDBACK" - - type: "view" - name: "进入网站" - url: "http://www.trustie.net/" \ No newline at end of file + name: "更多" + sub_button: + - + type: "view" + name: "进入网站" + url: "http://www.trustie.net/" + - + type: "view" + name: "使用手册" + url: "https://www.trustie.net/organizations/1/downloads" \ No newline at end of file diff --git a/public/assets/wechat/issue.html b/public/assets/wechat/issue.html new file mode 100644 index 000000000..7b6eedde2 --- /dev/null +++ b/public/assets/wechat/issue.html @@ -0,0 +1,52 @@ + + + + react js + + + + + + + + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/public/javascripts/wechat/wechat-dev.js b/public/javascripts/wechat/wechat-dev.js new file mode 100644 index 000000000..9c5704b8c --- /dev/null +++ b/public/javascripts/wechat/wechat-dev.js @@ -0,0 +1,54 @@ +/** + * Created by root on 3/25/16. + */ +$(document).ready(function(){ + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + + var apiUrl = '/api/v1/' + var setTemplate = function(data){ + console.log(data); + + + var html=bt('t:result-list',{issues: data}); + $('#container').prepend(html); + } + + var loadDataFromServer = function(id){ + $.ajax({ + url: apiUrl + 'issues/' + id, + dataType: 'json', + success: function(data){ + setTemplate(data.data); + }, + error: function(xhr,status,err){ + console.log(err); + } + }) + }; + + + loadDataFromServer(299); + + + var postWidth = $(".post-wrapper").width(); + var titleWidth = postWidth - 80; + $(".post-title").css("maxWidth",titleWidth); + + $(".post-all-content").each(function(){ + var postHeight = $(this).height(); + if (postHeight > 90){ + $(this).parent().next().css("display","block"); + $(this).parent().next().toggle(function(){ + $(this).text("点击隐藏"); + $(this).prev().css("height",postHeight); + },function(){ + $(this).text("点击展开"); + $(this).prev().css("height",90); + }); + } + }); +}); diff --git a/public/javascripts/wechat/wechat.jsx b/public/javascripts/wechat/wechat.jsx index 29a8da732..86d92318b 100644 --- a/public/javascripts/wechat/wechat.jsx +++ b/public/javascripts/wechat/wechat.jsx @@ -10,6 +10,8 @@ var Index = React.createClass({ var apiUrl = '/api/v1/'; +var converter = new Showdown.converter(); + var PostContainer = React.createClass({ loadDataFromServer: function(){ $.ajax({ @@ -31,36 +33,52 @@ var PostContainer = React.createClass({ }, render: function(){ return ( -
-
- -
-
- ) + + )issues } }); var PostView = React.createClass({ + testClick: function(){ + console.log("123123"); + }, + render: function(){ if(!this.props.data){ return
} - return ( -
-
-
{this.props.data.subject}
-
-
-
-

{this.props.data.description}

+ + var issueEach = this.props.data.map(function(issue){ + + var descMarkup = converter.makeHtml(issue.description.toString()); + + return ( +
+
+
+
+
{issue.subject}
+ +
+
+
+
+ 点击展开 +
+ {issue.created_on} +
+
+
- 点击展开 -
- {this.props.data.time} -
-
- ) + ) + }); + + return( +
{issueEach}
+ ); + + } }); @@ -77,5 +95,3 @@ var routes = ( React.render(routes, document.getElementById("container")); - - From 43de1a21b18d6c724c1a743a2f8512330eac96d0 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 26 Mar 2016 14:54:36 +0800 Subject: [PATCH 081/507] =?UTF-8?q?issues=20api=20=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/issues.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb index 212a505e7..23d8b955f 100644 --- a/app/api/mobile/apis/issues.rb +++ b/app/api/mobile/apis/issues.rb @@ -7,7 +7,7 @@ module Mobile desc "get special issuse" get ':id' do - issue = Issue.find(params[:id]) + issue = Issue.where("project_id = ?", params[:id]) present :data, issue, with: Mobile::Entities::Issue present :status, 0 end From 60931dde6ab2a87cf6c6b0a1a794635ce51b5749 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 26 Mar 2016 15:52:14 +0800 Subject: [PATCH 082/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96ope?= =?UTF-8?q?nid=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 12 ++++++++++ config/menu.yml | 2 +- config/routes.rb | 1 + public/assets/wechat/issue.html | 1 + public/javascripts/wechat/auth.js | 29 +++++++++++++++++++++++++ public/javascripts/wechat/wechat-dev.js | 25 +++++++++++---------- 6 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 public/javascripts/wechat/auth.js diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 60a674446..c00a8a86e 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -171,6 +171,18 @@ class WechatsController < ActionController::Base end end + + def get_open_id + begin + raise "非法操作, code不存在" unless params[:code] + openid = get_openid(params[:code]) + raise "无法获取到openid" unless openid + render :text => {status:0, openid: openid}.to_json + rescue Exception=>e + render :text => {status: -1, msg: e.message}.to_json + end + end + def bind begin raise "非法操作, code不存在" unless params[:code] diff --git a/config/menu.yml b/config/menu.yml index 711b087d1..106bbfd07 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ button: - type: "view" name: "最新动态" - url: "http://wechat.trustie.net/assets/wechat/issue.html" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/issue.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect" - type: "click" name: "意见返馈" diff --git a/config/routes.rb b/config/routes.rb index 396be9c66..2313088cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1165,6 +1165,7 @@ RedmineApp::Application.routes.draw do collection do get :login post :bind + get :get_open_id end end diff --git a/public/assets/wechat/issue.html b/public/assets/wechat/issue.html index 7b6eedde2..86c4e494a 100644 --- a/public/assets/wechat/issue.html +++ b/public/assets/wechat/issue.html @@ -47,6 +47,7 @@ + \ No newline at end of file diff --git a/public/javascripts/wechat/auth.js b/public/javascripts/wechat/auth.js new file mode 100644 index 000000000..aeaa03db1 --- /dev/null +++ b/public/javascripts/wechat/auth.js @@ -0,0 +1,29 @@ +$(function(){ + //获取url中的参数 + function getUrlParam(name) { + var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象 + var r = window.location.search.substr(1).match(reg); //匹配目标参数 + if (r != null) return unescape(r[2]); return null; //返回参数值 + } + + var g_openid = ""; + + window.getOpenId = function(cb){ + if (g_openid.length>0){ + cb(g_openid); + } + var code = getUrlParam("code"); + $.ajax({ + url: '/wechat/get_open_id?code='+code, + type: 'get', + dataType: 'json', + success: function(data){ + g_openid = data.openid; + cb(g_openid); + }, + error: function(xhr,err){ + alert("认证失败: "+err); + } + }); + } +}); \ No newline at end of file diff --git a/public/javascripts/wechat/wechat-dev.js b/public/javascripts/wechat/wechat-dev.js index 9c5704b8c..760140991 100644 --- a/public/javascripts/wechat/wechat-dev.js +++ b/public/javascripts/wechat/wechat-dev.js @@ -11,23 +11,26 @@ $(document).ready(function(){ var apiUrl = '/api/v1/' var setTemplate = function(data){ console.log(data); - - var html=bt('t:result-list',{issues: data}); $('#container').prepend(html); } var loadDataFromServer = function(id){ - $.ajax({ - url: apiUrl + 'issues/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } + getOpenId(function(openid){ + alert(openid); + $.ajax({ + url: apiUrl + 'issues/' + id + "?openid="+openid, + dataType: 'json', + success: function(data){ + setTemplate(data.data); + }, + error: function(xhr,status,err){ + console.log(err); + } + }); }) + + }; From d5124e128ee5a6eb68dae732ecd797a5cc3706b1 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 26 Mar 2016 15:56:36 +0800 Subject: [PATCH 083/507] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/issue.html | 3 --- public/javascripts/wechat/auth.js | 6 ++++++ public/javascripts/wechat/wechat-dev.js | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/public/assets/wechat/issue.html b/public/assets/wechat/issue.html index 86c4e494a..f49dfdcfa 100644 --- a/public/assets/wechat/issue.html +++ b/public/assets/wechat/issue.html @@ -15,9 +15,6 @@
- - - + + + + + + \ No newline at end of file diff --git a/public/javascripts/wechat/wechat-dev.js b/public/javascripts/wechat/wechat-dev.js index 9c5704b8c..56a95ac72 100644 --- a/public/javascripts/wechat/wechat-dev.js +++ b/public/javascripts/wechat/wechat-dev.js @@ -15,11 +15,13 @@ $(document).ready(function(){ var html=bt('t:result-list',{issues: data}); $('#container').prepend(html); + descToggle(); + } - var loadDataFromServer = function(id){ + var loadDataFromServer = function(page){ $.ajax({ - url: apiUrl + 'issues/' + id, + url: apiUrl + 'activities/' + page + "?openid=", dataType: 'json', success: function(data){ setTemplate(data.data); @@ -31,24 +33,32 @@ $(document).ready(function(){ }; - loadDataFromServer(299); + loadDataFromServer(0); + + var descToggle = function(){ + var postWidth = $(".post-wrapper").width(); + var titleWidth = postWidth - 80; + $(".post-title").css("maxWidth",titleWidth); + $(".post-all-content").each(function(){ + var postHeight = $(this).height(); + if (postHeight > 90){ + $(this).parent().next().css("display","block"); + $(this).parent().next().toggle(function(){ + $(this).text("点击隐藏"); + $(this).prev().css("height",postHeight); + },function(){ + $(this).text("点击展开"); + $(this).prev().css("height",90); + }); + } + }); + } + + var timeSpilt = function(){ + + } + - var postWidth = $(".post-wrapper").width(); - var titleWidth = postWidth - 80; - $(".post-title").css("maxWidth",titleWidth); - $(".post-all-content").each(function(){ - var postHeight = $(this).height(); - if (postHeight > 90){ - $(this).parent().next().css("display","block"); - $(this).parent().next().toggle(function(){ - $(this).text("点击隐藏"); - $(this).prev().css("height",postHeight); - },function(){ - $(this).text("点击展开"); - $(this).prev().css("height",90); - }); - } - }); }); From 4de598873fb6b623751fa6d16c2af206084de352 Mon Sep 17 00:00:00 2001 From: Yiang Gan Date: Wed, 30 Mar 2016 10:32:45 +0800 Subject: [PATCH 085/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=92=8C=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E7=9A=84api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 4 + app/api/mobile/apis/activities.rb | 32 ++++++ app/api/mobile/apis/whomeworks.rb | 17 +++ app/api/mobile/entities/activity.rb | 102 ++++++++++++++++++ app/api/mobile/entities/whomework.rb | 53 +++++++++ app/helpers/api_helper.rb | 38 +++++++ config/application.rb | 4 +- db/schema.rb | 20 +++- .../{acitivities.html => activities.html} | 1 + public/assets/wechat/issue.html | 2 +- public/javascripts/wechat/wechat-dev.js | 17 ++- public/javascripts/wechat/wechat.jsx | 8 +- 12 files changed, 280 insertions(+), 18 deletions(-) create mode 100644 app/api/mobile/apis/activities.rb create mode 100644 app/api/mobile/apis/whomeworks.rb create mode 100644 app/api/mobile/entities/activity.rb create mode 100644 app/api/mobile/entities/whomework.rb rename public/assets/wechat/{acitivities.html => activities.html} (97%) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 91cae64ef..690828b84 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -8,6 +8,8 @@ module Mobile require_relative 'apis/homeworks' require_relative 'apis/comments' require_relative 'apis/issues' + require_relative 'apis/activities' + require_relative 'apis/whomeworks' class API < Grape::API version 'v1', using: :path @@ -42,6 +44,8 @@ module Mobile mount Apis::Homeworks mount Apis::Comments mount Apis::Issues + mount Apis::Activities + mount Apis::Whomeworks #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb new file mode 100644 index 000000000..29cc3da8c --- /dev/null +++ b/app/api/mobile/apis/activities.rb @@ -0,0 +1,32 @@ +#coding=utf-8 + +module Mobile + module Apis + class Activities< Grape::API + resources :activities do + + desc "get user activities" + get ':id' do + #uw = UserWechat.find params[:openid] + user = User.find params[:id] + shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) + page = params[:page] ? params[:page].to_i + 1 : 0 + user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + project_types = "('Message','Issue','ProjectCreateInfo')" + principal_types = "JournalsForMessage" + + blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")" + activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(page * 10) + present :data, activities, with: Mobile::Entities::Activity + present :status, 0 + end + end + end + end +end \ No newline at end of file diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb new file mode 100644 index 000000000..84e9e1fdf --- /dev/null +++ b/app/api/mobile/apis/whomeworks.rb @@ -0,0 +1,17 @@ +#coding=utf-8 + +module Mobile + module Apis + class Whomeworks< Grape::API + resources :whomeworks do + + desc "get one homework" + get ':id' do + homework = HomeworkCommon.find params[:id] + present :data, homework, with: Mobile::Entities::Whomework + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb new file mode 100644 index 000000000..4d64a40d8 --- /dev/null +++ b/app/api/mobile/entities/activity.rb @@ -0,0 +1,102 @@ +# encoding: utf-8 +module Mobile + module Entities + class Activity 20160225024759) do +ActiveRecord::Schema.define(:version => 20160317090350) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -432,9 +432,11 @@ ActiveRecord::Schema.define(:version => 20160225024759) do t.integer "resource_num" t.integer "journal_num" t.integer "journal_reply_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "total_score" + t.integer "homework_journal_num", :default => 0 + t.integer "news_num", :default => 0 end create_table "course_groups", :force => true do |t| @@ -506,6 +508,7 @@ ActiveRecord::Schema.define(:version => 20160225024759) do t.integer "is_excellent", :default => 0 t.integer "excellent_option", :default => 0 t.integer "is_copy", :default => 0 + t.integer "visits", :default => 0 end create_table "custom_fields", :force => true do |t| @@ -1282,6 +1285,7 @@ ActiveRecord::Schema.define(:version => 20160225024759) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.boolean "allow_guest_download", :default => true + t.integer "visits", :default => 0 end create_table "phone_app_versions", :force => true do |t| @@ -1441,6 +1445,7 @@ ActiveRecord::Schema.define(:version => 20160225024759) do t.integer "acts_count", :default => 0 t.integer "journals_count", :default => 0 t.integer "boards_reply_count", :default => 0 + t.integer "visits", :default => 0 end add_index "projects", ["lft"], :name => "index_projects_on_lft" @@ -1777,6 +1782,14 @@ ActiveRecord::Schema.define(:version => 20160225024759) do t.integer "fields_bits", :default => 0 end + create_table "user_actions", :force => true do |t| + t.integer "user_id" + t.string "action_type" + t.integer "action_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "user_activities", :force => true do |t| t.string "act_type" t.integer "act_id" @@ -1919,6 +1932,7 @@ ActiveRecord::Schema.define(:version => 20160225024759) do t.string "mail_notification", :default => "", :null => false t.string "salt", :limit => 64 t.integer "gid" + t.integer "visits", :default => 0 end add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" diff --git a/public/assets/wechat/acitivities.html b/public/assets/wechat/activities.html similarity index 97% rename from public/assets/wechat/acitivities.html rename to public/assets/wechat/activities.html index 87c697aba..eb537363d 100644 --- a/public/assets/wechat/acitivities.html +++ b/public/assets/wechat/activities.html @@ -216,5 +216,6 @@ + \ No newline at end of file diff --git a/public/assets/wechat/issue.html b/public/assets/wechat/issue.html index 4c26551b1..558496ef0 100644 --- a/public/assets/wechat/issue.html +++ b/public/assets/wechat/issue.html @@ -18,7 +18,7 @@ + + + + + + + \ No newline at end of file From 77e11fe0fec7f8f0537940863e78c4d7d483aff1 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 30 Mar 2016 17:47:44 +0800 Subject: [PATCH 093/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 62 +- app/api/mobile/apis/blog_comments.rb | 34 +- app/api/mobile/apis/issues.rb | 34 +- app/api/mobile/apis/journal_for_messages.rb | 34 +- app/api/mobile/apis/messages.rb | 34 +- app/api/mobile/apis/newss.rb | 34 +- app/api/mobile/apis/whomeworks.rb | 34 +- app/api/mobile/entities/activity.rb | 262 +- app/api/mobile/entities/blog_comment.rb | 90 +- app/api/mobile/entities/issue.rb | 68 +- app/api/mobile/entities/whomework.rb | 130 +- config/application.rb | 192 +- db/schema.rb | 4184 +++++++++---------- public/assets/wechat/activities.html | 84 +- public/javascripts/wechat/wechat-dev.js | 130 +- public/javascripts/wechat/wechat.jsx | 194 +- 16 files changed, 2800 insertions(+), 2800 deletions(-) diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 29cc3da8c..ed49c0ada 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -1,32 +1,32 @@ -#coding=utf-8 - -module Mobile - module Apis - class Activities< Grape::API - resources :activities do - - desc "get user activities" - get ':id' do - #uw = UserWechat.find params[:openid] - user = User.find params[:id] - shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) - shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) - page = params[:page] ? params[:page].to_i + 1 : 0 - user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" - user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" - course_types = "('Message','News','HomeworkCommon','Poll','Course')" - project_types = "('Message','Issue','ProjectCreateInfo')" - principal_types = "JournalsForMessage" - - blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")" - activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + - "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ - "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + - "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(page * 10) - present :data, activities, with: Mobile::Entities::Activity - present :status, 0 - end - end - end - end +#coding=utf-8 + +module Mobile + module Apis + class Activities< Grape::API + resources :activities do + + desc "get user activities" + get ':id' do + #uw = UserWechat.find params[:openid] + user = User.find params[:id] + shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) + page = params[:page] ? params[:page].to_i + 1 : 0 + user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + project_types = "('Message','Issue','ProjectCreateInfo')" + principal_types = "JournalsForMessage" + + blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")" + activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(page * 10) + present :data, activities, with: Mobile::Entities::Activity + present :status, 0 + end + end + end + end end \ No newline at end of file diff --git a/app/api/mobile/apis/blog_comments.rb b/app/api/mobile/apis/blog_comments.rb index 3334b2bf8..f94d0bbc7 100644 --- a/app/api/mobile/apis/blog_comments.rb +++ b/app/api/mobile/apis/blog_comments.rb @@ -1,17 +1,17 @@ -#coding=utf-8 - -module Mobile - module Apis - class BlogComments< Grape::API - resources :blog_comments do - - desc "get special topic" - get ':id' do - blog = BlogComment.find params[:id] - present :blog, message, with: Mobile::Entities::BlogComment - present :status, 0 - end - end - end - end -end +#coding=utf-8 + +module Mobile + module Apis + class BlogComments< Grape::API + resources :blog_comments do + + desc "get special topic" + get ':id' do + blog = BlogComment.find params[:id] + present :blog, message, with: Mobile::Entities::BlogComment + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb index 7d5640d3b..1c7a9ef3d 100644 --- a/app/api/mobile/apis/issues.rb +++ b/app/api/mobile/apis/issues.rb @@ -1,17 +1,17 @@ -#coding=utf-8 - -module Mobile - module Apis - class Issues< Grape::API - resources :issues do - - desc "get special issuse" - get ':id' do - issue = Issue.find params[:id] - present :data, issue, with: Mobile::Entities::Issue - present :status, 0 - end - end - end - end -end +#coding=utf-8 + +module Mobile + module Apis + class Issues< Grape::API + resources :issues do + + desc "get special issuse" + get ':id' do + issue = Issue.find params[:id] + present :data, issue, with: Mobile::Entities::Issue + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb index ac9787d51..648924912 100644 --- a/app/api/mobile/apis/journal_for_messages.rb +++ b/app/api/mobile/apis/journal_for_messages.rb @@ -1,17 +1,17 @@ -#coding=utf-8 - -module Mobile - module Apis - class JournalForMessages< Grape::API - resources :journal_for_messages do - - desc "get special journal" - get ':id' do - jour = JournalsForMessage.find params[:id] - present :data, jour, with: Mobile::Entities::Jours - present :status, 0 - end - end - end - end -end +#coding=utf-8 + +module Mobile + module Apis + class JournalForMessages< Grape::API + resources :journal_for_messages do + + desc "get special journal" + get ':id' do + jour = JournalsForMessage.find params[:id] + present :data, jour, with: Mobile::Entities::Jours + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb index c1c403a50..5e2fb05b7 100644 --- a/app/api/mobile/apis/messages.rb +++ b/app/api/mobile/apis/messages.rb @@ -1,17 +1,17 @@ -#coding=utf-8 - -module Mobile - module Apis - class Messages< Grape::API - resources :messages do - - desc "get special topic" - get ':id' do - message = Message.find params[:id] - present :data, message, with: Mobile::Entities::Message - present :status, 0 - end - end - end - end -end +#coding=utf-8 + +module Mobile + module Apis + class Messages< Grape::API + resources :messages do + + desc "get special topic" + get ':id' do + message = Message.find params[:id] + present :data, message, with: Mobile::Entities::Message + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb index 52b77fb88..6f15ae2ee 100644 --- a/app/api/mobile/apis/newss.rb +++ b/app/api/mobile/apis/newss.rb @@ -1,17 +1,17 @@ -#coding=utf-8 - -module Mobile - module Apis - class Newss< Grape::API - resources :newss do - - desc "get special news" - get ':id' do - news = News.find params[:id] - present :data, news, with: Mobile::Entities::News - present :status, 0 - end - end - end - end -end +#coding=utf-8 + +module Mobile + module Apis + class Newss< Grape::API + resources :newss do + + desc "get special news" + get ':id' do + news = News.find params[:id] + present :data, news, with: Mobile::Entities::News + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb index 84e9e1fdf..39a6faa68 100644 --- a/app/api/mobile/apis/whomeworks.rb +++ b/app/api/mobile/apis/whomeworks.rb @@ -1,17 +1,17 @@ -#coding=utf-8 - -module Mobile - module Apis - class Whomeworks< Grape::API - resources :whomeworks do - - desc "get one homework" - get ':id' do - homework = HomeworkCommon.find params[:id] - present :data, homework, with: Mobile::Entities::Whomework - present :status, 0 - end - end - end - end -end +#coding=utf-8 + +module Mobile + module Apis + class Whomeworks< Grape::API + resources :whomeworks do + + desc "get one homework" + get ':id' do + homework = HomeworkCommon.find params[:id] + present :data, homework, with: Mobile::Entities::Whomework + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index c47f396e2..db1456e68 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -1,132 +1,132 @@ -# encoding: utf-8 -module Mobile - module Entities - class Activity %w(development test))) - # If you want your assets lazily compiled in production, use this line - # Bundler.require(:default, :assets, Rails.env) -end - -module RedmineApp - class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - #verifier if email is real - - - config.generators do |g| - g.test_framework :rspec, - fixtures: true, - view_specs: false, - helper_specs: false, - routing_specs: false, - controller_specs: true, - request_specs: false - g.fixture_replacement :factory_girl, dir: "spec/factories" - end - # Custom directories with classes and modules you want to be autoloadable. - config.autoload_paths += %W(#{config.root}/lib) - config.autoload_paths += %w(#{RAILS_ROOT}/app/sweepers) - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named. - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Activate observers that should always be running. - config.active_record.observers = :journals_for_message_observer, :issue_observer, :journal_observer, :wiki_content_observer - - config.active_record.store_full_sti_class = true - config.active_record.default_timezone = :local - config.time_zone = 'Beijing' - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - config.i18n.default_locale = :zh - - #config.i18n.enforce_available_locales = true - #I18n.config.enforce_available_locales = true - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" - - # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password] - - # Enable the asset pipeline - config.assets.enabled = false - - # Version of your assets, change this if you want to expire all your assets - config.assets.version = '1.0' - - config.action_mailer.perform_deliveries = false - - # Do not include all helpers - config.action_controller.include_all_helpers = false - - config.action_view.sanitized_allowed_tags = 'div', 'p', 'span', 'img', 'embed' - - config.before_initialize do - end - - config.after_initialize do - if RbConfig::CONFIG['target_os'] == 'mingw32' - Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true - elsif RbConfig::CONFIG['target_os'] == 'linux' && ["fast76"].include?(`hostname`.gsub("\n","")) - Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true - elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n","")) - Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true - elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n","")) - Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200'], retry_on_failure: true - else - Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true - end - end - - if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb')) - instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb')) - end - - end -end +require File.expand_path('../boot', __FILE__) + +require 'rails/all' +require 'sprockets/railtie' +require 'elasticsearch/model' +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require(*Rails.groups(:assets => %w(development test))) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end + +module RedmineApp + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + #verifier if email is real + + + config.generators do |g| + g.test_framework :rspec, + fixtures: true, + view_specs: false, + helper_specs: false, + routing_specs: false, + controller_specs: true, + request_specs: false + g.fixture_replacement :factory_girl, dir: "spec/factories" + end + # Custom directories with classes and modules you want to be autoloadable. + config.autoload_paths += %W(#{config.root}/lib) + config.autoload_paths += %w(#{RAILS_ROOT}/app/sweepers) + # Only load the plugins named here, in the order given (default is alphabetical). + # :all can be used as a placeholder for all plugins not explicitly named. + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Activate observers that should always be running. + config.active_record.observers = :journals_for_message_observer, :issue_observer, :journal_observer, :wiki_content_observer + + config.active_record.store_full_sti_class = true + config.active_record.default_timezone = :local + config.time_zone = 'Beijing' + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + config.i18n.default_locale = :zh + + #config.i18n.enforce_available_locales = true + #I18n.config.enforce_available_locales = true + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters += [:password] + + # Enable the asset pipeline + config.assets.enabled = false + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' + + config.action_mailer.perform_deliveries = false + + # Do not include all helpers + config.action_controller.include_all_helpers = false + + config.action_view.sanitized_allowed_tags = 'div', 'p', 'span', 'img', 'embed' + + config.before_initialize do + end + + config.after_initialize do + if RbConfig::CONFIG['target_os'] == 'mingw32' + Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true + elsif RbConfig::CONFIG['target_os'] == 'linux' && ["fast76"].include?(`hostname`.gsub("\n","")) + Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true + elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n","")) + Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true + elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n","")) + Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200'], retry_on_failure: true + else + Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true + end + end + + if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb')) + instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb')) + end + + end +end diff --git a/db/schema.rb b/db/schema.rb index 75f316f06..38c7e5ad2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,2092 +1,2092 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20160317090350) do - - create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - t.integer "activity_container_id" - t.string "activity_container_type", :default => "" - t.datetime "created_at" - end - - add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" - add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" - add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - - create_table "activity_notifies", :force => true do |t| - t.integer "activity_container_id" - t.string "activity_container_type" - t.integer "activity_id" - t.string "activity_type" - t.integer "notify_to" - t.datetime "created_on" - t.integer "is_read" - end - - add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" - add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" - add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" - - create_table "api_keys", :force => true do |t| - t.string "access_token" - t.datetime "expires_at" - t.integer "user_id" - t.boolean "active", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" - add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" - - create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - end - - create_table "apply_project_masters", :force => true do |t| - t.integer "user_id" - t.string "apply_type" - t.integer "apply_id" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "at_messages", :force => true do |t| - t.integer "user_id" - t.integer "at_message_id" - t.string "at_message_type" - t.boolean "viewed", :default => false - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sender_id" - end - - add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" - - create_table "attachment_histories", :force => true do |t| - t.integer "container_id" - t.string "container_type" - t.string "filename", :default => "" - t.string "disk_filename", :default => "" - t.integer "filesize", :default => 0 - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "" - t.integer "downloads", :default => 0 - t.integer "author_id" - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.integer "copy_from" - t.integer "quotes" - t.integer "version" - t.integer "attachment_id" - t.integer "is_publish", :default => 1 - t.date "publish_time" - end - - create_table "attachments", :force => true do |t| - t.integer "container_id" - t.string "container_type", :limit => 30 - t.string "filename", :default => "", :null => false - t.string "disk_filename", :default => "", :null => false - t.integer "filesize", :default => 0, :null => false - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "", :null => false - t.integer "downloads", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype", :default => 1 - t.integer "is_public", :default => 1 - t.integer "copy_from" - t.integer "quotes" - t.integer "is_publish", :default => 1 - t.date "publish_time" - end - - add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" - add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" - add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" - - create_table "attachmentstypes", :force => true do |t| - t.integer "typeId", :null => false - t.string "typeName", :limit => 50 - end - - create_table "auth_sources", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 60, :default => "", :null => false - t.string "host", :limit => 60 - t.integer "port" - t.string "account" - t.string "account_password", :default => "" - t.string "base_dn" - t.string "attr_login", :limit => 30 - t.string "attr_firstname", :limit => 30 - t.string "attr_lastname", :limit => 30 - t.string "attr_mail", :limit => 30 - t.boolean "onthefly_register", :default => false, :null => false - t.boolean "tls", :default => false, :null => false - t.string "filter" - t.integer "timeout" - end - - add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" - - create_table "biding_projects", :force => true do |t| - t.integer "project_id" - t.integer "bid_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "bids", :force => true do |t| - t.string "name" - t.string "budget", :null => false - t.integer "author_id" - t.date "deadline" - t.text "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.integer "commit" - t.integer "reward_type" - t.integer "homework_type" - t.integer "parent_id" - t.string "password" - t.integer "is_evaluation" - t.integer "proportion", :default => 60 - t.integer "comment_status", :default => 0 - t.integer "evaluation_num", :default => 3 - t.integer "open_anonymous_evaluation", :default => 1 - end - - create_table "blog_comments", :force => true do |t| - t.integer "blog_id", :null => false - t.integer "parent_id" - t.string "title", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comment_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "blogs", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.integer "position", :default => 1 - t.integer "article_count", :default => 0, :null => false - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comments_id" - t.integer "parent_id" - t.integer "author_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "homepage_id" - end - - create_table "boards", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :default => "", :null => false - t.string "description" - t.integer "position", :default => 1 - t.integer "topics_count", :default => 0, :null => false - t.integer "messages_count", :default => 0, :null => false - t.integer "last_message_id" - t.integer "parent_id" - t.integer "course_id" - t.integer "org_subfield_id" - end - - add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" - add_index "boards", ["project_id"], :name => "boards_project_id" - - create_table "bug_to_osps", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "changes", :force => true do |t| - t.integer "changeset_id", :null => false - t.string "action", :limit => 1, :default => "", :null => false - t.text "path", :null => false - t.text "from_path" - t.string "from_revision" - t.string "revision" - t.string "branch" - end - - add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" - - create_table "changeset_parents", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "parent_id", :null => false - end - - add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" - add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" - - create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false - t.string "committer" - t.datetime "committed_on", :null => false - t.text "comments" - t.date "commit_date" - t.string "scmid" - t.integer "user_id" - end - - add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" - add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true - add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" - add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" - add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" - - create_table "changesets_issues", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "issue_id", :null => false - end - - add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - - create_table "comments", :force => true do |t| - t.string "commented_type", :limit => 30, :default => "", :null => false - t.integer "commented_id", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.text "comments" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "comments", ["author_id"], :name => "index_comments_on_author_id" - add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" - - create_table "contest_notifications", :force => true do |t| - t.text "title" - t.text "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" - t.integer "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contestnotifications", :force => true do |t| - t.integer "contest_id" - t.string "title" - t.string "summary" - t.text "description" - t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contests", :force => true do |t| - t.string "name" - t.string "budget", :default => "" - t.integer "author_id" - t.date "deadline" - t.string "description" - t.integer "commit" - t.string "password" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - create_table "course_activities", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_act_id" - t.string "course_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_attachments", :force => true do |t| - t.string "filename" - t.string "disk_filename" - t.integer "filesize" - t.string "content_type" - t.string "digest" - t.integer "downloads" - t.string "author_id" - t.string "integer" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "container_id", :default => 0 - end - - create_table "course_contributor_scores", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.integer "message_num" - t.integer "message_reply_num" - t.integer "news_reply_num" - t.integer "resource_num" - t.integer "journal_num" - t.integer "journal_reply_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "total_score" - t.integer "homework_journal_num", :default => 0 - t.integer "news_num", :default => 0 - end - - create_table "course_groups", :force => true do |t| - t.string "name" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_infos", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_messages", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_message_id" - t.string "course_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "content" - t.integer "status" - end - - create_table "course_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "course_id" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "courses", :force => true do |t| - t.integer "tea_id" - t.string "name" - t.integer "state" - t.string "code" - t.integer "time" - t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "location" - t.string "term" - t.string "string" - t.string "password" - t.string "setup_time" - t.string "endup_time" - t.string "class_period" - t.integer "school_id" - t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 - t.integer "lft" - t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "is_delete", :default => 0 - t.integer "end_time" - t.string "end_term" - t.integer "is_excellent", :default => 0 - t.integer "excellent_option", :default => 0 - t.integer "is_copy", :default => 0 - t.integer "visits", :default => 0 - end - - create_table "custom_fields", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.string "field_format", :limit => 30, :default => "", :null => false - t.text "possible_values" - t.string "regexp", :default => "" - t.integer "min_length", :default => 0, :null => false - t.integer "max_length", :default => 0, :null => false - t.boolean "is_required", :default => false, :null => false - t.boolean "is_for_all", :default => false, :null => false - t.boolean "is_filter", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "searchable", :default => false - t.text "default_value" - t.boolean "editable", :default => true - t.boolean "visible", :default => true, :null => false - t.boolean "multiple", :default => false - end - - add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" - - create_table "custom_fields_projects", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "project_id", :default => 0, :null => false - end - - add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true - - create_table "custom_fields_trackers", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true - - create_table "custom_values", :force => true do |t| - t.string "customized_type", :limit => 30, :default => "", :null => false - t.integer "customized_id", :default => 0, :null => false - t.integer "custom_field_id", :default => 0, :null => false - t.text "value" - end - - add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" - add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" - - create_table "delayed_jobs", :force => true do |t| - t.integer "priority", :default => 0, :null => false - t.integer "attempts", :default => 0, :null => false - t.text "handler", :null => false - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "documents", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "category_id", :default => 0, :null => false - t.string "title", :limit => 60, :default => "", :null => false - t.text "description" - t.datetime "created_on" - t.integer "user_id", :default => 0 - t.integer "is_public", :default => 1 - end - - add_index "documents", ["category_id"], :name => "index_documents_on_category_id" - add_index "documents", ["created_on"], :name => "index_documents_on_created_on" - add_index "documents", ["project_id"], :name => "documents_project_id" - - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 - t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false - end - - create_table "editor_of_documents", :force => true do |t| - t.integer "editor_id" - t.integer "org_document_comment_id" - t.datetime "created_at" - end - - create_table "enabled_modules", :force => true do |t| - t.integer "project_id" - t.string "name", :null => false - t.integer "course_id" - end - - add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" - - create_table "enumerations", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "is_default", :default => false, :null => false - t.string "type" - t.boolean "active", :default => true, :null => false - t.integer "project_id" - t.integer "parent_id" - t.string "position_name", :limit => 30 - end - - add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" - add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" - - create_table "exercise_answers", :force => true do |t| - t.integer "user_id" - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_choices", :force => true do |t| - t.integer "exercise_question_id" - t.text "choice_text" - t.integer "choice_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_questions", :force => true do |t| - t.text "question_title" - t.integer "question_type" - t.integer "question_number" - t.integer "exercise_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_score" - end - - create_table "exercise_standard_answers", :force => true do |t| - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_users", :force => true do |t| - t.integer "user_id" - t.integer "exercise_id" - t.integer "score" - t.datetime "start_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "end_at" - t.integer "status" - end - - create_table "exercises", :force => true do |t| - t.text "exercise_name" - t.text "exercise_description" - t.integer "course_id" - t.integer "exercise_status" - t.integer "user_id" - t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "publish_time" - t.datetime "end_time" - t.integer "show_result" - end - - create_table "first_pages", :force => true do |t| - t.string "web_title" - t.string "title" - t.text "description" - t.string "page_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sort_type" - t.integer "image_width", :default => 107 - t.integer "image_height", :default => 63 - t.integer "show_course", :default => 1 - t.integer "show_contest", :default => 1 - end - - create_table "forge_activities", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_act_id" - t.string "forge_act_type" - t.integer "org_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" - - create_table "forge_messages", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_message_id" - t.string "forge_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "secret_key" - t.integer "status" - end - - create_table "forums", :force => true do |t| - t.string "name", :null => false - t.text "description" - t.integer "topic_count", :default => 0 - t.integer "memo_count", :default => 0 - t.integer "last_memo_id", :default => 0 - t.integer "creator_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sticky" - t.integer "locked" - end - - create_table "forwards", :force => true do |t| - t.integer "from_id" - t.string "from_type" - t.integer "to_id" - t.string "to_type" - t.datetime "created_at" - end - - create_table "groups_users", :id => false, :force => true do |t| - t.integer "group_id", :null => false - t.integer "user_id", :null => false - end - - add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true - - create_table "homework_attaches", :force => true do |t| - t.integer "bid_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - t.string "name" - t.text "description" - t.integer "state" - t.integer "project_id", :default => 0 - t.float "score", :default => 0.0 - t.integer "is_teacher_score", :default => 0 - end - - add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" - - create_table "homework_commons", :force => true do |t| - t.string "name" - t.integer "user_id" - t.text "description" - t.date "publish_time" - t.date "end_time" - t.integer "homework_type", :default => 1 - t.string "late_penalty" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "teacher_priority", :default => 1 - t.integer "anonymous_comment", :default => 0 - t.integer "quotes", :default => 0 - t.integer "is_open", :default => 0 - end - - add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" - - create_table "homework_detail_groups", :force => true do |t| - t.integer "homework_common_id" - t.integer "min_num" - t.integer "max_num" - t.integer "base_on_project" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" - - create_table "homework_detail_manuals", :force => true do |t| - t.float "ta_proportion" - t.integer "comment_status" - t.date "evaluation_start" - t.date "evaluation_end" - t.integer "evaluation_num" - t.integer "absence_penalty", :default => 1 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_detail_programings", :force => true do |t| - t.string "language" - t.text "standard_code", :limit => 2147483647 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "ta_proportion", :default => 0.1 - t.integer "question_id" - end - - create_table "homework_evaluations", :force => true do |t| - t.string "user_id" - t.string "homework_attach_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_for_courses", :force => true do |t| - t.integer "course_id" - t.integer "bid_id" - end - - add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" - add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" - - create_table "homework_tests", :force => true do |t| - t.text "input" - t.text "output" - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "result" - t.text "error_msg" - end - - create_table "homework_users", :force => true do |t| - t.string "homework_attach_id" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "invite_lists", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "mail" - end - - create_table "issue_categories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.integer "assigned_to_id" - end - - add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" - add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" - - create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :default => "", :null => false - t.integer "delay" - end - - add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true - add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" - add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" - - create_table "issue_statuses", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_closed", :default => false, :null => false - t.boolean "is_default", :default => false, :null => false - t.integer "position", :default => 1 - t.integer "default_done_ratio" - end - - add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" - add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" - add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" - - create_table "issues", :force => true do |t| - t.integer "tracker_id", :null => false - t.integer "project_id", :null => false - t.string "subject", :default => "", :null => false - t.text "description" - t.date "due_date" - t.integer "category_id" - t.integer "status_id", :null => false - t.integer "assigned_to_id" - t.integer "priority_id", :null => false - t.integer "fixed_version_id" - t.integer "author_id", :null => false - t.integer "lock_version", :default => 0, :null => false - t.datetime "created_on" - t.datetime "updated_on" - t.date "start_date" - t.integer "done_ratio", :default => 0, :null => false - t.float "estimated_hours" - t.integer "parent_id" - t.integer "root_id" - t.integer "lft" - t.integer "rgt" - t.boolean "is_private", :default => false, :null => false - t.datetime "closed_on" - t.integer "project_issues_index" - end - - add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" - add_index "issues", ["category_id"], :name => "index_issues_on_category_id" - add_index "issues", ["created_on"], :name => "index_issues_on_created_on" - add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" - add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" - add_index "issues", ["project_id"], :name => "issues_project_id" - add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" - add_index "issues", ["status_id"], :name => "index_issues_on_status_id" - add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" - - create_table "join_in_competitions", :force => true do |t| - t.integer "user_id" - t.integer "competition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "join_in_contests", :force => true do |t| - t.integer "user_id" - t.integer "bid_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "journal_details", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - - create_table "journal_replies", :id => false, :force => true do |t| - t.integer "journal_id" - t.integer "user_id" - t.integer "reply_id" - end - - add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" - add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" - add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" - - create_table "journals", :force => true do |t| - t.integer "journalized_id", :default => 0, :null => false - t.string "journalized_type", :limit => 30, :default => "", :null => false - t.integer "user_id", :default => 0, :null => false - t.text "notes" - t.datetime "created_on", :null => false - t.boolean "private_notes", :default => false, :null => false - end - - add_index "journals", ["created_on"], :name => "index_journals_on_created_on" - add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" - add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" - add_index "journals", ["user_id"], :name => "index_journals_on_user_id" - - create_table "journals_for_messages", :force => true do |t| - t.integer "jour_id" - t.string "jour_type" - t.integer "user_id" - t.text "notes" - t.integer "status" - t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.string "m_parent_id" - t.boolean "is_readed" - t.integer "m_reply_count" - t.integer "m_reply_id" - t.integer "is_comprehensive_evaluation" - t.integer "private", :default => 0 - end - - create_table "kindeditor_assets", :force => true do |t| - t.string "asset" - t.integer "file_size" - t.string "file_type" - t.integer "owner_id" - t.string "asset_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "owner_type", :default => 0 - end - - create_table "member_roles", :force => true do |t| - t.integer "member_id", :null => false - t.integer "role_id", :null => false - t.integer "inherited_from" - end - - add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" - add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" - - create_table "members", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "project_id", :default => 0 - t.datetime "created_on" - t.boolean "mail_notification", :default => false, :null => false - t.integer "course_id", :default => -1 - t.integer "course_group_id", :default => 0 - end - - add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true - add_index "members", ["user_id"], :name => "index_members_on_user_id" - - create_table "memo_messages", :force => true do |t| - t.integer "user_id" - t.integer "forum_id" - t.integer "memo_id" - t.string "memo_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "memos", :force => true do |t| - t.integer "forum_id", :null => false - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false - t.integer "author_id", :null => false - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count", :default => 0 - end - - create_table "message_alls", :force => true do |t| - t.integer "user_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "messages", :force => true do |t| - t.integer "board_id", :null => false - t.integer "parent_id" - t.string "subject", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "replies_count", :default => 0, :null => false - t.integer "last_reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.integer "quotes" - t.integer "status", :default => 0 - end - - add_index "messages", ["author_id"], :name => "index_messages_on_author_id" - add_index "messages", ["board_id"], :name => "messages_board_id" - add_index "messages", ["created_on"], :name => "index_messages_on_created_on" - add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" - add_index "messages", ["parent_id"], :name => "messages_parent_id" - - create_table "news", :force => true do |t| - t.integer "project_id" - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" - t.text "description" - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false - t.integer "course_id" - t.integer "sticky", :default => 0 - t.integer "org_subfield_id" - end - - add_index "news", ["author_id"], :name => "index_news_on_author_id" - add_index "news", ["created_on"], :name => "index_news_on_created_on" - add_index "news", ["project_id"], :name => "news_project_id" - - create_table "no_uses", :force => true do |t| - t.integer "user_id", :null => false - t.string "no_use_type" - t.integer "no_use_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "notificationcomments", :force => true do |t| - t.string "notificationcommented_type" - t.integer "notificationcommented_id" - t.integer "author_id" - t.text "notificationcomments" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "onclick_times", :force => true do |t| - t.integer "user_id" - t.datetime "onclick_time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "open_id_authentication_associations", :force => true do |t| - t.integer "issued" - t.integer "lifetime" - t.string "handle" - t.string "assoc_type" - t.binary "server_url" - t.binary "secret" - end - - create_table "open_id_authentication_nonces", :force => true do |t| - t.integer "timestamp", :null => false - t.string "server_url" - t.string "salt", :null => false - end - - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.text "description" - t.integer "commit_count", :default => 0 - t.integer "code_line", :default => 0 - t.integer "users_count", :default => 0 - t.date "last_commit_time" - t.string "url" - t.date "date_collected" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "option_numbers", :force => true do |t| - t.integer "user_id" - t.integer "memo" - t.integer "messages_for_issues" - t.integer "issues_status" - t.integer "replay_for_message" - t.integer "replay_for_memo" - t.integer "follow" - t.integer "tread" - t.integer "praise_by_one" - t.integer "praise_by_two" - t.integer "praise_by_three" - t.integer "tread_by_one" - t.integer "tread_by_two" - t.integer "tread_by_three" - t.integer "changeset" - t.integer "document" - t.integer "attachment" - t.integer "issue_done_ratio" - t.integer "post_issue" - t.integer "score_type" - t.integer "total_score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - end - - create_table "org_activities", :force => true do |t| - t.integer "user_id" - t.integer "org_act_id" - t.string "org_act_type" - t.integer "container_id" - t.string "container_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_courses", :force => true do |t| - t.integer "organization_id" - t.integer "course_id" - t.datetime "created_at" - end - - create_table "org_document_comments", :force => true do |t| - t.text "title" - t.text "content" - t.integer "organization_id" - t.integer "creator_id" - t.integer "parent_id" - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "org_subfield_id" - end - - create_table "org_member_roles", :force => true do |t| - t.integer "org_member_id" - t.integer "role_id" - end - - create_table "org_members", :force => true do |t| - t.integer "user_id" - t.integer "organization_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_messages", :force => true do |t| - t.integer "user_id" - t.integer "sender_id" - t.integer "organization_id" - t.string "message_type" - t.integer "message_id" - t.integer "viewed" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "status", :default => 0 - end - - create_table "org_projects", :force => true do |t| - t.integer "organization_id" - t.integer "project_id" - t.datetime "created_at" - end - - create_table "org_subfield_messages", :force => true do |t| - t.integer "org_subfield_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_subfields", :force => true do |t| - t.integer "organization_id" - t.integer "priority" - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "field_type" - t.integer "hide", :default => 0 - end - - create_table "organizations", :force => true do |t| - t.string "name" - t.text "description" - t.integer "creator_id" - t.integer "home_id" - t.boolean "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "allow_guest_download", :default => true - t.integer "visits", :default => 0 - end - - create_table "phone_app_versions", :force => true do |t| - t.string "version" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_answers", :force => true do |t| - t.integer "poll_question_id" - t.text "answer_text" - t.integer "answer_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_questions", :force => true do |t| - t.string "question_title" - t.integer "question_type" - t.integer "is_necessary" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_number" - end - - create_table "poll_users", :force => true do |t| - t.integer "user_id" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_votes", :force => true do |t| - t.integer "user_id" - t.integer "poll_question_id" - t.integer "poll_answer_id" - t.text "vote_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "polls", :force => true do |t| - t.string "polls_name" - t.string "polls_type" - t.integer "polls_group_id" - t.integer "polls_status" - t.integer "user_id" - t.datetime "published_at" - t.datetime "closed_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "polls_description" - t.integer "show_result", :default => 1 - end - - create_table "praise_tread_caches", :force => true do |t| - t.integer "object_id", :null => false - t.string "object_type" - t.integer "praise_num" - t.integer "tread_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "praise_treads", :force => true do |t| - t.integer "user_id", :null => false - t.integer "praise_tread_object_id" - t.string "praise_tread_object_type" - t.integer "praise_or_tread" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "principal_activities", :force => true do |t| - t.integer "user_id" - t.integer "principal_id" - t.integer "principal_act_id" - t.string "principal_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_infos", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_scores", :force => true do |t| - t.string "project_id" - t.integer "score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "issue_num", :default => 0 - t.integer "issue_journal_num", :default => 0 - t.integer "news_num", :default => 0 - t.integer "documents_num", :default => 0 - t.integer "changeset_num", :default => 0 - t.integer "board_message_num", :default => 0 - t.integer "board_num", :default => 0 - t.integer "attach_num", :default => 0 - t.datetime "commit_time" - end - - create_table "project_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "project_id" - t.integer "project_type" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - end - - add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - - create_table "projecting_softapplictions", :force => true do |t| - t.integer "user_id" - t.integer "softapplication_id" - t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false - t.integer "parent_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "identifier" - t.integer "status", :default => 1, :null => false - t.integer "lft" - t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false - t.integer "project_type" - t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 - t.integer "user_id" - t.integer "dts_test", :default => 0 - t.string "enterprise_name" - t.integer "organization_id" - t.integer "project_new_type" - t.integer "gpid" - t.integer "forked_from_project_id" - t.integer "forked_count" - t.integer "commits_count", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "issues_count", :default => 0 - t.integer "attachments_count", :default => 0 - t.integer "boards_count", :default => 0 - t.integer "news_count", :default => 0 - t.integer "acts_count", :default => 0 - t.integer "journals_count", :default => 0 - t.integer "boards_reply_count", :default => 0 - t.integer "visits", :default => 0 - end - - add_index "projects", ["lft"], :name => "index_projects_on_lft" - add_index "projects", ["rgt"], :name => "index_projects_on_rgt" - - create_table "projects_trackers", :id => false, :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true - add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" - - create_table "queries", :force => true do |t| - t.integer "project_id" - t.string "name", :default => "", :null => false - t.text "filters" - t.integer "user_id", :default => 0, :null => false - t.boolean "is_public", :default => false, :null => false - t.text "column_names" - t.text "sort_criteria" - t.string "group_by" - t.string "type" - end - - add_index "queries", ["project_id"], :name => "index_queries_on_project_id" - add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - - create_table "relative_memo_to_open_source_projects", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "relative_memos", :force => true do |t| - t.integer "osp_id" - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 16777215, :null => false - t.integer "author_id" - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 - t.string "url" - t.string "username" - t.string "userhomeurl" - t.date "date_collected" - t.string "topic_resource" - end - - create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" - t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 - t.text "extra_info" - t.string "identifier" - t.boolean "is_default", :default => false - t.boolean "hidden", :default => false - end - - add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - - create_table "roles", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "assignable", :default => true - t.integer "builtin", :default => 0, :null => false - t.text "permissions" - t.string "issues_visibility", :limit => 30, :default => "default", :null => false - end - - create_table "schools", :force => true do |t| - t.string "name" - t.string "province" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "logo_link" - t.string "pinyin" - end - - create_table "secdomains", :force => true do |t| - t.integer "sub_type" - t.string "subname" - t.integer "pid", :default => 0 - t.string "desc" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_cached_ratings", :force => true do |t| - t.integer "cacheable_id", :limit => 8 - t.string "cacheable_type" - t.float "avg", :null => false - t.integer "cnt", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_rates", :force => true do |t| - t.integer "rater_id", :limit => 8 - t.integer "rateable_id" - t.string "rateable_type" - t.float "stars", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "is_teacher_score", :default => 0 - end - - create_table "settings", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "value" - t.datetime "updated_on" - end - - add_index "settings", ["name"], :name => "index_settings_on_name" - - create_table "shares", :force => true do |t| - t.date "created_on" - t.string "url" - t.string "title" - t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - t.integer "user_id" - t.string "description" - end - - create_table "shield_activities", :force => true do |t| - t.string "container_type" - t.integer "container_id" - t.string "shield_type" - t.integer "shield_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "softapplications", :force => true do |t| - t.string "name" - t.text "description" - t.integer "app_type_id" - t.string "app_type_name" - t.string "android_min_version_available" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "contest_id" - t.integer "softapplication_id" - t.integer "is_public" - t.string "application_developers" - t.string "deposit_project_url" - t.string "deposit_project" - t.integer "project_id" - end - - create_table "student_work_projects", :force => true do |t| - t.integer "homework_common_id" - t.integer "student_work_id" - t.integer "project_id" - t.integer "user_id" - t.integer "is_leader" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "student_work_projects", ["homework_common_id"], :name => "index_student_work_projects_on_homework_common_id" - add_index "student_work_projects", ["project_id"], :name => "index_student_work_projects_on_project_id" - add_index "student_work_projects", ["student_work_id"], :name => "index_student_work_projects_on_student_work_id" - add_index "student_work_projects", ["user_id"], :name => "index_student_work_projects_on_user_id" - - create_table "student_work_tests", :force => true do |t| - t.integer "student_work_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "status", :default => 9 - t.text "results" - t.text "src" - end - - create_table "student_works", :force => true do |t| - t.string "name" - t.text "description", :limit => 2147483647 - t.integer "homework_common_id" - t.integer "user_id" - t.float "final_score" - t.float "teacher_score" - t.float "student_score" - t.float "teaching_asistant_score" - t.integer "project_id", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "late_penalty", :default => 0 - t.integer "absence_penalty", :default => 0 - t.float "system_score", :default => 0.0 - t.boolean "is_test", :default => false - end - - add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" - - create_table "student_works_evaluation_distributions", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "student_works_scores", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.integer "score" - t.text "comment" - t.integer "reviewer_role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "students_for_courses", :force => true do |t| - t.integer "student_id" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" - add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" - - create_table "subfield_subdomain_dirs", :force => true do |t| - t.integer "org_subfield_id" - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "system_messages", :force => true do |t| - t.integer "user_id" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "description" - t.string "subject" - end - - create_table "taggings", :force => true do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", :limit => 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" - - create_table "tags", :force => true do |t| - t.string "name" - end - - create_table "teachers", :force => true do |t| - t.string "tea_name" - t.string "location" - t.integer "couurse_time" - t.integer "course_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "extra" - end - - create_table "time_entries", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "issue_id" - t.float "hours", :null => false - t.string "comments" - t.integer "activity_id", :null => false - t.date "spent_on", :null => false - t.integer "tyear", :null => false - t.integer "tmonth", :null => false - t.integer "tweek", :null => false - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" - add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" - add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" - add_index "time_entries", ["project_id"], :name => "time_entries_project_id" - add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - - create_table "tokens", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40, :default => "", :null => false - t.datetime "created_on", :null => false - end - - add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" - add_index "tokens", ["value"], :name => "tokens_value", :unique => true - - create_table "trackers", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_in_chlog", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "is_in_roadmap", :default => true, :null => false - t.integer "fields_bits", :default => 0 - end - - create_table "user_actions", :force => true do |t| - t.integer "user_id" - t.string "action_type" - t.integer "action_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_activities", :force => true do |t| - t.string "act_type" - t.integer "act_id" - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "user_id" - end - - create_table "user_extensions", :force => true do |t| - t.integer "user_id", :null => false - t.date "birthday" - t.string "brief_introduction" - t.integer "gender" - t.string "location" - t.string "occupation" - t.integer "work_experience" - t.integer "zip_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "technical_title" - t.integer "identity" - t.string "student_id" - t.string "teacher_realname" - t.string "student_realname" - t.string "location_city" - t.integer "school_id" - t.string "description", :default => "" - end - - create_table "user_feedback_messages", :force => true do |t| - t.integer "user_id" - t.integer "journals_for_message_id" - t.string "journals_for_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_grades", :force => true do |t| - t.integer "user_id", :null => false - t.integer "project_id", :null => false - t.float "grade", :default => 0.0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" - add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" - add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" - - create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - end - - create_table "user_preferences", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.text "others" - t.boolean "hide_mail", :default => false - t.string "time_zone" - end - - add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" - - create_table "user_score_details", :force => true do |t| - t.integer "current_user_id" - t.integer "target_user_id" - t.string "score_type" - t.string "score_action" - t.integer "user_id" - t.integer "old_score" - t.integer "new_score" - t.integer "current_user_level" - t.integer "target_user_level" - t.integer "score_changeable_obj_id" - t.string "score_changeable_obj_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "grade", :default => 0.0 - end - - add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" - add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" - add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" - - create_table "user_wechats", :force => true do |t| - t.integer "subscribe" - t.string "openid" - t.string "nickname" - t.integer "sex" - t.string "language" - t.string "city" - t.string "province" - t.string "country" - t.string "headimgurl" - t.string "subscribe_time" - t.string "unionid" - t.string "remark" - t.integer "groupid" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "users", :force => true do |t| - t.string "login", :default => "", :null => false - t.string "hashed_password", :limit => 40, :default => "", :null => false - t.string "firstname", :limit => 30, :default => "", :null => false - t.string "lastname", :default => "", :null => false - t.string "mail", :limit => 60, :default => "", :null => false - t.boolean "admin", :default => false, :null => false - t.integer "status", :default => 1, :null => false - t.datetime "last_login_on" - t.string "language", :limit => 5, :default => "" - t.integer "auth_source_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "type" - t.string "identity_url" - t.string "mail_notification", :default => "", :null => false - t.string "salt", :limit => 64 - t.integer "gid" - t.integer "visits", :default => 0 - end - - add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" - add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" - add_index "users", ["type"], :name => "index_users_on_type" - - create_table "versions", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :default => "", :null => false - t.string "description", :default => "" - t.date "effective_date" - t.datetime "created_on" - t.datetime "updated_on" - t.string "wiki_page_title" - t.string "status", :default => "open" - t.string "sharing", :default => "none", :null => false - end - - add_index "versions", ["project_id"], :name => "versions_project_id" - add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - - create_table "visitors", :force => true do |t| - t.integer "user_id" - t.integer "master_id" - t.datetime "updated_on" - t.datetime "created_on" - end - - add_index "visitors", ["master_id"], :name => "index_visitors_master_id" - add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" - add_index "visitors", ["user_id"], :name => "index_visitors_user_id" - - create_table "watchers", :force => true do |t| - t.string "watchable_type", :default => "", :null => false - t.integer "watchable_id", :default => 0, :null => false - t.integer "user_id" - end - - add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" - add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" - add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" - - create_table "web_footer_companies", :force => true do |t| - t.string "name" - t.string "logo_size" - t.string "url" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "web_footer_oranizers", :force => true do |t| - t.string "name" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "wechat_logs", :force => true do |t| - t.string "openid", :null => false - t.text "request_raw" - t.text "response_raw" - t.text "session_raw" - t.datetime "created_at", :null => false - end - - create_table "wiki_content_versions", :force => true do |t| - t.integer "wiki_content_id", :null => false - t.integer "page_id", :null => false - t.integer "author_id" - t.binary "data", :limit => 2147483647 - t.string "compression", :limit => 6, :default => "" - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" - add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" - - create_table "wiki_contents", :force => true do |t| - t.integer "page_id", :null => false - t.integer "author_id" - t.text "text", :limit => 2147483647 - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" - add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" - - create_table "wiki_pages", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title", :null => false - t.datetime "created_on", :null => false - t.boolean "protected", :default => false, :null => false - t.integer "parent_id" - end - - add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" - add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" - add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" - - create_table "wiki_redirects", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title" - t.string "redirects_to" - t.datetime "created_on", :null => false - end - - add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" - add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" - - create_table "wikis", :force => true do |t| - t.integer "project_id", :null => false - t.string "start_page", :null => false - t.integer "status", :default => 1, :null => false - end - - add_index "wikis", ["project_id"], :name => "wikis_project_id" - - create_table "workflows", :force => true do |t| - t.integer "tracker_id", :default => 0, :null => false - t.integer "old_status_id", :default => 0, :null => false - t.integer "new_status_id", :default => 0, :null => false - t.integer "role_id", :default => 0, :null => false - t.boolean "assignee", :default => false, :null => false - t.boolean "author", :default => false, :null => false - t.string "type", :limit => 30 - t.string "field_name", :limit => 30 - t.string "rule", :limit => 30 - end - - add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" - add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" - add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" - add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - - create_table "works_categories", :force => true do |t| - t.string "category" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "zip_packs", :force => true do |t| - t.integer "user_id" - t.integer "homework_id" - t.string "file_digest" - t.string "file_path" - t.integer "pack_times", :default => 1 - t.integer "pack_size", :default => 0 - t.text "file_digests" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -end +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20160317090350) do + + create_table "activities", :force => true do |t| + t.integer "act_id", :null => false + t.string "act_type", :null => false + t.integer "user_id", :null => false + t.integer "activity_container_id" + t.string "activity_container_type", :default => "" + t.datetime "created_at" + end + + add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" + add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" + add_index "activities", ["user_id"], :name => "index_activities_on_user_id" + + create_table "activity_notifies", :force => true do |t| + t.integer "activity_container_id" + t.string "activity_container_type" + t.integer "activity_id" + t.string "activity_type" + t.integer "notify_to" + t.datetime "created_on" + t.integer "is_read" + end + + add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" + add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" + add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" + + create_table "api_keys", :force => true do |t| + t.string "access_token" + t.datetime "expires_at" + t.integer "user_id" + t.boolean "active", :default => true + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" + add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" + + create_table "applied_projects", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + end + + create_table "apply_project_masters", :force => true do |t| + t.integer "user_id" + t.string "apply_type" + t.integer "apply_id" + t.integer "status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "at_messages", :force => true do |t| + t.integer "user_id" + t.integer "at_message_id" + t.string "at_message_type" + t.boolean "viewed", :default => false + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sender_id" + end + + add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" + + create_table "attachment_histories", :force => true do |t| + t.integer "container_id" + t.string "container_type" + t.string "filename", :default => "" + t.string "disk_filename", :default => "" + t.integer "filesize", :default => 0 + t.string "content_type", :default => "" + t.string "digest", :limit => 40, :default => "" + t.integer "downloads", :default => 0 + t.integer "author_id" + t.datetime "created_on" + t.string "description" + t.string "disk_directory" + t.integer "attachtype" + t.integer "is_public" + t.integer "copy_from" + t.integer "quotes" + t.integer "version" + t.integer "attachment_id" + t.integer "is_publish", :default => 1 + t.date "publish_time" + end + + create_table "attachments", :force => true do |t| + t.integer "container_id" + t.string "container_type", :limit => 30 + t.string "filename", :default => "", :null => false + t.string "disk_filename", :default => "", :null => false + t.integer "filesize", :default => 0, :null => false + t.string "content_type", :default => "" + t.string "digest", :limit => 40, :default => "", :null => false + t.integer "downloads", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.string "description" + t.string "disk_directory" + t.integer "attachtype", :default => 1 + t.integer "is_public", :default => 1 + t.integer "copy_from" + t.integer "quotes" + t.integer "is_publish", :default => 1 + t.date "publish_time" + end + + add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" + add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" + add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" + + create_table "attachmentstypes", :force => true do |t| + t.integer "typeId", :null => false + t.string "typeName", :limit => 50 + end + + create_table "auth_sources", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 60, :default => "", :null => false + t.string "host", :limit => 60 + t.integer "port" + t.string "account" + t.string "account_password", :default => "" + t.string "base_dn" + t.string "attr_login", :limit => 30 + t.string "attr_firstname", :limit => 30 + t.string "attr_lastname", :limit => 30 + t.string "attr_mail", :limit => 30 + t.boolean "onthefly_register", :default => false, :null => false + t.boolean "tls", :default => false, :null => false + t.string "filter" + t.integer "timeout" + end + + add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" + + create_table "biding_projects", :force => true do |t| + t.integer "project_id" + t.integer "bid_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "bids", :force => true do |t| + t.string "name" + t.string "budget", :null => false + t.integer "author_id" + t.date "deadline" + t.text "description" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.integer "commit" + t.integer "reward_type" + t.integer "homework_type" + t.integer "parent_id" + t.string "password" + t.integer "is_evaluation" + t.integer "proportion", :default => 60 + t.integer "comment_status", :default => 0 + t.integer "evaluation_num", :default => 3 + t.integer "open_anonymous_evaluation", :default => 1 + end + + create_table "blog_comments", :force => true do |t| + t.integer "blog_id", :null => false + t.integer "parent_id" + t.string "title", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comment_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "blogs", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.integer "position", :default => 1 + t.integer "article_count", :default => 0, :null => false + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comments_id" + t.integer "parent_id" + t.integer "author_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "homepage_id" + end + + create_table "boards", :force => true do |t| + t.integer "project_id", :null => false + t.string "name", :default => "", :null => false + t.string "description" + t.integer "position", :default => 1 + t.integer "topics_count", :default => 0, :null => false + t.integer "messages_count", :default => 0, :null => false + t.integer "last_message_id" + t.integer "parent_id" + t.integer "course_id" + t.integer "org_subfield_id" + end + + add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" + add_index "boards", ["project_id"], :name => "boards_project_id" + + create_table "bug_to_osps", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "changes", :force => true do |t| + t.integer "changeset_id", :null => false + t.string "action", :limit => 1, :default => "", :null => false + t.text "path", :null => false + t.text "from_path" + t.string "from_revision" + t.string "revision" + t.string "branch" + end + + add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" + + create_table "changeset_parents", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "parent_id", :null => false + end + + add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" + add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" + + create_table "changesets", :force => true do |t| + t.integer "repository_id", :null => false + t.string "revision", :null => false + t.string "committer" + t.datetime "committed_on", :null => false + t.text "comments" + t.date "commit_date" + t.string "scmid" + t.integer "user_id" + end + + add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" + add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true + add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" + add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" + add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" + + create_table "changesets_issues", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "issue_id", :null => false + end + + add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true + + create_table "code_review_assignments", :force => true do |t| + t.integer "issue_id" + t.integer "change_id" + t.integer "attachment_id" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.string "action_type" + t.integer "changeset_id" + end + + create_table "code_review_project_settings", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "updated_by" + t.boolean "hide_code_review_tab", :default => false + t.integer "auto_relation", :default => 1 + t.integer "assignment_tracker_id" + t.text "auto_assign" + t.integer "lock_version", :default => 0, :null => false + t.boolean "tracker_in_review_dialog", :default => false + end + + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "code_reviews", :force => true do |t| + t.integer "project_id" + t.integer "change_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line" + t.integer "updated_by_id" + t.integer "lock_version", :default => 0, :null => false + t.integer "status_changed_from" + t.integer "status_changed_to" + t.integer "issue_id" + t.string "action_type" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.integer "attachment_id" + t.integer "file_count", :default => 0, :null => false + t.boolean "diff_all" + end + + create_table "comments", :force => true do |t| + t.string "commented_type", :limit => 30, :default => "", :null => false + t.integer "commented_id", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.text "comments" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + add_index "comments", ["author_id"], :name => "index_comments_on_author_id" + add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + + create_table "contest_notifications", :force => true do |t| + t.text "title" + t.text "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contesting_projects", :force => true do |t| + t.integer "project_id" + t.string "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contesting_softapplications", :force => true do |t| + t.integer "softapplication_id" + t.integer "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.text "description" + t.integer "author_id" + t.integer "notificationcomments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contests", :force => true do |t| + t.string "name" + t.string "budget", :default => "" + t.integer "author_id" + t.date "deadline" + t.string "description" + t.integer "commit" + t.string "password" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + create_table "course_activities", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_act_id" + t.string "course_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_attachments", :force => true do |t| + t.string "filename" + t.string "disk_filename" + t.integer "filesize" + t.string "content_type" + t.string "digest" + t.integer "downloads" + t.string "author_id" + t.string "integer" + t.string "description" + t.string "disk_directory" + t.integer "attachtype" + t.integer "is_public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "container_id", :default => 0 + end + + create_table "course_contributor_scores", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.integer "message_num" + t.integer "message_reply_num" + t.integer "news_reply_num" + t.integer "resource_num" + t.integer "journal_num" + t.integer "journal_reply_num" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "total_score" + t.integer "homework_journal_num", :default => 0 + t.integer "news_num", :default => 0 + end + + create_table "course_groups", :force => true do |t| + t.string "name" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_infos", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_messages", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_message_id" + t.string "course_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "content" + t.integer "status" + end + + create_table "course_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "course_id" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "courses", :force => true do |t| + t.integer "tea_id" + t.string "name" + t.integer "state" + t.string "code" + t.integer "time" + t.string "extra" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "location" + t.string "term" + t.string "string" + t.string "password" + t.string "setup_time" + t.string "endup_time" + t.string "class_period" + t.integer "school_id" + t.text "description" + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 + t.integer "lft" + t.integer "rgt" + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 + t.integer "open_student", :default => 0 + t.integer "outline", :default => 0 + t.integer "publish_resource", :default => 0 + t.integer "is_delete", :default => 0 + t.integer "end_time" + t.string "end_term" + t.integer "is_excellent", :default => 0 + t.integer "excellent_option", :default => 0 + t.integer "is_copy", :default => 0 + t.integer "visits", :default => 0 + end + + create_table "custom_fields", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.string "field_format", :limit => 30, :default => "", :null => false + t.text "possible_values" + t.string "regexp", :default => "" + t.integer "min_length", :default => 0, :null => false + t.integer "max_length", :default => 0, :null => false + t.boolean "is_required", :default => false, :null => false + t.boolean "is_for_all", :default => false, :null => false + t.boolean "is_filter", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "searchable", :default => false + t.text "default_value" + t.boolean "editable", :default => true + t.boolean "visible", :default => true, :null => false + t.boolean "multiple", :default => false + end + + add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" + + create_table "custom_fields_projects", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "project_id", :default => 0, :null => false + end + + add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true + + create_table "custom_fields_trackers", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true + + create_table "custom_values", :force => true do |t| + t.string "customized_type", :limit => 30, :default => "", :null => false + t.integer "customized_id", :default => 0, :null => false + t.integer "custom_field_id", :default => 0, :null => false + t.text "value" + end + + add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" + add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" + + create_table "delayed_jobs", :force => true do |t| + t.integer "priority", :default => 0, :null => false + t.integer "attempts", :default => 0, :null => false + t.text "handler", :null => false + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "documents", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "category_id", :default => 0, :null => false + t.string "title", :limit => 60, :default => "", :null => false + t.text "description" + t.datetime "created_on" + t.integer "user_id", :default => 0 + t.integer "is_public", :default => 1 + end + + add_index "documents", ["category_id"], :name => "index_documents_on_category_id" + add_index "documents", ["created_on"], :name => "index_documents_on_created_on" + add_index "documents", ["project_id"], :name => "documents_project_id" + + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 + t.string "File" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false + end + + create_table "editor_of_documents", :force => true do |t| + t.integer "editor_id" + t.integer "org_document_comment_id" + t.datetime "created_at" + end + + create_table "enabled_modules", :force => true do |t| + t.integer "project_id" + t.string "name", :null => false + t.integer "course_id" + end + + add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" + + create_table "enumerations", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "is_default", :default => false, :null => false + t.string "type" + t.boolean "active", :default => true, :null => false + t.integer "project_id" + t.integer "parent_id" + t.string "position_name", :limit => 30 + end + + add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" + add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" + + create_table "exercise_answers", :force => true do |t| + t.integer "user_id" + t.integer "exercise_question_id" + t.integer "exercise_choice_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_choices", :force => true do |t| + t.integer "exercise_question_id" + t.text "choice_text" + t.integer "choice_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_questions", :force => true do |t| + t.text "question_title" + t.integer "question_type" + t.integer "question_number" + t.integer "exercise_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_score" + end + + create_table "exercise_standard_answers", :force => true do |t| + t.integer "exercise_question_id" + t.integer "exercise_choice_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_users", :force => true do |t| + t.integer "user_id" + t.integer "exercise_id" + t.integer "score" + t.datetime "start_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.datetime "end_at" + t.integer "status" + end + + create_table "exercises", :force => true do |t| + t.text "exercise_name" + t.text "exercise_description" + t.integer "course_id" + t.integer "exercise_status" + t.integer "user_id" + t.integer "time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.datetime "publish_time" + t.datetime "end_time" + t.integer "show_result" + end + + create_table "first_pages", :force => true do |t| + t.string "web_title" + t.string "title" + t.text "description" + t.string "page_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sort_type" + t.integer "image_width", :default => 107 + t.integer "image_height", :default => 63 + t.integer "show_course", :default => 1 + t.integer "show_contest", :default => 1 + end + + create_table "forge_activities", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_act_id" + t.string "forge_act_type" + t.integer "org_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" + + create_table "forge_messages", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_message_id" + t.string "forge_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "secret_key" + t.integer "status" + end + + create_table "forums", :force => true do |t| + t.string "name", :null => false + t.text "description" + t.integer "topic_count", :default => 0 + t.integer "memo_count", :default => 0 + t.integer "last_memo_id", :default => 0 + t.integer "creator_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sticky" + t.integer "locked" + end + + create_table "forwards", :force => true do |t| + t.integer "from_id" + t.string "from_type" + t.integer "to_id" + t.string "to_type" + t.datetime "created_at" + end + + create_table "groups_users", :id => false, :force => true do |t| + t.integer "group_id", :null => false + t.integer "user_id", :null => false + end + + add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true + + create_table "homework_attaches", :force => true do |t| + t.integer "bid_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + t.string "name" + t.text "description" + t.integer "state" + t.integer "project_id", :default => 0 + t.float "score", :default => 0.0 + t.integer "is_teacher_score", :default => 0 + end + + add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" + + create_table "homework_commons", :force => true do |t| + t.string "name" + t.integer "user_id" + t.text "description" + t.date "publish_time" + t.date "end_time" + t.integer "homework_type", :default => 1 + t.string "late_penalty" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "teacher_priority", :default => 1 + t.integer "anonymous_comment", :default => 0 + t.integer "quotes", :default => 0 + t.integer "is_open", :default => 0 + end + + add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" + + create_table "homework_detail_groups", :force => true do |t| + t.integer "homework_common_id" + t.integer "min_num" + t.integer "max_num" + t.integer "base_on_project" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" + + create_table "homework_detail_manuals", :force => true do |t| + t.float "ta_proportion" + t.integer "comment_status" + t.date "evaluation_start" + t.date "evaluation_end" + t.integer "evaluation_num" + t.integer "absence_penalty", :default => 1 + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_detail_programings", :force => true do |t| + t.string "language" + t.text "standard_code", :limit => 2147483647 + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "ta_proportion", :default => 0.1 + t.integer "question_id" + end + + create_table "homework_evaluations", :force => true do |t| + t.string "user_id" + t.string "homework_attach_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_for_courses", :force => true do |t| + t.integer "course_id" + t.integer "bid_id" + end + + add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" + add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" + + create_table "homework_tests", :force => true do |t| + t.text "input" + t.text "output" + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "result" + t.text "error_msg" + end + + create_table "homework_users", :force => true do |t| + t.string "homework_attach_id" + t.string "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "invite_lists", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "mail" + end + + create_table "issue_categories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.integer "assigned_to_id" + end + + add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" + add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" + + create_table "issue_relations", :force => true do |t| + t.integer "issue_from_id", :null => false + t.integer "issue_to_id", :null => false + t.string "relation_type", :default => "", :null => false + t.integer "delay" + end + + add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true + add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" + add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" + + create_table "issue_statuses", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_closed", :default => false, :null => false + t.boolean "is_default", :default => false, :null => false + t.integer "position", :default => 1 + t.integer "default_done_ratio" + end + + add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" + add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" + add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" + + create_table "issues", :force => true do |t| + t.integer "tracker_id", :null => false + t.integer "project_id", :null => false + t.string "subject", :default => "", :null => false + t.text "description" + t.date "due_date" + t.integer "category_id" + t.integer "status_id", :null => false + t.integer "assigned_to_id" + t.integer "priority_id", :null => false + t.integer "fixed_version_id" + t.integer "author_id", :null => false + t.integer "lock_version", :default => 0, :null => false + t.datetime "created_on" + t.datetime "updated_on" + t.date "start_date" + t.integer "done_ratio", :default => 0, :null => false + t.float "estimated_hours" + t.integer "parent_id" + t.integer "root_id" + t.integer "lft" + t.integer "rgt" + t.boolean "is_private", :default => false, :null => false + t.datetime "closed_on" + t.integer "project_issues_index" + end + + add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" + add_index "issues", ["author_id"], :name => "index_issues_on_author_id" + add_index "issues", ["category_id"], :name => "index_issues_on_category_id" + add_index "issues", ["created_on"], :name => "index_issues_on_created_on" + add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" + add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" + add_index "issues", ["project_id"], :name => "issues_project_id" + add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" + add_index "issues", ["status_id"], :name => "index_issues_on_status_id" + add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" + + create_table "join_in_competitions", :force => true do |t| + t.integer "user_id" + t.integer "competition_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "join_in_contests", :force => true do |t| + t.integer "user_id" + t.integer "bid_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "journal_details", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + + create_table "journal_replies", :id => false, :force => true do |t| + t.integer "journal_id" + t.integer "user_id" + t.integer "reply_id" + end + + add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" + add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" + add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" + + create_table "journals", :force => true do |t| + t.integer "journalized_id", :default => 0, :null => false + t.string "journalized_type", :limit => 30, :default => "", :null => false + t.integer "user_id", :default => 0, :null => false + t.text "notes" + t.datetime "created_on", :null => false + t.boolean "private_notes", :default => false, :null => false + end + + add_index "journals", ["created_on"], :name => "index_journals_on_created_on" + add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" + add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" + add_index "journals", ["user_id"], :name => "index_journals_on_user_id" + + create_table "journals_for_messages", :force => true do |t| + t.integer "jour_id" + t.string "jour_type" + t.integer "user_id" + t.text "notes" + t.integer "status" + t.integer "reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.string "m_parent_id" + t.boolean "is_readed" + t.integer "m_reply_count" + t.integer "m_reply_id" + t.integer "is_comprehensive_evaluation" + t.integer "private", :default => 0 + end + + create_table "kindeditor_assets", :force => true do |t| + t.string "asset" + t.integer "file_size" + t.string "file_type" + t.integer "owner_id" + t.string "asset_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "owner_type", :default => 0 + end + + create_table "member_roles", :force => true do |t| + t.integer "member_id", :null => false + t.integer "role_id", :null => false + t.integer "inherited_from" + end + + add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" + add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" + + create_table "members", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "project_id", :default => 0 + t.datetime "created_on" + t.boolean "mail_notification", :default => false, :null => false + t.integer "course_id", :default => -1 + t.integer "course_group_id", :default => 0 + end + + add_index "members", ["project_id"], :name => "index_members_on_project_id" + add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true + add_index "members", ["user_id"], :name => "index_members_on_user_id" + + create_table "memo_messages", :force => true do |t| + t.integer "user_id" + t.integer "forum_id" + t.integer "memo_id" + t.string "memo_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "memos", :force => true do |t| + t.integer "forum_id", :null => false + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :null => false + t.integer "author_id", :null => false + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count", :default => 0 + end + + create_table "message_alls", :force => true do |t| + t.integer "user_id" + t.integer "message_id" + t.string "message_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "messages", :force => true do |t| + t.integer "board_id", :null => false + t.integer "parent_id" + t.string "subject", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "replies_count", :default => 0, :null => false + t.integer "last_reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + t.integer "quotes" + t.integer "status", :default => 0 + end + + add_index "messages", ["author_id"], :name => "index_messages_on_author_id" + add_index "messages", ["board_id"], :name => "messages_board_id" + add_index "messages", ["created_on"], :name => "index_messages_on_created_on" + add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" + add_index "messages", ["parent_id"], :name => "messages_parent_id" + + create_table "news", :force => true do |t| + t.integer "project_id" + t.string "title", :limit => 60, :default => "", :null => false + t.string "summary", :default => "" + t.text "description" + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.integer "comments_count", :default => 0, :null => false + t.integer "course_id" + t.integer "sticky", :default => 0 + t.integer "org_subfield_id" + end + + add_index "news", ["author_id"], :name => "index_news_on_author_id" + add_index "news", ["created_on"], :name => "index_news_on_created_on" + add_index "news", ["project_id"], :name => "news_project_id" + + create_table "no_uses", :force => true do |t| + t.integer "user_id", :null => false + t.string "no_use_type" + t.integer "no_use_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "notificationcomments", :force => true do |t| + t.string "notificationcommented_type" + t.integer "notificationcommented_id" + t.integer "author_id" + t.text "notificationcomments" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "onclick_times", :force => true do |t| + t.integer "user_id" + t.datetime "onclick_time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "open_id_authentication_associations", :force => true do |t| + t.integer "issued" + t.integer "lifetime" + t.string "handle" + t.string "assoc_type" + t.binary "server_url" + t.binary "secret" + end + + create_table "open_id_authentication_nonces", :force => true do |t| + t.integer "timestamp", :null => false + t.string "server_url" + t.string "salt", :null => false + end + + create_table "open_source_projects", :force => true do |t| + t.string "name" + t.text "description" + t.integer "commit_count", :default => 0 + t.integer "code_line", :default => 0 + t.integer "users_count", :default => 0 + t.date "last_commit_time" + t.string "url" + t.date "date_collected" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "option_numbers", :force => true do |t| + t.integer "user_id" + t.integer "memo" + t.integer "messages_for_issues" + t.integer "issues_status" + t.integer "replay_for_message" + t.integer "replay_for_memo" + t.integer "follow" + t.integer "tread" + t.integer "praise_by_one" + t.integer "praise_by_two" + t.integer "praise_by_three" + t.integer "tread_by_one" + t.integer "tread_by_two" + t.integer "tread_by_three" + t.integer "changeset" + t.integer "document" + t.integer "attachment" + t.integer "issue_done_ratio" + t.integer "post_issue" + t.integer "score_type" + t.integer "total_score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + end + + create_table "org_activities", :force => true do |t| + t.integer "user_id" + t.integer "org_act_id" + t.string "org_act_type" + t.integer "container_id" + t.string "container_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_courses", :force => true do |t| + t.integer "organization_id" + t.integer "course_id" + t.datetime "created_at" + end + + create_table "org_document_comments", :force => true do |t| + t.text "title" + t.text "content" + t.integer "organization_id" + t.integer "creator_id" + t.integer "parent_id" + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "org_subfield_id" + end + + create_table "org_member_roles", :force => true do |t| + t.integer "org_member_id" + t.integer "role_id" + end + + create_table "org_members", :force => true do |t| + t.integer "user_id" + t.integer "organization_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_messages", :force => true do |t| + t.integer "user_id" + t.integer "sender_id" + t.integer "organization_id" + t.string "message_type" + t.integer "message_id" + t.integer "viewed" + t.string "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "status", :default => 0 + end + + create_table "org_projects", :force => true do |t| + t.integer "organization_id" + t.integer "project_id" + t.datetime "created_at" + end + + create_table "org_subfield_messages", :force => true do |t| + t.integer "org_subfield_id" + t.integer "message_id" + t.string "message_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_subfields", :force => true do |t| + t.integer "organization_id" + t.integer "priority" + t.string "name" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "field_type" + t.integer "hide", :default => 0 + end + + create_table "organizations", :force => true do |t| + t.string "name" + t.text "description" + t.integer "creator_id" + t.integer "home_id" + t.boolean "is_public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "allow_guest_download", :default => true + t.integer "visits", :default => 0 + end + + create_table "phone_app_versions", :force => true do |t| + t.string "version" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_answers", :force => true do |t| + t.integer "poll_question_id" + t.text "answer_text" + t.integer "answer_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_questions", :force => true do |t| + t.string "question_title" + t.integer "question_type" + t.integer "is_necessary" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_number" + end + + create_table "poll_users", :force => true do |t| + t.integer "user_id" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_votes", :force => true do |t| + t.integer "user_id" + t.integer "poll_question_id" + t.integer "poll_answer_id" + t.text "vote_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "polls", :force => true do |t| + t.string "polls_name" + t.string "polls_type" + t.integer "polls_group_id" + t.integer "polls_status" + t.integer "user_id" + t.datetime "published_at" + t.datetime "closed_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "polls_description" + t.integer "show_result", :default => 1 + end + + create_table "praise_tread_caches", :force => true do |t| + t.integer "object_id", :null => false + t.string "object_type" + t.integer "praise_num" + t.integer "tread_num" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "praise_treads", :force => true do |t| + t.integer "user_id", :null => false + t.integer "praise_tread_object_id" + t.string "praise_tread_object_type" + t.integer "praise_or_tread" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "principal_activities", :force => true do |t| + t.integer "user_id" + t.integer "principal_id" + t.integer "principal_act_id" + t.string "principal_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_infos", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_scores", :force => true do |t| + t.string "project_id" + t.integer "score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "issue_num", :default => 0 + t.integer "issue_journal_num", :default => 0 + t.integer "news_num", :default => 0 + t.integer "documents_num", :default => 0 + t.integer "changeset_num", :default => 0 + t.integer "board_message_num", :default => 0 + t.integer "board_num", :default => 0 + t.integer "attach_num", :default => 0 + t.datetime "commit_time" + end + + create_table "project_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "project_id" + t.integer "project_type" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + end + + add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" + + create_table "projecting_softapplictions", :force => true do |t| + t.integer "user_id" + t.integer "softapplication_id" + t.integer "project_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "projects", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.string "homepage", :default => "" + t.boolean "is_public", :default => true, :null => false + t.integer "parent_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "identifier" + t.integer "status", :default => 1, :null => false + t.integer "lft" + t.integer "rgt" + t.boolean "inherit_members", :default => false, :null => false + t.integer "project_type" + t.boolean "hidden_repo", :default => false, :null => false + t.integer "attachmenttype", :default => 1 + t.integer "user_id" + t.integer "dts_test", :default => 0 + t.string "enterprise_name" + t.integer "organization_id" + t.integer "project_new_type" + t.integer "gpid" + t.integer "forked_from_project_id" + t.integer "forked_count" + t.integer "commits_count", :default => 0 + t.integer "publish_resource", :default => 0 + t.integer "issues_count", :default => 0 + t.integer "attachments_count", :default => 0 + t.integer "boards_count", :default => 0 + t.integer "news_count", :default => 0 + t.integer "acts_count", :default => 0 + t.integer "journals_count", :default => 0 + t.integer "boards_reply_count", :default => 0 + t.integer "visits", :default => 0 + end + + add_index "projects", ["lft"], :name => "index_projects_on_lft" + add_index "projects", ["rgt"], :name => "index_projects_on_rgt" + + create_table "projects_trackers", :id => false, :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true + add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" + + create_table "queries", :force => true do |t| + t.integer "project_id" + t.string "name", :default => "", :null => false + t.text "filters" + t.integer "user_id", :default => 0, :null => false + t.boolean "is_public", :default => false, :null => false + t.text "column_names" + t.text "sort_criteria" + t.string "group_by" + t.string "type" + end + + add_index "queries", ["project_id"], :name => "index_queries_on_project_id" + add_index "queries", ["user_id"], :name => "index_queries_on_user_id" + + create_table "relative_memo_to_open_source_projects", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "relative_memos", :force => true do |t| + t.integer "osp_id" + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :limit => 16777215, :null => false + t.integer "author_id" + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 + t.string "url" + t.string "username" + t.string "userhomeurl" + t.date "date_collected" + t.string "topic_resource" + end + + create_table "repositories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "url", :default => "", :null => false + t.string "login", :limit => 60, :default => "" + t.string "password", :default => "" + t.string "root_url", :default => "" + t.string "type" + t.string "path_encoding", :limit => 64 + t.string "log_encoding", :limit => 64 + t.text "extra_info" + t.string "identifier" + t.boolean "is_default", :default => false + t.boolean "hidden", :default => false + end + + add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" + + create_table "rich_rich_files", :force => true do |t| + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "rich_file_file_name" + t.string "rich_file_content_type" + t.integer "rich_file_file_size" + t.datetime "rich_file_updated_at" + t.string "owner_type" + t.integer "owner_id" + t.text "uri_cache" + t.string "simplified_type", :default => "file" + end + + create_table "roles", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "assignable", :default => true + t.integer "builtin", :default => 0, :null => false + t.text "permissions" + t.string "issues_visibility", :limit => 30, :default => "default", :null => false + end + + create_table "schools", :force => true do |t| + t.string "name" + t.string "province" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "logo_link" + t.string "pinyin" + end + + create_table "secdomains", :force => true do |t| + t.integer "sub_type" + t.string "subname" + t.integer "pid", :default => 0 + t.string "desc" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "seems_rateable_cached_ratings", :force => true do |t| + t.integer "cacheable_id", :limit => 8 + t.string "cacheable_type" + t.float "avg", :null => false + t.integer "cnt", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "seems_rateable_rates", :force => true do |t| + t.integer "rater_id", :limit => 8 + t.integer "rateable_id" + t.string "rateable_type" + t.float "stars", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "is_teacher_score", :default => 0 + end + + create_table "settings", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "value" + t.datetime "updated_on" + end + + add_index "settings", ["name"], :name => "index_settings_on_name" + + create_table "shares", :force => true do |t| + t.date "created_on" + t.string "url" + t.string "title" + t.integer "share_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + t.integer "user_id" + t.string "description" + end + + create_table "shield_activities", :force => true do |t| + t.string "container_type" + t.integer "container_id" + t.string "shield_type" + t.integer "shield_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "softapplications", :force => true do |t| + t.string "name" + t.text "description" + t.integer "app_type_id" + t.string "app_type_name" + t.string "android_min_version_available" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "contest_id" + t.integer "softapplication_id" + t.integer "is_public" + t.string "application_developers" + t.string "deposit_project_url" + t.string "deposit_project" + t.integer "project_id" + end + + create_table "student_work_projects", :force => true do |t| + t.integer "homework_common_id" + t.integer "student_work_id" + t.integer "project_id" + t.integer "user_id" + t.integer "is_leader" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "student_work_projects", ["homework_common_id"], :name => "index_student_work_projects_on_homework_common_id" + add_index "student_work_projects", ["project_id"], :name => "index_student_work_projects_on_project_id" + add_index "student_work_projects", ["student_work_id"], :name => "index_student_work_projects_on_student_work_id" + add_index "student_work_projects", ["user_id"], :name => "index_student_work_projects_on_user_id" + + create_table "student_work_tests", :force => true do |t| + t.integer "student_work_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "status", :default => 9 + t.text "results" + t.text "src" + end + + create_table "student_works", :force => true do |t| + t.string "name" + t.text "description", :limit => 2147483647 + t.integer "homework_common_id" + t.integer "user_id" + t.float "final_score" + t.float "teacher_score" + t.float "student_score" + t.float "teaching_asistant_score" + t.integer "project_id", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "late_penalty", :default => 0 + t.integer "absence_penalty", :default => 0 + t.float "system_score", :default => 0.0 + t.boolean "is_test", :default => false + end + + add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" + + create_table "student_works_evaluation_distributions", :force => true do |t| + t.integer "student_work_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "student_works_scores", :force => true do |t| + t.integer "student_work_id" + t.integer "user_id" + t.integer "score" + t.text "comment" + t.integer "reviewer_role" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "students_for_courses", :force => true do |t| + t.integer "student_id" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" + add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" + + create_table "subfield_subdomain_dirs", :force => true do |t| + t.integer "org_subfield_id" + t.string "name" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "system_messages", :force => true do |t| + t.integer "user_id" + t.string "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "description" + t.string "subject" + end + + create_table "taggings", :force => true do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context", :limit => 128 + t.datetime "created_at" + end + + add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" + add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" + + create_table "tags", :force => true do |t| + t.string "name" + end + + create_table "teachers", :force => true do |t| + t.string "tea_name" + t.string "location" + t.integer "couurse_time" + t.integer "course_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "extra" + end + + create_table "time_entries", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.integer "issue_id" + t.float "hours", :null => false + t.string "comments" + t.integer "activity_id", :null => false + t.date "spent_on", :null => false + t.integer "tyear", :null => false + t.integer "tmonth", :null => false + t.integer "tweek", :null => false + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" + add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" + add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" + add_index "time_entries", ["project_id"], :name => "time_entries_project_id" + add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" + + create_table "tokens", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.string "action", :limit => 30, :default => "", :null => false + t.string "value", :limit => 40, :default => "", :null => false + t.datetime "created_on", :null => false + end + + add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" + add_index "tokens", ["value"], :name => "tokens_value", :unique => true + + create_table "trackers", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_in_chlog", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "is_in_roadmap", :default => true, :null => false + t.integer "fields_bits", :default => 0 + end + + create_table "user_actions", :force => true do |t| + t.integer "user_id" + t.string "action_type" + t.integer "action_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_activities", :force => true do |t| + t.string "act_type" + t.integer "act_id" + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "user_id" + end + + create_table "user_extensions", :force => true do |t| + t.integer "user_id", :null => false + t.date "birthday" + t.string "brief_introduction" + t.integer "gender" + t.string "location" + t.string "occupation" + t.integer "work_experience" + t.integer "zip_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "technical_title" + t.integer "identity" + t.string "student_id" + t.string "teacher_realname" + t.string "student_realname" + t.string "location_city" + t.integer "school_id" + t.string "description", :default => "" + end + + create_table "user_feedback_messages", :force => true do |t| + t.integer "user_id" + t.integer "journals_for_message_id" + t.string "journals_for_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_grades", :force => true do |t| + t.integer "user_id", :null => false + t.integer "project_id", :null => false + t.float "grade", :default => 0.0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" + add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" + add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" + + create_table "user_levels", :force => true do |t| + t.integer "user_id" + t.integer "level" + end + + create_table "user_preferences", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.text "others" + t.boolean "hide_mail", :default => false + t.string "time_zone" + end + + add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" + + create_table "user_score_details", :force => true do |t| + t.integer "current_user_id" + t.integer "target_user_id" + t.string "score_type" + t.string "score_action" + t.integer "user_id" + t.integer "old_score" + t.integer "new_score" + t.integer "current_user_level" + t.integer "target_user_level" + t.integer "score_changeable_obj_id" + t.string "score_changeable_obj_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_scores", :force => true do |t| + t.integer "user_id", :null => false + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "active" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "grade", :default => 0.0 + end + + add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" + add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" + add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" + + create_table "user_wechats", :force => true do |t| + t.integer "subscribe" + t.string "openid" + t.string "nickname" + t.integer "sex" + t.string "language" + t.string "city" + t.string "province" + t.string "country" + t.string "headimgurl" + t.string "subscribe_time" + t.string "unionid" + t.string "remark" + t.integer "groupid" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "users", :force => true do |t| + t.string "login", :default => "", :null => false + t.string "hashed_password", :limit => 40, :default => "", :null => false + t.string "firstname", :limit => 30, :default => "", :null => false + t.string "lastname", :default => "", :null => false + t.string "mail", :limit => 60, :default => "", :null => false + t.boolean "admin", :default => false, :null => false + t.integer "status", :default => 1, :null => false + t.datetime "last_login_on" + t.string "language", :limit => 5, :default => "" + t.integer "auth_source_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "type" + t.string "identity_url" + t.string "mail_notification", :default => "", :null => false + t.string "salt", :limit => 64 + t.integer "gid" + t.integer "visits", :default => 0 + end + + add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" + add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" + add_index "users", ["type"], :name => "index_users_on_type" + + create_table "versions", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :default => "", :null => false + t.string "description", :default => "" + t.date "effective_date" + t.datetime "created_on" + t.datetime "updated_on" + t.string "wiki_page_title" + t.string "status", :default => "open" + t.string "sharing", :default => "none", :null => false + end + + add_index "versions", ["project_id"], :name => "versions_project_id" + add_index "versions", ["sharing"], :name => "index_versions_on_sharing" + + create_table "visitors", :force => true do |t| + t.integer "user_id" + t.integer "master_id" + t.datetime "updated_on" + t.datetime "created_on" + end + + add_index "visitors", ["master_id"], :name => "index_visitors_master_id" + add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" + add_index "visitors", ["user_id"], :name => "index_visitors_user_id" + + create_table "watchers", :force => true do |t| + t.string "watchable_type", :default => "", :null => false + t.integer "watchable_id", :default => 0, :null => false + t.integer "user_id" + end + + add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" + add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" + add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" + + create_table "web_footer_companies", :force => true do |t| + t.string "name" + t.string "logo_size" + t.string "url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "web_footer_oranizers", :force => true do |t| + t.string "name" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "wechat_logs", :force => true do |t| + t.string "openid", :null => false + t.text "request_raw" + t.text "response_raw" + t.text "session_raw" + t.datetime "created_at", :null => false + end + + create_table "wiki_content_versions", :force => true do |t| + t.integer "wiki_content_id", :null => false + t.integer "page_id", :null => false + t.integer "author_id" + t.binary "data", :limit => 2147483647 + t.string "compression", :limit => 6, :default => "" + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" + add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" + + create_table "wiki_contents", :force => true do |t| + t.integer "page_id", :null => false + t.integer "author_id" + t.text "text", :limit => 2147483647 + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" + add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" + + create_table "wiki_pages", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title", :null => false + t.datetime "created_on", :null => false + t.boolean "protected", :default => false, :null => false + t.integer "parent_id" + end + + add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" + add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" + add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" + + create_table "wiki_redirects", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title" + t.string "redirects_to" + t.datetime "created_on", :null => false + end + + add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" + add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" + + create_table "wikis", :force => true do |t| + t.integer "project_id", :null => false + t.string "start_page", :null => false + t.integer "status", :default => 1, :null => false + end + + add_index "wikis", ["project_id"], :name => "wikis_project_id" + + create_table "workflows", :force => true do |t| + t.integer "tracker_id", :default => 0, :null => false + t.integer "old_status_id", :default => 0, :null => false + t.integer "new_status_id", :default => 0, :null => false + t.integer "role_id", :default => 0, :null => false + t.boolean "assignee", :default => false, :null => false + t.boolean "author", :default => false, :null => false + t.string "type", :limit => 30 + t.string "field_name", :limit => 30 + t.string "rule", :limit => 30 + end + + add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" + add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" + add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" + add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" + + create_table "works_categories", :force => true do |t| + t.string "category" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "zip_packs", :force => true do |t| + t.integer "user_id" + t.integer "homework_id" + t.string "file_digest" + t.string "file_path" + t.integer "pack_times", :default => 1 + t.integer "pack_size", :default => 0 + t.text "file_digests" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + +end diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index eb537363d..398d0fc2f 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -1,7 +1,7 @@ - react js + 最新动态 @@ -20,65 +20,65 @@ + \ No newline at end of file diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html new file mode 100644 index 000000000..4bc2d7c0e --- /dev/null +++ b/public/assets/wechat/homework_detail.html @@ -0,0 +1,75 @@ + + + + 作业详情 + + + + + + + + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 1c08c6f39..c06988ba6 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -20,36 +20,12 @@ diff --git a/public/javascripts/wechat/homework-detail.js b/public/javascripts/wechat/homework-detail.js new file mode 100644 index 000000000..a5fdfa694 --- /dev/null +++ b/public/javascripts/wechat/homework-detail.js @@ -0,0 +1,57 @@ +/** + * Created by root on 3/31/16. + */ +$(document).ready(function(){ + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + + var apiUrl = '/api/v1/'; + + var setTemplate = function(data){ + console.log(data); + var html=bt('t:homework-detail',{homework: data}); + $('#homework-container').prepend(html); + $('.post-reply-submit').click(function(){ + replyInsert(); + }); + }; + + var loadDataFromServer = function(id){ + //getOpenId(function(openid){ + $.ajax({ + url: apiUrl + 'whomeworks/' + id, + dataType: 'json', + success: function(data){ + setTemplate(data.data); + }, + error: function(xhr,status,err){ + console.log(err); + } + }); + //}) + + + }; + + loadDataFromServer(808); + + //点击回复按钮,插入回复内容 + var replyInsert = function(){ + var replyContent = $("#postInput").val(); + if (!replyContent){ + alert("请输入回复"); + }else{ + $(".post-reply-wrap:last").after('
1分钟前
回复
'); + $(".post-reply-content:last").append(replyContent); + $("#postInput").val("");} + } + + var getID = function(){ + var homeworkID = $("#homework-id").html(); + alert(homeworkID); + return homeworkID; + } +}); \ No newline at end of file diff --git a/public/javascripts/wechat/wechat-dev.js b/public/javascripts/wechat/wechat-dev.js index 20c118b96..b7ed32332 100644 --- a/public/javascripts/wechat/wechat-dev.js +++ b/public/javascripts/wechat/wechat-dev.js @@ -9,12 +9,15 @@ $(document).ready(function(){ var apiUrl = '/api/v1/'; + var setTemplate = function(data){ console.log(data); var html=bt('t:result-list',{activities: data}); $('#container').prepend(html); descToggle(); - + $('.post-reply-submit').click(function(){ + replyInsert(); + }); }; var loadDataFromServer = function(id){ @@ -36,10 +39,8 @@ $(document).ready(function(){ loadDataFromServer(8686); + //内容全部显示与部分隐藏 var descToggle = function(){ - var postWidth = $(".post-wrapper").width(); - var titleWidth = postWidth - 80; - $(".post-title").css("maxWidth",titleWidth); $(".post-all-content").each(function(){ var postHeight = $(this).height(); if (postHeight > 90){ @@ -55,11 +56,14 @@ $(document).ready(function(){ }); } - var timeSpilt = function(){ - + //点击回复按钮,插入回复内容 + var replyInsert = function(){ + var replyContent = $("#postInput").val(); + if (!replyContent){ + alert("请输入回复"); + }else{ + $(".post-reply-wrap:last").after('
1分钟前
回复
'); + $(".post-reply-content:last").append(replyContent); + $("#postInput").val("");} } - - - - }); diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index b702e1d0d..837ff1abc 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -10,14 +10,17 @@ h1,h2,h3,h4,h5,p {padding:0px; margin:0px;} .mt5 {margin-top:5px;} .mt10 {margin-top:10px;} .mb5 {margin-bottom:5px;} +.mb10 {margin-bottom:10px;} .ml10 {margin-left:10px;} .mr10 {margin-right:10px;} .ml15 {margin-left:15px;} .mr15 {margin-right:15px;} +.ml55 {margin-left:55px;} .c-blue {color:#269ac9;} .c-grey {color:#9a9a9a;} .c-grey2 {color:#707070;} .c-grey3 {color:#555555;} +a.c-grey {color:#707070;} a:link,a:visited{text-decoration:none;} a:hover,a:active{cursor:pointer;} a.link-blue {color:#269ac9;} @@ -35,7 +38,21 @@ a.link-blue {color:#269ac9;} .post-avatar {width:45px; height:45px; margin-right:10px;} .post-title {font-size:13px; text-align:left;} .fl {float:left;} +.fr {float:right;} .cl {clear:both; overflow:hidden;} .post-content {width:100%; font-size:13px; line-height:18px; height:90px; overflow:hidden;} .post-interactive {width:100%; height:35px; line-height:35px; vertical-align:middle; border-top:1px solid #e6e6e6; background-color:#f8f9fb;} -.post-interactive-column {width:50%; text-align:center; float:left; font-size:13px;} \ No newline at end of file +.post-interactive-column {width:50%; text-align:center; float:left; font-size:13px;} +.more-wrap {width:100%;} +.more-events {width:98%; font-size:13px; text-align:center; margin:0px auto; padding: 5px 0px; border:1px solid #e6e6e6; border-radius:3px; background-color:#f8f9fb; } +.border-bottom {border-bottom:1px solid #e6e6e6;} +.post-reply-wrap {width:100%; line-height:18px; background-color:#f8f9fb;} +.post-input-wrap {width:100%; line-height:18px; background-color:#f8f9fb;} +.post-reply-row {padding:10px; color:#9a9a9a;} +.post-reply-avatar {width:45px; height:30px; text-align:center; margin-right:10px;} +.post-reply-user {font-size:13px; text-align:left; margin-bottom:10px;} +.post-reply-content {font-size:13px; text-align:left;} +.post-reply-date {font-size:13px;} +.post-reply-trigger {font-size:13px;} +.post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; border-radius:3px;} +.post-reply-submit {font-size:13px; padding:3px 8px; color:#fff; background-color:#269ac9; outline:none; border:none; display:inline-block;} \ No newline at end of file From 536394663a2b8b27944b08babf0103938a985521 Mon Sep 17 00:00:00 2001 From: Yiang Gan Date: Thu, 31 Mar 2016 20:46:36 +0800 Subject: [PATCH 097/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/issue.rb | 12 ++- app/api/mobile/entities/journal.rb | 37 +++++++ app/helpers/api_helper.rb | 152 +++++++++++++++++++++++++++++ app/helpers/issues_helper.rb | 2 +- app/models/blog_comment.rb | 50 +++++++++- app/models/homework_common.rb | 49 +++++++++- app/models/journal.rb | 50 +++++++++- app/models/journals_for_message.rb | 51 ++++++++++ app/models/mailer.rb | 63 ++++++++++++ 9 files changed, 461 insertions(+), 5 deletions(-) create mode 100644 app/api/mobile/entities/journal.rb diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index 1a23bb464..cd0cbb0ce 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -9,7 +9,11 @@ module Mobile issue[f] elsif issue.is_a?(::Issue) if issue.respond_to?(f) - issue.send(f) + if f == :created_on + format_time(issue.send(f)) + else + issue.send(f) + end else case f when :issue_priority @@ -27,9 +31,15 @@ module Mobile expose :description expose :author, using: Mobile::Entities::User expose :done_ratio + issue_expose :created_on issue_expose :issue_priority issue_expose :issue_assigned_to issue_expose :issue_status + expose :issue_journals, using: Mobile::Entities::Journal do |f, opt| + if f.is_a?(::Issue) + f.journals + end + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/journal.rb b/app/api/mobile/entities/journal.rb new file mode 100644 index 000000000..a2c54248e --- /dev/null +++ b/app/api/mobile/entities/journal.rb @@ -0,0 +1,37 @@ +module Mobile +module Entities + class Journal [], :deleted => []} + if detail.old_value + values_by_field[field_id][:deleted] << detail.old_value + end + if detail.value + values_by_field[field_id][:added] << detail.value + end + next + end + end + strings << jshow_detail(detail, no_html, options) + + end + values_by_field.each do |field_id, changes| + detail = JournalDetail.new(:property => 'cf', :prop_key => field_id) + if changes[:added].any? + detail.value = changes[:added] + strings << jshow_detail(detail, no_html, options) + elsif changes[:deleted].any? + detail.old_value = changes[:deleted] + strings << jshow_detail(detail, no_html, options) + end + end + strings + end + + # Returns the textual representation of a single journal detail + def jshow_detail(detail, no_html=false, options={}) + multiple = false + case detail.property + when 'attr' + field = detail.prop_key.to_s.gsub(/\_id$/, "") + label = l(("field_" + field).to_sym) + case detail.prop_key + when 'due_date', 'start_date' + value = format_date(detail.value.to_date) if detail.value + old_value = format_date(detail.old_value.to_date) if detail.old_value + + when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id', + 'priority_id', 'category_id', 'fixed_version_id' + value = find_name_by_reflection(field, detail.value) + old_value = find_name_by_reflection(field, detail.old_value) + + when 'estimated_hours' + value = "%0.02f" % detail.value.to_f unless detail.value.blank? + old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank? + + when 'parent_id' + label = l(:field_parent_issue) + value = "##{detail.value}" unless detail.value.blank? + old_value = "##{detail.old_value}" unless detail.old_value.blank? + + when 'is_private' + value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank? + old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank? + end + when 'cf' + custom_field = CustomField.find_by_id(detail.prop_key) + if custom_field + multiple = custom_field.multiple? + label = custom_field.name + value = format_value(detail.value, custom_field.field_format) if detail.value + old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value + end + when 'attachment' + label = l(:label_attachment) + end + call_hook(:helper_issues_show_detail_after_setting, + {:detail => detail, :label => label, :value => value, :old_value => old_value }) + + label ||= detail.prop_key + value ||= detail.value + old_value ||= detail.old_value + + unless no_html + label = content_tag('strong', label) + old_value = content_tag("i", old_value) if detail.old_value + old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank? + if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key) + # Link to the attachment if it has not been removed + if options[:token].nil? + value = atta.filename + else + value = atta.filename + end + # 放大镜搜索功能 + # if options[:only_path] != false && atta.is_text? + # value += link_to( + # image_tag('magnifier.png'), + # :controller => 'attachments', :action => 'show', + # :id => atta, :filename => atta.filename + # ) + # end + else + value = content_tag("i", value) if value + end + end + # 缺陷更新结果在消息中显示样式 + if no_html == "message" + label = content_tag(:span, label, :class => "issue_update_message") + old_value = content_tag("span", old_value) if detail.old_value + old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank? + if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key) + # Link to the attachment if it has not been removed + if options[:token].nil? + value = atta.filename + else + value = atta.filename + end + else + value = content_tag(:span, value, :class => "issue_update_message_value") if value + end + end + + if detail.property == 'attr' && detail.prop_key == 'description' + s = l(:text_journal_changed_no_detail, :label => label) + unless no_html + diff_link = link_to l(:label_diff), + {:controller => 'journals', :action => 'diff', :id => detail.journal_id, + :detail_id => detail.id, :only_path => options[:only_path]}, + :title => l(:label_view_diff) + s << " (#{ diff_link })" + end + s.html_safe + elsif detail.value.present? + case detail.property + when 'attr', 'cf' + if detail.old_value.present? + l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe + elsif multiple + l(:text_journal_added, :label => label, :value => value).html_safe + else + l(:text_journal_set_to, :label => label, :value => value).html_safe + end + when 'attachment' + l(:text_journal_added, :label => label, :value => value).html_safe + end + else + l(:text_journal_deleted, :label => label, :old => old_value).html_safe + end + end end \ No newline at end of file diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 4ad3cb49d..bef6b580c 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -19,7 +19,7 @@ module IssuesHelper include ApplicationHelper - + include TagsHelper def issue_list(issues, &block) ancestors = [] issues.each do |issue| diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 2b31af604..3775523b3 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -1,5 +1,7 @@ class BlogComment < ActiveRecord::Base # attr_accessible :title, :body + require 'net/http' + require 'json' include Redmine::SafeAttributes belongs_to :blog belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' @@ -18,7 +20,7 @@ class BlogComment < ActiveRecord::Base after_save :add_user_activity after_update :update_activity - after_create :update_parent_time + after_create :update_parent_time, :blog_wechat_message before_destroy :destroy_user_activity scope :like, lambda {|arg| @@ -72,4 +74,50 @@ class BlogComment < ActiveRecord::Base end def project end + + #博客回复微信模板消息 + def blog_wechat_message + unless self.parent_id == nil + uw = UserWechat.where(user_id: self.parent.author_id).first + #unless uw.nil? && self.parent.author_id != User.current.id + unless uw.nil? + data = { + touser:uw.openid, + template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", + url:"http://weixin.qq.com/download", + topcolor:"#FF0000", + data:{ + first: { + value:"您的博客有新回复了", + color:"#173177" + }, + keyword1:{ + value:self.author.try(:realname), + color:"#173177" + }, + keyword2:{ + value:self.created_at, + color:"#173177" + }, + keyword3:{ + value:h(truncate(" - #{self.content.html_safe}", length:50, omission: '...')), + color:"#173177" + }, + remark:{ + value:"具体内容请点击详情查看网站", + color:"#173177" + } + } + } + uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567") + body = data.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + end + end + end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index f8e222b0f..e1f4766de 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -2,6 +2,8 @@ #homework_type: 0:普通作业;1:匿评作业;2:编程作业 class HomeworkCommon < ActiveRecord::Base # attr_accessible :name, :user_id, :description, :publish_time, :end_time, :homework_type, :late_penalty, :course_id + require 'net/http' + require 'json' include Redmine::SafeAttributes include ApplicationHelper @@ -26,7 +28,7 @@ class HomeworkCommon < ActiveRecord::Base :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} after_create :act_as_activity, :send_mail, :act_as_course_message - after_update :update_activity + after_update :update_activity, :wechat_message after_save :act_as_course_activity after_destroy :delete_kindeditor_assets @@ -98,6 +100,51 @@ class HomeworkCommon < ActiveRecord::Base jfm end + #修改作业后发送微信模板消息 + def wechat_message + self.course.members.each do |member| + uw = UserWechat.where("user_id=?", member.user_id).first + unless uw.nil? + data = { + touser:uw.openid, + template_id:"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", + url:"http://weixin.qq.com/download", + topcolor:"#FF0000", + data:{ + first: { + value:"您的作业已被修改", + color:"#173177" + }, + keyword1:{ + value:self.course.name, + color:"#173177" + }, + keyword2:{ + value:self.name, + color:"#173177" + }, + keyword3:{ + value:self.end_time.to_s + "23:59:59", + color:"#173177" + }, + remark:{ + value:"具体内容请点击详情查看网站", + color:"#173177" + } + } + } + uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567") + body = data.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + end + end + end + delegate :language_name, :language, :to => :homework_detail_programing end diff --git a/app/models/journal.rb b/app/models/journal.rb index fd67e8a62..2432f1db1 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -16,6 +16,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Journal < ActiveRecord::Base + require 'net/http' + require 'json' include UserScoreHelper belongs_to :journalized, :polymorphic => true,:touch => true # added as a quick fix to allow eager loading of the polymorphic association @@ -52,7 +54,7 @@ class Journal < ActiveRecord::Base # fq after_save :act_as_activity,:be_user_score, :act_as_forge_message, act_as_at_message(:notes, :user_id) - after_create :update_issue_time + after_create :update_issue_timeissue, :issue_wechat_message # end #after_destroy :down_user_score #before_save :be_user_score @@ -233,4 +235,50 @@ class Journal < ActiveRecord::Base forge_activity.update_attribute(:created_at, self.created_on) unless forge_activity.nil? end end + + #缺陷回复微信模板消息 + def issue_wechat_message + unless self.parent_id == nil + uw = UserWechat.where(user_id: self.issue.author_id).first + #unless uw.nil? && self.issue.author_id != User.current.id + unless uw.nil? + data = { + touser:uw.openid, + template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", + url:"http://weixin.qq.com/download", + topcolor:"#FF0000", + data:{ + first: { + value:"您的缺陷有新回复了", + color:"#173177" + }, + keyword1:{ + value:self.author.try(:realname), + color:"#173177" + }, + keyword2:{ + value:self.created_on, + color:"#173177" + }, + keyword3:{ + value:h(truncate(" - #{self.description.html_safe}", length:50, omission: '...')), + color:"#173177" + }, + remark:{ + value:"具体内容请点击详情查看网站", + color:"#173177" + } + } + } + uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567") + body = data.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + end + end + end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index fa5beb813..33dcc78af 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -2,6 +2,8 @@ # 数据库字段中带有m前缀和is_readed是二次开发添加,之前的字段基本复用 # 注意reply_id 是提到人的id,不是留言id, Base中叫做 at_user class JournalsForMessage < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes include UserScoreHelper include ApplicationHelper @@ -253,6 +255,9 @@ class JournalsForMessage < ActiveRecord::Base self.course_messages << CourseMessage.new(:user_id => r, :course_id => self.jour.id, :viewed => false) end end + if self.jour_type == 'HomeworkCommon' + journal_wechat_message '您的作业有新回复了' + end end @@ -264,6 +269,7 @@ class JournalsForMessage < ActiveRecord::Base if self.reply_id == 0 if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour + journal_wechat_message "您有新留言了" end else # 留言回复 reply_to = User.find(self.reply_id) @@ -273,6 +279,7 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 receivers << self.parent.jour end + journal_wechat_message "您的留言有新回复了" end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) @@ -299,4 +306,48 @@ class JournalsForMessage < ActiveRecord::Base end end + #微信模板消息 + def journal_wechat_message type + uw = UserWechat.where(user_id: self.reply_id).first + #unless uw.nil? && self.reply_id != User.current.id + unless uw.nil? + data = { + touser:uw.openid, + template_id:"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", + url:"http://weixin.qq.com/download", + topcolor:"#FF0000", + data:{ + first: { + value:type, + color:"#173177" + }, + keyword1:{ + value:self.user.try(:realname), + color:"#173177" + }, + keyword2:{ + value:self.created_on, + color:"#173177" + }, + keyword3:{ + value:h(truncate(" - #{self.notes.html_safe}", length:50, omission: '...')), + color:"#173177" + }, + remark:{ + value:"具体内容请点击详情查看网站", + color:"#173177" + } + } + } + uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567") + body = data.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + end + end + end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 05b0349ec..98ed4ee1f 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -16,6 +16,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Mailer < ActionMailer::Base + require 'net/http' + require 'json' layout 'mailer' helper :application helper :issues @@ -638,6 +640,9 @@ class Mailer < ActionMailer::Base mail :to => recipients, :subject => "[ #{l(:label_user_homework)} : #{homework_common.name} #{l(:label_memo_create_succ)}]", :filter => true + @homework_common.course.members.each do |member| + mail_wechat_message member.user_id, "3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", "您的课程有新作业了", @homework_common.course.name, @homework_common.name, @homework_common.end_time.to_s + " 23:59:59" + end end # Builds a Mail::Message object used to email recipients of a news' project when a news item is added. @@ -703,6 +708,8 @@ class Mailer < ActionMailer::Base mail :to => recipients, :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}", :filter => true + + mail_wechat_message news.author_id, "3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", "您的课程通知有新回复了", @author.try(:realname), comment.created_on, comment.comments.html_safe end end @@ -727,6 +734,13 @@ class Mailer < ActionMailer::Base :cc => cc, :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", :filter => true + if message.parent_id == nil + message.project.members.each do |member| + mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "项目讨论区有新帖子发布了", message.subject, @author.try(:realname), message.created_on + end + else + mail_wechat_message member.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), message.created_on, message.content.html_safe + end elsif message.course redmine_headers 'Course' => message.course.id, 'Topic-Id' => (message.parent_id || message.id) @@ -742,6 +756,13 @@ class Mailer < ActionMailer::Base :cc => cc, :subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", :filter => true + if message.parent_id == nil + message.course.members.each do |member| + mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "课程问答区有新帖子发布了", message.subject, @author.try(:realname), message.created_on + end + else + mail_wechat_message member.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), message.created_on, message.content.html_safe + end end end @@ -1097,4 +1118,46 @@ class Mailer < ActionMailer::Base return newpass end + #微信模板消息 + def mail_wechat_message user_id, template_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站" + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = { + touser:uw.openid, + template_id:template_id, + url:"http://weixin.qq.com/download", + topcolor:"#FF0000", + data:{ + first: { + value:first, + color:"#173177" + }, + keyword1:{ + value:key1, + color:"#173177" + }, + keyword2:{ + value:key2, + color:"#173177" + }, + keyword3:{ + value:h(truncate(" - #{key3}", length:50, omission: '...')), + color:"#173177" + }, + remark:{ + value:remark, + color:"#173177" + } + } + } + uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567") + body = data.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + end + end end From 4088fb9cb4b40de6538ae897136d823992992bc8 Mon Sep 17 00:00:00 2001 From: Yiang Gan Date: Fri, 1 Apr 2016 14:58:41 +0800 Subject: [PATCH 098/507] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 2 +- app/api/mobile/entities/activity.rb | 1 + public/assets/wechat/activities.html | 2 +- public/assets/wechat/homework_detail.html | 26 +++++----- public/javascripts/wechat/homework-detail.js | 52 +++++++++++++++++--- public/javascripts/wechat/wechat-dev.js | 13 +---- public/stylesheets/weui/weixin.css | 4 ++ 7 files changed, 67 insertions(+), 33 deletions(-) diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 813b2232b..41069b4bf 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -22,7 +22,7 @@ module Mobile activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + - "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(200).offset(page * 10) + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(50).offset(page * 10) present :data, activities, with: Mobile::Entities::Activity present :status, 0 end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index db1456e68..9389f589e 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -95,6 +95,7 @@ module Mobile end end expose :act_type #缺陷/作业/讨论区/留言等类型 + expose :act_id expose :container_type #课程/项目/博客/个人 expose :author, using: Mobile::Entities::User do |a, opt| #用户信息 if a.is_a? ::UserActivity diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 22d642bde..c1467bc52 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -43,7 +43,7 @@
-
回复 ()
+
回复 ()
赞 ()
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 4bc2d7c0e..72e3b46f0 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -19,7 +19,7 @@ - + \ No newline at end of file diff --git a/public/javascripts/wechat/homework-detail.js b/public/javascripts/wechat/homework-detail.js index e4e3a9758..1c223bfc2 100644 --- a/public/javascripts/wechat/homework-detail.js +++ b/public/javascripts/wechat/homework-detail.js @@ -64,14 +64,14 @@ $(document).ready(function(){ //获取并传送回复用户数据 var userInfo = { - "replyType" : "homework_assignment", - "replyContent" : postInput + "type" : "HomeworkCommon", + "content" : postInput }; $.ajax({ type: "POST", //提交方式 dataType: "json", //类型 - url: "前台地址/后台方法", //提交的页面,方法名 + url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 @@ -82,14 +82,14 @@ $(document).ready(function(){ }); } - } + }; //点赞效果 var praiseClick = function(){ var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); praiseNum++; $(".praise-num").text("(" + praiseNum + ")"); - } + }; }); \ No newline at end of file diff --git a/public/javascripts/wechat/wechat-dev.js b/public/javascripts/wechat/wechat-dev.js index eacbf8559..c921ed64d 100644 --- a/public/javascripts/wechat/wechat-dev.js +++ b/public/javascripts/wechat/wechat-dev.js @@ -2,59 +2,5 @@ * Created by root on 3/25/16. */ $(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:result-list',{activities: data}); - $('#container').prepend(html); - descToggle(); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'activities/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - loadDataFromServer(1); - - //内容全部显示与部分隐藏 - var descToggle = function(){ - $(".post-all-content").each(function(){ - var postHeight = $(this).height(); - if (postHeight > 90){ - $(this).parent().next().css("display","block"); - $(this).parent().next().toggle(function(){ - $(this).text("点击隐藏"); - $(this).prev().css("height",postHeight); - },function(){ - $(this).text("点击展开"); - $(this).prev().css("height",90); - }); - } - }); - } - - + loadDataFromServer(8686, 0); }); From 596bf641acc7cbde92f2f57bafa528945e19fa21 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Apr 2016 20:53:21 +0800 Subject: [PATCH 102/507] =?UTF-8?q?=E6=9C=80=E6=96=B0=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=90=84=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/activity.rb | 2 + public/assets/wechat/activities.html | 29 +++--- public/assets/wechat/blog_detail.html | 73 ++++++++++++++ public/assets/wechat/course_discussion.html | 73 ++++++++++++++ public/assets/wechat/course_notice.html | 73 ++++++++++++++ public/assets/wechat/homework_detail.html | 4 +- public/assets/wechat/issue_detail.html | 40 ++++---- public/assets/wechat/message_detail.html | 71 ++++++++++++++ public/assets/wechat/project_discussion.html | 73 ++++++++++++++ public/javascripts/wechat/blog_detail.js | 95 ++++++++++++++++++ .../javascripts/wechat/course_discussion.js | 95 ++++++++++++++++++ public/javascripts/wechat/course_notice.js | 95 ++++++++++++++++++ ...{homework-detail.js => homework_detail.js} | 0 public/javascripts/wechat/issue_detail.js | 98 +++++++++++++++++++ public/javascripts/wechat/message_detail.js | 95 ++++++++++++++++++ .../javascripts/wechat/project_discussion.js | 3 + .../wechat/{wechat-dev.js => wechat_dev.js} | 0 17 files changed, 881 insertions(+), 38 deletions(-) create mode 100644 public/assets/wechat/blog_detail.html create mode 100644 public/assets/wechat/course_discussion.html create mode 100644 public/assets/wechat/course_notice.html create mode 100644 public/assets/wechat/message_detail.html create mode 100644 public/assets/wechat/project_discussion.html create mode 100644 public/javascripts/wechat/blog_detail.js create mode 100644 public/javascripts/wechat/course_discussion.js create mode 100644 public/javascripts/wechat/course_notice.js rename public/javascripts/wechat/{homework-detail.js => homework_detail.js} (100%) create mode 100644 public/javascripts/wechat/issue_detail.js create mode 100644 public/javascripts/wechat/message_detail.js create mode 100644 public/javascripts/wechat/project_discussion.js rename public/javascripts/wechat/{wechat-dev.js => wechat_dev.js} (100%) diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 9389f589e..d58057b62 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -44,6 +44,8 @@ module Mobile ac.act.description unless ac.nil? || ac.act.nil? elsif ac.act_type == "Message" || ac.act_type == "BlogComment" ac.act.content unless ac.nil? || ac.act.nil? + elsif ac.act_type == "JournalsForMessage" + ac.act.notes end when :latest_update time_from_now ac.updated_at unless ac.nil? diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index c1467bc52..0f5420984 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -66,7 +66,7 @@
-
回复 ()
+
回复 ()
赞 ()
@@ -77,17 +77,18 @@
- + +

点击展开 +
-
回复 ()
+
回复 ()
赞 ()
@@ -97,7 +98,7 @@
- +
@@ -124,7 +125,7 @@
-
回复 ()
+
回复 ()
赞 ()
@@ -147,7 +148,7 @@
-
回复 ()
+
回复 ()
赞 ()
@@ -171,8 +172,8 @@
- + +

@@ -181,7 +182,7 @@
-
回复 ()
+
回复 ()
赞 ()
@@ -204,20 +205,20 @@
-
回复 ()
+
回复 ()
赞 ()
-
更多
+
更多
- - + + \ No newline at end of file diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html new file mode 100644 index 000000000..8b3f44eb5 --- /dev/null +++ b/public/assets/wechat/blog_detail.html @@ -0,0 +1,73 @@ + + + + 博客 + + + + + + + + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html new file mode 100644 index 000000000..b5d56cd7e --- /dev/null +++ b/public/assets/wechat/course_discussion.html @@ -0,0 +1,73 @@ + + + + 课程讨论区 + + + + + + + + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html new file mode 100644 index 000000000..6c508ab9c --- /dev/null +++ b/public/assets/wechat/course_notice.html @@ -0,0 +1,73 @@ + + + + 课程通知 + + + + + + + + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 72e3b46f0..3f05b1b8e 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -57,7 +57,7 @@
-
+
@@ -68,7 +68,7 @@ - + diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index c06988ba6..8c326d631 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -1,7 +1,7 @@ - 缺陷详情 + 问题跟踪 @@ -13,13 +13,13 @@ -
+
- - + \ No newline at end of file diff --git a/public/assets/wechat/message_detail.html b/public/assets/wechat/message_detail.html new file mode 100644 index 000000000..04563184f --- /dev/null +++ b/public/assets/wechat/message_detail.html @@ -0,0 +1,71 @@ + + + + 留言 + + + + + + + + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html new file mode 100644 index 000000000..5201d8299 --- /dev/null +++ b/public/assets/wechat/project_discussion.html @@ -0,0 +1,73 @@ + + + + 课程讨论区 + + + + + + + + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/javascripts/wechat/blog_detail.js b/public/javascripts/wechat/blog_detail.js new file mode 100644 index 000000000..44121f83c --- /dev/null +++ b/public/javascripts/wechat/blog_detail.js @@ -0,0 +1,95 @@ +/** + * Created by root on 4/1/16. + */ +$(document).ready(function(){ + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + + var apiUrl = '/api/v1/'; + + var setTemplate = function(data){ + console.log(data); + var html=bt('t:blog-detail',{blog: data}); + $('#blog-container').prepend(html); + $('.post-reply-submit').click(function(){ + replyInsert(); + }); + $('post-interactive-praise').click(function(){ + praiseClick(); + }); + }; + + var loadDataFromServer = function(id){ + //getOpenId(function(openid){ + $.ajax({ + url: apiUrl + 'blog_comments/' + id, + dataType: 'json', + success: function(data){ + setTemplate(data.data); + }, + error: function(xhr,status,err){ + console.log(err); + } + }); + //}) + + + }; + + var homeworkUrl = window.location.search; + var homeworkID = homeworkUrl.split("=")[1]; + + loadDataFromServer(homeworkID); + + //点击回复按钮,插入回复内容 + var replyInsert = function(){ + var replyContent = $("#postInput").val(); + if (!replyContent){ + alert("请输入回复"); + }else{ + + //将用户输入内容插入最后一条回复 + $(".post-reply-wrap:last").after('
回复
'); + $(".post-reply-content:last").append(replyContent); + $(".post-reply-date:last").append(Date()); + var postInput = $("#postInput").val(); + $("#postInput").val(""); + //回复数目+1 + var replyNum = $(".post-interactive-reply").text().match(/\d+/g); + replyNum++; + $(".reply-num").text("(" + replyNum + ")"); + + //获取并传送回复用户数据 + var userInfo = { + "replyType" : "homework_assignment", + "replyContent" : postInput + }; + + $.ajax({ + type: "POST", //提交方式 + dataType: "json", //类型 + url: "前台地址/后台方法", //提交的页面,方法名 + data: userInfo, //参数,如果没有,可以为null + success: function (data) { //如果执行成功,那么执行此方法 + alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + }, + error: function (err) { //如果执行不成功,那么执行此方法 + alert("err:" + err); + } + }); + } + + } + + //点赞效果 + var praiseClick = function(){ + var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); + praiseNum++; + $(".praise-num").text("(" + praiseNum + ")"); + } + + +}); \ No newline at end of file diff --git a/public/javascripts/wechat/course_discussion.js b/public/javascripts/wechat/course_discussion.js new file mode 100644 index 000000000..12533d5f6 --- /dev/null +++ b/public/javascripts/wechat/course_discussion.js @@ -0,0 +1,95 @@ +/** + * Created by root on 4/1/16. + */ +$(document).ready(function(){ + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + + var apiUrl = '/api/v1/'; + + var setTemplate = function(data){ + console.log(data); + var html=bt('t:course-discussion',{discussion: data}); + $('#c-discussion-container').prepend(html); + $('.post-reply-submit').click(function(){ + replyInsert(); + }); + $('post-interactive-praise').click(function(){ + praiseClick(); + }); + }; + + var loadDataFromServer = function(id){ + //getOpenId(function(openid){ + $.ajax({ + url: apiUrl + 'messages/' + id, + dataType: 'json', + success: function(data){ + setTemplate(data.data); + }, + error: function(xhr,status,err){ + console.log(err); + } + }); + //}) + + + }; + + var homeworkUrl = window.location.search; + var homeworkID = homeworkUrl.split("=")[1]; + + loadDataFromServer(homeworkID); + + //点击回复按钮,插入回复内容 + var replyInsert = function(){ + var replyContent = $("#postInput").val(); + if (!replyContent){ + alert("请输入回复"); + }else{ + + //将用户输入内容插入最后一条回复 + $(".post-reply-wrap:last").after('
回复
'); + $(".post-reply-content:last").append(replyContent); + $(".post-reply-date:last").append(Date()); + var postInput = $("#postInput").val(); + $("#postInput").val(""); + //回复数目+1 + var replyNum = $(".post-interactive-reply").text().match(/\d+/g); + replyNum++; + $(".reply-num").text("(" + replyNum + ")"); + + //获取并传送回复用户数据 + var userInfo = { + "Type" : "Message", + "Content" : postInput + }; + + $.ajax({ + type: "POST", //提交方式 + dataType: "json", //类型 + url: "前台地址/后台方法", //提交的页面,方法名 + data: userInfo, //参数,如果没有,可以为null + success: function (data) { //如果执行成功,那么执行此方法 + alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + }, + error: function (err) { //如果执行不成功,那么执行此方法 + alert("err:" + err); + } + }); + } + + } + + //点赞效果 + var praiseClick = function(){ + var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); + praiseNum++; + $(".praise-num").text("(" + praiseNum + ")"); + } + + +}); \ No newline at end of file diff --git a/public/javascripts/wechat/course_notice.js b/public/javascripts/wechat/course_notice.js new file mode 100644 index 000000000..f20526a5f --- /dev/null +++ b/public/javascripts/wechat/course_notice.js @@ -0,0 +1,95 @@ +/** + * Created by root on 4/1/16. + */ +$(document).ready(function(){ + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + + var apiUrl = '/api/v1/'; + + var setTemplate = function(data){ + console.log(data); + var html=bt('t:course-notice',{course: data}); + $('#c-notice-container').prepend(html); + $('.post-reply-submit').click(function(){ + replyInsert(); + }); + $('post-interactive-praise').click(function(){ + praiseClick(); + }); + }; + + var loadDataFromServer = function(id){ + //getOpenId(function(openid){ + $.ajax({ + url: apiUrl + 'newss/' + id, + dataType: 'json', + success: function(data){ + setTemplate(data.data); + }, + error: function(xhr,status,err){ + console.log(err); + } + }); + //}) + + + }; + + var homeworkUrl = window.location.search; + var homeworkID = homeworkUrl.split("=")[1]; + + loadDataFromServer(homeworkID); + + //点击回复按钮,插入回复内容 + var replyInsert = function(){ + var replyContent = $("#postInput").val(); + if (!replyContent){ + alert("请输入回复"); + }else{ + + //将用户输入内容插入最后一条回复 + $(".post-reply-wrap:last").after('
回复
'); + $(".post-reply-content:last").append(replyContent); + $(".post-reply-date:last").append(Date()); + var postInput = $("#postInput").val(); + $("#postInput").val(""); + //回复数目+1 + var replyNum = $(".post-interactive-reply").text().match(/\d+/g); + replyNum++; + $(".reply-num").text("(" + replyNum + ")"); + + //获取并传送回复用户数据 + var userInfo = { + "replyType" : "homework_assignment", + "replyContent" : postInput + }; + + $.ajax({ + type: "POST", //提交方式 + dataType: "json", //类型 + url: "前台地址/后台方法", //提交的页面,方法名 + data: userInfo, //参数,如果没有,可以为null + success: function (data) { //如果执行成功,那么执行此方法 + alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + }, + error: function (err) { //如果执行不成功,那么执行此方法 + alert("err:" + err); + } + }); + } + + } + + //点赞效果 + var praiseClick = function(){ + var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); + praiseNum++; + $(".praise-num").text("(" + praiseNum + ")"); + } + + +}); \ No newline at end of file diff --git a/public/javascripts/wechat/homework-detail.js b/public/javascripts/wechat/homework_detail.js similarity index 100% rename from public/javascripts/wechat/homework-detail.js rename to public/javascripts/wechat/homework_detail.js diff --git a/public/javascripts/wechat/issue_detail.js b/public/javascripts/wechat/issue_detail.js new file mode 100644 index 000000000..2a2153062 --- /dev/null +++ b/public/javascripts/wechat/issue_detail.js @@ -0,0 +1,98 @@ +/** + * Created by root on 4/1/16. + */ +/** + * Created by root on 3/31/16. + */ +$(document).ready(function(){ + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + + var apiUrl = '/api/v1/'; + + var setTemplate = function(data){ + console.log(data); + var html=bt('t:issue-detail',{issues: data}); + $('#issue-container').prepend(html); + $('.post-reply-submit').click(function(){ + replyInsert(); + }); + $('post-interactive-praise').click(function(){ + praiseClick(); + }); + }; + + var loadDataFromServer = function(id){ + //getOpenId(function(openid){ + $.ajax({ + url: apiUrl + 'issues/' + id, + dataType: 'json', + success: function(data){ + setTemplate(data.data); + }, + error: function(xhr,status,err){ + console.log(err); + } + }); + //}) + + + }; + + var homeworkUrl = window.location.search; + var homeworkID = homeworkUrl.split("=")[1]; + + loadDataFromServer(homeworkID); + + //点击回复按钮,插入回复内容 + var replyInsert = function(){ + var replyContent = $("#postInput").val(); + if (!replyContent){ + alert("请输入回复"); + }else{ + + //将用户输入内容插入最后一条回复 + $(".post-reply-wrap:last").after('
回复
'); + $(".post-reply-content:last").append(replyContent); + $(".post-reply-date:last").append(Date()); + var postInput = $("#postInput").val(); + $("#postInput").val(""); + //回复数目+1 + var replyNum = $(".post-interactive-reply").text().match(/\d+/g); + replyNum++; + $(".reply-num").text("(" + replyNum + ")"); + + //获取并传送回复用户数据 + var userInfo = { + "replyType" : "homework_assignment", + "replyContent" : postInput + }; + + $.ajax({ + type: "POST", //提交方式 + dataType: "json", //类型 + url: "前台地址/后台方法", //提交的页面,方法名 + data: userInfo, //参数,如果没有,可以为null + success: function (data) { //如果执行成功,那么执行此方法 + alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + }, + error: function (err) { //如果执行不成功,那么执行此方法 + alert("err:" + err); + } + }); + } + + } + + //点赞效果 + var praiseClick = function(){ + var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); + praiseNum++; + $(".praise-num").text("(" + praiseNum + ")"); + } + + +}); \ No newline at end of file diff --git a/public/javascripts/wechat/message_detail.js b/public/javascripts/wechat/message_detail.js new file mode 100644 index 000000000..279da05d9 --- /dev/null +++ b/public/javascripts/wechat/message_detail.js @@ -0,0 +1,95 @@ +/** + * Created by root on 4/1/16. + */ +$(document).ready(function(){ + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + + var apiUrl = '/api/v1/'; + + var setTemplate = function(data){ + console.log(data); + var html=bt('t:message-detail',{message: data}); + $('#message-container').prepend(html); + $('.post-reply-submit').click(function(){ + replyInsert(); + }); + $('post-interactive-praise').click(function(){ + praiseClick(); + }); + }; + + var loadDataFromServer = function(id){ + //getOpenId(function(openid){ + $.ajax({ + url: apiUrl + 'journal_for_messages/' + id, + dataType: 'json', + success: function(data){ + setTemplate(data.data); + }, + error: function(xhr,status,err){ + console.log(err); + } + }); + //}) + + + }; + + var homeworkUrl = window.location.search; + var homeworkID = homeworkUrl.split("=")[1]; + + loadDataFromServer(homeworkID); + + //点击回复按钮,插入回复内容 + var replyInsert = function(){ + var replyContent = $("#postInput").val(); + if (!replyContent){ + alert("请输入回复"); + }else{ + + //将用户输入内容插入最后一条回复 + $(".post-reply-wrap:last").after('
回复
'); + $(".post-reply-content:last").append(replyContent); + $(".post-reply-date:last").append(Date()); + var postInput = $("#postInput").val(); + $("#postInput").val(""); + //回复数目+1 + var replyNum = $(".post-interactive-reply").text().match(/\d+/g); + replyNum++; + $(".reply-num").text("(" + replyNum + ")"); + + //获取并传送回复用户数据 + var userInfo = { + "replyType" : "homework_assignment", + "replyContent" : postInput + }; + + $.ajax({ + type: "POST", //提交方式 + dataType: "json", //类型 + url: "前台地址/后台方法", //提交的页面,方法名 + data: userInfo, //参数,如果没有,可以为null + success: function (data) { //如果执行成功,那么执行此方法 + alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + }, + error: function (err) { //如果执行不成功,那么执行此方法 + alert("err:" + err); + } + }); + } + + } + + //点赞效果 + var praiseClick = function(){ + var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); + praiseNum++; + $(".praise-num").text("(" + praiseNum + ")"); + } + + +}); \ No newline at end of file diff --git a/public/javascripts/wechat/project_discussion.js b/public/javascripts/wechat/project_discussion.js new file mode 100644 index 000000000..0ba69c153 --- /dev/null +++ b/public/javascripts/wechat/project_discussion.js @@ -0,0 +1,3 @@ +/** + * Created by root on 4/1/16. + */ diff --git a/public/javascripts/wechat/wechat-dev.js b/public/javascripts/wechat/wechat_dev.js similarity index 100% rename from public/javascripts/wechat/wechat-dev.js rename to public/javascripts/wechat/wechat_dev.js From 58e5fe85c361c8934ab25b15a4b97888e3073b97 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Apr 2016 21:28:25 +0800 Subject: [PATCH 103/507] =?UTF-8?q?issue=20=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/issue.rb | 3 +++ public/assets/wechat/issue_detail.html | 30 +++++++++-------------- public/javascripts/wechat/issue_detail.js | 2 +- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index bc2d92b1b..de60adddf 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -24,6 +24,8 @@ module Mobile IssueStatus.find(issue.status_id).name when :journals_count issue.journals.count + when :project_name + issue.project.name end end end @@ -38,6 +40,7 @@ module Mobile issue_expose :issue_assigned_to issue_expose :issue_status issue_expose :journals_count + issue_expose :project_name expose :issue_journals, using: Mobile::Entities::Journal do |f, opt| if f.is_a?(::Issue) f.journals.where("notes != null") diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 8c326d631..e1fc8aef8 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -20,39 +20,33 @@ diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 3f05b1b8e..10ddd9d7a 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -40,7 +40,8 @@
回复 ()
()
- +
+ = 0; --j){ !>
@@ -54,6 +55,7 @@
+
@@ -66,6 +68,20 @@
+ + diff --git a/public/javascripts/wechat/homework_detail.js b/public/javascripts/wechat/homework_detail.js index 92796cf3f..094a1d432 100644 --- a/public/javascripts/wechat/homework_detail.js +++ b/public/javascripts/wechat/homework_detail.js @@ -10,6 +10,12 @@ $(document).ready(function(){ var apiUrl = '/api/v1/'; + var setReplyTemplate = function(data){ + console.log(data); + var html=bt('t:homework-detail-reply',{reply: data}); + $('#all_homework_reply').prepend(html); + }; + var setTemplate = function(data){ console.log(data); var html=bt('t:homework-detail',{homework: data}); @@ -51,10 +57,10 @@ $(document).ready(function(){ alert("请输入回复"); }else{ - //将用户输入内容插入最后一条回复 + /*//将用户输入内容插入最后一条回复 $(".post-reply-wrap:last").after('
回复
'); $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); + $(".post-reply-date:last").append(Date());*/ var postInput = $("#postInput").val(); $("#postInput").val(""); //回复数目+1 @@ -75,6 +81,7 @@ $(document).ready(function(){ data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 alert(data.result); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + setReplyTemplate(data.data); }, error: function (err) { //如果执行不成功,那么执行此方法 alert("err:" + err); diff --git a/public/javascripts/wechat/wechat_dev.js b/public/javascripts/wechat/wechat_dev.js index c921ed64d..6ed55c624 100644 --- a/public/javascripts/wechat/wechat_dev.js +++ b/public/javascripts/wechat/wechat_dev.js @@ -2,5 +2,5 @@ * Created by root on 3/25/16. */ $(document).ready(function(){ - loadDataFromServer(8686, 0); + loadDataFromServer(868, 0); }); From 3b70970651bc0d453901a33e509efb3e79b62878 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 1 Apr 2016 23:21:18 +0800 Subject: [PATCH 107/507] =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=B7=9F=E8=B8=AA?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/homework_detail.html | 5 ++--- public/assets/wechat/issue_detail.html | 10 ++++------ public/javascripts/wechat/issue_detail.js | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 3f05b1b8e..f1a86d2fb 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -19,7 +19,6 @@ diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index e1fc8aef8..fd9f93aa1 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -37,15 +37,16 @@
回复 ()
-
赞 ()
+
赞 ()
+
-
+
回复
@@ -53,6 +54,7 @@
+
@@ -67,6 +69,20 @@
+ + diff --git a/public/javascripts/wechat/issue_detail.js b/public/javascripts/wechat/issue_detail.js index dcd5ae723..3ddd03356 100644 --- a/public/javascripts/wechat/issue_detail.js +++ b/public/javascripts/wechat/issue_detail.js @@ -13,12 +13,19 @@ $(document).ready(function(){ var apiUrl = '/api/v1/'; + var setReplyTemplate = function(data){ + console.log(data); + var html=bt('t:issue-detail-reply',{reply: data}); + $('#all_issue_reply').prepend(html); + }; + + var setTemplate = function(data){ console.log(data); var html=bt('t:issue-detail',{issues: data}); $('#issue-container').prepend(html); $('.post-reply-submit').click(function(){ - replyInsert(); + IssueReplyInsert(); }); /*$('post-interactive-praise').click(function(){ praiseClick(); @@ -48,16 +55,16 @@ $(document).ready(function(){ loadDataFromServer(homeworkID); //点击回复按钮,插入回复内容 - var replyInsert = function(){ + var IssueReplyInsert = function(){ var replyContent = $("#postInput").val(); if (!replyContent){ alert("请输入回复"); }else{ //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
回复
'); + /*$(".post-reply-wrap:last").after('
回复
'); $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); + $(".post-reply-date:last").append(Date());*/ var postInput = $("#postInput").val(); $("#postInput").val(""); //回复数目+1 @@ -78,6 +85,7 @@ $(document).ready(function(){ data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 alert(data.result); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + setReplyTemplate(data.data); }, error: function (err) { //如果执行不成功,那么执行此方法 alert("err:" + err); diff --git a/public/javascripts/wechat/wechat_dev.js b/public/javascripts/wechat/wechat_dev.js index 6ed55c624..c921ed64d 100644 --- a/public/javascripts/wechat/wechat_dev.js +++ b/public/javascripts/wechat/wechat_dev.js @@ -2,5 +2,5 @@ * Created by root on 3/25/16. */ $(document).ready(function(){ - loadDataFromServer(868, 0); + loadDataFromServer(8686, 0); }); From d47f887fd13a5c5129b8eefebdc727e0c78dcb6e Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 1 Apr 2016 23:48:29 +0800 Subject: [PATCH 109/507] =?UTF-8?q?issue=E5=9B=9E=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/issue_detail.html | 14 ++++++-------- public/javascripts/wechat/homework_detail.js | 1 - public/javascripts/wechat/issue_detail.js | 15 +++++++-------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 89fa4c689..964ea7d5b 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -36,10 +36,8 @@
-
回复 ()
-
赞 ()
-
回复 ()
-
()
+
回复 ()
+
()
= 0; --j){ !> @@ -72,11 +70,11 @@ + + diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 6c508ab9c..6765281fa 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -36,14 +36,15 @@
回复 ()
-
1
+
()
- +
+ = 0; --j){ !>
-
+
- +
回复
@@ -52,11 +53,12 @@
+
- +
@@ -64,6 +66,22 @@
+ + + + diff --git a/public/javascripts/wechat/course_discussion.js b/public/javascripts/wechat/course_discussion.js index 12533d5f6..e01b6b451 100644 --- a/public/javascripts/wechat/course_discussion.js +++ b/public/javascripts/wechat/course_discussion.js @@ -10,6 +10,12 @@ $(document).ready(function(){ var apiUrl = '/api/v1/'; + var setReplyTemplate = function(data){ + console.log(data); + var html=bt('t:c-message-detail-reply',{reply: data}); + $('#all_course_message_reply').prepend(html); + }; + var setTemplate = function(data){ console.log(data); var html=bt('t:course-discussion',{discussion: data}); @@ -17,9 +23,9 @@ $(document).ready(function(){ $('.post-reply-submit').click(function(){ replyInsert(); }); - $('post-interactive-praise').click(function(){ + /*$('post-interactive-praise').click(function(){ praiseClick(); - }); + });*/ }; var loadDataFromServer = function(id){ @@ -52,9 +58,9 @@ $(document).ready(function(){ }else{ //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
回复
'); + /*$(".post-reply-wrap:last").after('
回复
'); $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); + $(".post-reply-date:last").append(Date());*/ var postInput = $("#postInput").val(); $("#postInput").val(""); //回复数目+1 @@ -71,10 +77,11 @@ $(document).ready(function(){ $.ajax({ type: "POST", //提交方式 dataType: "json", //类型 - url: "前台地址/后台方法", //提交的页面,方法名 + url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 - alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + setReplyTemplate(data.data); + alert("6"); }, error: function (err) { //如果执行不成功,那么执行此方法 alert("err:" + err); @@ -84,12 +91,12 @@ $(document).ready(function(){ } - //点赞效果 + /*//点赞效果 var praiseClick = function(){ var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); praiseNum++; $(".praise-num").text("(" + praiseNum + ")"); - } + }*/ }); \ No newline at end of file diff --git a/public/javascripts/wechat/course_notice.js b/public/javascripts/wechat/course_notice.js index f20526a5f..546aac385 100644 --- a/public/javascripts/wechat/course_notice.js +++ b/public/javascripts/wechat/course_notice.js @@ -10,6 +10,12 @@ $(document).ready(function(){ var apiUrl = '/api/v1/'; + var setReplyTemplate = function(data){ + console.log(data); + var html=bt('t:news-detail-reply',{reply: data}); + $('#all_news_reply').prepend(html); + }; + var setTemplate = function(data){ console.log(data); var html=bt('t:course-notice',{course: data}); @@ -17,9 +23,9 @@ $(document).ready(function(){ $('.post-reply-submit').click(function(){ replyInsert(); }); - $('post-interactive-praise').click(function(){ + /*$('post-interactive-praise').click(function(){ praiseClick(); - }); + });*/ }; var loadDataFromServer = function(id){ @@ -52,9 +58,9 @@ $(document).ready(function(){ }else{ //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
回复
'); + /*$(".post-reply-wrap:last").after('
回复
'); $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); + $(".post-reply-date:last").append(Date());*/ var postInput = $("#postInput").val(); $("#postInput").val(""); //回复数目+1 @@ -64,17 +70,17 @@ $(document).ready(function(){ //获取并传送回复用户数据 var userInfo = { - "replyType" : "homework_assignment", - "replyContent" : postInput + "type" : "News", + "content" : postInput }; $.ajax({ type: "POST", //提交方式 dataType: "json", //类型 - url: "前台地址/后台方法", //提交的页面,方法名 + url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 - alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + setReplyTemplate(data.data); }, error: function (err) { //如果执行不成功,那么执行此方法 alert("err:" + err); From 5839959f0a256cf2c73026f43652affa528bf291 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 07:32:40 +0800 Subject: [PATCH 112/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9openid=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 53 +------------------------ public/javascripts/wechat/auth.js | 3 ++ public/javascripts/wechat/wechat_dev.js | 49 +++++++++++++++++++++++ 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index ea730d4f7..2fb2fa81d 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -219,58 +219,7 @@ - - + \ No newline at end of file diff --git a/public/javascripts/wechat/auth.js b/public/javascripts/wechat/auth.js index 1d9682720..79f5f96a1 100644 --- a/public/javascripts/wechat/auth.js +++ b/public/javascripts/wechat/auth.js @@ -15,16 +15,19 @@ $(function(){ } window.getOpenId = function(cb){ + alert(g_openid); if (g_openid.length>0){ cb(g_openid); } var code = getUrlParam("code"); + alert(code); $.ajax({ url: '/wechat/get_open_id?code='+code, type: 'get', dataType: 'json', success: function(data){ g_openid = data.openid; + alert(g_openid); cb(g_openid); }, error: function(xhr,err){ diff --git a/public/javascripts/wechat/wechat_dev.js b/public/javascripts/wechat/wechat_dev.js index c921ed64d..18fe67e1f 100644 --- a/public/javascripts/wechat/wechat_dev.js +++ b/public/javascripts/wechat/wechat_dev.js @@ -2,5 +2,54 @@ * Created by root on 3/25/16. */ $(document).ready(function(){ + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + var apiUrl = '/api/v1/'; + var loadDataFromServer = function(id, page){ + getOpenId(function(openid){ + $.ajax({ + url: apiUrl + 'activities/' + openid +"?page=" + parseInt(page), + dataType: 'json', + success: function(data){ + setTemplate(data.data, data.all_count, data.count, data.page); + }, + error: function(xhr,status,err){ + console.log(err); + } + }); + }) + + }; + var setTemplate = function(data, all_count, count, page){ + console.log(data); + var html=bt('t:result-list',{activities: data, all_count: all_count, count: count, page: page}); + if (page == 0) { + $('#container').prepend(html); + } else { + $("#more_activities").remove(); + $('#container').append(html); + } + descToggle(); + }; + //内容全部显示与部分隐藏 + var descToggle = function(){ + $(".post-all-content").each(function(){ + var postHeight = $(this).height(); + if (postHeight > 90){ + $(this).parent().next().css("display","block"); + $(this).parent().next().toggle(function(){ + $(this).text("点击隐藏"); + $(this).prev().css("height",postHeight); + },function(){ + $(this).text("点击展开"); + $(this).prev().css("height",90); + }); + } + }); + } + loadDataFromServer(8686, 0); }); From 7d4de365216a1a13b26cef7b84253fb00fa23708 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 07:39:46 +0800 Subject: [PATCH 113/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9openid=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 6 +++--- public/assets/wechat/blog_detail.html | 2 +- public/assets/wechat/course_discussion.html | 2 +- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/homework_detail.html | 2 +- public/assets/wechat/issue_detail.html | 2 +- public/assets/wechat/message_detail.html | 2 +- public/assets/wechat/project_discussion.html | 2 +- public/javascripts/wechat/wechat_dev.js | 4 +++- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 9329ea860..15f244715 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -9,10 +9,10 @@ module Mobile params do requires :page, type: Integer + requires :token, type: String end - get ':id' do - #uw = UserWechat.find params[:openid] - user = User.find params[:id] + post do + user = UserWechat.find_by_openid(params[:openid]) shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) page = params[:page] ? params[:page] : 0 diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 8b3f44eb5..dd40df5ab 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -66,8 +66,8 @@ - + \ No newline at end of file diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index acef95c64..93982d70c 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -82,8 +82,8 @@ - + \ No newline at end of file diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 6765281fa..33ea6fe4b 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -84,8 +84,8 @@ - + \ No newline at end of file diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index c4f7b8ad2..6f7449754 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -83,8 +83,8 @@ - + \ No newline at end of file diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 964ea7d5b..8a3cb73b1 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -83,7 +83,7 @@ - + \ No newline at end of file diff --git a/public/assets/wechat/message_detail.html b/public/assets/wechat/message_detail.html index 04563184f..3709f65cf 100644 --- a/public/assets/wechat/message_detail.html +++ b/public/assets/wechat/message_detail.html @@ -64,8 +64,8 @@ - + \ No newline at end of file diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 5201d8299..0c0428a03 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -66,8 +66,8 @@ - + \ No newline at end of file diff --git a/public/javascripts/wechat/wechat_dev.js b/public/javascripts/wechat/wechat_dev.js index 18fe67e1f..36529e0b8 100644 --- a/public/javascripts/wechat/wechat_dev.js +++ b/public/javascripts/wechat/wechat_dev.js @@ -11,7 +11,9 @@ $(document).ready(function(){ var loadDataFromServer = function(id, page){ getOpenId(function(openid){ $.ajax({ - url: apiUrl + 'activities/' + openid +"?page=" + parseInt(page), + url: apiUrl + 'activities', + data: {openid: openid, page: page}, + type: 'POST', dataType: 'json', success: function(data){ setTemplate(data.data, data.all_count, data.count, data.page); From 9c93b3f9a6c2b0b6ddb958caef6d691fbdcfa081 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 07:43:55 +0800 Subject: [PATCH 114/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9openid=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 5 ++++- public/javascripts/wechat/auth.js | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index e9dc03f0e..65189daa1 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -214,7 +214,10 @@ class WechatsController < ActionController::Base private def get_openid(code) url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code" - JSON.parse(URI.parse(url).read)["openid"] + logger.debug url + body = URI.parse(url).read + logger.debug body + JSON.parse(body)["openid"] end diff --git a/public/javascripts/wechat/auth.js b/public/javascripts/wechat/auth.js index 79f5f96a1..44c90c836 100644 --- a/public/javascripts/wechat/auth.js +++ b/public/javascripts/wechat/auth.js @@ -15,12 +15,10 @@ $(function(){ } window.getOpenId = function(cb){ - alert(g_openid); if (g_openid.length>0){ cb(g_openid); } var code = getUrlParam("code"); - alert(code); $.ajax({ url: '/wechat/get_open_id?code='+code, type: 'get', From a25fe6cef8e83dc599a816a408ea5221e42aeefb Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 07:47:34 +0800 Subject: [PATCH 115/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9openid=E8=B7=AF?= =?UTF-8?q?=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 65189daa1..ed890d1e1 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -175,7 +175,7 @@ class WechatsController < ActionController::Base def get_open_id begin raise "非法操作, code不存在" unless params[:code] - openid = get_openid(params[:code]) + openid = get_openid_from_code(params[:code]) raise "无法获取到openid" unless openid render :text => {status:0, openid: openid}.to_json rescue Exception=>e @@ -186,7 +186,7 @@ class WechatsController < ActionController::Base def bind begin raise "非法操作, code不存在" unless params[:code] - openid = get_openid(params[:code]) + openid = get_openid_from_code(params[:code]) raise "无法获取到openid" unless openid raise "此微信号已绑定用户, 不能得复绑定" if user_binded?(openid) @@ -211,8 +211,15 @@ class WechatsController < ActionController::Base render 'wechats/login', layout: 'base_wechat' end + def get_openid + code = params[:code] + openid = get_openid_from_code(code) + render :text => {openid: openid}.to_json + end + + private - def get_openid(code) + def get_openid_from_code(code) url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code" logger.debug url body = URI.parse(url).read @@ -220,7 +227,6 @@ class WechatsController < ActionController::Base JSON.parse(body)["openid"] end - def user_binded?(openid) uw = UserWechat.where(openid: openid).first end From 1926f0ba533682bdcb98eb1ff5aaa7a78c0ae69f Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 07:49:36 +0800 Subject: [PATCH 116/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9openid=E8=B7=AF?= =?UTF-8?q?=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 7 ------- config/routes.rb | 2 +- public/javascripts/wechat/auth.js | 5 +++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ed890d1e1..8863043a5 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -211,13 +211,6 @@ class WechatsController < ActionController::Base render 'wechats/login', layout: 'base_wechat' end - def get_openid - code = params[:code] - openid = get_openid_from_code(code) - render :text => {openid: openid}.to_json - end - - private def get_openid_from_code(code) url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code" diff --git a/config/routes.rb b/config/routes.rb index 2313088cc..327c6af8d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1165,7 +1165,7 @@ RedmineApp::Application.routes.draw do collection do get :login post :bind - get :get_open_id + post :get_open_id end end diff --git a/public/javascripts/wechat/auth.js b/public/javascripts/wechat/auth.js index 44c90c836..e2f8424d4 100644 --- a/public/javascripts/wechat/auth.js +++ b/public/javascripts/wechat/auth.js @@ -20,8 +20,9 @@ $(function(){ } var code = getUrlParam("code"); $.ajax({ - url: '/wechat/get_open_id?code='+code, - type: 'get', + url: '/wechat/get_open_id', + data: {code: code}, + type: 'post', dataType: 'json', success: function(data){ g_openid = data.openid; From ff93e9f79b6d5fea02887db2849461b9a8b0a140 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 07:56:12 +0800 Subject: [PATCH 117/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E4=B8=BAjson?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 8863043a5..dac449834 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -177,9 +177,9 @@ class WechatsController < ActionController::Base raise "非法操作, code不存在" unless params[:code] openid = get_openid_from_code(params[:code]) raise "无法获取到openid" unless openid - render :text => {status:0, openid: openid}.to_json + render :json => {status:0, openid: openid} rescue Exception=>e - render :text => {status: -1, msg: e.message}.to_json + render :json => {status: -1, msg: e.message} end end @@ -200,9 +200,9 @@ class WechatsController < ActionController::Base openid: openid, user: user ) - render :text => {status:0, msg: "绑定成功"}.to_json + render :json => {status:0, msg: "绑定成功"} rescue Exception=>e - render :text => {status: -1, msg: e.message}.to_json + render :json => {status: -1, msg: e.message} end end From e1f1c6fbc08af9c6565887825e0356c2b05507e3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 08:05:49 +0800 Subject: [PATCH 118/507] =?UTF-8?q?openid=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 2 +- public/javascripts/wechat/auth.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 15f244715..9d75b8560 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -9,7 +9,7 @@ module Mobile params do requires :page, type: Integer - requires :token, type: String + requires :openid, type: String end post do user = UserWechat.find_by_openid(params[:openid]) diff --git a/public/javascripts/wechat/auth.js b/public/javascripts/wechat/auth.js index e2f8424d4..f9c2917fc 100644 --- a/public/javascripts/wechat/auth.js +++ b/public/javascripts/wechat/auth.js @@ -26,7 +26,6 @@ $(function(){ dataType: 'json', success: function(data){ g_openid = data.openid; - alert(g_openid); cb(g_openid); }, error: function(xhr,err){ From a6a0681b78d13b2f55101ca153c6436d05029025 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 08:08:03 +0800 Subject: [PATCH 119/507] =?UTF-8?q?openid=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 9d75b8560..c7f8509ae 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -12,7 +12,7 @@ module Mobile requires :openid, type: String end post do - user = UserWechat.find_by_openid(params[:openid]) + user = UserWechat.find_by_openid(params[:openid]).user shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) page = params[:page] ? params[:page] : 0 From 58c1b276005f5d582c0c7875cf3d74521df6bdd7 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 08:13:52 +0800 Subject: [PATCH 120/507] =?UTF-8?q?=E5=8A=A0=E5=85=A5openid=E4=BC=A0?= =?UTF-8?q?=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 3 +- public/javascripts/wechat/homework_detail.js | 35 +++++++++++--------- public/javascripts/wechat/issue_detail.js | 35 +++++++++++--------- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 8c46d530c..8b27803ad 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -11,11 +11,12 @@ module Mobile params do requires :type, type: String requires :content, type: String + requires :openid, type: String end post ':id' do type = params[:type] result = 1 - current_user = User.find 8686 + current_user = UserWechat.find_by_openid(params[:openid]).user if params[:content]!="" && current_user case type when "HomeworkCommon" diff --git a/public/javascripts/wechat/homework_detail.js b/public/javascripts/wechat/homework_detail.js index 39d016133..166ed20bf 100644 --- a/public/javascripts/wechat/homework_detail.js +++ b/public/javascripts/wechat/homework_detail.js @@ -68,23 +68,26 @@ $(document).ready(function(){ replyNum++; $(".reply-num").text("(" + replyNum + ")"); - //获取并传送回复用户数据 - var userInfo = { - "type" : "HomeworkCommon", - "content" : postInput - }; + getOpenId(function(openid) { + //获取并传送回复用户数据 + var userInfo = { + "type": "HomeworkCommon", + "content": postInput, + openid: openid + }; - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } + $.ajax({ + type: "POST", //提交方式 + dataType: "json", //类型 + url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 + data: userInfo, //参数,如果没有,可以为null + success: function (data) { //如果执行成功,那么执行此方法 + setReplyTemplate(data.data); + }, + error: function (err) { //如果执行不成功,那么执行此方法 + alert("err:" + err); + } + }) }); } diff --git a/public/javascripts/wechat/issue_detail.js b/public/javascripts/wechat/issue_detail.js index 03ebda233..2b2766d29 100644 --- a/public/javascripts/wechat/issue_detail.js +++ b/public/javascripts/wechat/issue_detail.js @@ -72,23 +72,26 @@ $(document).ready(function(){ replyNum++; $(".reply-num").text("(" + replyNum + ")"); - //获取并传送回复用户数据 - var userInfo = { - "type" : "Issue", - "content" : postInput - }; + getOpenId(function(openid) { + //获取并传送回复用户数据 + var userInfo = { + "type": "Issue", + "content": postInput, + openid: openid, + }; - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + IssueID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } + $.ajax({ + type: "POST", //提交方式 + dataType: "json", //类型 + url: apiUrl + 'new_comment/' + IssueID, //提交的页面,方法名 + data: userInfo, //参数,如果没有,可以为null + success: function (data) { //如果执行成功,那么执行此方法 + setReplyTemplate(data.data); + }, + error: function (err) { //如果执行不成功,那么执行此方法 + alert("err:" + err); + } + }) }); } From 36f3e3a46ca4c0307aa8c3241463f686996d1552 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 4 Apr 2016 22:24:13 +0800 Subject: [PATCH 121/507] =?UTF-8?q?=E6=94=B9=E4=B8=BAangularjs=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 396 +- public/assets/wechat/app.html | 25 + public/assets/wechat/issue_detail.html | 69 +- public/javascripts/wechat/JSXTransformer.js | 15924 -------------- public/javascripts/wechat/ReactRouter.js | 5064 ----- public/javascripts/wechat/ReactRouter.min.js | 2 - public/javascripts/wechat/app.js | 131 + public/javascripts/wechat/browser.min.js | 44 - public/javascripts/wechat/marked.min.js | 6 - public/javascripts/wechat/react-dom.js | 42 - public/javascripts/wechat/react.js | 19535 ----------------- public/javascripts/wechat/react.min.js | 15 - public/javascripts/wechat/wechat.jsx | 97 - 13 files changed, 370 insertions(+), 40980 deletions(-) create mode 100644 public/assets/wechat/app.html delete mode 100644 public/javascripts/wechat/JSXTransformer.js delete mode 100644 public/javascripts/wechat/ReactRouter.js delete mode 100644 public/javascripts/wechat/ReactRouter.min.js create mode 100644 public/javascripts/wechat/app.js delete mode 100644 public/javascripts/wechat/browser.min.js delete mode 100644 public/javascripts/wechat/marked.min.js delete mode 100644 public/javascripts/wechat/react-dom.js delete mode 100644 public/javascripts/wechat/react.js delete mode 100644 public/javascripts/wechat/react.min.js delete mode 100644 public/javascripts/wechat/wechat.jsx diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 2fb2fa81d..05ce3eb16 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -1,225 +1,217 @@ - - - - 最新动态 - - - - - - +
- - - - -
- - - - - - - - - - - - \ No newline at end of file + +
+
+
+
+
+ + +
+
+
+
+ 点击展开 +
+ {{act.latest_update}} +
+
+
+
回复 ({{act.reply_count}})
+
赞 ({{act.activity_praise_count}})
+
+
+
+
+ + + +
+
+
+
+
+ + +
+
+
+
+
+ +
+
+
+
+
+ + +
+
+

+
+ 点击展开 +
+
+
+
回复 ({{act.reply_count}})
+
赞 ({{act.activity_praise_count}})
+
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+ 点击展开 +
+ {{act.latest_update}} +
+
+
+
回复 ({{act.reply_count}})
+
赞 ({{act.activity_praise_count}})
+
+
+
+
+ + +
+ + + +
更多
+ + + diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html new file mode 100644 index 000000000..ef8e06d64 --- /dev/null +++ b/public/assets/wechat/app.html @@ -0,0 +1,25 @@ + + + + 最新动态 + + + + + + + + + + + +
+ + + + + + + + + \ No newline at end of file diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 8a3cb73b1..b8fdc5928 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -1,89 +1,60 @@ - - - - 问题跟踪 - - - - - - - - - - - -
- - - - - - - - - - - \ No newline at end of file diff --git a/public/javascripts/wechat/JSXTransformer.js b/public/javascripts/wechat/JSXTransformer.js deleted file mode 100644 index 63608d408..000000000 --- a/public/javascripts/wechat/JSXTransformer.js +++ /dev/null @@ -1,15924 +0,0 @@ -/** - * JSXTransformer v0.13.0 - */ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JSXTransformer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o - * @license MIT - */ - -var base64 = _dereq_('base64-js') -var ieee754 = _dereq_('ieee754') -var isArray = _dereq_('is-array') - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 -Buffer.poolSize = 8192 // not used by this implementation - -var kMaxLength = 0x3fffffff -var rootParent = {} - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * Note: - * - * - Implementation must support adding new properties to `Uint8Array` instances. - * Firefox 4-29 lacked support, fixed in Firefox 30+. - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - * - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will - * get the Object implementation, which is slower but will work correctly. - */ -Buffer.TYPED_ARRAY_SUPPORT = (function () { - try { - var buf = new ArrayBuffer(0) - var arr = new Uint8Array(buf) - arr.foo = function () { return 42 } - return arr.foo() === 42 && // typed array instances can be augmented - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` - } catch (e) { - return false - } -})() - -/** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. - */ -function Buffer (subject, encoding, noZero) { - if (!(this instanceof Buffer)) return new Buffer(subject, encoding, noZero) - - var type = typeof subject - var length - - if (type === 'number') { - length = +subject - } else if (type === 'string') { - length = Buffer.byteLength(subject, encoding) - } else if (type === 'object' && subject !== null) { - // assume object is array-like - if (subject.type === 'Buffer' && isArray(subject.data)) subject = subject.data - length = +subject.length - } else { - throw new TypeError('must start with number, buffer, array or string') - } - - if (length > kMaxLength) { - throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x' + - kMaxLength.toString(16) + ' bytes') - } - - if (length < 0) length = 0 - else length >>>= 0 // coerce to uint32 - - var self = this - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Preferred: Return an augmented `Uint8Array` instance for best performance - /*eslint-disable consistent-this */ - self = Buffer._augment(new Uint8Array(length)) - /*eslint-enable consistent-this */ - } else { - // Fallback: Return THIS instance of Buffer (created by `new`) - self.length = length - self._isBuffer = true - } - - var i - if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') { - // Speed optimization -- use set if we're copying from a typed array - self._set(subject) - } else if (isArrayish(subject)) { - // Treat array-ish objects as a byte array - if (Buffer.isBuffer(subject)) { - for (i = 0; i < length; i++) { - self[i] = subject.readUInt8(i) - } - } else { - for (i = 0; i < length; i++) { - self[i] = ((subject[i] % 256) + 256) % 256 - } - } - } else if (type === 'string') { - self.write(subject, 0, encoding) - } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) { - for (i = 0; i < length; i++) { - self[i] = 0 - } - } - - if (length > 0 && length <= Buffer.poolSize) self.parent = rootParent - - return self -} - -function SlowBuffer (subject, encoding, noZero) { - if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding, noZero) - - var buf = new Buffer(subject, encoding, noZero) - delete buf.parent - return buf -} - -Buffer.isBuffer = function isBuffer (b) { - return !!(b != null && b._isBuffer) -} - -Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {} - if (i !== len) { - x = a[i] - y = b[i] - } - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'binary': - case 'base64': - case 'raw': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, totalLength) { - if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])') - - if (list.length === 0) { - return new Buffer(0) - } else if (list.length === 1) { - return list[0] - } - - var i - if (totalLength === undefined) { - totalLength = 0 - for (i = 0; i < list.length; i++) { - totalLength += list[i].length - } - } - - var buf = new Buffer(totalLength) - var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length - } - return buf -} - -Buffer.byteLength = function byteLength (str, encoding) { - var ret - str = str + '' - switch (encoding || 'utf8') { - case 'ascii': - case 'binary': - case 'raw': - ret = str.length - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = str.length * 2 - break - case 'hex': - ret = str.length >>> 1 - break - case 'utf8': - case 'utf-8': - ret = utf8ToBytes(str).length - break - case 'base64': - ret = base64ToBytes(str).length - break - default: - ret = str.length - } - return ret -} - -// pre-set for values that may exist in the future -Buffer.prototype.length = undefined -Buffer.prototype.parent = undefined - -// toString(encoding, start=0, end=buffer.length) -Buffer.prototype.toString = function toString (encoding, start, end) { - var loweredCase = false - - start = start >>> 0 - end = end === undefined || end === Infinity ? this.length : end >>> 0 - - if (!encoding) encoding = 'utf8' - if (start < 0) start = 0 - if (end > this.length) end = this.length - if (end <= start) return '' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'binary': - return binarySlice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' -} - -Buffer.prototype.compare = function compare (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return 0 - return Buffer.compare(this, b) -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset) { - if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff - else if (byteOffset < -0x80000000) byteOffset = -0x80000000 - byteOffset >>= 0 - - if (this.length === 0) return -1 - if (byteOffset >= this.length) return -1 - - // Negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) - - if (typeof val === 'string') { - if (val.length === 0) return -1 // special case: looking for empty string always fails - return String.prototype.indexOf.call(this, val, byteOffset) - } - if (Buffer.isBuffer(val)) { - return arrayIndexOf(this, val, byteOffset) - } - if (typeof val === 'number') { - if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { - return Uint8Array.prototype.indexOf.call(this, val, byteOffset) - } - return arrayIndexOf(this, [ val ], byteOffset) - } - - function arrayIndexOf (arr, val, byteOffset) { - var foundIndex = -1 - for (var i = 0; byteOffset + i < arr.length; i++) { - if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex - } else { - foundIndex = -1 - } - } - return -1 - } - - throw new TypeError('val must be string, number or Buffer') -} - -// `get` will be removed in Node 0.13+ -Buffer.prototype.get = function get (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) -} - -// `set` will be removed in Node 0.13+ -Buffer.prototype.set = function set (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - // must be an even number of digits - var strLen = string.length - if (strLen % 2 !== 0) throw new Error('Invalid hex string') - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; i++) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(parsed)) throw new Error('Invalid hex string') - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) - return charsWritten -} - -function asciiWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length) - return charsWritten -} - -function binaryWrite (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length) - return charsWritten -} - -function utf16leWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) - return charsWritten -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Support both (string, offset, length, encoding) - // and the legacy (string, encoding, offset, length) - if (isFinite(offset)) { - if (!isFinite(length)) { - encoding = length - length = undefined - } - } else { // legacy - var swap = encoding - encoding = offset - offset = length - length = swap - } - - offset = Number(offset) || 0 - - if (length < 0 || offset < 0 || offset > this.length) { - throw new RangeError('attempt to write outside buffer bounds') - } - - var remaining = this.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - encoding = String(encoding || 'utf8').toLowerCase() - - var ret - switch (encoding) { - case 'hex': - ret = hexWrite(this, string, offset, length) - break - case 'utf8': - case 'utf-8': - ret = utf8Write(this, string, offset, length) - break - case 'ascii': - ret = asciiWrite(this, string, offset, length) - break - case 'binary': - ret = binaryWrite(this, string, offset, length) - break - case 'base64': - ret = base64Write(this, string, offset, length) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = utf16leWrite(this, string, offset, length) - break - default: - throw new TypeError('Unknown encoding: ' + encoding) - } - return ret -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - var res = '' - var tmp = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) - tmp = '' - } else { - tmp += '%' + buf[i].toString(16) - } - } - - return res + decodeUtf8Char(tmp) -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function binarySlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; i++) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf - if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = Buffer._augment(this.subarray(start, end)) - } else { - var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined, true) - for (var i = 0; i < sliceLen; i++) { - newBuf[i] = this[i + start] - } - } - - if (newBuf.length) newBuf.parent = this.parent || this - - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) >>> 0 & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) >>> 0 & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - this[offset] = value - return offset + 1 -} - -function objectWriteUInt16 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = value - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 -} - -function objectWriteUInt32 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = value - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = value - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkInt( - this, value, offset, byteLength, - Math.pow(2, 8 * byteLength - 1) - 1, - -Math.pow(2, 8 * byteLength - 1) - ) - } - - var i = 0 - var mul = 1 - var sub = value < 0 ? 1 : 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkInt( - this, value, offset, byteLength, - Math.pow(2, 8 * byteLength - 1) - 1, - -Math.pow(2, 8 * byteLength - 1) - ) - } - - var i = byteLength - 1 - var mul = 1 - var sub = value < 0 ? 1 : 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - if (value < 0) value = 0xff + value + 1 - this[offset] = value - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = value - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = value - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') - if (offset < 0) throw new RangeError('index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, target_start, start, end) { - var self = this // source - - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (target_start >= target.length) target_start = target.length - if (!target_start) target_start = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || self.length === 0) return 0 - - // Fatal error conditions - if (target_start < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= self.length) throw new RangeError('sourceStart out of bounds') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - target_start < end - start) { - end = target.length - target_start + start - } - - var len = end - start - - if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < len; i++) { - target[i + target_start] = this[i + start] - } - } else { - target._set(this.subarray(start, start + len), target_start) - } - - return len -} - -// fill(value, start=0, end=buffer.length) -Buffer.prototype.fill = function fill (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length - - if (end < start) throw new RangeError('end < start') - - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return - - if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') - if (end < 0 || end > this.length) throw new RangeError('end out of bounds') - - var i - if (typeof value === 'number') { - for (i = start; i < end; i++) { - this[i] = value - } - } else { - var bytes = utf8ToBytes(value.toString()) - var len = bytes.length - for (i = start; i < end; i++) { - this[i] = bytes[i % len] - } - } - - return this -} - -/** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ -Buffer.prototype.toArrayBuffer = function toArrayBuffer () { - if (typeof Uint8Array !== 'undefined') { - if (Buffer.TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i] - } - return buf.buffer - } - } else { - throw new TypeError('Buffer.toArrayBuffer not supported in this browser') - } -} - -// HELPER FUNCTIONS -// ================ - -var BP = Buffer.prototype - -/** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ -Buffer._augment = function _augment (arr) { - arr.constructor = Buffer - arr._isBuffer = true - - // save reference to original Uint8Array get/set methods before overwriting - arr._get = arr.get - arr._set = arr.set - - // deprecated, will be removed in node 0.13+ - arr.get = BP.get - arr.set = BP.set - - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.equals = BP.equals - arr.compare = BP.compare - arr.indexOf = BP.indexOf - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUIntLE = BP.readUIntLE - arr.readUIntBE = BP.readUIntBE - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readIntLE = BP.readIntLE - arr.readIntBE = BP.readIntBE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUIntLE = BP.writeUIntLE - arr.writeUIntBE = BP.writeUIntBE - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeIntLE = BP.writeIntLE - arr.writeIntBE = BP.writeIntBE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer - - return arr -} - -var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g - -function base64clean (str) { - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') -} - -function isArrayish (subject) { - return isArray(subject) || Buffer.isBuffer(subject) || - subject && typeof subject === 'object' && - typeof subject.length === 'number' -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - var i = 0 - - for (; i < length; i++) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (leadSurrogate) { - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } else { - // valid surrogate pair - codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 - leadSurrogate = null - } - } else { - // no lead yet - - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else { - // valid lead - leadSurrogate = codePoint - continue - } - } - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = null - } - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x200000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; i++) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; i++) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -function decodeUtf8Char (str) { - try { - return decodeURIComponent(str) - } catch (err) { - return String.fromCharCode(0xFFFD) // UTF 8 invalid char - } -} - -},{"base64-js":4,"ieee754":5,"is-array":6}],4:[function(_dereq_,module,exports){ -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - -;(function (exports) { - 'use strict'; - - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array - - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - var PLUS_URL_SAFE = '-'.charCodeAt(0) - var SLASH_URL_SAFE = '_'.charCodeAt(0) - - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62 // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } - - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length - - var L = 0 - - function push (v) { - arr[L++] = v - } - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } - - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } - - return arr - } - - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length - - function encode (num) { - return lookup.charAt(num) - } - - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } - - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } - - return output - } - - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 -}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) - -},{}],5:[function(_dereq_,module,exports){ -exports.read = function(buffer, offset, isLE, mLen, nBytes) { - var e, m, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - nBits = -7, - i = isLE ? (nBytes - 1) : 0, - d = isLE ? -1 : 1, - s = buffer[offset + i]; - - i += d; - - e = s & ((1 << (-nBits)) - 1); - s >>= (-nBits); - nBits += eLen; - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); - - m = e & ((1 << (-nBits)) - 1); - e >>= (-nBits); - nBits += mLen; - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); - - if (e === 0) { - e = 1 - eBias; - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity); - } else { - m = m + Math.pow(2, mLen); - e = e - eBias; - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen); -}; - -exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), - i = isLE ? 0 : (nBytes - 1), - d = isLE ? 1 : -1, - s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; - - value = Math.abs(value); - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0; - e = eMax; - } else { - e = Math.floor(Math.log(value) / Math.LN2); - if (value * (c = Math.pow(2, -e)) < 1) { - e--; - c *= 2; - } - if (e + eBias >= 1) { - value += rt / c; - } else { - value += rt * Math.pow(2, 1 - eBias); - } - if (value * c >= 2) { - e++; - c /= 2; - } - - if (e + eBias >= eMax) { - m = 0; - e = eMax; - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen); - e = e + eBias; - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); - e = 0; - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); - - e = (e << mLen) | m; - eLen += mLen; - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); - - buffer[offset + i - d] |= s * 128; -}; - -},{}],6:[function(_dereq_,module,exports){ - -/** - * isArray - */ - -var isArray = Array.isArray; - -/** - * toString - */ - -var str = Object.prototype.toString; - -/** - * Whether or not the given `val` - * is an array. - * - * example: - * - * isArray([]); - * // > true - * isArray(arguments); - * // > false - * isArray(''); - * // > false - * - * @param {mixed} val - * @return {bool} - */ - -module.exports = isArray || function (val) { - return !! val && '[object Array]' == str.call(val); -}; - -},{}],7:[function(_dereq_,module,exports){ -(function (process){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// resolves . and .. elements in a path array with directory names there -// must be no slashes, empty elements, or device names (c:\) in the array -// (so also no leading and trailing slashes - it does not distinguish -// relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = parts.length - 1; i >= 0; i--) { - var last = parts[i]; - if (last === '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); - } - } - - return parts; -} - -// Split a filename into [root, dir, basename, ext], unix version -// 'root' is just a slash, or nothing. -var splitPathRe = - /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; -var splitPath = function(filename) { - return splitPathRe.exec(filename).slice(1); -}; - -// path.resolve([from ...], to) -// posix version -exports.resolve = function() { - var resolvedPath = '', - resolvedAbsolute = false; - - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - var path = (i >= 0) ? arguments[i] : process.cwd(); - - // Skip empty and invalid entries - if (typeof path !== 'string') { - throw new TypeError('Arguments to path.resolve must be strings'); - } else if (!path) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charAt(0) === '/'; - } - - // At this point the path should be resolved to a full absolute path, but - // handle relative paths to be safe (might happen when process.cwd() fails) - - // Normalize the path - resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { - return !!p; - }), !resolvedAbsolute).join('/'); - - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; -}; - -// path.normalize(path) -// posix version -exports.normalize = function(path) { - var isAbsolute = exports.isAbsolute(path), - trailingSlash = substr(path, -1) === '/'; - - // Normalize the path - path = normalizeArray(filter(path.split('/'), function(p) { - return !!p; - }), !isAbsolute).join('/'); - - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } - - return (isAbsolute ? '/' : '') + path; -}; - -// posix version -exports.isAbsolute = function(path) { - return path.charAt(0) === '/'; -}; - -// posix version -exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(filter(paths, function(p, index) { - if (typeof p !== 'string') { - throw new TypeError('Arguments to path.join must be strings'); - } - return p; - }).join('/')); -}; - - -// path.relative(from, to) -// posix version -exports.relative = function(from, to) { - from = exports.resolve(from).substr(1); - to = exports.resolve(to).substr(1); - - function trim(arr) { - var start = 0; - for (; start < arr.length; start++) { - if (arr[start] !== '') break; - } - - var end = arr.length - 1; - for (; end >= 0; end--) { - if (arr[end] !== '') break; - } - - if (start > end) return []; - return arr.slice(start, end - start + 1); - } - - var fromParts = trim(from.split('/')); - var toParts = trim(to.split('/')); - - var length = Math.min(fromParts.length, toParts.length); - var samePartsLength = length; - for (var i = 0; i < length; i++) { - if (fromParts[i] !== toParts[i]) { - samePartsLength = i; - break; - } - } - - var outputParts = []; - for (var i = samePartsLength; i < fromParts.length; i++) { - outputParts.push('..'); - } - - outputParts = outputParts.concat(toParts.slice(samePartsLength)); - - return outputParts.join('/'); -}; - -exports.sep = '/'; -exports.delimiter = ':'; - -exports.dirname = function(path) { - var result = splitPath(path), - root = result[0], - dir = result[1]; - - if (!root && !dir) { - // No dirname whatsoever - return '.'; - } - - if (dir) { - // It has a dirname, strip trailing slash - dir = dir.substr(0, dir.length - 1); - } - - return root + dir; -}; - - -exports.basename = function(path, ext) { - var f = splitPath(path)[2]; - // TODO: make this comparison case-insensitive on windows? - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); - } - return f; -}; - - -exports.extname = function(path) { - return splitPath(path)[3]; -}; - -function filter (xs, f) { - if (xs.filter) return xs.filter(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - if (f(xs[i], i, xs)) res.push(xs[i]); - } - return res; -} - -// String.prototype.substr - negative index don't work in IE8 -var substr = 'ab'.substr(-1) === 'b' - ? function (str, start, len) { return str.substr(start, len) } - : function (str, start, len) { - if (start < 0) start = str.length + start; - return str.substr(start, len); - } -; - -}).call(this,_dereq_('_process')) -},{"_process":8}],8:[function(_dereq_,module,exports){ -// shim for using process in browser - -var process = module.exports = {}; -var queue = []; -var draining = false; - -function drainQueue() { - if (draining) { - return; - } - draining = true; - var currentQueue; - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - var i = -1; - while (++i < len) { - currentQueue[i](); - } - len = queue.length; - } - draining = false; -} -process.nextTick = function (fun) { - queue.push(fun); - if (!draining) { - setTimeout(drainQueue, 0); - } -}; - -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -// TODO(shtylman) -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],9:[function(_dereq_,module,exports){ -/* - Copyright (C) 2013 Ariya Hidayat - Copyright (C) 2013 Thaddee Tyl - Copyright (C) 2012 Ariya Hidayat - Copyright (C) 2012 Mathias Bynens - Copyright (C) 2012 Joost-Wim Boekesteijn - Copyright (C) 2012 Kris Kowal - Copyright (C) 2012 Yusuke Suzuki - Copyright (C) 2012 Arpad Borsos - Copyright (C) 2011 Ariya Hidayat - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -(function (root, factory) { - 'use strict'; - - // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, - // Rhino, and plain browser loading. - - /* istanbul ignore next */ - if (typeof define === 'function' && define.amd) { - define(['exports'], factory); - } else if (typeof exports !== 'undefined') { - factory(exports); - } else { - factory((root.esprima = {})); - } -}(this, function (exports) { - 'use strict'; - - var Token, - TokenName, - FnExprTokens, - Syntax, - PropertyKind, - Messages, - Regex, - SyntaxTreeDelegate, - XHTMLEntities, - ClassPropertyType, - source, - strict, - index, - lineNumber, - lineStart, - length, - delegate, - lookahead, - state, - extra; - - Token = { - BooleanLiteral: 1, - EOF: 2, - Identifier: 3, - Keyword: 4, - NullLiteral: 5, - NumericLiteral: 6, - Punctuator: 7, - StringLiteral: 8, - RegularExpression: 9, - Template: 10, - JSXIdentifier: 11, - JSXText: 12 - }; - - TokenName = {}; - TokenName[Token.BooleanLiteral] = 'Boolean'; - TokenName[Token.EOF] = ''; - TokenName[Token.Identifier] = 'Identifier'; - TokenName[Token.Keyword] = 'Keyword'; - TokenName[Token.NullLiteral] = 'Null'; - TokenName[Token.NumericLiteral] = 'Numeric'; - TokenName[Token.Punctuator] = 'Punctuator'; - TokenName[Token.StringLiteral] = 'String'; - TokenName[Token.JSXIdentifier] = 'JSXIdentifier'; - TokenName[Token.JSXText] = 'JSXText'; - TokenName[Token.RegularExpression] = 'RegularExpression'; - - // A function following one of those tokens is an expression. - FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', - 'return', 'case', 'delete', 'throw', 'void', - // assignment operators - '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', - '&=', '|=', '^=', ',', - // binary/unary operators - '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&', - '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', - '<=', '<', '>', '!=', '!==']; - - Syntax = { - AnyTypeAnnotation: 'AnyTypeAnnotation', - ArrayExpression: 'ArrayExpression', - ArrayPattern: 'ArrayPattern', - ArrayTypeAnnotation: 'ArrayTypeAnnotation', - ArrowFunctionExpression: 'ArrowFunctionExpression', - AssignmentExpression: 'AssignmentExpression', - BinaryExpression: 'BinaryExpression', - BlockStatement: 'BlockStatement', - BooleanTypeAnnotation: 'BooleanTypeAnnotation', - BreakStatement: 'BreakStatement', - CallExpression: 'CallExpression', - CatchClause: 'CatchClause', - ClassBody: 'ClassBody', - ClassDeclaration: 'ClassDeclaration', - ClassExpression: 'ClassExpression', - ClassImplements: 'ClassImplements', - ClassProperty: 'ClassProperty', - ComprehensionBlock: 'ComprehensionBlock', - ComprehensionExpression: 'ComprehensionExpression', - ConditionalExpression: 'ConditionalExpression', - ContinueStatement: 'ContinueStatement', - DebuggerStatement: 'DebuggerStatement', - DeclareClass: 'DeclareClass', - DeclareFunction: 'DeclareFunction', - DeclareModule: 'DeclareModule', - DeclareVariable: 'DeclareVariable', - DoWhileStatement: 'DoWhileStatement', - EmptyStatement: 'EmptyStatement', - ExportDeclaration: 'ExportDeclaration', - ExportBatchSpecifier: 'ExportBatchSpecifier', - ExportSpecifier: 'ExportSpecifier', - ExpressionStatement: 'ExpressionStatement', - ForInStatement: 'ForInStatement', - ForOfStatement: 'ForOfStatement', - ForStatement: 'ForStatement', - FunctionDeclaration: 'FunctionDeclaration', - FunctionExpression: 'FunctionExpression', - FunctionTypeAnnotation: 'FunctionTypeAnnotation', - FunctionTypeParam: 'FunctionTypeParam', - GenericTypeAnnotation: 'GenericTypeAnnotation', - Identifier: 'Identifier', - IfStatement: 'IfStatement', - ImportDeclaration: 'ImportDeclaration', - ImportDefaultSpecifier: 'ImportDefaultSpecifier', - ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', - ImportSpecifier: 'ImportSpecifier', - InterfaceDeclaration: 'InterfaceDeclaration', - InterfaceExtends: 'InterfaceExtends', - IntersectionTypeAnnotation: 'IntersectionTypeAnnotation', - LabeledStatement: 'LabeledStatement', - Literal: 'Literal', - LogicalExpression: 'LogicalExpression', - MemberExpression: 'MemberExpression', - MethodDefinition: 'MethodDefinition', - ModuleSpecifier: 'ModuleSpecifier', - NewExpression: 'NewExpression', - NullableTypeAnnotation: 'NullableTypeAnnotation', - NumberTypeAnnotation: 'NumberTypeAnnotation', - ObjectExpression: 'ObjectExpression', - ObjectPattern: 'ObjectPattern', - ObjectTypeAnnotation: 'ObjectTypeAnnotation', - ObjectTypeCallProperty: 'ObjectTypeCallProperty', - ObjectTypeIndexer: 'ObjectTypeIndexer', - ObjectTypeProperty: 'ObjectTypeProperty', - Program: 'Program', - Property: 'Property', - QualifiedTypeIdentifier: 'QualifiedTypeIdentifier', - ReturnStatement: 'ReturnStatement', - SequenceExpression: 'SequenceExpression', - SpreadElement: 'SpreadElement', - SpreadProperty: 'SpreadProperty', - StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation', - StringTypeAnnotation: 'StringTypeAnnotation', - SwitchCase: 'SwitchCase', - SwitchStatement: 'SwitchStatement', - TaggedTemplateExpression: 'TaggedTemplateExpression', - TemplateElement: 'TemplateElement', - TemplateLiteral: 'TemplateLiteral', - ThisExpression: 'ThisExpression', - ThrowStatement: 'ThrowStatement', - TupleTypeAnnotation: 'TupleTypeAnnotation', - TryStatement: 'TryStatement', - TypeAlias: 'TypeAlias', - TypeAnnotation: 'TypeAnnotation', - TypeCastExpression: 'TypeCastExpression', - TypeofTypeAnnotation: 'TypeofTypeAnnotation', - TypeParameterDeclaration: 'TypeParameterDeclaration', - TypeParameterInstantiation: 'TypeParameterInstantiation', - UnaryExpression: 'UnaryExpression', - UnionTypeAnnotation: 'UnionTypeAnnotation', - UpdateExpression: 'UpdateExpression', - VariableDeclaration: 'VariableDeclaration', - VariableDeclarator: 'VariableDeclarator', - VoidTypeAnnotation: 'VoidTypeAnnotation', - WhileStatement: 'WhileStatement', - WithStatement: 'WithStatement', - JSXIdentifier: 'JSXIdentifier', - JSXNamespacedName: 'JSXNamespacedName', - JSXMemberExpression: 'JSXMemberExpression', - JSXEmptyExpression: 'JSXEmptyExpression', - JSXExpressionContainer: 'JSXExpressionContainer', - JSXElement: 'JSXElement', - JSXClosingElement: 'JSXClosingElement', - JSXOpeningElement: 'JSXOpeningElement', - JSXAttribute: 'JSXAttribute', - JSXSpreadAttribute: 'JSXSpreadAttribute', - JSXText: 'JSXText', - YieldExpression: 'YieldExpression', - AwaitExpression: 'AwaitExpression' - }; - - PropertyKind = { - Data: 1, - Get: 2, - Set: 4 - }; - - ClassPropertyType = { - 'static': 'static', - prototype: 'prototype' - }; - - // Error messages should be identical to V8. - Messages = { - UnexpectedToken: 'Unexpected token %0', - UnexpectedNumber: 'Unexpected number', - UnexpectedString: 'Unexpected string', - UnexpectedIdentifier: 'Unexpected identifier', - UnexpectedReserved: 'Unexpected reserved word', - UnexpectedTemplate: 'Unexpected quasi %0', - UnexpectedEOS: 'Unexpected end of input', - NewlineAfterThrow: 'Illegal newline after throw', - InvalidRegExp: 'Invalid regular expression', - UnterminatedRegExp: 'Invalid regular expression: missing /', - InvalidLHSInAssignment: 'Invalid left-hand side in assignment', - InvalidLHSInFormalsList: 'Invalid left-hand side in formals list', - InvalidLHSInForIn: 'Invalid left-hand side in for-in', - MultipleDefaultsInSwitch: 'More than one default clause in switch statement', - NoCatchOrFinally: 'Missing catch or finally after try', - UnknownLabel: 'Undefined label \'%0\'', - Redeclaration: '%0 \'%1\' has already been declared', - IllegalContinue: 'Illegal continue statement', - IllegalBreak: 'Illegal break statement', - IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition', - IllegalClassConstructorProperty: 'Illegal constructor property in class definition', - IllegalReturn: 'Illegal return statement', - IllegalSpread: 'Illegal spread element', - StrictModeWith: 'Strict mode code may not include a with statement', - StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', - StrictVarName: 'Variable name may not be eval or arguments in strict mode', - StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', - StrictParamDupe: 'Strict mode function may not have duplicate parameter names', - ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list', - DefaultRestParameter: 'Rest parameter can not have a default value', - ElementAfterSpreadElement: 'Spread must be the final element of an element list', - PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal', - ObjectPatternAsRestParameter: 'Invalid rest parameter', - ObjectPatternAsSpread: 'Invalid spread argument', - StrictFunctionName: 'Function name may not be eval or arguments in strict mode', - StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', - StrictDelete: 'Delete of an unqualified identifier in strict mode.', - StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode', - AccessorDataProperty: 'Object literal may not have data and accessor property with the same name', - AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name', - StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', - StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', - StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', - StrictReservedWord: 'Use of future reserved word in strict mode', - MissingFromClause: 'Missing from clause', - NoAsAfterImportNamespace: 'Missing as after import *', - InvalidModuleSpecifier: 'Invalid module specifier', - IllegalImportDeclaration: 'Illegal import declaration', - IllegalExportDeclaration: 'Illegal export declaration', - NoUninitializedConst: 'Const must be initialized', - ComprehensionRequiresBlock: 'Comprehension must have at least one block', - ComprehensionError: 'Comprehension Error', - EachNotAllowed: 'Each is not supported', - InvalidJSXAttributeValue: 'JSX value should be either an expression or a quoted JSX text', - ExpectedJSXClosingTag: 'Expected corresponding JSX closing tag for %0', - AdjacentJSXElements: 'Adjacent JSX elements must be wrapped in an enclosing tag', - ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' + - 'you are trying to write a function type, but you ended up ' + - 'writing a grouped type followed by an =>, which is a syntax ' + - 'error. Remember, function type parameters are named so function ' + - 'types look like (name1: type1, name2: type2) => returnType. You ' + - 'probably wrote (type1) => returnType' - }; - - // See also tools/generate-unicode-regex.py. - Regex = { - NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'), - NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'), - LeadingZeros: new RegExp('^0+(?!$)') - }; - - // Ensure the condition is true, otherwise throw an error. - // This is only to have a better contract semantic, i.e. another safety net - // to catch a logic error. The condition shall be fulfilled in normal case. - // Do NOT use this to enforce a certain condition on any user input. - - function assert(condition, message) { - /* istanbul ignore if */ - if (!condition) { - throw new Error('ASSERT: ' + message); - } - } - - function StringMap() { - this.$data = {}; - } - - StringMap.prototype.get = function (key) { - key = '$' + key; - return this.$data[key]; - }; - - StringMap.prototype.set = function (key, value) { - key = '$' + key; - this.$data[key] = value; - return this; - }; - - StringMap.prototype.has = function (key) { - key = '$' + key; - return Object.prototype.hasOwnProperty.call(this.$data, key); - }; - - StringMap.prototype["delete"] = function (key) { - key = '$' + key; - return delete this.$data[key]; - }; - - function isDecimalDigit(ch) { - return (ch >= 48 && ch <= 57); // 0..9 - } - - function isHexDigit(ch) { - return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; - } - - function isOctalDigit(ch) { - return '01234567'.indexOf(ch) >= 0; - } - - - // 7.2 White Space - - function isWhiteSpace(ch) { - return (ch === 32) || // space - (ch === 9) || // tab - (ch === 0xB) || - (ch === 0xC) || - (ch === 0xA0) || - (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0); - } - - // 7.3 Line Terminators - - function isLineTerminator(ch) { - return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029); - } - - // 7.6 Identifier Names and Identifiers - - function isIdentifierStart(ch) { - return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) - (ch >= 65 && ch <= 90) || // A..Z - (ch >= 97 && ch <= 122) || // a..z - (ch === 92) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); - } - - function isIdentifierPart(ch) { - return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore) - (ch >= 65 && ch <= 90) || // A..Z - (ch >= 97 && ch <= 122) || // a..z - (ch >= 48 && ch <= 57) || // 0..9 - (ch === 92) || // \ (backslash) - ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); - } - - // 7.6.1.2 Future Reserved Words - - function isFutureReservedWord(id) { - switch (id) { - case 'class': - case 'enum': - case 'export': - case 'extends': - case 'import': - case 'super': - return true; - default: - return false; - } - } - - function isStrictModeReservedWord(id) { - switch (id) { - case 'implements': - case 'interface': - case 'package': - case 'private': - case 'protected': - case 'public': - case 'static': - case 'yield': - case 'let': - return true; - default: - return false; - } - } - - function isRestrictedWord(id) { - return id === 'eval' || id === 'arguments'; - } - - // 7.6.1.1 Keywords - - function isKeyword(id) { - if (strict && isStrictModeReservedWord(id)) { - return true; - } - - // 'const' is specialized as Keyword in V8. - // 'yield' is only treated as a keyword in strict mode. - // 'let' is for compatiblity with SpiderMonkey and ES.next. - // Some others are from future reserved words. - - switch (id.length) { - case 2: - return (id === 'if') || (id === 'in') || (id === 'do'); - case 3: - return (id === 'var') || (id === 'for') || (id === 'new') || - (id === 'try') || (id === 'let'); - case 4: - return (id === 'this') || (id === 'else') || (id === 'case') || - (id === 'void') || (id === 'with') || (id === 'enum'); - case 5: - return (id === 'while') || (id === 'break') || (id === 'catch') || - (id === 'throw') || (id === 'const') || - (id === 'class') || (id === 'super'); - case 6: - return (id === 'return') || (id === 'typeof') || (id === 'delete') || - (id === 'switch') || (id === 'export') || (id === 'import'); - case 7: - return (id === 'default') || (id === 'finally') || (id === 'extends'); - case 8: - return (id === 'function') || (id === 'continue') || (id === 'debugger'); - case 10: - return (id === 'instanceof'); - default: - return false; - } - } - - // 7.4 Comments - - function addComment(type, value, start, end, loc) { - var comment; - assert(typeof start === 'number', 'Comment must have valid position'); - - // Because the way the actual token is scanned, often the comments - // (if any) are skipped twice during the lexical analysis. - // Thus, we need to skip adding a comment if the comment array already - // handled it. - if (state.lastCommentStart >= start) { - return; - } - state.lastCommentStart = start; - - comment = { - type: type, - value: value - }; - if (extra.range) { - comment.range = [start, end]; - } - if (extra.loc) { - comment.loc = loc; - } - extra.comments.push(comment); - if (extra.attachComment) { - extra.leadingComments.push(comment); - extra.trailingComments.push(comment); - } - } - - function skipSingleLineComment() { - var start, loc, ch, comment; - - start = index - 2; - loc = { - start: { - line: lineNumber, - column: index - lineStart - 2 - } - }; - - while (index < length) { - ch = source.charCodeAt(index); - ++index; - if (isLineTerminator(ch)) { - if (extra.comments) { - comment = source.slice(start + 2, index - 1); - loc.end = { - line: lineNumber, - column: index - lineStart - 1 - }; - addComment('Line', comment, start, index - 1, loc); - } - if (ch === 13 && source.charCodeAt(index) === 10) { - ++index; - } - ++lineNumber; - lineStart = index; - return; - } - } - - if (extra.comments) { - comment = source.slice(start + 2, index); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - addComment('Line', comment, start, index, loc); - } - } - - function skipMultiLineComment() { - var start, loc, ch, comment; - - if (extra.comments) { - start = index - 2; - loc = { - start: { - line: lineNumber, - column: index - lineStart - 2 - } - }; - } - - while (index < length) { - ch = source.charCodeAt(index); - if (isLineTerminator(ch)) { - if (ch === 13 && source.charCodeAt(index + 1) === 10) { - ++index; - } - ++lineNumber; - ++index; - lineStart = index; - if (index >= length) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - } else if (ch === 42) { - // Block comment ends with '*/' (char #42, char #47). - if (source.charCodeAt(index + 1) === 47) { - ++index; - ++index; - if (extra.comments) { - comment = source.slice(start + 2, index - 2); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - addComment('Block', comment, start, index, loc); - } - return; - } - ++index; - } else { - ++index; - } - } - - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - function skipComment() { - var ch; - - while (index < length) { - ch = source.charCodeAt(index); - - if (isWhiteSpace(ch)) { - ++index; - } else if (isLineTerminator(ch)) { - ++index; - if (ch === 13 && source.charCodeAt(index) === 10) { - ++index; - } - ++lineNumber; - lineStart = index; - } else if (ch === 47) { // 47 is '/' - ch = source.charCodeAt(index + 1); - if (ch === 47) { - ++index; - ++index; - skipSingleLineComment(); - } else if (ch === 42) { // 42 is '*' - ++index; - ++index; - skipMultiLineComment(); - } else { - break; - } - } else { - break; - } - } - } - - function scanHexEscape(prefix) { - var i, len, ch, code = 0; - - len = (prefix === 'u') ? 4 : 2; - for (i = 0; i < len; ++i) { - if (index < length && isHexDigit(source[index])) { - ch = source[index++]; - code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); - } else { - return ''; - } - } - return String.fromCharCode(code); - } - - function scanUnicodeCodePointEscape() { - var ch, code, cu1, cu2; - - ch = source[index]; - code = 0; - - // At least, one hex digit is required. - if (ch === '}') { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - while (index < length) { - ch = source[index++]; - if (!isHexDigit(ch)) { - break; - } - code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); - } - - if (code > 0x10FFFF || ch !== '}') { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - // UTF-16 Encoding - if (code <= 0xFFFF) { - return String.fromCharCode(code); - } - cu1 = ((code - 0x10000) >> 10) + 0xD800; - cu2 = ((code - 0x10000) & 1023) + 0xDC00; - return String.fromCharCode(cu1, cu2); - } - - function getEscapedIdentifier() { - var ch, id; - - ch = source.charCodeAt(index++); - id = String.fromCharCode(ch); - - // '\u' (char #92, char #117) denotes an escaped character. - if (ch === 92) { - if (source.charCodeAt(index) !== 117) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - ++index; - ch = scanHexEscape('u'); - if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - id = ch; - } - - while (index < length) { - ch = source.charCodeAt(index); - if (!isIdentifierPart(ch)) { - break; - } - ++index; - id += String.fromCharCode(ch); - - // '\u' (char #92, char #117) denotes an escaped character. - if (ch === 92) { - id = id.substr(0, id.length - 1); - if (source.charCodeAt(index) !== 117) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - ++index; - ch = scanHexEscape('u'); - if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - id += ch; - } - } - - return id; - } - - function getIdentifier() { - var start, ch; - - start = index++; - while (index < length) { - ch = source.charCodeAt(index); - if (ch === 92) { - // Blackslash (char #92) marks Unicode escape sequence. - index = start; - return getEscapedIdentifier(); - } - if (isIdentifierPart(ch)) { - ++index; - } else { - break; - } - } - - return source.slice(start, index); - } - - function scanIdentifier() { - var start, id, type; - - start = index; - - // Backslash (char #92) starts an escaped character. - id = (source.charCodeAt(index) === 92) ? getEscapedIdentifier() : getIdentifier(); - - // There is no keyword or literal with only one character. - // Thus, it must be an identifier. - if (id.length === 1) { - type = Token.Identifier; - } else if (isKeyword(id)) { - type = Token.Keyword; - } else if (id === 'null') { - type = Token.NullLiteral; - } else if (id === 'true' || id === 'false') { - type = Token.BooleanLiteral; - } else { - type = Token.Identifier; - } - - return { - type: type, - value: id, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - - // 7.7 Punctuators - - function scanPunctuator() { - var start = index, - code = source.charCodeAt(index), - code2, - ch1 = source[index], - ch2, - ch3, - ch4; - - if (state.inJSXTag || state.inJSXChild) { - // Don't need to check for '{' and '}' as it's already handled - // correctly by default. - switch (code) { - case 60: // < - case 62: // > - ++index; - return { - type: Token.Punctuator, - value: String.fromCharCode(code), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - } - - switch (code) { - // Check for most common single-character punctuators. - case 40: // ( open bracket - case 41: // ) close bracket - case 59: // ; semicolon - case 44: // , comma - case 123: // { open curly brace - case 125: // } close curly brace - case 91: // [ - case 93: // ] - case 58: // : - case 63: // ? - case 126: // ~ - ++index; - if (extra.tokenize) { - if (code === 40) { - extra.openParenToken = extra.tokens.length; - } else if (code === 123) { - extra.openCurlyToken = extra.tokens.length; - } - } - return { - type: Token.Punctuator, - value: String.fromCharCode(code), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - - default: - code2 = source.charCodeAt(index + 1); - - // '=' (char #61) marks an assignment or comparison operator. - if (code2 === 61) { - switch (code) { - case 37: // % - case 38: // & - case 42: // *: - case 43: // + - case 45: // - - case 47: // / - case 60: // < - case 62: // > - case 94: // ^ - case 124: // | - index += 2; - return { - type: Token.Punctuator, - value: String.fromCharCode(code) + String.fromCharCode(code2), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - - case 33: // ! - case 61: // = - index += 2; - - // !== and === - if (source.charCodeAt(index) === 61) { - ++index; - } - return { - type: Token.Punctuator, - value: source.slice(start, index), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - default: - break; - } - } - break; - } - - // Peek more characters. - - ch2 = source[index + 1]; - ch3 = source[index + 2]; - ch4 = source[index + 3]; - - // 4-character punctuator: >>>= - - if (ch1 === '>' && ch2 === '>' && ch3 === '>') { - if (ch4 === '=') { - index += 4; - return { - type: Token.Punctuator, - value: '>>>=', - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - } - - // 3-character punctuators: === !== >>> <<= >>= - - if (ch1 === '>' && ch2 === '>' && ch3 === '>' && !state.inType) { - index += 3; - return { - type: Token.Punctuator, - value: '>>>', - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - if (ch1 === '<' && ch2 === '<' && ch3 === '=') { - index += 3; - return { - type: Token.Punctuator, - value: '<<=', - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - if (ch1 === '>' && ch2 === '>' && ch3 === '=') { - index += 3; - return { - type: Token.Punctuator, - value: '>>=', - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - if (ch1 === '.' && ch2 === '.' && ch3 === '.') { - index += 3; - return { - type: Token.Punctuator, - value: '...', - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - // Other 2-character punctuators: ++ -- << >> && || - - // Don't match these tokens if we're in a type, since they never can - // occur and can mess up types like Map> - if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) { - index += 2; - return { - type: Token.Punctuator, - value: ch1 + ch2, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - if (ch1 === '=' && ch2 === '>') { - index += 2; - return { - type: Token.Punctuator, - value: '=>', - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) { - ++index; - return { - type: Token.Punctuator, - value: ch1, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - if (ch1 === '.') { - ++index; - return { - type: Token.Punctuator, - value: ch1, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - // 7.8.3 Numeric Literals - - function scanHexLiteral(start) { - var number = ''; - - while (index < length) { - if (!isHexDigit(source[index])) { - break; - } - number += source[index++]; - } - - if (number.length === 0) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - if (isIdentifierStart(source.charCodeAt(index))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - return { - type: Token.NumericLiteral, - value: parseInt('0x' + number, 16), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - function scanBinaryLiteral(start) { - var ch, number; - - number = ''; - - while (index < length) { - ch = source[index]; - if (ch !== '0' && ch !== '1') { - break; - } - number += source[index++]; - } - - if (number.length === 0) { - // only 0b or 0B - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - if (index < length) { - ch = source.charCodeAt(index); - /* istanbul ignore else */ - if (isIdentifierStart(ch) || isDecimalDigit(ch)) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - } - - return { - type: Token.NumericLiteral, - value: parseInt(number, 2), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - function scanOctalLiteral(prefix, start) { - var number, octal; - - if (isOctalDigit(prefix)) { - octal = true; - number = '0' + source[index++]; - } else { - octal = false; - ++index; - number = ''; - } - - while (index < length) { - if (!isOctalDigit(source[index])) { - break; - } - number += source[index++]; - } - - if (!octal && number.length === 0) { - // only 0o or 0O - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - return { - type: Token.NumericLiteral, - value: parseInt(number, 8), - octal: octal, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - function scanNumericLiteral() { - var number, start, ch; - - ch = source[index]; - assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), - 'Numeric literal must start with a decimal digit or a decimal point'); - - start = index; - number = ''; - if (ch !== '.') { - number = source[index++]; - ch = source[index]; - - // Hex number starts with '0x'. - // Octal number starts with '0'. - // Octal number in ES6 starts with '0o'. - // Binary number in ES6 starts with '0b'. - if (number === '0') { - if (ch === 'x' || ch === 'X') { - ++index; - return scanHexLiteral(start); - } - if (ch === 'b' || ch === 'B') { - ++index; - return scanBinaryLiteral(start); - } - if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) { - return scanOctalLiteral(ch, start); - } - // decimal number starts with '0' such as '09' is illegal. - if (ch && isDecimalDigit(ch.charCodeAt(0))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - } - - while (isDecimalDigit(source.charCodeAt(index))) { - number += source[index++]; - } - ch = source[index]; - } - - if (ch === '.') { - number += source[index++]; - while (isDecimalDigit(source.charCodeAt(index))) { - number += source[index++]; - } - ch = source[index]; - } - - if (ch === 'e' || ch === 'E') { - number += source[index++]; - - ch = source[index]; - if (ch === '+' || ch === '-') { - number += source[index++]; - } - if (isDecimalDigit(source.charCodeAt(index))) { - while (isDecimalDigit(source.charCodeAt(index))) { - number += source[index++]; - } - } else { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - } - - if (isIdentifierStart(source.charCodeAt(index))) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - return { - type: Token.NumericLiteral, - value: parseFloat(number), - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - // 7.8.4 String Literals - - function scanStringLiteral() { - var str = '', quote, start, ch, code, unescaped, restore, octal = false; - - quote = source[index]; - assert((quote === '\'' || quote === '"'), - 'String literal must starts with a quote'); - - start = index; - ++index; - - while (index < length) { - ch = source[index++]; - - if (ch === quote) { - quote = ''; - break; - } else if (ch === '\\') { - ch = source[index++]; - if (!ch || !isLineTerminator(ch.charCodeAt(0))) { - switch (ch) { - case 'n': - str += '\n'; - break; - case 'r': - str += '\r'; - break; - case 't': - str += '\t'; - break; - case 'u': - case 'x': - if (source[index] === '{') { - ++index; - str += scanUnicodeCodePointEscape(); - } else { - restore = index; - unescaped = scanHexEscape(ch); - if (unescaped) { - str += unescaped; - } else { - index = restore; - str += ch; - } - } - break; - case 'b': - str += '\b'; - break; - case 'f': - str += '\f'; - break; - case 'v': - str += '\x0B'; - break; - - default: - if (isOctalDigit(ch)) { - code = '01234567'.indexOf(ch); - - // \0 is not octal escape sequence - if (code !== 0) { - octal = true; - } - - /* istanbul ignore else */ - if (index < length && isOctalDigit(source[index])) { - octal = true; - code = code * 8 + '01234567'.indexOf(source[index++]); - - // 3 digits are only allowed when string starts - // with 0, 1, 2, 3 - if ('0123'.indexOf(ch) >= 0 && - index < length && - isOctalDigit(source[index])) { - code = code * 8 + '01234567'.indexOf(source[index++]); - } - } - str += String.fromCharCode(code); - } else { - str += ch; - } - break; - } - } else { - ++lineNumber; - if (ch === '\r' && source[index] === '\n') { - ++index; - } - lineStart = index; - } - } else if (isLineTerminator(ch.charCodeAt(0))) { - break; - } else { - str += ch; - } - } - - if (quote !== '') { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - return { - type: Token.StringLiteral, - value: str, - octal: octal, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - function scanTemplate() { - var cooked = '', ch, start, terminated, tail, restore, unescaped, code, octal; - - terminated = false; - tail = false; - start = index; - - ++index; - - while (index < length) { - ch = source[index++]; - if (ch === '`') { - tail = true; - terminated = true; - break; - } else if (ch === '$') { - if (source[index] === '{') { - ++index; - terminated = true; - break; - } - cooked += ch; - } else if (ch === '\\') { - ch = source[index++]; - if (!isLineTerminator(ch.charCodeAt(0))) { - switch (ch) { - case 'n': - cooked += '\n'; - break; - case 'r': - cooked += '\r'; - break; - case 't': - cooked += '\t'; - break; - case 'u': - case 'x': - if (source[index] === '{') { - ++index; - cooked += scanUnicodeCodePointEscape(); - } else { - restore = index; - unescaped = scanHexEscape(ch); - if (unescaped) { - cooked += unescaped; - } else { - index = restore; - cooked += ch; - } - } - break; - case 'b': - cooked += '\b'; - break; - case 'f': - cooked += '\f'; - break; - case 'v': - cooked += '\v'; - break; - - default: - if (isOctalDigit(ch)) { - code = '01234567'.indexOf(ch); - - // \0 is not octal escape sequence - if (code !== 0) { - octal = true; - } - - /* istanbul ignore else */ - if (index < length && isOctalDigit(source[index])) { - octal = true; - code = code * 8 + '01234567'.indexOf(source[index++]); - - // 3 digits are only allowed when string starts - // with 0, 1, 2, 3 - if ('0123'.indexOf(ch) >= 0 && - index < length && - isOctalDigit(source[index])) { - code = code * 8 + '01234567'.indexOf(source[index++]); - } - } - cooked += String.fromCharCode(code); - } else { - cooked += ch; - } - break; - } - } else { - ++lineNumber; - if (ch === '\r' && source[index] === '\n') { - ++index; - } - lineStart = index; - } - } else if (isLineTerminator(ch.charCodeAt(0))) { - ++lineNumber; - if (ch === '\r' && source[index] === '\n') { - ++index; - } - lineStart = index; - cooked += '\n'; - } else { - cooked += ch; - } - } - - if (!terminated) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - return { - type: Token.Template, - value: { - cooked: cooked, - raw: source.slice(start + 1, index - ((tail) ? 1 : 2)) - }, - tail: tail, - octal: octal, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - function scanTemplateElement(option) { - var startsWith, template; - - lookahead = null; - skipComment(); - - startsWith = (option.head) ? '`' : '}'; - - if (source[index] !== startsWith) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - template = scanTemplate(); - - peek(); - - return template; - } - - function testRegExp(pattern, flags) { - var tmp = pattern, - value; - - if (flags.indexOf('u') >= 0) { - // Replace each astral symbol and every Unicode code point - // escape sequence with a single ASCII symbol to avoid throwing on - // regular expressions that are only valid in combination with the - // `/u` flag. - // Note: replacing with the ASCII symbol `x` might cause false - // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a - // perfectly valid pattern that is equivalent to `[a-b]`, but it - // would be replaced by `[x-b]` which throws an error. - tmp = tmp - .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) { - if (parseInt($1, 16) <= 0x10FFFF) { - return 'x'; - } - throwError({}, Messages.InvalidRegExp); - }) - .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x'); - } - - // First, detect invalid regular expressions. - try { - value = new RegExp(tmp); - } catch (e) { - throwError({}, Messages.InvalidRegExp); - } - - // Return a regular expression object for this pattern-flag pair, or - // `null` in case the current environment doesn't support the flags it - // uses. - try { - return new RegExp(pattern, flags); - } catch (exception) { - return null; - } - } - - function scanRegExpBody() { - var ch, str, classMarker, terminated, body; - - ch = source[index]; - assert(ch === '/', 'Regular expression literal must start with a slash'); - str = source[index++]; - - classMarker = false; - terminated = false; - while (index < length) { - ch = source[index++]; - str += ch; - if (ch === '\\') { - ch = source[index++]; - // ECMA-262 7.8.5 - if (isLineTerminator(ch.charCodeAt(0))) { - throwError({}, Messages.UnterminatedRegExp); - } - str += ch; - } else if (isLineTerminator(ch.charCodeAt(0))) { - throwError({}, Messages.UnterminatedRegExp); - } else if (classMarker) { - if (ch === ']') { - classMarker = false; - } - } else { - if (ch === '/') { - terminated = true; - break; - } else if (ch === '[') { - classMarker = true; - } - } - } - - if (!terminated) { - throwError({}, Messages.UnterminatedRegExp); - } - - // Exclude leading and trailing slash. - body = str.substr(1, str.length - 2); - return { - value: body, - literal: str - }; - } - - function scanRegExpFlags() { - var ch, str, flags, restore; - - str = ''; - flags = ''; - while (index < length) { - ch = source[index]; - if (!isIdentifierPart(ch.charCodeAt(0))) { - break; - } - - ++index; - if (ch === '\\' && index < length) { - ch = source[index]; - if (ch === 'u') { - ++index; - restore = index; - ch = scanHexEscape('u'); - if (ch) { - flags += ch; - for (str += '\\u'; restore < index; ++restore) { - str += source[restore]; - } - } else { - index = restore; - flags += 'u'; - str += '\\u'; - } - throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL'); - } else { - str += '\\'; - throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - } else { - flags += ch; - str += ch; - } - } - - return { - value: flags, - literal: str - }; - } - - function scanRegExp() { - var start, body, flags, value; - - lookahead = null; - skipComment(); - start = index; - - body = scanRegExpBody(); - flags = scanRegExpFlags(); - value = testRegExp(body.value, flags.value); - - if (extra.tokenize) { - return { - type: Token.RegularExpression, - value: value, - regex: { - pattern: body.value, - flags: flags.value - }, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - return { - literal: body.literal + flags.literal, - value: value, - regex: { - pattern: body.value, - flags: flags.value - }, - range: [start, index] - }; - } - - function isIdentifierName(token) { - return token.type === Token.Identifier || - token.type === Token.Keyword || - token.type === Token.BooleanLiteral || - token.type === Token.NullLiteral; - } - - function advanceSlash() { - var prevToken, - checkToken; - // Using the following algorithm: - // https://github.com/mozilla/sweet.js/wiki/design - prevToken = extra.tokens[extra.tokens.length - 1]; - if (!prevToken) { - // Nothing before that: it cannot be a division. - return scanRegExp(); - } - if (prevToken.type === 'Punctuator') { - if (prevToken.value === ')') { - checkToken = extra.tokens[extra.openParenToken - 1]; - if (checkToken && - checkToken.type === 'Keyword' && - (checkToken.value === 'if' || - checkToken.value === 'while' || - checkToken.value === 'for' || - checkToken.value === 'with')) { - return scanRegExp(); - } - return scanPunctuator(); - } - if (prevToken.value === '}') { - // Dividing a function by anything makes little sense, - // but we have to check for that. - if (extra.tokens[extra.openCurlyToken - 3] && - extra.tokens[extra.openCurlyToken - 3].type === 'Keyword') { - // Anonymous function. - checkToken = extra.tokens[extra.openCurlyToken - 4]; - if (!checkToken) { - return scanPunctuator(); - } - } else if (extra.tokens[extra.openCurlyToken - 4] && - extra.tokens[extra.openCurlyToken - 4].type === 'Keyword') { - // Named function. - checkToken = extra.tokens[extra.openCurlyToken - 5]; - if (!checkToken) { - return scanRegExp(); - } - } else { - return scanPunctuator(); - } - // checkToken determines whether the function is - // a declaration or an expression. - if (FnExprTokens.indexOf(checkToken.value) >= 0) { - // It is an expression. - return scanPunctuator(); - } - // It is a declaration. - return scanRegExp(); - } - return scanRegExp(); - } - if (prevToken.type === 'Keyword' && prevToken.value !== 'this') { - return scanRegExp(); - } - return scanPunctuator(); - } - - function advance() { - var ch; - - if (!state.inJSXChild) { - skipComment(); - } - - if (index >= length) { - return { - type: Token.EOF, - lineNumber: lineNumber, - lineStart: lineStart, - range: [index, index] - }; - } - - if (state.inJSXChild) { - return advanceJSXChild(); - } - - ch = source.charCodeAt(index); - - // Very common: ( and ) and ; - if (ch === 40 || ch === 41 || ch === 58) { - return scanPunctuator(); - } - - // String literal starts with single quote (#39) or double quote (#34). - if (ch === 39 || ch === 34) { - if (state.inJSXTag) { - return scanJSXStringLiteral(); - } - return scanStringLiteral(); - } - - if (state.inJSXTag && isJSXIdentifierStart(ch)) { - return scanJSXIdentifier(); - } - - if (ch === 96) { - return scanTemplate(); - } - if (isIdentifierStart(ch)) { - return scanIdentifier(); - } - - // Dot (.) char #46 can also start a floating-point number, hence the need - // to check the next character. - if (ch === 46) { - if (isDecimalDigit(source.charCodeAt(index + 1))) { - return scanNumericLiteral(); - } - return scanPunctuator(); - } - - if (isDecimalDigit(ch)) { - return scanNumericLiteral(); - } - - // Slash (/) char #47 can also start a regex. - if (extra.tokenize && ch === 47) { - return advanceSlash(); - } - - return scanPunctuator(); - } - - function lex() { - var token; - - token = lookahead; - index = token.range[1]; - lineNumber = token.lineNumber; - lineStart = token.lineStart; - - lookahead = advance(); - - index = token.range[1]; - lineNumber = token.lineNumber; - lineStart = token.lineStart; - - return token; - } - - function peek() { - var pos, line, start; - - pos = index; - line = lineNumber; - start = lineStart; - lookahead = advance(); - index = pos; - lineNumber = line; - lineStart = start; - } - - function lookahead2() { - var adv, pos, line, start, result; - - // If we are collecting the tokens, don't grab the next one yet. - /* istanbul ignore next */ - adv = (typeof extra.advance === 'function') ? extra.advance : advance; - - pos = index; - line = lineNumber; - start = lineStart; - - // Scan for the next immediate token. - /* istanbul ignore if */ - if (lookahead === null) { - lookahead = adv(); - } - index = lookahead.range[1]; - lineNumber = lookahead.lineNumber; - lineStart = lookahead.lineStart; - - // Grab the token right after. - result = adv(); - index = pos; - lineNumber = line; - lineStart = start; - - return result; - } - - function rewind(token) { - index = token.range[0]; - lineNumber = token.lineNumber; - lineStart = token.lineStart; - lookahead = token; - } - - function markerCreate() { - if (!extra.loc && !extra.range) { - return undefined; - } - skipComment(); - return {offset: index, line: lineNumber, col: index - lineStart}; - } - - function markerCreatePreserveWhitespace() { - if (!extra.loc && !extra.range) { - return undefined; - } - return {offset: index, line: lineNumber, col: index - lineStart}; - } - - function processComment(node) { - var lastChild, - trailingComments, - bottomRight = extra.bottomRightStack, - last = bottomRight[bottomRight.length - 1]; - - if (node.type === Syntax.Program) { - /* istanbul ignore else */ - if (node.body.length > 0) { - return; - } - } - - if (extra.trailingComments.length > 0) { - if (extra.trailingComments[0].range[0] >= node.range[1]) { - trailingComments = extra.trailingComments; - extra.trailingComments = []; - } else { - extra.trailingComments.length = 0; - } - } else { - if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) { - trailingComments = last.trailingComments; - delete last.trailingComments; - } - } - - // Eating the stack. - if (last) { - while (last && last.range[0] >= node.range[0]) { - lastChild = last; - last = bottomRight.pop(); - } - } - - if (lastChild) { - if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) { - node.leadingComments = lastChild.leadingComments; - delete lastChild.leadingComments; - } - } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) { - node.leadingComments = extra.leadingComments; - extra.leadingComments = []; - } - - if (trailingComments) { - node.trailingComments = trailingComments; - } - - bottomRight.push(node); - } - - function markerApply(marker, node) { - if (extra.range) { - node.range = [marker.offset, index]; - } - if (extra.loc) { - node.loc = { - start: { - line: marker.line, - column: marker.col - }, - end: { - line: lineNumber, - column: index - lineStart - } - }; - node = delegate.postProcess(node); - } - if (extra.attachComment) { - processComment(node); - } - return node; - } - - SyntaxTreeDelegate = { - - name: 'SyntaxTree', - - postProcess: function (node) { - return node; - }, - - createArrayExpression: function (elements) { - return { - type: Syntax.ArrayExpression, - elements: elements - }; - }, - - createAssignmentExpression: function (operator, left, right) { - return { - type: Syntax.AssignmentExpression, - operator: operator, - left: left, - right: right - }; - }, - - createBinaryExpression: function (operator, left, right) { - var type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : - Syntax.BinaryExpression; - return { - type: type, - operator: operator, - left: left, - right: right - }; - }, - - createBlockStatement: function (body) { - return { - type: Syntax.BlockStatement, - body: body - }; - }, - - createBreakStatement: function (label) { - return { - type: Syntax.BreakStatement, - label: label - }; - }, - - createCallExpression: function (callee, args) { - return { - type: Syntax.CallExpression, - callee: callee, - 'arguments': args - }; - }, - - createCatchClause: function (param, body) { - return { - type: Syntax.CatchClause, - param: param, - body: body - }; - }, - - createConditionalExpression: function (test, consequent, alternate) { - return { - type: Syntax.ConditionalExpression, - test: test, - consequent: consequent, - alternate: alternate - }; - }, - - createContinueStatement: function (label) { - return { - type: Syntax.ContinueStatement, - label: label - }; - }, - - createDebuggerStatement: function () { - return { - type: Syntax.DebuggerStatement - }; - }, - - createDoWhileStatement: function (body, test) { - return { - type: Syntax.DoWhileStatement, - body: body, - test: test - }; - }, - - createEmptyStatement: function () { - return { - type: Syntax.EmptyStatement - }; - }, - - createExpressionStatement: function (expression) { - return { - type: Syntax.ExpressionStatement, - expression: expression - }; - }, - - createForStatement: function (init, test, update, body) { - return { - type: Syntax.ForStatement, - init: init, - test: test, - update: update, - body: body - }; - }, - - createForInStatement: function (left, right, body) { - return { - type: Syntax.ForInStatement, - left: left, - right: right, - body: body, - each: false - }; - }, - - createForOfStatement: function (left, right, body) { - return { - type: Syntax.ForOfStatement, - left: left, - right: right, - body: body - }; - }, - - createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression, - isAsync, returnType, typeParameters) { - var funDecl = { - type: Syntax.FunctionDeclaration, - id: id, - params: params, - defaults: defaults, - body: body, - rest: rest, - generator: generator, - expression: expression, - returnType: returnType, - typeParameters: typeParameters - }; - - if (isAsync) { - funDecl.async = true; - } - - return funDecl; - }, - - createFunctionExpression: function (id, params, defaults, body, rest, generator, expression, - isAsync, returnType, typeParameters) { - var funExpr = { - type: Syntax.FunctionExpression, - id: id, - params: params, - defaults: defaults, - body: body, - rest: rest, - generator: generator, - expression: expression, - returnType: returnType, - typeParameters: typeParameters - }; - - if (isAsync) { - funExpr.async = true; - } - - return funExpr; - }, - - createIdentifier: function (name) { - return { - type: Syntax.Identifier, - name: name, - // Only here to initialize the shape of the object to ensure - // that the 'typeAnnotation' key is ordered before others that - // are added later (like 'loc' and 'range'). This just helps - // keep the shape of Identifier nodes consistent with everything - // else. - typeAnnotation: undefined, - optional: undefined - }; - }, - - createTypeAnnotation: function (typeAnnotation) { - return { - type: Syntax.TypeAnnotation, - typeAnnotation: typeAnnotation - }; - }, - - createTypeCast: function (expression, typeAnnotation) { - return { - type: Syntax.TypeCastExpression, - expression: expression, - typeAnnotation: typeAnnotation - }; - }, - - createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) { - return { - type: Syntax.FunctionTypeAnnotation, - params: params, - returnType: returnType, - rest: rest, - typeParameters: typeParameters - }; - }, - - createFunctionTypeParam: function (name, typeAnnotation, optional) { - return { - type: Syntax.FunctionTypeParam, - name: name, - typeAnnotation: typeAnnotation, - optional: optional - }; - }, - - createNullableTypeAnnotation: function (typeAnnotation) { - return { - type: Syntax.NullableTypeAnnotation, - typeAnnotation: typeAnnotation - }; - }, - - createArrayTypeAnnotation: function (elementType) { - return { - type: Syntax.ArrayTypeAnnotation, - elementType: elementType - }; - }, - - createGenericTypeAnnotation: function (id, typeParameters) { - return { - type: Syntax.GenericTypeAnnotation, - id: id, - typeParameters: typeParameters - }; - }, - - createQualifiedTypeIdentifier: function (qualification, id) { - return { - type: Syntax.QualifiedTypeIdentifier, - qualification: qualification, - id: id - }; - }, - - createTypeParameterDeclaration: function (params) { - return { - type: Syntax.TypeParameterDeclaration, - params: params - }; - }, - - createTypeParameterInstantiation: function (params) { - return { - type: Syntax.TypeParameterInstantiation, - params: params - }; - }, - - createAnyTypeAnnotation: function () { - return { - type: Syntax.AnyTypeAnnotation - }; - }, - - createBooleanTypeAnnotation: function () { - return { - type: Syntax.BooleanTypeAnnotation - }; - }, - - createNumberTypeAnnotation: function () { - return { - type: Syntax.NumberTypeAnnotation - }; - }, - - createStringTypeAnnotation: function () { - return { - type: Syntax.StringTypeAnnotation - }; - }, - - createStringLiteralTypeAnnotation: function (token) { - return { - type: Syntax.StringLiteralTypeAnnotation, - value: token.value, - raw: source.slice(token.range[0], token.range[1]) - }; - }, - - createVoidTypeAnnotation: function () { - return { - type: Syntax.VoidTypeAnnotation - }; - }, - - createTypeofTypeAnnotation: function (argument) { - return { - type: Syntax.TypeofTypeAnnotation, - argument: argument - }; - }, - - createTupleTypeAnnotation: function (types) { - return { - type: Syntax.TupleTypeAnnotation, - types: types - }; - }, - - createObjectTypeAnnotation: function (properties, indexers, callProperties) { - return { - type: Syntax.ObjectTypeAnnotation, - properties: properties, - indexers: indexers, - callProperties: callProperties - }; - }, - - createObjectTypeIndexer: function (id, key, value, isStatic) { - return { - type: Syntax.ObjectTypeIndexer, - id: id, - key: key, - value: value, - "static": isStatic - }; - }, - - createObjectTypeCallProperty: function (value, isStatic) { - return { - type: Syntax.ObjectTypeCallProperty, - value: value, - "static": isStatic - }; - }, - - createObjectTypeProperty: function (key, value, optional, isStatic) { - return { - type: Syntax.ObjectTypeProperty, - key: key, - value: value, - optional: optional, - "static": isStatic - }; - }, - - createUnionTypeAnnotation: function (types) { - return { - type: Syntax.UnionTypeAnnotation, - types: types - }; - }, - - createIntersectionTypeAnnotation: function (types) { - return { - type: Syntax.IntersectionTypeAnnotation, - types: types - }; - }, - - createTypeAlias: function (id, typeParameters, right) { - return { - type: Syntax.TypeAlias, - id: id, - typeParameters: typeParameters, - right: right - }; - }, - - createInterface: function (id, typeParameters, body, extended) { - return { - type: Syntax.InterfaceDeclaration, - id: id, - typeParameters: typeParameters, - body: body, - "extends": extended - }; - }, - - createInterfaceExtends: function (id, typeParameters) { - return { - type: Syntax.InterfaceExtends, - id: id, - typeParameters: typeParameters - }; - }, - - createDeclareFunction: function (id) { - return { - type: Syntax.DeclareFunction, - id: id - }; - }, - - createDeclareVariable: function (id) { - return { - type: Syntax.DeclareVariable, - id: id - }; - }, - - createDeclareModule: function (id, body) { - return { - type: Syntax.DeclareModule, - id: id, - body: body - }; - }, - - createJSXAttribute: function (name, value) { - return { - type: Syntax.JSXAttribute, - name: name, - value: value || null - }; - }, - - createJSXSpreadAttribute: function (argument) { - return { - type: Syntax.JSXSpreadAttribute, - argument: argument - }; - }, - - createJSXIdentifier: function (name) { - return { - type: Syntax.JSXIdentifier, - name: name - }; - }, - - createJSXNamespacedName: function (namespace, name) { - return { - type: Syntax.JSXNamespacedName, - namespace: namespace, - name: name - }; - }, - - createJSXMemberExpression: function (object, property) { - return { - type: Syntax.JSXMemberExpression, - object: object, - property: property - }; - }, - - createJSXElement: function (openingElement, closingElement, children) { - return { - type: Syntax.JSXElement, - openingElement: openingElement, - closingElement: closingElement, - children: children - }; - }, - - createJSXEmptyExpression: function () { - return { - type: Syntax.JSXEmptyExpression - }; - }, - - createJSXExpressionContainer: function (expression) { - return { - type: Syntax.JSXExpressionContainer, - expression: expression - }; - }, - - createJSXOpeningElement: function (name, attributes, selfClosing) { - return { - type: Syntax.JSXOpeningElement, - name: name, - selfClosing: selfClosing, - attributes: attributes - }; - }, - - createJSXClosingElement: function (name) { - return { - type: Syntax.JSXClosingElement, - name: name - }; - }, - - createIfStatement: function (test, consequent, alternate) { - return { - type: Syntax.IfStatement, - test: test, - consequent: consequent, - alternate: alternate - }; - }, - - createLabeledStatement: function (label, body) { - return { - type: Syntax.LabeledStatement, - label: label, - body: body - }; - }, - - createLiteral: function (token) { - var object = { - type: Syntax.Literal, - value: token.value, - raw: source.slice(token.range[0], token.range[1]) - }; - if (token.regex) { - object.regex = token.regex; - } - return object; - }, - - createMemberExpression: function (accessor, object, property) { - return { - type: Syntax.MemberExpression, - computed: accessor === '[', - object: object, - property: property - }; - }, - - createNewExpression: function (callee, args) { - return { - type: Syntax.NewExpression, - callee: callee, - 'arguments': args - }; - }, - - createObjectExpression: function (properties) { - return { - type: Syntax.ObjectExpression, - properties: properties - }; - }, - - createPostfixExpression: function (operator, argument) { - return { - type: Syntax.UpdateExpression, - operator: operator, - argument: argument, - prefix: false - }; - }, - - createProgram: function (body) { - return { - type: Syntax.Program, - body: body - }; - }, - - createProperty: function (kind, key, value, method, shorthand, computed) { - return { - type: Syntax.Property, - key: key, - value: value, - kind: kind, - method: method, - shorthand: shorthand, - computed: computed - }; - }, - - createReturnStatement: function (argument) { - return { - type: Syntax.ReturnStatement, - argument: argument - }; - }, - - createSequenceExpression: function (expressions) { - return { - type: Syntax.SequenceExpression, - expressions: expressions - }; - }, - - createSwitchCase: function (test, consequent) { - return { - type: Syntax.SwitchCase, - test: test, - consequent: consequent - }; - }, - - createSwitchStatement: function (discriminant, cases) { - return { - type: Syntax.SwitchStatement, - discriminant: discriminant, - cases: cases - }; - }, - - createThisExpression: function () { - return { - type: Syntax.ThisExpression - }; - }, - - createThrowStatement: function (argument) { - return { - type: Syntax.ThrowStatement, - argument: argument - }; - }, - - createTryStatement: function (block, guardedHandlers, handlers, finalizer) { - return { - type: Syntax.TryStatement, - block: block, - guardedHandlers: guardedHandlers, - handlers: handlers, - finalizer: finalizer - }; - }, - - createUnaryExpression: function (operator, argument) { - if (operator === '++' || operator === '--') { - return { - type: Syntax.UpdateExpression, - operator: operator, - argument: argument, - prefix: true - }; - } - return { - type: Syntax.UnaryExpression, - operator: operator, - argument: argument, - prefix: true - }; - }, - - createVariableDeclaration: function (declarations, kind) { - return { - type: Syntax.VariableDeclaration, - declarations: declarations, - kind: kind - }; - }, - - createVariableDeclarator: function (id, init) { - return { - type: Syntax.VariableDeclarator, - id: id, - init: init - }; - }, - - createWhileStatement: function (test, body) { - return { - type: Syntax.WhileStatement, - test: test, - body: body - }; - }, - - createWithStatement: function (object, body) { - return { - type: Syntax.WithStatement, - object: object, - body: body - }; - }, - - createTemplateElement: function (value, tail) { - return { - type: Syntax.TemplateElement, - value: value, - tail: tail - }; - }, - - createTemplateLiteral: function (quasis, expressions) { - return { - type: Syntax.TemplateLiteral, - quasis: quasis, - expressions: expressions - }; - }, - - createSpreadElement: function (argument) { - return { - type: Syntax.SpreadElement, - argument: argument - }; - }, - - createSpreadProperty: function (argument) { - return { - type: Syntax.SpreadProperty, - argument: argument - }; - }, - - createTaggedTemplateExpression: function (tag, quasi) { - return { - type: Syntax.TaggedTemplateExpression, - tag: tag, - quasi: quasi - }; - }, - - createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) { - var arrowExpr = { - type: Syntax.ArrowFunctionExpression, - id: null, - params: params, - defaults: defaults, - body: body, - rest: rest, - generator: false, - expression: expression - }; - - if (isAsync) { - arrowExpr.async = true; - } - - return arrowExpr; - }, - - createMethodDefinition: function (propertyType, kind, key, value, computed) { - return { - type: Syntax.MethodDefinition, - key: key, - value: value, - kind: kind, - 'static': propertyType === ClassPropertyType["static"], - computed: computed - }; - }, - - createClassProperty: function (key, typeAnnotation, computed, isStatic) { - return { - type: Syntax.ClassProperty, - key: key, - typeAnnotation: typeAnnotation, - computed: computed, - "static": isStatic - }; - }, - - createClassBody: function (body) { - return { - type: Syntax.ClassBody, - body: body - }; - }, - - createClassImplements: function (id, typeParameters) { - return { - type: Syntax.ClassImplements, - id: id, - typeParameters: typeParameters - }; - }, - - createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) { - return { - type: Syntax.ClassExpression, - id: id, - superClass: superClass, - body: body, - typeParameters: typeParameters, - superTypeParameters: superTypeParameters, - "implements": implemented - }; - }, - - createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) { - return { - type: Syntax.ClassDeclaration, - id: id, - superClass: superClass, - body: body, - typeParameters: typeParameters, - superTypeParameters: superTypeParameters, - "implements": implemented - }; - }, - - createModuleSpecifier: function (token) { - return { - type: Syntax.ModuleSpecifier, - value: token.value, - raw: source.slice(token.range[0], token.range[1]) - }; - }, - - createExportSpecifier: function (id, name) { - return { - type: Syntax.ExportSpecifier, - id: id, - name: name - }; - }, - - createExportBatchSpecifier: function () { - return { - type: Syntax.ExportBatchSpecifier - }; - }, - - createImportDefaultSpecifier: function (id) { - return { - type: Syntax.ImportDefaultSpecifier, - id: id - }; - }, - - createImportNamespaceSpecifier: function (id) { - return { - type: Syntax.ImportNamespaceSpecifier, - id: id - }; - }, - - createExportDeclaration: function (isDefault, declaration, specifiers, src) { - return { - type: Syntax.ExportDeclaration, - 'default': !!isDefault, - declaration: declaration, - specifiers: specifiers, - source: src - }; - }, - - createImportSpecifier: function (id, name) { - return { - type: Syntax.ImportSpecifier, - id: id, - name: name - }; - }, - - createImportDeclaration: function (specifiers, src, isType) { - return { - type: Syntax.ImportDeclaration, - specifiers: specifiers, - source: src, - isType: isType - }; - }, - - createYieldExpression: function (argument, dlg) { - return { - type: Syntax.YieldExpression, - argument: argument, - delegate: dlg - }; - }, - - createAwaitExpression: function (argument) { - return { - type: Syntax.AwaitExpression, - argument: argument - }; - }, - - createComprehensionExpression: function (filter, blocks, body) { - return { - type: Syntax.ComprehensionExpression, - filter: filter, - blocks: blocks, - body: body - }; - } - - }; - - // Return true if there is a line terminator before the next token. - - function peekLineTerminator() { - var pos, line, start, found; - - pos = index; - line = lineNumber; - start = lineStart; - skipComment(); - found = lineNumber !== line; - index = pos; - lineNumber = line; - lineStart = start; - - return found; - } - - // Throw an exception - - function throwError(token, messageFormat) { - var error, - args = Array.prototype.slice.call(arguments, 2), - msg = messageFormat.replace( - /%(\d)/g, - function (whole, idx) { - assert(idx < args.length, 'Message reference must be in range'); - return args[idx]; - } - ); - - if (typeof token.lineNumber === 'number') { - error = new Error('Line ' + token.lineNumber + ': ' + msg); - error.index = token.range[0]; - error.lineNumber = token.lineNumber; - error.column = token.range[0] - lineStart + 1; - } else { - error = new Error('Line ' + lineNumber + ': ' + msg); - error.index = index; - error.lineNumber = lineNumber; - error.column = index - lineStart + 1; - } - - error.description = msg; - throw error; - } - - function throwErrorTolerant() { - try { - throwError.apply(null, arguments); - } catch (e) { - if (extra.errors) { - extra.errors.push(e); - } else { - throw e; - } - } - } - - - // Throw an exception because of the token. - - function throwUnexpected(token) { - if (token.type === Token.EOF) { - throwError(token, Messages.UnexpectedEOS); - } - - if (token.type === Token.NumericLiteral) { - throwError(token, Messages.UnexpectedNumber); - } - - if (token.type === Token.StringLiteral || token.type === Token.JSXText) { - throwError(token, Messages.UnexpectedString); - } - - if (token.type === Token.Identifier) { - throwError(token, Messages.UnexpectedIdentifier); - } - - if (token.type === Token.Keyword) { - if (isFutureReservedWord(token.value)) { - throwError(token, Messages.UnexpectedReserved); - } else if (strict && isStrictModeReservedWord(token.value)) { - throwErrorTolerant(token, Messages.StrictReservedWord); - return; - } - throwError(token, Messages.UnexpectedToken, token.value); - } - - if (token.type === Token.Template) { - throwError(token, Messages.UnexpectedTemplate, token.value.raw); - } - - // BooleanLiteral, NullLiteral, or Punctuator. - throwError(token, Messages.UnexpectedToken, token.value); - } - - // Expect the next token to match the specified punctuator. - // If not, an exception will be thrown. - - function expect(value) { - var token = lex(); - if (token.type !== Token.Punctuator || token.value !== value) { - throwUnexpected(token); - } - } - - // Expect the next token to match the specified keyword. - // If not, an exception will be thrown. - - function expectKeyword(keyword, contextual) { - var token = lex(); - if (token.type !== (contextual ? Token.Identifier : Token.Keyword) || - token.value !== keyword) { - throwUnexpected(token); - } - } - - // Expect the next token to match the specified contextual keyword. - // If not, an exception will be thrown. - - function expectContextualKeyword(keyword) { - return expectKeyword(keyword, true); - } - - // Return true if the next token matches the specified punctuator. - - function match(value) { - return lookahead.type === Token.Punctuator && lookahead.value === value; - } - - // Return true if the next token matches the specified keyword - - function matchKeyword(keyword, contextual) { - var expectedType = contextual ? Token.Identifier : Token.Keyword; - return lookahead.type === expectedType && lookahead.value === keyword; - } - - // Return true if the next token matches the specified contextual keyword - - function matchContextualKeyword(keyword) { - return matchKeyword(keyword, true); - } - - // Return true if the next token is an assignment operator - - function matchAssign() { - var op; - - if (lookahead.type !== Token.Punctuator) { - return false; - } - op = lookahead.value; - return op === '=' || - op === '*=' || - op === '/=' || - op === '%=' || - op === '+=' || - op === '-=' || - op === '<<=' || - op === '>>=' || - op === '>>>=' || - op === '&=' || - op === '^=' || - op === '|='; - } - - // Note that 'yield' is treated as a keyword in strict mode, but a - // contextual keyword (identifier) in non-strict mode, so we need to - // use matchKeyword('yield', false) and matchKeyword('yield', true) - // (i.e. matchContextualKeyword) appropriately. - function matchYield() { - return state.yieldAllowed && matchKeyword('yield', !strict); - } - - function matchAsync() { - var backtrackToken = lookahead, matches = false; - - if (matchContextualKeyword('async')) { - lex(); // Make sure peekLineTerminator() starts after 'async'. - matches = !peekLineTerminator(); - rewind(backtrackToken); // Revert the lex(). - } - - return matches; - } - - function matchAwait() { - return state.awaitAllowed && matchContextualKeyword('await'); - } - - function consumeSemicolon() { - var line, oldIndex = index, oldLineNumber = lineNumber, - oldLineStart = lineStart, oldLookahead = lookahead; - - // Catch the very common case first: immediately a semicolon (char #59). - if (source.charCodeAt(index) === 59) { - lex(); - return; - } - - line = lineNumber; - skipComment(); - if (lineNumber !== line) { - index = oldIndex; - lineNumber = oldLineNumber; - lineStart = oldLineStart; - lookahead = oldLookahead; - return; - } - - if (match(';')) { - lex(); - return; - } - - if (lookahead.type !== Token.EOF && !match('}')) { - throwUnexpected(lookahead); - } - } - - // Return true if provided expression is LeftHandSideExpression - - function isLeftHandSide(expr) { - return expr.type === Syntax.Identifier || expr.type === Syntax.MemberExpression; - } - - function isAssignableLeftHandSide(expr) { - return isLeftHandSide(expr) || expr.type === Syntax.ObjectPattern || expr.type === Syntax.ArrayPattern; - } - - // 11.1.4 Array Initialiser - - function parseArrayInitialiser() { - var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true, - marker = markerCreate(); - - expect('['); - while (!match(']')) { - if (lookahead.value === 'for' && - lookahead.type === Token.Keyword) { - if (!possiblecomprehension) { - throwError({}, Messages.ComprehensionError); - } - matchKeyword('for'); - tmp = parseForStatement({ignoreBody: true}); - tmp.of = tmp.type === Syntax.ForOfStatement; - tmp.type = Syntax.ComprehensionBlock; - if (tmp.left.kind) { // can't be let or const - throwError({}, Messages.ComprehensionError); - } - blocks.push(tmp); - } else if (lookahead.value === 'if' && - lookahead.type === Token.Keyword) { - if (!possiblecomprehension) { - throwError({}, Messages.ComprehensionError); - } - expectKeyword('if'); - expect('('); - filter = parseExpression(); - expect(')'); - } else if (lookahead.value === ',' && - lookahead.type === Token.Punctuator) { - possiblecomprehension = false; // no longer allowed. - lex(); - elements.push(null); - } else { - tmp = parseSpreadOrAssignmentExpression(); - elements.push(tmp); - if (tmp && tmp.type === Syntax.SpreadElement) { - if (!match(']')) { - throwError({}, Messages.ElementAfterSpreadElement); - } - } else if (!(match(']') || matchKeyword('for') || matchKeyword('if'))) { - expect(','); // this lexes. - possiblecomprehension = false; - } - } - } - - expect(']'); - - if (filter && !blocks.length) { - throwError({}, Messages.ComprehensionRequiresBlock); - } - - if (blocks.length) { - if (elements.length !== 1) { - throwError({}, Messages.ComprehensionError); - } - return markerApply(marker, delegate.createComprehensionExpression(filter, blocks, elements[0])); - } - return markerApply(marker, delegate.createArrayExpression(elements)); - } - - // 11.1.5 Object Initialiser - - function parsePropertyFunction(options) { - var previousStrict, previousYieldAllowed, previousAwaitAllowed, - params, defaults, body, marker = markerCreate(); - - previousStrict = strict; - previousYieldAllowed = state.yieldAllowed; - state.yieldAllowed = options.generator; - previousAwaitAllowed = state.awaitAllowed; - state.awaitAllowed = options.async; - params = options.params || []; - defaults = options.defaults || []; - - body = parseConciseBody(); - if (options.name && strict && isRestrictedWord(params[0].name)) { - throwErrorTolerant(options.name, Messages.StrictParamName); - } - strict = previousStrict; - state.yieldAllowed = previousYieldAllowed; - state.awaitAllowed = previousAwaitAllowed; - - return markerApply(marker, delegate.createFunctionExpression( - null, - params, - defaults, - body, - options.rest || null, - options.generator, - body.type !== Syntax.BlockStatement, - options.async, - options.returnType, - options.typeParameters - )); - } - - - function parsePropertyMethodFunction(options) { - var previousStrict, tmp, method; - - previousStrict = strict; - strict = true; - - tmp = parseParams(); - - if (tmp.stricted) { - throwErrorTolerant(tmp.stricted, tmp.message); - } - - method = parsePropertyFunction({ - params: tmp.params, - defaults: tmp.defaults, - rest: tmp.rest, - generator: options.generator, - async: options.async, - returnType: tmp.returnType, - typeParameters: options.typeParameters - }); - - strict = previousStrict; - - return method; - } - - - function parseObjectPropertyKey() { - var marker = markerCreate(), - token = lex(), - propertyKey, - result; - - // Note: This function is called only from parseObjectProperty(), where - // EOF and Punctuator tokens are already filtered out. - - if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) { - if (strict && token.octal) { - throwErrorTolerant(token, Messages.StrictOctalLiteral); - } - return markerApply(marker, delegate.createLiteral(token)); - } - - if (token.type === Token.Punctuator && token.value === '[') { - // For computed properties we should skip the [ and ], and - // capture in marker only the assignment expression itself. - marker = markerCreate(); - propertyKey = parseAssignmentExpression(); - result = markerApply(marker, propertyKey); - expect(']'); - return result; - } - - return markerApply(marker, delegate.createIdentifier(token.value)); - } - - function parseObjectProperty() { - var token, key, id, param, computed, - marker = markerCreate(), returnType, typeParameters; - - token = lookahead; - computed = (token.value === '[' && token.type === Token.Punctuator); - - if (token.type === Token.Identifier || computed || matchAsync()) { - id = parseObjectPropertyKey(); - - if (match(':')) { - lex(); - - return markerApply( - marker, - delegate.createProperty( - 'init', - id, - parseAssignmentExpression(), - false, - false, - computed - ) - ); - } - - if (match('(') || match('<')) { - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - return markerApply( - marker, - delegate.createProperty( - 'init', - id, - parsePropertyMethodFunction({ - generator: false, - async: false, - typeParameters: typeParameters - }), - true, - false, - computed - ) - ); - } - - // Property Assignment: Getter and Setter. - - if (token.value === 'get') { - computed = (lookahead.value === '['); - key = parseObjectPropertyKey(); - - expect('('); - expect(')'); - if (match(':')) { - returnType = parseTypeAnnotation(); - } - - return markerApply( - marker, - delegate.createProperty( - 'get', - key, - parsePropertyFunction({ - generator: false, - async: false, - returnType: returnType - }), - false, - false, - computed - ) - ); - } - - if (token.value === 'set') { - computed = (lookahead.value === '['); - key = parseObjectPropertyKey(); - - expect('('); - token = lookahead; - param = [ parseTypeAnnotatableIdentifier() ]; - expect(')'); - if (match(':')) { - returnType = parseTypeAnnotation(); - } - - return markerApply( - marker, - delegate.createProperty( - 'set', - key, - parsePropertyFunction({ - params: param, - generator: false, - async: false, - name: token, - returnType: returnType - }), - false, - false, - computed - ) - ); - } - - if (token.value === 'async') { - computed = (lookahead.value === '['); - key = parseObjectPropertyKey(); - - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - - return markerApply( - marker, - delegate.createProperty( - 'init', - key, - parsePropertyMethodFunction({ - generator: false, - async: true, - typeParameters: typeParameters - }), - true, - false, - computed - ) - ); - } - - if (computed) { - // Computed properties can only be used with full notation. - throwUnexpected(lookahead); - } - - return markerApply( - marker, - delegate.createProperty('init', id, id, false, true, false) - ); - } - - if (token.type === Token.EOF || token.type === Token.Punctuator) { - if (!match('*')) { - throwUnexpected(token); - } - lex(); - - computed = (lookahead.type === Token.Punctuator && lookahead.value === '['); - - id = parseObjectPropertyKey(); - - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - - if (!match('(')) { - throwUnexpected(lex()); - } - - return markerApply(marker, delegate.createProperty( - 'init', - id, - parsePropertyMethodFunction({ - generator: true, - typeParameters: typeParameters - }), - true, - false, - computed - )); - } - key = parseObjectPropertyKey(); - if (match(':')) { - lex(); - return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false)); - } - if (match('(') || match('<')) { - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - return markerApply(marker, delegate.createProperty( - 'init', - key, - parsePropertyMethodFunction({ - generator: false, - typeParameters: typeParameters - }), - true, - false, - false - )); - } - throwUnexpected(lex()); - } - - function parseObjectSpreadProperty() { - var marker = markerCreate(); - expect('...'); - return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression())); - } - - function getFieldName(key) { - var toString = String; - if (key.type === Syntax.Identifier) { - return key.name; - } - return toString(key.value); - } - - function parseObjectInitialiser() { - var properties = [], property, name, kind, storedKind, map = new StringMap(), - marker = markerCreate(), toString = String; - - expect('{'); - - while (!match('}')) { - if (match('...')) { - property = parseObjectSpreadProperty(); - } else { - property = parseObjectProperty(); - - if (property.key.type === Syntax.Identifier) { - name = property.key.name; - } else { - name = toString(property.key.value); - } - kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set; - - if (map.has(name)) { - storedKind = map.get(name); - if (storedKind === PropertyKind.Data) { - if (strict && kind === PropertyKind.Data) { - throwErrorTolerant({}, Messages.StrictDuplicateProperty); - } else if (kind !== PropertyKind.Data) { - throwErrorTolerant({}, Messages.AccessorDataProperty); - } - } else { - if (kind === PropertyKind.Data) { - throwErrorTolerant({}, Messages.AccessorDataProperty); - } else if (storedKind & kind) { - throwErrorTolerant({}, Messages.AccessorGetSet); - } - } - map.set(name, storedKind | kind); - } else { - map.set(name, kind); - } - } - - properties.push(property); - - if (!match('}')) { - expect(','); - } - } - - expect('}'); - - return markerApply(marker, delegate.createObjectExpression(properties)); - } - - function parseTemplateElement(option) { - var marker = markerCreate(), - token = scanTemplateElement(option); - if (strict && token.octal) { - throwError(token, Messages.StrictOctalLiteral); - } - return markerApply(marker, delegate.createTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail)); - } - - function parseTemplateLiteral() { - var quasi, quasis, expressions, marker = markerCreate(); - - quasi = parseTemplateElement({ head: true }); - quasis = [ quasi ]; - expressions = []; - - while (!quasi.tail) { - expressions.push(parseExpression()); - quasi = parseTemplateElement({ head: false }); - quasis.push(quasi); - } - - return markerApply(marker, delegate.createTemplateLiteral(quasis, expressions)); - } - - // 11.1.6 The Grouping Operator - - function parseGroupExpression() { - var expr, marker, typeAnnotation; - - expect('('); - - ++state.parenthesizedCount; - - marker = markerCreate(); - - expr = parseExpression(); - - if (match(':')) { - typeAnnotation = parseTypeAnnotation(); - expr = markerApply(marker, delegate.createTypeCast( - expr, - typeAnnotation - )); - } - - expect(')'); - - return expr; - } - - function matchAsyncFuncExprOrDecl() { - var token; - - if (matchAsync()) { - token = lookahead2(); - if (token.type === Token.Keyword && token.value === 'function') { - return true; - } - } - - return false; - } - - // 11.1 Primary Expressions - - function parsePrimaryExpression() { - var marker, type, token, expr; - - type = lookahead.type; - - if (type === Token.Identifier) { - marker = markerCreate(); - return markerApply(marker, delegate.createIdentifier(lex().value)); - } - - if (type === Token.StringLiteral || type === Token.NumericLiteral) { - if (strict && lookahead.octal) { - throwErrorTolerant(lookahead, Messages.StrictOctalLiteral); - } - marker = markerCreate(); - return markerApply(marker, delegate.createLiteral(lex())); - } - - if (type === Token.Keyword) { - if (matchKeyword('this')) { - marker = markerCreate(); - lex(); - return markerApply(marker, delegate.createThisExpression()); - } - - if (matchKeyword('function')) { - return parseFunctionExpression(); - } - - if (matchKeyword('class')) { - return parseClassExpression(); - } - - if (matchKeyword('super')) { - marker = markerCreate(); - lex(); - return markerApply(marker, delegate.createIdentifier('super')); - } - } - - if (type === Token.BooleanLiteral) { - marker = markerCreate(); - token = lex(); - token.value = (token.value === 'true'); - return markerApply(marker, delegate.createLiteral(token)); - } - - if (type === Token.NullLiteral) { - marker = markerCreate(); - token = lex(); - token.value = null; - return markerApply(marker, delegate.createLiteral(token)); - } - - if (match('[')) { - return parseArrayInitialiser(); - } - - if (match('{')) { - return parseObjectInitialiser(); - } - - if (match('(')) { - return parseGroupExpression(); - } - - if (match('/') || match('/=')) { - marker = markerCreate(); - expr = delegate.createLiteral(scanRegExp()); - peek(); - return markerApply(marker, expr); - } - - if (type === Token.Template) { - return parseTemplateLiteral(); - } - - if (match('<')) { - return parseJSXElement(); - } - - throwUnexpected(lex()); - } - - // 11.2 Left-Hand-Side Expressions - - function parseArguments() { - var args = [], arg; - - expect('('); - - if (!match(')')) { - while (index < length) { - arg = parseSpreadOrAssignmentExpression(); - args.push(arg); - - if (match(')')) { - break; - } else if (arg.type === Syntax.SpreadElement) { - throwError({}, Messages.ElementAfterSpreadElement); - } - - expect(','); - } - } - - expect(')'); - - return args; - } - - function parseSpreadOrAssignmentExpression() { - if (match('...')) { - var marker = markerCreate(); - lex(); - return markerApply(marker, delegate.createSpreadElement(parseAssignmentExpression())); - } - return parseAssignmentExpression(); - } - - function parseNonComputedProperty() { - var marker = markerCreate(), - token = lex(); - - if (!isIdentifierName(token)) { - throwUnexpected(token); - } - - return markerApply(marker, delegate.createIdentifier(token.value)); - } - - function parseNonComputedMember() { - expect('.'); - - return parseNonComputedProperty(); - } - - function parseComputedMember() { - var expr; - - expect('['); - - expr = parseExpression(); - - expect(']'); - - return expr; - } - - function parseNewExpression() { - var callee, args, marker = markerCreate(); - - expectKeyword('new'); - callee = parseLeftHandSideExpression(); - args = match('(') ? parseArguments() : []; - - return markerApply(marker, delegate.createNewExpression(callee, args)); - } - - function parseLeftHandSideExpressionAllowCall() { - var expr, args, marker = markerCreate(); - - expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); - - while (match('.') || match('[') || match('(') || lookahead.type === Token.Template) { - if (match('(')) { - args = parseArguments(); - expr = markerApply(marker, delegate.createCallExpression(expr, args)); - } else if (match('[')) { - expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember())); - } else if (match('.')) { - expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember())); - } else { - expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral())); - } - } - - return expr; - } - - function parseLeftHandSideExpression() { - var expr, marker = markerCreate(); - - expr = matchKeyword('new') ? parseNewExpression() : parsePrimaryExpression(); - - while (match('.') || match('[') || lookahead.type === Token.Template) { - if (match('[')) { - expr = markerApply(marker, delegate.createMemberExpression('[', expr, parseComputedMember())); - } else if (match('.')) { - expr = markerApply(marker, delegate.createMemberExpression('.', expr, parseNonComputedMember())); - } else { - expr = markerApply(marker, delegate.createTaggedTemplateExpression(expr, parseTemplateLiteral())); - } - } - - return expr; - } - - // 11.3 Postfix Expressions - - function parsePostfixExpression() { - var marker = markerCreate(), - expr = parseLeftHandSideExpressionAllowCall(), - token; - - if (lookahead.type !== Token.Punctuator) { - return expr; - } - - if ((match('++') || match('--')) && !peekLineTerminator()) { - // 11.3.1, 11.3.2 - if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { - throwErrorTolerant({}, Messages.StrictLHSPostfix); - } - - if (!isLeftHandSide(expr)) { - throwError({}, Messages.InvalidLHSInAssignment); - } - - token = lex(); - expr = markerApply(marker, delegate.createPostfixExpression(token.value, expr)); - } - - return expr; - } - - // 11.4 Unary Operators - - function parseUnaryExpression() { - var marker, token, expr; - - if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) { - return parsePostfixExpression(); - } - - if (match('++') || match('--')) { - marker = markerCreate(); - token = lex(); - expr = parseUnaryExpression(); - // 11.4.4, 11.4.5 - if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { - throwErrorTolerant({}, Messages.StrictLHSPrefix); - } - - if (!isLeftHandSide(expr)) { - throwError({}, Messages.InvalidLHSInAssignment); - } - - return markerApply(marker, delegate.createUnaryExpression(token.value, expr)); - } - - if (match('+') || match('-') || match('~') || match('!')) { - marker = markerCreate(); - token = lex(); - expr = parseUnaryExpression(); - return markerApply(marker, delegate.createUnaryExpression(token.value, expr)); - } - - if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { - marker = markerCreate(); - token = lex(); - expr = parseUnaryExpression(); - expr = markerApply(marker, delegate.createUnaryExpression(token.value, expr)); - if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { - throwErrorTolerant({}, Messages.StrictDelete); - } - return expr; - } - - return parsePostfixExpression(); - } - - function binaryPrecedence(token, allowIn) { - var prec = 0; - - if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { - return 0; - } - - switch (token.value) { - case '||': - prec = 1; - break; - - case '&&': - prec = 2; - break; - - case '|': - prec = 3; - break; - - case '^': - prec = 4; - break; - - case '&': - prec = 5; - break; - - case '==': - case '!=': - case '===': - case '!==': - prec = 6; - break; - - case '<': - case '>': - case '<=': - case '>=': - case 'instanceof': - prec = 7; - break; - - case 'in': - prec = allowIn ? 7 : 0; - break; - - case '<<': - case '>>': - case '>>>': - prec = 8; - break; - - case '+': - case '-': - prec = 9; - break; - - case '*': - case '/': - case '%': - prec = 11; - break; - - default: - break; - } - - return prec; - } - - // 11.5 Multiplicative Operators - // 11.6 Additive Operators - // 11.7 Bitwise Shift Operators - // 11.8 Relational Operators - // 11.9 Equality Operators - // 11.10 Binary Bitwise Operators - // 11.11 Binary Logical Operators - - function parseBinaryExpression() { - var expr, token, prec, previousAllowIn, stack, right, operator, left, i, - marker, markers; - - previousAllowIn = state.allowIn; - state.allowIn = true; - - marker = markerCreate(); - left = parseUnaryExpression(); - - token = lookahead; - prec = binaryPrecedence(token, previousAllowIn); - if (prec === 0) { - return left; - } - token.prec = prec; - lex(); - - markers = [marker, markerCreate()]; - right = parseUnaryExpression(); - - stack = [left, token, right]; - - while ((prec = binaryPrecedence(lookahead, previousAllowIn)) > 0) { - - // Reduce: make a binary expression from the three topmost entries. - while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { - right = stack.pop(); - operator = stack.pop().value; - left = stack.pop(); - expr = delegate.createBinaryExpression(operator, left, right); - markers.pop(); - marker = markers.pop(); - markerApply(marker, expr); - stack.push(expr); - markers.push(marker); - } - - // Shift. - token = lex(); - token.prec = prec; - stack.push(token); - markers.push(markerCreate()); - expr = parseUnaryExpression(); - stack.push(expr); - } - - state.allowIn = previousAllowIn; - - // Final reduce to clean-up the stack. - i = stack.length - 1; - expr = stack[i]; - markers.pop(); - while (i > 1) { - expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr); - i -= 2; - marker = markers.pop(); - markerApply(marker, expr); - } - - return expr; - } - - - // 11.12 Conditional Operator - - function parseConditionalExpression() { - var expr, previousAllowIn, consequent, alternate, marker = markerCreate(); - expr = parseBinaryExpression(); - - if (match('?')) { - lex(); - previousAllowIn = state.allowIn; - state.allowIn = true; - consequent = parseAssignmentExpression(); - state.allowIn = previousAllowIn; - expect(':'); - alternate = parseAssignmentExpression(); - - expr = markerApply(marker, delegate.createConditionalExpression(expr, consequent, alternate)); - } - - return expr; - } - - // 11.13 Assignment Operators - - // 12.14.5 AssignmentPattern - - function reinterpretAsAssignmentBindingPattern(expr) { - var i, len, property, element; - - if (expr.type === Syntax.ObjectExpression) { - expr.type = Syntax.ObjectPattern; - for (i = 0, len = expr.properties.length; i < len; i += 1) { - property = expr.properties[i]; - if (property.type === Syntax.SpreadProperty) { - if (i < len - 1) { - throwError({}, Messages.PropertyAfterSpreadProperty); - } - reinterpretAsAssignmentBindingPattern(property.argument); - } else { - if (property.kind !== 'init') { - throwError({}, Messages.InvalidLHSInAssignment); - } - reinterpretAsAssignmentBindingPattern(property.value); - } - } - } else if (expr.type === Syntax.ArrayExpression) { - expr.type = Syntax.ArrayPattern; - for (i = 0, len = expr.elements.length; i < len; i += 1) { - element = expr.elements[i]; - /* istanbul ignore else */ - if (element) { - reinterpretAsAssignmentBindingPattern(element); - } - } - } else if (expr.type === Syntax.Identifier) { - if (isRestrictedWord(expr.name)) { - throwError({}, Messages.InvalidLHSInAssignment); - } - } else if (expr.type === Syntax.SpreadElement) { - reinterpretAsAssignmentBindingPattern(expr.argument); - if (expr.argument.type === Syntax.ObjectPattern) { - throwError({}, Messages.ObjectPatternAsSpread); - } - } else { - /* istanbul ignore else */ - if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) { - throwError({}, Messages.InvalidLHSInAssignment); - } - } - } - - // 13.2.3 BindingPattern - - function reinterpretAsDestructuredParameter(options, expr) { - var i, len, property, element; - - if (expr.type === Syntax.ObjectExpression) { - expr.type = Syntax.ObjectPattern; - for (i = 0, len = expr.properties.length; i < len; i += 1) { - property = expr.properties[i]; - if (property.type === Syntax.SpreadProperty) { - if (i < len - 1) { - throwError({}, Messages.PropertyAfterSpreadProperty); - } - reinterpretAsDestructuredParameter(options, property.argument); - } else { - if (property.kind !== 'init') { - throwError({}, Messages.InvalidLHSInFormalsList); - } - reinterpretAsDestructuredParameter(options, property.value); - } - } - } else if (expr.type === Syntax.ArrayExpression) { - expr.type = Syntax.ArrayPattern; - for (i = 0, len = expr.elements.length; i < len; i += 1) { - element = expr.elements[i]; - if (element) { - reinterpretAsDestructuredParameter(options, element); - } - } - } else if (expr.type === Syntax.Identifier) { - validateParam(options, expr, expr.name); - } else if (expr.type === Syntax.SpreadElement) { - // BindingRestElement only allows BindingIdentifier - if (expr.argument.type !== Syntax.Identifier) { - throwError({}, Messages.InvalidLHSInFormalsList); - } - validateParam(options, expr.argument, expr.argument.name); - } else { - throwError({}, Messages.InvalidLHSInFormalsList); - } - } - - function reinterpretAsCoverFormalsList(expressions) { - var i, len, param, params, defaults, defaultCount, options, rest; - - params = []; - defaults = []; - defaultCount = 0; - rest = null; - options = { - paramSet: new StringMap() - }; - - for (i = 0, len = expressions.length; i < len; i += 1) { - param = expressions[i]; - if (param.type === Syntax.Identifier) { - params.push(param); - defaults.push(null); - validateParam(options, param, param.name); - } else if (param.type === Syntax.ObjectExpression || param.type === Syntax.ArrayExpression) { - reinterpretAsDestructuredParameter(options, param); - params.push(param); - defaults.push(null); - } else if (param.type === Syntax.SpreadElement) { - assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression'); - if (param.argument.type !== Syntax.Identifier) { - throwError({}, Messages.InvalidLHSInFormalsList); - } - reinterpretAsDestructuredParameter(options, param.argument); - rest = param.argument; - } else if (param.type === Syntax.AssignmentExpression) { - params.push(param.left); - defaults.push(param.right); - ++defaultCount; - validateParam(options, param.left, param.left.name); - } else { - return null; - } - } - - if (options.message === Messages.StrictParamDupe) { - throwError( - strict ? options.stricted : options.firstRestricted, - options.message - ); - } - - if (defaultCount === 0) { - defaults = []; - } - - return { - params: params, - defaults: defaults, - rest: rest, - stricted: options.stricted, - firstRestricted: options.firstRestricted, - message: options.message - }; - } - - function parseArrowFunctionExpression(options, marker) { - var previousStrict, previousYieldAllowed, previousAwaitAllowed, body; - - expect('=>'); - - previousStrict = strict; - previousYieldAllowed = state.yieldAllowed; - state.yieldAllowed = false; - previousAwaitAllowed = state.awaitAllowed; - state.awaitAllowed = !!options.async; - body = parseConciseBody(); - - if (strict && options.firstRestricted) { - throwError(options.firstRestricted, options.message); - } - if (strict && options.stricted) { - throwErrorTolerant(options.stricted, options.message); - } - - strict = previousStrict; - state.yieldAllowed = previousYieldAllowed; - state.awaitAllowed = previousAwaitAllowed; - - return markerApply(marker, delegate.createArrowFunctionExpression( - options.params, - options.defaults, - body, - options.rest, - body.type !== Syntax.BlockStatement, - !!options.async - )); - } - - function parseAssignmentExpression() { - var marker, expr, token, params, oldParenthesizedCount, - startsWithParen = false, backtrackToken = lookahead, - possiblyAsync = false; - - if (matchYield()) { - return parseYieldExpression(); - } - - if (matchAwait()) { - return parseAwaitExpression(); - } - - oldParenthesizedCount = state.parenthesizedCount; - - marker = markerCreate(); - - if (matchAsyncFuncExprOrDecl()) { - return parseFunctionExpression(); - } - - if (matchAsync()) { - // We can't be completely sure that this 'async' token is - // actually a contextual keyword modifying a function - // expression, so we might have to un-lex() it later by - // calling rewind(backtrackToken). - possiblyAsync = true; - lex(); - } - - if (match('(')) { - token = lookahead2(); - if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') { - params = parseParams(); - if (!match('=>')) { - throwUnexpected(lex()); - } - params.async = possiblyAsync; - return parseArrowFunctionExpression(params, marker); - } - startsWithParen = true; - } - - token = lookahead; - - // If the 'async' keyword is not followed by a '(' character or an - // identifier, then it can't be an arrow function modifier, and we - // should interpret it as a normal identifer. - if (possiblyAsync && !match('(') && token.type !== Token.Identifier) { - possiblyAsync = false; - rewind(backtrackToken); - } - - expr = parseConditionalExpression(); - - if (match('=>') && - (state.parenthesizedCount === oldParenthesizedCount || - state.parenthesizedCount === (oldParenthesizedCount + 1))) { - if (expr.type === Syntax.Identifier) { - params = reinterpretAsCoverFormalsList([ expr ]); - } else if (expr.type === Syntax.AssignmentExpression || - expr.type === Syntax.ArrayExpression || - expr.type === Syntax.ObjectExpression) { - if (!startsWithParen) { - throwUnexpected(lex()); - } - params = reinterpretAsCoverFormalsList([ expr ]); - } else if (expr.type === Syntax.SequenceExpression) { - params = reinterpretAsCoverFormalsList(expr.expressions); - } - if (params) { - params.async = possiblyAsync; - return parseArrowFunctionExpression(params, marker); - } - } - - // If we haven't returned by now, then the 'async' keyword was not - // a function modifier, and we should rewind and interpret it as a - // normal identifier. - if (possiblyAsync) { - possiblyAsync = false; - rewind(backtrackToken); - expr = parseConditionalExpression(); - } - - if (matchAssign()) { - // 11.13.1 - if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { - throwErrorTolerant(token, Messages.StrictLHSAssignment); - } - - // ES.next draf 11.13 Runtime Semantics step 1 - if (match('=') && (expr.type === Syntax.ObjectExpression || expr.type === Syntax.ArrayExpression)) { - reinterpretAsAssignmentBindingPattern(expr); - } else if (!isLeftHandSide(expr)) { - throwError({}, Messages.InvalidLHSInAssignment); - } - - expr = markerApply(marker, delegate.createAssignmentExpression(lex().value, expr, parseAssignmentExpression())); - } - - return expr; - } - - // 11.14 Comma Operator - - function parseExpression() { - var marker, expr, expressions, sequence, spreadFound; - - marker = markerCreate(); - expr = parseAssignmentExpression(); - expressions = [ expr ]; - - if (match(',')) { - while (index < length) { - if (!match(',')) { - break; - } - - lex(); - expr = parseSpreadOrAssignmentExpression(); - expressions.push(expr); - - if (expr.type === Syntax.SpreadElement) { - spreadFound = true; - if (!match(')')) { - throwError({}, Messages.ElementAfterSpreadElement); - } - break; - } - } - - sequence = markerApply(marker, delegate.createSequenceExpression(expressions)); - } - - if (spreadFound && lookahead2().value !== '=>') { - throwError({}, Messages.IllegalSpread); - } - - return sequence || expr; - } - - // 12.1 Block - - function parseStatementList() { - var list = [], - statement; - - while (index < length) { - if (match('}')) { - break; - } - statement = parseSourceElement(); - if (typeof statement === 'undefined') { - break; - } - list.push(statement); - } - - return list; - } - - function parseBlock() { - var block, marker = markerCreate(); - - expect('{'); - - block = parseStatementList(); - - expect('}'); - - return markerApply(marker, delegate.createBlockStatement(block)); - } - - // 12.2 Variable Statement - - function parseTypeParameterDeclaration() { - var marker = markerCreate(), paramTypes = []; - - expect('<'); - while (!match('>')) { - paramTypes.push(parseTypeAnnotatableIdentifier()); - if (!match('>')) { - expect(','); - } - } - expect('>'); - - return markerApply(marker, delegate.createTypeParameterDeclaration( - paramTypes - )); - } - - function parseTypeParameterInstantiation() { - var marker = markerCreate(), oldInType = state.inType, paramTypes = []; - - state.inType = true; - - expect('<'); - while (!match('>')) { - paramTypes.push(parseType()); - if (!match('>')) { - expect(','); - } - } - expect('>'); - - state.inType = oldInType; - - return markerApply(marker, delegate.createTypeParameterInstantiation( - paramTypes - )); - } - - function parseObjectTypeIndexer(marker, isStatic) { - var id, key, value; - - expect('['); - id = parseObjectPropertyKey(); - expect(':'); - key = parseType(); - expect(']'); - expect(':'); - value = parseType(); - - return markerApply(marker, delegate.createObjectTypeIndexer( - id, - key, - value, - isStatic - )); - } - - function parseObjectTypeMethodish(marker) { - var params = [], rest = null, returnType, typeParameters = null; - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - - expect('('); - while (lookahead.type === Token.Identifier) { - params.push(parseFunctionTypeParam()); - if (!match(')')) { - expect(','); - } - } - - if (match('...')) { - lex(); - rest = parseFunctionTypeParam(); - } - expect(')'); - expect(':'); - returnType = parseType(); - - return markerApply(marker, delegate.createFunctionTypeAnnotation( - params, - returnType, - rest, - typeParameters - )); - } - - function parseObjectTypeMethod(marker, isStatic, key) { - var optional = false, value; - value = parseObjectTypeMethodish(marker); - - return markerApply(marker, delegate.createObjectTypeProperty( - key, - value, - optional, - isStatic - )); - } - - function parseObjectTypeCallProperty(marker, isStatic) { - var valueMarker = markerCreate(); - return markerApply(marker, delegate.createObjectTypeCallProperty( - parseObjectTypeMethodish(valueMarker), - isStatic - )); - } - - function parseObjectType(allowStatic) { - var callProperties = [], indexers = [], marker, optional = false, - properties = [], propertyKey, propertyTypeAnnotation, - token, isStatic, matchStatic; - - expect('{'); - - while (!match('}')) { - marker = markerCreate(); - matchStatic = - strict - ? matchKeyword('static') - : matchContextualKeyword('static'); - - if (allowStatic && matchStatic) { - token = lex(); - isStatic = true; - } - - if (match('[')) { - indexers.push(parseObjectTypeIndexer(marker, isStatic)); - } else if (match('(') || match('<')) { - callProperties.push(parseObjectTypeCallProperty(marker, allowStatic)); - } else { - if (isStatic && match(':')) { - propertyKey = markerApply(marker, delegate.createIdentifier(token)); - throwErrorTolerant(token, Messages.StrictReservedWord); - } else { - propertyKey = parseObjectPropertyKey(); - } - if (match('<') || match('(')) { - // This is a method property - properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey)); - } else { - if (match('?')) { - lex(); - optional = true; - } - expect(':'); - propertyTypeAnnotation = parseType(); - properties.push(markerApply(marker, delegate.createObjectTypeProperty( - propertyKey, - propertyTypeAnnotation, - optional, - isStatic - ))); - } - } - - if (match(';')) { - lex(); - } else if (!match('}')) { - throwUnexpected(lookahead); - } - } - - expect('}'); - - return delegate.createObjectTypeAnnotation( - properties, - indexers, - callProperties - ); - } - - function parseGenericType() { - var marker = markerCreate(), - typeParameters = null, typeIdentifier; - - typeIdentifier = parseVariableIdentifier(); - - while (match('.')) { - expect('.'); - typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier( - typeIdentifier, - parseVariableIdentifier() - )); - } - - if (match('<')) { - typeParameters = parseTypeParameterInstantiation(); - } - - return markerApply(marker, delegate.createGenericTypeAnnotation( - typeIdentifier, - typeParameters - )); - } - - function parseVoidType() { - var marker = markerCreate(); - expectKeyword('void'); - return markerApply(marker, delegate.createVoidTypeAnnotation()); - } - - function parseTypeofType() { - var argument, marker = markerCreate(); - expectKeyword('typeof'); - argument = parsePrimaryType(); - return markerApply(marker, delegate.createTypeofTypeAnnotation( - argument - )); - } - - function parseTupleType() { - var marker = markerCreate(), types = []; - expect('['); - // We allow trailing commas - while (index < length && !match(']')) { - types.push(parseType()); - if (match(']')) { - break; - } - expect(','); - } - expect(']'); - return markerApply(marker, delegate.createTupleTypeAnnotation( - types - )); - } - - function parseFunctionTypeParam() { - var marker = markerCreate(), name, optional = false, typeAnnotation; - name = parseVariableIdentifier(); - if (match('?')) { - lex(); - optional = true; - } - expect(':'); - typeAnnotation = parseType(); - return markerApply(marker, delegate.createFunctionTypeParam( - name, - typeAnnotation, - optional - )); - } - - function parseFunctionTypeParams() { - var ret = { params: [], rest: null }; - while (lookahead.type === Token.Identifier) { - ret.params.push(parseFunctionTypeParam()); - if (!match(')')) { - expect(','); - } - } - - if (match('...')) { - lex(); - ret.rest = parseFunctionTypeParam(); - } - return ret; - } - - // The parsing of types roughly parallels the parsing of expressions, and - // primary types are kind of like primary expressions...they're the - // primitives with which other types are constructed. - function parsePrimaryType() { - var params = null, returnType = null, - marker = markerCreate(), rest = null, tmp, - typeParameters, token, type, isGroupedType = false; - - switch (lookahead.type) { - case Token.Identifier: - switch (lookahead.value) { - case 'any': - lex(); - return markerApply(marker, delegate.createAnyTypeAnnotation()); - case 'bool': // fallthrough - case 'boolean': - lex(); - return markerApply(marker, delegate.createBooleanTypeAnnotation()); - case 'number': - lex(); - return markerApply(marker, delegate.createNumberTypeAnnotation()); - case 'string': - lex(); - return markerApply(marker, delegate.createStringTypeAnnotation()); - } - return markerApply(marker, parseGenericType()); - case Token.Punctuator: - switch (lookahead.value) { - case '{': - return markerApply(marker, parseObjectType()); - case '[': - return parseTupleType(); - case '<': - typeParameters = parseTypeParameterDeclaration(); - expect('('); - tmp = parseFunctionTypeParams(); - params = tmp.params; - rest = tmp.rest; - expect(')'); - - expect('=>'); - - returnType = parseType(); - - return markerApply(marker, delegate.createFunctionTypeAnnotation( - params, - returnType, - rest, - typeParameters - )); - case '(': - lex(); - // Check to see if this is actually a grouped type - if (!match(')') && !match('...')) { - if (lookahead.type === Token.Identifier) { - token = lookahead2(); - isGroupedType = token.value !== '?' && token.value !== ':'; - } else { - isGroupedType = true; - } - } - - if (isGroupedType) { - type = parseType(); - expect(')'); - - // If we see a => next then someone was probably confused about - // function types, so we can provide a better error message - if (match('=>')) { - throwError({}, Messages.ConfusedAboutFunctionType); - } - - return type; - } - - tmp = parseFunctionTypeParams(); - params = tmp.params; - rest = tmp.rest; - - expect(')'); - - expect('=>'); - - returnType = parseType(); - - return markerApply(marker, delegate.createFunctionTypeAnnotation( - params, - returnType, - rest, - null /* typeParameters */ - )); - } - break; - case Token.Keyword: - switch (lookahead.value) { - case 'void': - return markerApply(marker, parseVoidType()); - case 'typeof': - return markerApply(marker, parseTypeofType()); - } - break; - case Token.StringLiteral: - token = lex(); - if (token.octal) { - throwError(token, Messages.StrictOctalLiteral); - } - return markerApply(marker, delegate.createStringLiteralTypeAnnotation( - token - )); - } - - throwUnexpected(lookahead); - } - - function parsePostfixType() { - var marker = markerCreate(), t = parsePrimaryType(); - if (match('[')) { - expect('['); - expect(']'); - return markerApply(marker, delegate.createArrayTypeAnnotation(t)); - } - return t; - } - - function parsePrefixType() { - var marker = markerCreate(); - if (match('?')) { - lex(); - return markerApply(marker, delegate.createNullableTypeAnnotation( - parsePrefixType() - )); - } - return parsePostfixType(); - } - - - function parseIntersectionType() { - var marker = markerCreate(), type, types; - type = parsePrefixType(); - types = [type]; - while (match('&')) { - lex(); - types.push(parsePrefixType()); - } - - return types.length === 1 ? - type : - markerApply(marker, delegate.createIntersectionTypeAnnotation( - types - )); - } - - function parseUnionType() { - var marker = markerCreate(), type, types; - type = parseIntersectionType(); - types = [type]; - while (match('|')) { - lex(); - types.push(parseIntersectionType()); - } - return types.length === 1 ? - type : - markerApply(marker, delegate.createUnionTypeAnnotation( - types - )); - } - - function parseType() { - var oldInType = state.inType, type; - state.inType = true; - - type = parseUnionType(); - - state.inType = oldInType; - return type; - } - - function parseTypeAnnotation() { - var marker = markerCreate(), type; - - expect(':'); - type = parseType(); - - return markerApply(marker, delegate.createTypeAnnotation(type)); - } - - function parseVariableIdentifier() { - var marker = markerCreate(), - token = lex(); - - if (token.type !== Token.Identifier) { - throwUnexpected(token); - } - - return markerApply(marker, delegate.createIdentifier(token.value)); - } - - function parseTypeAnnotatableIdentifier(requireTypeAnnotation, canBeOptionalParam) { - var marker = markerCreate(), - ident = parseVariableIdentifier(), - isOptionalParam = false; - - if (canBeOptionalParam && match('?')) { - expect('?'); - isOptionalParam = true; - } - - if (requireTypeAnnotation || match(':')) { - ident.typeAnnotation = parseTypeAnnotation(); - ident = markerApply(marker, ident); - } - - if (isOptionalParam) { - ident.optional = true; - ident = markerApply(marker, ident); - } - - return ident; - } - - function parseVariableDeclaration(kind) { - var id, - marker = markerCreate(), - init = null, - typeAnnotationMarker = markerCreate(); - if (match('{')) { - id = parseObjectInitialiser(); - reinterpretAsAssignmentBindingPattern(id); - if (match(':')) { - id.typeAnnotation = parseTypeAnnotation(); - markerApply(typeAnnotationMarker, id); - } - } else if (match('[')) { - id = parseArrayInitialiser(); - reinterpretAsAssignmentBindingPattern(id); - if (match(':')) { - id.typeAnnotation = parseTypeAnnotation(); - markerApply(typeAnnotationMarker, id); - } - } else { - /* istanbul ignore next */ - id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier(); - // 12.2.1 - if (strict && isRestrictedWord(id.name)) { - throwErrorTolerant({}, Messages.StrictVarName); - } - } - - if (kind === 'const') { - if (!match('=')) { - throwError({}, Messages.NoUninitializedConst); - } - expect('='); - init = parseAssignmentExpression(); - } else if (match('=')) { - lex(); - init = parseAssignmentExpression(); - } - - return markerApply(marker, delegate.createVariableDeclarator(id, init)); - } - - function parseVariableDeclarationList(kind) { - var list = []; - - do { - list.push(parseVariableDeclaration(kind)); - if (!match(',')) { - break; - } - lex(); - } while (index < length); - - return list; - } - - function parseVariableStatement() { - var declarations, marker = markerCreate(); - - expectKeyword('var'); - - declarations = parseVariableDeclarationList(); - - consumeSemicolon(); - - return markerApply(marker, delegate.createVariableDeclaration(declarations, 'var')); - } - - // kind may be `const` or `let` - // Both are experimental and not in the specification yet. - // see http://wiki.ecmascript.org/doku.php?id=harmony:const - // and http://wiki.ecmascript.org/doku.php?id=harmony:let - function parseConstLetDeclaration(kind) { - var declarations, marker = markerCreate(); - - expectKeyword(kind); - - declarations = parseVariableDeclarationList(kind); - - consumeSemicolon(); - - return markerApply(marker, delegate.createVariableDeclaration(declarations, kind)); - } - - // people.mozilla.org/~jorendorff/es6-draft.html - - function parseModuleSpecifier() { - var marker = markerCreate(), - specifier; - - if (lookahead.type !== Token.StringLiteral) { - throwError({}, Messages.InvalidModuleSpecifier); - } - specifier = delegate.createModuleSpecifier(lookahead); - lex(); - return markerApply(marker, specifier); - } - - function parseExportBatchSpecifier() { - var marker = markerCreate(); - expect('*'); - return markerApply(marker, delegate.createExportBatchSpecifier()); - } - - function parseExportSpecifier() { - var id, name = null, marker = markerCreate(), from; - if (matchKeyword('default')) { - lex(); - id = markerApply(marker, delegate.createIdentifier('default')); - // export {default} from "something"; - } else { - id = parseVariableIdentifier(); - } - if (matchContextualKeyword('as')) { - lex(); - name = parseNonComputedProperty(); - } - - return markerApply(marker, delegate.createExportSpecifier(id, name)); - } - - function parseExportDeclaration() { - var declaration = null, - possibleIdentifierToken, sourceElement, - isExportFromIdentifier, - src = null, specifiers = [], - marker = markerCreate(); - - expectKeyword('export'); - - if (matchKeyword('default')) { - // covers: - // export default ... - lex(); - if (matchKeyword('function') || matchKeyword('class')) { - possibleIdentifierToken = lookahead2(); - if (isIdentifierName(possibleIdentifierToken)) { - // covers: - // export default function foo () {} - // export default class foo {} - sourceElement = parseSourceElement(); - return markerApply(marker, delegate.createExportDeclaration(true, sourceElement, [sourceElement.id], null)); - } - // covers: - // export default function () {} - // export default class {} - switch (lookahead.value) { - case 'class': - return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null)); - case 'function': - return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null)); - } - } - - if (matchContextualKeyword('from')) { - throwError({}, Messages.UnexpectedToken, lookahead.value); - } - - // covers: - // export default {}; - // export default []; - if (match('{')) { - declaration = parseObjectInitialiser(); - } else if (match('[')) { - declaration = parseArrayInitialiser(); - } else { - declaration = parseAssignmentExpression(); - } - consumeSemicolon(); - return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null)); - } - - // non-default export - if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) { - // covers: - // export var f = 1; - switch (lookahead.value) { - case 'type': - case 'let': - case 'const': - case 'var': - case 'class': - case 'function': - return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null)); - } - } - - if (match('*')) { - // covers: - // export * from "foo"; - specifiers.push(parseExportBatchSpecifier()); - - if (!matchContextualKeyword('from')) { - throwError({}, lookahead.value ? - Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); - } - lex(); - src = parseModuleSpecifier(); - consumeSemicolon(); - - return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src)); - } - - expect('{'); - if (!match('}')) { - do { - isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default'); - specifiers.push(parseExportSpecifier()); - } while (match(',') && lex()); - } - expect('}'); - - if (matchContextualKeyword('from')) { - // covering: - // export {default} from "foo"; - // export {foo} from "foo"; - lex(); - src = parseModuleSpecifier(); - consumeSemicolon(); - } else if (isExportFromIdentifier) { - // covering: - // export {default}; // missing fromClause - throwError({}, lookahead.value ? - Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); - } else { - // cover - // export {foo}; - consumeSemicolon(); - } - return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src)); - } - - - function parseImportSpecifier() { - // import {} ...; - var id, name = null, marker = markerCreate(); - - id = parseNonComputedProperty(); - if (matchContextualKeyword('as')) { - lex(); - name = parseVariableIdentifier(); - } - - return markerApply(marker, delegate.createImportSpecifier(id, name)); - } - - function parseNamedImports() { - var specifiers = []; - // {foo, bar as bas} - expect('{'); - if (!match('}')) { - do { - specifiers.push(parseImportSpecifier()); - } while (match(',') && lex()); - } - expect('}'); - return specifiers; - } - - function parseImportDefaultSpecifier() { - // import ...; - var id, marker = markerCreate(); - - id = parseNonComputedProperty(); - - return markerApply(marker, delegate.createImportDefaultSpecifier(id)); - } - - function parseImportNamespaceSpecifier() { - // import <* as foo> ...; - var id, marker = markerCreate(); - - expect('*'); - if (!matchContextualKeyword('as')) { - throwError({}, Messages.NoAsAfterImportNamespace); - } - lex(); - id = parseNonComputedProperty(); - - return markerApply(marker, delegate.createImportNamespaceSpecifier(id)); - } - - function parseImportDeclaration() { - var specifiers, src, marker = markerCreate(), isType = false, token2; - - expectKeyword('import'); - - if (matchContextualKeyword('type')) { - token2 = lookahead2(); - if ((token2.type === Token.Identifier && token2.value !== 'from') || - (token2.type === Token.Punctuator && - (token2.value === '{' || token2.value === '*'))) { - isType = true; - lex(); - } - } - - specifiers = []; - - if (lookahead.type === Token.StringLiteral) { - // covers: - // import "foo"; - src = parseModuleSpecifier(); - consumeSemicolon(); - return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType)); - } - - if (!matchKeyword('default') && isIdentifierName(lookahead)) { - // covers: - // import foo - // import foo, ... - specifiers.push(parseImportDefaultSpecifier()); - if (match(',')) { - lex(); - } - } - if (match('*')) { - // covers: - // import foo, * as foo - // import * as foo - specifiers.push(parseImportNamespaceSpecifier()); - } else if (match('{')) { - // covers: - // import foo, {bar} - // import {bar} - specifiers = specifiers.concat(parseNamedImports()); - } - - if (!matchContextualKeyword('from')) { - throwError({}, lookahead.value ? - Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); - } - lex(); - src = parseModuleSpecifier(); - consumeSemicolon(); - - return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType)); - } - - // 12.3 Empty Statement - - function parseEmptyStatement() { - var marker = markerCreate(); - expect(';'); - return markerApply(marker, delegate.createEmptyStatement()); - } - - // 12.4 Expression Statement - - function parseExpressionStatement() { - var marker = markerCreate(), expr = parseExpression(); - consumeSemicolon(); - return markerApply(marker, delegate.createExpressionStatement(expr)); - } - - // 12.5 If statement - - function parseIfStatement() { - var test, consequent, alternate, marker = markerCreate(); - - expectKeyword('if'); - - expect('('); - - test = parseExpression(); - - expect(')'); - - consequent = parseStatement(); - - if (matchKeyword('else')) { - lex(); - alternate = parseStatement(); - } else { - alternate = null; - } - - return markerApply(marker, delegate.createIfStatement(test, consequent, alternate)); - } - - // 12.6 Iteration Statements - - function parseDoWhileStatement() { - var body, test, oldInIteration, marker = markerCreate(); - - expectKeyword('do'); - - oldInIteration = state.inIteration; - state.inIteration = true; - - body = parseStatement(); - - state.inIteration = oldInIteration; - - expectKeyword('while'); - - expect('('); - - test = parseExpression(); - - expect(')'); - - if (match(';')) { - lex(); - } - - return markerApply(marker, delegate.createDoWhileStatement(body, test)); - } - - function parseWhileStatement() { - var test, body, oldInIteration, marker = markerCreate(); - - expectKeyword('while'); - - expect('('); - - test = parseExpression(); - - expect(')'); - - oldInIteration = state.inIteration; - state.inIteration = true; - - body = parseStatement(); - - state.inIteration = oldInIteration; - - return markerApply(marker, delegate.createWhileStatement(test, body)); - } - - function parseForVariableDeclaration() { - var marker = markerCreate(), - token = lex(), - declarations = parseVariableDeclarationList(); - - return markerApply(marker, delegate.createVariableDeclaration(declarations, token.value)); - } - - function parseForStatement(opts) { - var init, test, update, left, right, body, operator, oldInIteration, - marker = markerCreate(); - init = test = update = null; - expectKeyword('for'); - - // http://wiki.ecmascript.org/doku.php?id=proposals:iterators_and_generators&s=each - if (matchContextualKeyword('each')) { - throwError({}, Messages.EachNotAllowed); - } - - expect('('); - - if (match(';')) { - lex(); - } else { - if (matchKeyword('var') || matchKeyword('let') || matchKeyword('const')) { - state.allowIn = false; - init = parseForVariableDeclaration(); - state.allowIn = true; - - if (init.declarations.length === 1) { - if (matchKeyword('in') || matchContextualKeyword('of')) { - operator = lookahead; - if (!((operator.value === 'in' || init.kind !== 'var') && init.declarations[0].init)) { - lex(); - left = init; - right = parseExpression(); - init = null; - } - } - } - } else { - state.allowIn = false; - init = parseExpression(); - state.allowIn = true; - - if (matchContextualKeyword('of')) { - operator = lex(); - left = init; - right = parseExpression(); - init = null; - } else if (matchKeyword('in')) { - // LeftHandSideExpression - if (!isAssignableLeftHandSide(init)) { - throwError({}, Messages.InvalidLHSInForIn); - } - operator = lex(); - left = init; - right = parseExpression(); - init = null; - } - } - - if (typeof left === 'undefined') { - expect(';'); - } - } - - if (typeof left === 'undefined') { - - if (!match(';')) { - test = parseExpression(); - } - expect(';'); - - if (!match(')')) { - update = parseExpression(); - } - } - - expect(')'); - - oldInIteration = state.inIteration; - state.inIteration = true; - - if (!(opts !== undefined && opts.ignoreBody)) { - body = parseStatement(); - } - - state.inIteration = oldInIteration; - - if (typeof left === 'undefined') { - return markerApply(marker, delegate.createForStatement(init, test, update, body)); - } - - if (operator.value === 'in') { - return markerApply(marker, delegate.createForInStatement(left, right, body)); - } - return markerApply(marker, delegate.createForOfStatement(left, right, body)); - } - - // 12.7 The continue statement - - function parseContinueStatement() { - var label = null, marker = markerCreate(); - - expectKeyword('continue'); - - // Optimize the most common form: 'continue;'. - if (source.charCodeAt(index) === 59) { - lex(); - - if (!state.inIteration) { - throwError({}, Messages.IllegalContinue); - } - - return markerApply(marker, delegate.createContinueStatement(null)); - } - - if (peekLineTerminator()) { - if (!state.inIteration) { - throwError({}, Messages.IllegalContinue); - } - - return markerApply(marker, delegate.createContinueStatement(null)); - } - - if (lookahead.type === Token.Identifier) { - label = parseVariableIdentifier(); - - if (!state.labelSet.has(label.name)) { - throwError({}, Messages.UnknownLabel, label.name); - } - } - - consumeSemicolon(); - - if (label === null && !state.inIteration) { - throwError({}, Messages.IllegalContinue); - } - - return markerApply(marker, delegate.createContinueStatement(label)); - } - - // 12.8 The break statement - - function parseBreakStatement() { - var label = null, marker = markerCreate(); - - expectKeyword('break'); - - // Catch the very common case first: immediately a semicolon (char #59). - if (source.charCodeAt(index) === 59) { - lex(); - - if (!(state.inIteration || state.inSwitch)) { - throwError({}, Messages.IllegalBreak); - } - - return markerApply(marker, delegate.createBreakStatement(null)); - } - - if (peekLineTerminator()) { - if (!(state.inIteration || state.inSwitch)) { - throwError({}, Messages.IllegalBreak); - } - - return markerApply(marker, delegate.createBreakStatement(null)); - } - - if (lookahead.type === Token.Identifier) { - label = parseVariableIdentifier(); - - if (!state.labelSet.has(label.name)) { - throwError({}, Messages.UnknownLabel, label.name); - } - } - - consumeSemicolon(); - - if (label === null && !(state.inIteration || state.inSwitch)) { - throwError({}, Messages.IllegalBreak); - } - - return markerApply(marker, delegate.createBreakStatement(label)); - } - - // 12.9 The return statement - - function parseReturnStatement() { - var argument = null, marker = markerCreate(); - - expectKeyword('return'); - - if (!state.inFunctionBody) { - throwErrorTolerant({}, Messages.IllegalReturn); - } - - // 'return' followed by a space and an identifier is very common. - if (source.charCodeAt(index) === 32) { - if (isIdentifierStart(source.charCodeAt(index + 1))) { - argument = parseExpression(); - consumeSemicolon(); - return markerApply(marker, delegate.createReturnStatement(argument)); - } - } - - if (peekLineTerminator()) { - return markerApply(marker, delegate.createReturnStatement(null)); - } - - if (!match(';')) { - if (!match('}') && lookahead.type !== Token.EOF) { - argument = parseExpression(); - } - } - - consumeSemicolon(); - - return markerApply(marker, delegate.createReturnStatement(argument)); - } - - // 12.10 The with statement - - function parseWithStatement() { - var object, body, marker = markerCreate(); - - if (strict) { - throwErrorTolerant({}, Messages.StrictModeWith); - } - - expectKeyword('with'); - - expect('('); - - object = parseExpression(); - - expect(')'); - - body = parseStatement(); - - return markerApply(marker, delegate.createWithStatement(object, body)); - } - - // 12.10 The swith statement - - function parseSwitchCase() { - var test, - consequent = [], - sourceElement, - marker = markerCreate(); - - if (matchKeyword('default')) { - lex(); - test = null; - } else { - expectKeyword('case'); - test = parseExpression(); - } - expect(':'); - - while (index < length) { - if (match('}') || matchKeyword('default') || matchKeyword('case')) { - break; - } - sourceElement = parseSourceElement(); - if (typeof sourceElement === 'undefined') { - break; - } - consequent.push(sourceElement); - } - - return markerApply(marker, delegate.createSwitchCase(test, consequent)); - } - - function parseSwitchStatement() { - var discriminant, cases, clause, oldInSwitch, defaultFound, marker = markerCreate(); - - expectKeyword('switch'); - - expect('('); - - discriminant = parseExpression(); - - expect(')'); - - expect('{'); - - cases = []; - - if (match('}')) { - lex(); - return markerApply(marker, delegate.createSwitchStatement(discriminant, cases)); - } - - oldInSwitch = state.inSwitch; - state.inSwitch = true; - defaultFound = false; - - while (index < length) { - if (match('}')) { - break; - } - clause = parseSwitchCase(); - if (clause.test === null) { - if (defaultFound) { - throwError({}, Messages.MultipleDefaultsInSwitch); - } - defaultFound = true; - } - cases.push(clause); - } - - state.inSwitch = oldInSwitch; - - expect('}'); - - return markerApply(marker, delegate.createSwitchStatement(discriminant, cases)); - } - - // 12.13 The throw statement - - function parseThrowStatement() { - var argument, marker = markerCreate(); - - expectKeyword('throw'); - - if (peekLineTerminator()) { - throwError({}, Messages.NewlineAfterThrow); - } - - argument = parseExpression(); - - consumeSemicolon(); - - return markerApply(marker, delegate.createThrowStatement(argument)); - } - - // 12.14 The try statement - - function parseCatchClause() { - var param, body, marker = markerCreate(); - - expectKeyword('catch'); - - expect('('); - if (match(')')) { - throwUnexpected(lookahead); - } - - param = parseExpression(); - // 12.14.1 - if (strict && param.type === Syntax.Identifier && isRestrictedWord(param.name)) { - throwErrorTolerant({}, Messages.StrictCatchVariable); - } - - expect(')'); - body = parseBlock(); - return markerApply(marker, delegate.createCatchClause(param, body)); - } - - function parseTryStatement() { - var block, handlers = [], finalizer = null, marker = markerCreate(); - - expectKeyword('try'); - - block = parseBlock(); - - if (matchKeyword('catch')) { - handlers.push(parseCatchClause()); - } - - if (matchKeyword('finally')) { - lex(); - finalizer = parseBlock(); - } - - if (handlers.length === 0 && !finalizer) { - throwError({}, Messages.NoCatchOrFinally); - } - - return markerApply(marker, delegate.createTryStatement(block, [], handlers, finalizer)); - } - - // 12.15 The debugger statement - - function parseDebuggerStatement() { - var marker = markerCreate(); - expectKeyword('debugger'); - - consumeSemicolon(); - - return markerApply(marker, delegate.createDebuggerStatement()); - } - - // 12 Statements - - function parseStatement() { - var type = lookahead.type, - marker, - expr, - labeledBody; - - if (type === Token.EOF) { - throwUnexpected(lookahead); - } - - if (type === Token.Punctuator) { - switch (lookahead.value) { - case ';': - return parseEmptyStatement(); - case '{': - return parseBlock(); - case '(': - return parseExpressionStatement(); - default: - break; - } - } - - if (type === Token.Keyword) { - switch (lookahead.value) { - case 'break': - return parseBreakStatement(); - case 'continue': - return parseContinueStatement(); - case 'debugger': - return parseDebuggerStatement(); - case 'do': - return parseDoWhileStatement(); - case 'for': - return parseForStatement(); - case 'function': - return parseFunctionDeclaration(); - case 'class': - return parseClassDeclaration(); - case 'if': - return parseIfStatement(); - case 'return': - return parseReturnStatement(); - case 'switch': - return parseSwitchStatement(); - case 'throw': - return parseThrowStatement(); - case 'try': - return parseTryStatement(); - case 'var': - return parseVariableStatement(); - case 'while': - return parseWhileStatement(); - case 'with': - return parseWithStatement(); - default: - break; - } - } - - if (matchAsyncFuncExprOrDecl()) { - return parseFunctionDeclaration(); - } - - marker = markerCreate(); - expr = parseExpression(); - - // 12.12 Labelled Statements - if ((expr.type === Syntax.Identifier) && match(':')) { - lex(); - - if (state.labelSet.has(expr.name)) { - throwError({}, Messages.Redeclaration, 'Label', expr.name); - } - - state.labelSet.set(expr.name, true); - labeledBody = parseStatement(); - state.labelSet["delete"](expr.name); - return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody)); - } - - consumeSemicolon(); - - return markerApply(marker, delegate.createExpressionStatement(expr)); - } - - // 13 Function Definition - - function parseConciseBody() { - if (match('{')) { - return parseFunctionSourceElements(); - } - return parseAssignmentExpression(); - } - - function parseFunctionSourceElements() { - var sourceElement, sourceElements = [], token, directive, firstRestricted, - oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, oldParenthesizedCount, - marker = markerCreate(); - - expect('{'); - - while (index < length) { - if (lookahead.type !== Token.StringLiteral) { - break; - } - token = lookahead; - - sourceElement = parseSourceElement(); - sourceElements.push(sourceElement); - if (sourceElement.expression.type !== Syntax.Literal) { - // this is not directive - break; - } - directive = source.slice(token.range[0] + 1, token.range[1] - 1); - if (directive === 'use strict') { - strict = true; - if (firstRestricted) { - throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); - } - } else { - if (!firstRestricted && token.octal) { - firstRestricted = token; - } - } - } - - oldLabelSet = state.labelSet; - oldInIteration = state.inIteration; - oldInSwitch = state.inSwitch; - oldInFunctionBody = state.inFunctionBody; - oldParenthesizedCount = state.parenthesizedCount; - - state.labelSet = new StringMap(); - state.inIteration = false; - state.inSwitch = false; - state.inFunctionBody = true; - state.parenthesizedCount = 0; - - while (index < length) { - if (match('}')) { - break; - } - sourceElement = parseSourceElement(); - if (typeof sourceElement === 'undefined') { - break; - } - sourceElements.push(sourceElement); - } - - expect('}'); - - state.labelSet = oldLabelSet; - state.inIteration = oldInIteration; - state.inSwitch = oldInSwitch; - state.inFunctionBody = oldInFunctionBody; - state.parenthesizedCount = oldParenthesizedCount; - - return markerApply(marker, delegate.createBlockStatement(sourceElements)); - } - - function validateParam(options, param, name) { - if (strict) { - if (isRestrictedWord(name)) { - options.stricted = param; - options.message = Messages.StrictParamName; - } - if (options.paramSet.has(name)) { - options.stricted = param; - options.message = Messages.StrictParamDupe; - } - } else if (!options.firstRestricted) { - if (isRestrictedWord(name)) { - options.firstRestricted = param; - options.message = Messages.StrictParamName; - } else if (isStrictModeReservedWord(name)) { - options.firstRestricted = param; - options.message = Messages.StrictReservedWord; - } else if (options.paramSet.has(name)) { - options.firstRestricted = param; - options.message = Messages.StrictParamDupe; - } - } - options.paramSet.set(name, true); - } - - function parseParam(options) { - var marker, token, rest, param, def; - - token = lookahead; - if (token.value === '...') { - token = lex(); - rest = true; - } - - if (match('[')) { - marker = markerCreate(); - param = parseArrayInitialiser(); - reinterpretAsDestructuredParameter(options, param); - if (match(':')) { - param.typeAnnotation = parseTypeAnnotation(); - markerApply(marker, param); - } - } else if (match('{')) { - marker = markerCreate(); - if (rest) { - throwError({}, Messages.ObjectPatternAsRestParameter); - } - param = parseObjectInitialiser(); - reinterpretAsDestructuredParameter(options, param); - if (match(':')) { - param.typeAnnotation = parseTypeAnnotation(); - markerApply(marker, param); - } - } else { - param = - rest - ? parseTypeAnnotatableIdentifier( - false, /* requireTypeAnnotation */ - false /* canBeOptionalParam */ - ) - : parseTypeAnnotatableIdentifier( - false, /* requireTypeAnnotation */ - true /* canBeOptionalParam */ - ); - - validateParam(options, token, token.value); - } - - if (match('=')) { - if (rest) { - throwErrorTolerant(lookahead, Messages.DefaultRestParameter); - } - lex(); - def = parseAssignmentExpression(); - ++options.defaultCount; - } - - if (rest) { - if (!match(')')) { - throwError({}, Messages.ParameterAfterRestParameter); - } - options.rest = param; - return false; - } - - options.params.push(param); - options.defaults.push(def); - return !match(')'); - } - - function parseParams(firstRestricted) { - var options, marker = markerCreate(); - - options = { - params: [], - defaultCount: 0, - defaults: [], - rest: null, - firstRestricted: firstRestricted - }; - - expect('('); - - if (!match(')')) { - options.paramSet = new StringMap(); - while (index < length) { - if (!parseParam(options)) { - break; - } - expect(','); - } - } - - expect(')'); - - if (options.defaultCount === 0) { - options.defaults = []; - } - - if (match(':')) { - options.returnType = parseTypeAnnotation(); - } - - return markerApply(marker, options); - } - - function parseFunctionDeclaration() { - var id, body, token, tmp, firstRestricted, message, generator, isAsync, - previousStrict, previousYieldAllowed, previousAwaitAllowed, - marker = markerCreate(), typeParameters; - - isAsync = false; - if (matchAsync()) { - lex(); - isAsync = true; - } - - expectKeyword('function'); - - generator = false; - if (match('*')) { - lex(); - generator = true; - } - - token = lookahead; - - id = parseVariableIdentifier(); - - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - - if (strict) { - if (isRestrictedWord(token.value)) { - throwErrorTolerant(token, Messages.StrictFunctionName); - } - } else { - if (isRestrictedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictFunctionName; - } else if (isStrictModeReservedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictReservedWord; - } - } - - tmp = parseParams(firstRestricted); - firstRestricted = tmp.firstRestricted; - if (tmp.message) { - message = tmp.message; - } - - previousStrict = strict; - previousYieldAllowed = state.yieldAllowed; - state.yieldAllowed = generator; - previousAwaitAllowed = state.awaitAllowed; - state.awaitAllowed = isAsync; - - body = parseFunctionSourceElements(); - - if (strict && firstRestricted) { - throwError(firstRestricted, message); - } - if (strict && tmp.stricted) { - throwErrorTolerant(tmp.stricted, message); - } - strict = previousStrict; - state.yieldAllowed = previousYieldAllowed; - state.awaitAllowed = previousAwaitAllowed; - - return markerApply( - marker, - delegate.createFunctionDeclaration( - id, - tmp.params, - tmp.defaults, - body, - tmp.rest, - generator, - false, - isAsync, - tmp.returnType, - typeParameters - ) - ); - } - - function parseFunctionExpression() { - var token, id = null, firstRestricted, message, tmp, body, generator, isAsync, - previousStrict, previousYieldAllowed, previousAwaitAllowed, - marker = markerCreate(), typeParameters; - - isAsync = false; - if (matchAsync()) { - lex(); - isAsync = true; - } - - expectKeyword('function'); - - generator = false; - - if (match('*')) { - lex(); - generator = true; - } - - if (!match('(')) { - if (!match('<')) { - token = lookahead; - id = parseVariableIdentifier(); - - if (strict) { - if (isRestrictedWord(token.value)) { - throwErrorTolerant(token, Messages.StrictFunctionName); - } - } else { - if (isRestrictedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictFunctionName; - } else if (isStrictModeReservedWord(token.value)) { - firstRestricted = token; - message = Messages.StrictReservedWord; - } - } - } - - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - } - - tmp = parseParams(firstRestricted); - firstRestricted = tmp.firstRestricted; - if (tmp.message) { - message = tmp.message; - } - - previousStrict = strict; - previousYieldAllowed = state.yieldAllowed; - state.yieldAllowed = generator; - previousAwaitAllowed = state.awaitAllowed; - state.awaitAllowed = isAsync; - - body = parseFunctionSourceElements(); - - if (strict && firstRestricted) { - throwError(firstRestricted, message); - } - if (strict && tmp.stricted) { - throwErrorTolerant(tmp.stricted, message); - } - strict = previousStrict; - state.yieldAllowed = previousYieldAllowed; - state.awaitAllowed = previousAwaitAllowed; - - return markerApply( - marker, - delegate.createFunctionExpression( - id, - tmp.params, - tmp.defaults, - body, - tmp.rest, - generator, - false, - isAsync, - tmp.returnType, - typeParameters - ) - ); - } - - function parseYieldExpression() { - var delegateFlag, expr, marker = markerCreate(); - - expectKeyword('yield', !strict); - - delegateFlag = false; - if (match('*')) { - lex(); - delegateFlag = true; - } - - expr = parseAssignmentExpression(); - - return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag)); - } - - function parseAwaitExpression() { - var expr, marker = markerCreate(); - expectContextualKeyword('await'); - expr = parseAssignmentExpression(); - return markerApply(marker, delegate.createAwaitExpression(expr)); - } - - // 14 Functions and classes - - // 14.1 Functions is defined above (13 in ES5) - // 14.2 Arrow Functions Definitions is defined in (7.3 assignments) - - // 14.3 Method Definitions - // 14.3.7 - function specialMethod(methodDefinition) { - return methodDefinition.kind === 'get' || - methodDefinition.kind === 'set' || - methodDefinition.value.generator; - } - - function parseMethodDefinition(key, isStatic, generator, computed) { - var token, param, propType, - isAsync, typeParameters, tokenValue, returnType; - - propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype; - - if (generator) { - return delegate.createMethodDefinition( - propType, - '', - key, - parsePropertyMethodFunction({ generator: true }), - computed - ); - } - - tokenValue = key.type === 'Identifier' && key.name; - - if (tokenValue === 'get' && !match('(')) { - key = parseObjectPropertyKey(); - - expect('('); - expect(')'); - if (match(':')) { - returnType = parseTypeAnnotation(); - } - return delegate.createMethodDefinition( - propType, - 'get', - key, - parsePropertyFunction({ generator: false, returnType: returnType }), - computed - ); - } - if (tokenValue === 'set' && !match('(')) { - key = parseObjectPropertyKey(); - - expect('('); - token = lookahead; - param = [ parseTypeAnnotatableIdentifier() ]; - expect(')'); - if (match(':')) { - returnType = parseTypeAnnotation(); - } - return delegate.createMethodDefinition( - propType, - 'set', - key, - parsePropertyFunction({ - params: param, - generator: false, - name: token, - returnType: returnType - }), - computed - ); - } - - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - - isAsync = tokenValue === 'async' && !match('('); - if (isAsync) { - key = parseObjectPropertyKey(); - } - - return delegate.createMethodDefinition( - propType, - '', - key, - parsePropertyMethodFunction({ - generator: false, - async: isAsync, - typeParameters: typeParameters - }), - computed - ); - } - - function parseClassProperty(key, computed, isStatic) { - var typeAnnotation; - - typeAnnotation = parseTypeAnnotation(); - expect(';'); - - return delegate.createClassProperty( - key, - typeAnnotation, - computed, - isStatic - ); - } - - function parseClassElement() { - var computed = false, generator = false, key, marker = markerCreate(), - isStatic = false, possiblyOpenBracketToken; - if (match(';')) { - lex(); - return undefined; - } - - if (lookahead.value === 'static') { - lex(); - isStatic = true; - } - - if (match('*')) { - lex(); - generator = true; - } - - possiblyOpenBracketToken = lookahead; - if (matchContextualKeyword('get') || matchContextualKeyword('set')) { - possiblyOpenBracketToken = lookahead2(); - } - - if (possiblyOpenBracketToken.type === Token.Punctuator - && possiblyOpenBracketToken.value === '[') { - computed = true; - } - - key = parseObjectPropertyKey(); - - if (!generator && lookahead.value === ':') { - return markerApply(marker, parseClassProperty(key, computed, isStatic)); - } - - return markerApply(marker, parseMethodDefinition( - key, - isStatic, - generator, - computed - )); - } - - function parseClassBody() { - var classElement, classElements = [], existingProps = {}, - marker = markerCreate(), propName, propType; - - existingProps[ClassPropertyType["static"]] = new StringMap(); - existingProps[ClassPropertyType.prototype] = new StringMap(); - - expect('{'); - - while (index < length) { - if (match('}')) { - break; - } - classElement = parseClassElement(existingProps); - - if (typeof classElement !== 'undefined') { - classElements.push(classElement); - - propName = !classElement.computed && getFieldName(classElement.key); - if (propName !== false) { - propType = classElement["static"] ? - ClassPropertyType["static"] : - ClassPropertyType.prototype; - - if (classElement.type === Syntax.MethodDefinition) { - if (propName === 'constructor' && !classElement["static"]) { - if (specialMethod(classElement)) { - throwError(classElement, Messages.IllegalClassConstructorProperty); - } - if (existingProps[ClassPropertyType.prototype].has('constructor')) { - throwError(classElement.key, Messages.IllegalDuplicateClassProperty); - } - } - existingProps[propType].set(propName, true); - } - } - } - } - - expect('}'); - - return markerApply(marker, delegate.createClassBody(classElements)); - } - - function parseClassImplements() { - var id, implemented = [], marker, typeParameters; - if (strict) { - expectKeyword('implements'); - } else { - expectContextualKeyword('implements'); - } - while (index < length) { - marker = markerCreate(); - id = parseVariableIdentifier(); - if (match('<')) { - typeParameters = parseTypeParameterInstantiation(); - } else { - typeParameters = null; - } - implemented.push(markerApply(marker, delegate.createClassImplements( - id, - typeParameters - ))); - if (!match(',')) { - break; - } - expect(','); - } - return implemented; - } - - function parseClassExpression() { - var id, implemented, previousYieldAllowed, superClass = null, - superTypeParameters, marker = markerCreate(), typeParameters, - matchImplements; - - expectKeyword('class'); - - matchImplements = - strict - ? matchKeyword('implements') - : matchContextualKeyword('implements'); - - if (!matchKeyword('extends') && !matchImplements && !match('{')) { - id = parseVariableIdentifier(); - } - - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - - if (matchKeyword('extends')) { - expectKeyword('extends'); - previousYieldAllowed = state.yieldAllowed; - state.yieldAllowed = false; - superClass = parseLeftHandSideExpressionAllowCall(); - if (match('<')) { - superTypeParameters = parseTypeParameterInstantiation(); - } - state.yieldAllowed = previousYieldAllowed; - } - - if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) { - implemented = parseClassImplements(); - } - - return markerApply(marker, delegate.createClassExpression( - id, - superClass, - parseClassBody(), - typeParameters, - superTypeParameters, - implemented - )); - } - - function parseClassDeclaration() { - var id, implemented, previousYieldAllowed, superClass = null, - superTypeParameters, marker = markerCreate(), typeParameters; - - expectKeyword('class'); - - id = parseVariableIdentifier(); - - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - - if (matchKeyword('extends')) { - expectKeyword('extends'); - previousYieldAllowed = state.yieldAllowed; - state.yieldAllowed = false; - superClass = parseLeftHandSideExpressionAllowCall(); - if (match('<')) { - superTypeParameters = parseTypeParameterInstantiation(); - } - state.yieldAllowed = previousYieldAllowed; - } - - if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) { - implemented = parseClassImplements(); - } - - return markerApply(marker, delegate.createClassDeclaration( - id, - superClass, - parseClassBody(), - typeParameters, - superTypeParameters, - implemented - )); - } - - // 15 Program - - function parseSourceElement() { - var token; - if (lookahead.type === Token.Keyword) { - switch (lookahead.value) { - case 'const': - case 'let': - return parseConstLetDeclaration(lookahead.value); - case 'function': - return parseFunctionDeclaration(); - case 'export': - throwErrorTolerant({}, Messages.IllegalExportDeclaration); - return parseExportDeclaration(); - case 'import': - throwErrorTolerant({}, Messages.IllegalImportDeclaration); - return parseImportDeclaration(); - case 'interface': - if (lookahead2().type === Token.Identifier) { - return parseInterface(); - } - return parseStatement(); - default: - return parseStatement(); - } - } - - if (matchContextualKeyword('type') - && lookahead2().type === Token.Identifier) { - return parseTypeAlias(); - } - - if (matchContextualKeyword('interface') - && lookahead2().type === Token.Identifier) { - return parseInterface(); - } - - if (matchContextualKeyword('declare')) { - token = lookahead2(); - if (token.type === Token.Keyword) { - switch (token.value) { - case 'class': - return parseDeclareClass(); - case 'function': - return parseDeclareFunction(); - case 'var': - return parseDeclareVariable(); - } - } else if (token.type === Token.Identifier - && token.value === 'module') { - return parseDeclareModule(); - } - } - - if (lookahead.type !== Token.EOF) { - return parseStatement(); - } - } - - function parseProgramElement() { - var isModule = extra.sourceType === 'module' || extra.sourceType === 'nonStrictModule'; - - if (isModule && lookahead.type === Token.Keyword) { - switch (lookahead.value) { - case 'export': - return parseExportDeclaration(); - case 'import': - return parseImportDeclaration(); - } - } - - return parseSourceElement(); - } - - function parseProgramElements() { - var sourceElement, sourceElements = [], token, directive, firstRestricted; - - while (index < length) { - token = lookahead; - if (token.type !== Token.StringLiteral) { - break; - } - - sourceElement = parseProgramElement(); - sourceElements.push(sourceElement); - if (sourceElement.expression.type !== Syntax.Literal) { - // this is not directive - break; - } - directive = source.slice(token.range[0] + 1, token.range[1] - 1); - if (directive === 'use strict') { - strict = true; - if (firstRestricted) { - throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral); - } - } else { - if (!firstRestricted && token.octal) { - firstRestricted = token; - } - } - } - - while (index < length) { - sourceElement = parseProgramElement(); - if (typeof sourceElement === 'undefined') { - break; - } - sourceElements.push(sourceElement); - } - return sourceElements; - } - - function parseProgram() { - var body, marker = markerCreate(); - strict = extra.sourceType === 'module'; - peek(); - body = parseProgramElements(); - return markerApply(marker, delegate.createProgram(body)); - } - - // 16 JSX - - XHTMLEntities = { - quot: '\u0022', - amp: '&', - apos: '\u0027', - lt: '<', - gt: '>', - nbsp: '\u00A0', - iexcl: '\u00A1', - cent: '\u00A2', - pound: '\u00A3', - curren: '\u00A4', - yen: '\u00A5', - brvbar: '\u00A6', - sect: '\u00A7', - uml: '\u00A8', - copy: '\u00A9', - ordf: '\u00AA', - laquo: '\u00AB', - not: '\u00AC', - shy: '\u00AD', - reg: '\u00AE', - macr: '\u00AF', - deg: '\u00B0', - plusmn: '\u00B1', - sup2: '\u00B2', - sup3: '\u00B3', - acute: '\u00B4', - micro: '\u00B5', - para: '\u00B6', - middot: '\u00B7', - cedil: '\u00B8', - sup1: '\u00B9', - ordm: '\u00BA', - raquo: '\u00BB', - frac14: '\u00BC', - frac12: '\u00BD', - frac34: '\u00BE', - iquest: '\u00BF', - Agrave: '\u00C0', - Aacute: '\u00C1', - Acirc: '\u00C2', - Atilde: '\u00C3', - Auml: '\u00C4', - Aring: '\u00C5', - AElig: '\u00C6', - Ccedil: '\u00C7', - Egrave: '\u00C8', - Eacute: '\u00C9', - Ecirc: '\u00CA', - Euml: '\u00CB', - Igrave: '\u00CC', - Iacute: '\u00CD', - Icirc: '\u00CE', - Iuml: '\u00CF', - ETH: '\u00D0', - Ntilde: '\u00D1', - Ograve: '\u00D2', - Oacute: '\u00D3', - Ocirc: '\u00D4', - Otilde: '\u00D5', - Ouml: '\u00D6', - times: '\u00D7', - Oslash: '\u00D8', - Ugrave: '\u00D9', - Uacute: '\u00DA', - Ucirc: '\u00DB', - Uuml: '\u00DC', - Yacute: '\u00DD', - THORN: '\u00DE', - szlig: '\u00DF', - agrave: '\u00E0', - aacute: '\u00E1', - acirc: '\u00E2', - atilde: '\u00E3', - auml: '\u00E4', - aring: '\u00E5', - aelig: '\u00E6', - ccedil: '\u00E7', - egrave: '\u00E8', - eacute: '\u00E9', - ecirc: '\u00EA', - euml: '\u00EB', - igrave: '\u00EC', - iacute: '\u00ED', - icirc: '\u00EE', - iuml: '\u00EF', - eth: '\u00F0', - ntilde: '\u00F1', - ograve: '\u00F2', - oacute: '\u00F3', - ocirc: '\u00F4', - otilde: '\u00F5', - ouml: '\u00F6', - divide: '\u00F7', - oslash: '\u00F8', - ugrave: '\u00F9', - uacute: '\u00FA', - ucirc: '\u00FB', - uuml: '\u00FC', - yacute: '\u00FD', - thorn: '\u00FE', - yuml: '\u00FF', - OElig: '\u0152', - oelig: '\u0153', - Scaron: '\u0160', - scaron: '\u0161', - Yuml: '\u0178', - fnof: '\u0192', - circ: '\u02C6', - tilde: '\u02DC', - Alpha: '\u0391', - Beta: '\u0392', - Gamma: '\u0393', - Delta: '\u0394', - Epsilon: '\u0395', - Zeta: '\u0396', - Eta: '\u0397', - Theta: '\u0398', - Iota: '\u0399', - Kappa: '\u039A', - Lambda: '\u039B', - Mu: '\u039C', - Nu: '\u039D', - Xi: '\u039E', - Omicron: '\u039F', - Pi: '\u03A0', - Rho: '\u03A1', - Sigma: '\u03A3', - Tau: '\u03A4', - Upsilon: '\u03A5', - Phi: '\u03A6', - Chi: '\u03A7', - Psi: '\u03A8', - Omega: '\u03A9', - alpha: '\u03B1', - beta: '\u03B2', - gamma: '\u03B3', - delta: '\u03B4', - epsilon: '\u03B5', - zeta: '\u03B6', - eta: '\u03B7', - theta: '\u03B8', - iota: '\u03B9', - kappa: '\u03BA', - lambda: '\u03BB', - mu: '\u03BC', - nu: '\u03BD', - xi: '\u03BE', - omicron: '\u03BF', - pi: '\u03C0', - rho: '\u03C1', - sigmaf: '\u03C2', - sigma: '\u03C3', - tau: '\u03C4', - upsilon: '\u03C5', - phi: '\u03C6', - chi: '\u03C7', - psi: '\u03C8', - omega: '\u03C9', - thetasym: '\u03D1', - upsih: '\u03D2', - piv: '\u03D6', - ensp: '\u2002', - emsp: '\u2003', - thinsp: '\u2009', - zwnj: '\u200C', - zwj: '\u200D', - lrm: '\u200E', - rlm: '\u200F', - ndash: '\u2013', - mdash: '\u2014', - lsquo: '\u2018', - rsquo: '\u2019', - sbquo: '\u201A', - ldquo: '\u201C', - rdquo: '\u201D', - bdquo: '\u201E', - dagger: '\u2020', - Dagger: '\u2021', - bull: '\u2022', - hellip: '\u2026', - permil: '\u2030', - prime: '\u2032', - Prime: '\u2033', - lsaquo: '\u2039', - rsaquo: '\u203A', - oline: '\u203E', - frasl: '\u2044', - euro: '\u20AC', - image: '\u2111', - weierp: '\u2118', - real: '\u211C', - trade: '\u2122', - alefsym: '\u2135', - larr: '\u2190', - uarr: '\u2191', - rarr: '\u2192', - darr: '\u2193', - harr: '\u2194', - crarr: '\u21B5', - lArr: '\u21D0', - uArr: '\u21D1', - rArr: '\u21D2', - dArr: '\u21D3', - hArr: '\u21D4', - forall: '\u2200', - part: '\u2202', - exist: '\u2203', - empty: '\u2205', - nabla: '\u2207', - isin: '\u2208', - notin: '\u2209', - ni: '\u220B', - prod: '\u220F', - sum: '\u2211', - minus: '\u2212', - lowast: '\u2217', - radic: '\u221A', - prop: '\u221D', - infin: '\u221E', - ang: '\u2220', - and: '\u2227', - or: '\u2228', - cap: '\u2229', - cup: '\u222A', - 'int': '\u222B', - there4: '\u2234', - sim: '\u223C', - cong: '\u2245', - asymp: '\u2248', - ne: '\u2260', - equiv: '\u2261', - le: '\u2264', - ge: '\u2265', - sub: '\u2282', - sup: '\u2283', - nsub: '\u2284', - sube: '\u2286', - supe: '\u2287', - oplus: '\u2295', - otimes: '\u2297', - perp: '\u22A5', - sdot: '\u22C5', - lceil: '\u2308', - rceil: '\u2309', - lfloor: '\u230A', - rfloor: '\u230B', - lang: '\u2329', - rang: '\u232A', - loz: '\u25CA', - spades: '\u2660', - clubs: '\u2663', - hearts: '\u2665', - diams: '\u2666' - }; - - function getQualifiedJSXName(object) { - if (object.type === Syntax.JSXIdentifier) { - return object.name; - } - if (object.type === Syntax.JSXNamespacedName) { - return object.namespace.name + ':' + object.name.name; - } - /* istanbul ignore else */ - if (object.type === Syntax.JSXMemberExpression) { - return ( - getQualifiedJSXName(object.object) + '.' + - getQualifiedJSXName(object.property) - ); - } - /* istanbul ignore next */ - throwUnexpected(object); - } - - function isJSXIdentifierStart(ch) { - // exclude backslash (\) - return (ch !== 92) && isIdentifierStart(ch); - } - - function isJSXIdentifierPart(ch) { - // exclude backslash (\) and add hyphen (-) - return (ch !== 92) && (ch === 45 || isIdentifierPart(ch)); - } - - function scanJSXIdentifier() { - var ch, start, value = ''; - - start = index; - while (index < length) { - ch = source.charCodeAt(index); - if (!isJSXIdentifierPart(ch)) { - break; - } - value += source[index++]; - } - - return { - type: Token.JSXIdentifier, - value: value, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - function scanJSXEntity() { - var ch, str = '', start = index, count = 0, code; - ch = source[index]; - assert(ch === '&', 'Entity must start with an ampersand'); - index++; - while (index < length && count++ < 10) { - ch = source[index++]; - if (ch === ';') { - break; - } - str += ch; - } - - // Well-formed entity (ending was found). - if (ch === ';') { - // Numeric entity. - if (str[0] === '#') { - if (str[1] === 'x') { - code = +('0' + str.substr(1)); - } else { - // Removing leading zeros in order to avoid treating as octal in old browsers. - code = +str.substr(1).replace(Regex.LeadingZeros, ''); - } - - if (!isNaN(code)) { - return String.fromCharCode(code); - } - /* istanbul ignore else */ - } else if (XHTMLEntities[str]) { - return XHTMLEntities[str]; - } - } - - // Treat non-entity sequences as regular text. - index = start + 1; - return '&'; - } - - function scanJSXText(stopChars) { - var ch, str = '', start; - start = index; - while (index < length) { - ch = source[index]; - if (stopChars.indexOf(ch) !== -1) { - break; - } - if (ch === '&') { - str += scanJSXEntity(); - } else { - index++; - if (ch === '\r' && source[index] === '\n') { - str += ch; - ch = source[index]; - index++; - } - if (isLineTerminator(ch.charCodeAt(0))) { - ++lineNumber; - lineStart = index; - } - str += ch; - } - } - return { - type: Token.JSXText, - value: str, - lineNumber: lineNumber, - lineStart: lineStart, - range: [start, index] - }; - } - - function scanJSXStringLiteral() { - var innerToken, quote, start; - - quote = source[index]; - assert((quote === '\'' || quote === '"'), - 'String literal must starts with a quote'); - - start = index; - ++index; - - innerToken = scanJSXText([quote]); - - if (quote !== source[index]) { - throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); - } - - ++index; - - innerToken.range = [start, index]; - - return innerToken; - } - - /** - * Between JSX opening and closing tags (e.g. HERE), anything that - * is not another JSX tag and is not an expression wrapped by {} is text. - */ - function advanceJSXChild() { - var ch = source.charCodeAt(index); - - // '<' 60, '>' 62, '{' 123, '}' 125 - if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) { - return scanJSXText(['<', '>', '{', '}']); - } - - return scanPunctuator(); - } - - function parseJSXIdentifier() { - var token, marker = markerCreate(); - - if (lookahead.type !== Token.JSXIdentifier) { - throwUnexpected(lookahead); - } - - token = lex(); - return markerApply(marker, delegate.createJSXIdentifier(token.value)); - } - - function parseJSXNamespacedName() { - var namespace, name, marker = markerCreate(); - - namespace = parseJSXIdentifier(); - expect(':'); - name = parseJSXIdentifier(); - - return markerApply(marker, delegate.createJSXNamespacedName(namespace, name)); - } - - function parseJSXMemberExpression() { - var marker = markerCreate(), - expr = parseJSXIdentifier(); - - while (match('.')) { - lex(); - expr = markerApply(marker, delegate.createJSXMemberExpression(expr, parseJSXIdentifier())); - } - - return expr; - } - - function parseJSXElementName() { - if (lookahead2().value === ':') { - return parseJSXNamespacedName(); - } - if (lookahead2().value === '.') { - return parseJSXMemberExpression(); - } - - return parseJSXIdentifier(); - } - - function parseJSXAttributeName() { - if (lookahead2().value === ':') { - return parseJSXNamespacedName(); - } - - return parseJSXIdentifier(); - } - - function parseJSXAttributeValue() { - var value, marker; - if (match('{')) { - value = parseJSXExpressionContainer(); - if (value.expression.type === Syntax.JSXEmptyExpression) { - throwError( - value, - 'JSX attributes must only be assigned a non-empty ' + - 'expression' - ); - } - } else if (match('<')) { - value = parseJSXElement(); - } else if (lookahead.type === Token.JSXText) { - marker = markerCreate(); - value = markerApply(marker, delegate.createLiteral(lex())); - } else { - throwError({}, Messages.InvalidJSXAttributeValue); - } - return value; - } - - function parseJSXEmptyExpression() { - var marker = markerCreatePreserveWhitespace(); - while (source.charAt(index) !== '}') { - index++; - } - return markerApply(marker, delegate.createJSXEmptyExpression()); - } - - function parseJSXExpressionContainer() { - var expression, origInJSXChild, origInJSXTag, marker = markerCreate(); - - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - state.inJSXChild = false; - state.inJSXTag = false; - - expect('{'); - - if (match('}')) { - expression = parseJSXEmptyExpression(); - } else { - expression = parseExpression(); - } - - state.inJSXChild = origInJSXChild; - state.inJSXTag = origInJSXTag; - - expect('}'); - - return markerApply(marker, delegate.createJSXExpressionContainer(expression)); - } - - function parseJSXSpreadAttribute() { - var expression, origInJSXChild, origInJSXTag, marker = markerCreate(); - - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - state.inJSXChild = false; - state.inJSXTag = false; - - expect('{'); - expect('...'); - - expression = parseAssignmentExpression(); - - state.inJSXChild = origInJSXChild; - state.inJSXTag = origInJSXTag; - - expect('}'); - - return markerApply(marker, delegate.createJSXSpreadAttribute(expression)); - } - - function parseJSXAttribute() { - var name, marker; - - if (match('{')) { - return parseJSXSpreadAttribute(); - } - - marker = markerCreate(); - - name = parseJSXAttributeName(); - - // HTML empty attribute - if (match('=')) { - lex(); - return markerApply(marker, delegate.createJSXAttribute(name, parseJSXAttributeValue())); - } - - return markerApply(marker, delegate.createJSXAttribute(name)); - } - - function parseJSXChild() { - var token, marker; - if (match('{')) { - token = parseJSXExpressionContainer(); - } else if (lookahead.type === Token.JSXText) { - marker = markerCreatePreserveWhitespace(); - token = markerApply(marker, delegate.createLiteral(lex())); - } else if (match('<')) { - token = parseJSXElement(); - } else { - throwUnexpected(lookahead); - } - return token; - } - - function parseJSXClosingElement() { - var name, origInJSXChild, origInJSXTag, marker = markerCreate(); - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - state.inJSXChild = false; - state.inJSXTag = true; - expect('<'); - expect('/'); - name = parseJSXElementName(); - // Because advance() (called by lex() called by expect()) expects there - // to be a valid token after >, it needs to know whether to look for a - // standard JS token or an JSX text node - state.inJSXChild = origInJSXChild; - state.inJSXTag = origInJSXTag; - expect('>'); - return markerApply(marker, delegate.createJSXClosingElement(name)); - } - - function parseJSXOpeningElement() { - var name, attributes = [], selfClosing = false, origInJSXChild, origInJSXTag, marker = markerCreate(); - - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - state.inJSXChild = false; - state.inJSXTag = true; - - expect('<'); - - name = parseJSXElementName(); - - while (index < length && - lookahead.value !== '/' && - lookahead.value !== '>') { - attributes.push(parseJSXAttribute()); - } - - state.inJSXTag = origInJSXTag; - - if (lookahead.value === '/') { - expect('/'); - // Because advance() (called by lex() called by expect()) expects - // there to be a valid token after >, it needs to know whether to - // look for a standard JS token or an JSX text node - state.inJSXChild = origInJSXChild; - expect('>'); - selfClosing = true; - } else { - state.inJSXChild = true; - expect('>'); - } - return markerApply(marker, delegate.createJSXOpeningElement(name, attributes, selfClosing)); - } - - function parseJSXElement() { - var openingElement, closingElement = null, children = [], origInJSXChild, origInJSXTag, marker = markerCreate(); - - origInJSXChild = state.inJSXChild; - origInJSXTag = state.inJSXTag; - openingElement = parseJSXOpeningElement(); - - if (!openingElement.selfClosing) { - while (index < length) { - state.inJSXChild = false; // Call lookahead2() with inJSXChild = false because one
two
; - // - // the default error message is a bit incomprehensible. Since it's - // rarely (never?) useful to write a less-than sign after an JSX - // element, we disallow it here in the parser in order to provide a - // better error message. (In the rare case that the less-than operator - // was intended, the left tag can be wrapped in parentheses.) - if (!origInJSXChild && match('<')) { - throwError(lookahead, Messages.AdjacentJSXElements); - } - - return markerApply(marker, delegate.createJSXElement(openingElement, closingElement, children)); - } - - function parseTypeAlias() { - var id, marker = markerCreate(), typeParameters = null, right; - expectContextualKeyword('type'); - id = parseVariableIdentifier(); - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - expect('='); - right = parseType(); - consumeSemicolon(); - return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right)); - } - - function parseInterfaceExtends() { - var marker = markerCreate(), id, typeParameters = null; - - id = parseVariableIdentifier(); - if (match('<')) { - typeParameters = parseTypeParameterInstantiation(); - } - - return markerApply(marker, delegate.createInterfaceExtends( - id, - typeParameters - )); - } - - function parseInterfaceish(marker, allowStatic) { - var body, bodyMarker, extended = [], id, - typeParameters = null; - - id = parseVariableIdentifier(); - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - - if (matchKeyword('extends')) { - expectKeyword('extends'); - - while (index < length) { - extended.push(parseInterfaceExtends()); - if (!match(',')) { - break; - } - expect(','); - } - } - - bodyMarker = markerCreate(); - body = markerApply(bodyMarker, parseObjectType(allowStatic)); - - return markerApply(marker, delegate.createInterface( - id, - typeParameters, - body, - extended - )); - } - - function parseInterface() { - var marker = markerCreate(); - - if (strict) { - expectKeyword('interface'); - } else { - expectContextualKeyword('interface'); - } - - return parseInterfaceish(marker, /* allowStatic */false); - } - - function parseDeclareClass() { - var marker = markerCreate(), ret; - expectContextualKeyword('declare'); - expectKeyword('class'); - - ret = parseInterfaceish(marker, /* allowStatic */true); - ret.type = Syntax.DeclareClass; - return ret; - } - - function parseDeclareFunction() { - var id, idMarker, - marker = markerCreate(), params, returnType, rest, tmp, - typeParameters = null, value, valueMarker; - - expectContextualKeyword('declare'); - expectKeyword('function'); - idMarker = markerCreate(); - id = parseVariableIdentifier(); - - valueMarker = markerCreate(); - if (match('<')) { - typeParameters = parseTypeParameterDeclaration(); - } - expect('('); - tmp = parseFunctionTypeParams(); - params = tmp.params; - rest = tmp.rest; - expect(')'); - - expect(':'); - returnType = parseType(); - - value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation( - params, - returnType, - rest, - typeParameters - )); - - id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation( - value - )); - markerApply(idMarker, id); - - consumeSemicolon(); - - return markerApply(marker, delegate.createDeclareFunction( - id - )); - } - - function parseDeclareVariable() { - var id, marker = markerCreate(); - expectContextualKeyword('declare'); - expectKeyword('var'); - id = parseTypeAnnotatableIdentifier(); - - consumeSemicolon(); - - return markerApply(marker, delegate.createDeclareVariable( - id - )); - } - - function parseDeclareModule() { - var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token; - expectContextualKeyword('declare'); - expectContextualKeyword('module'); - - if (lookahead.type === Token.StringLiteral) { - if (strict && lookahead.octal) { - throwErrorTolerant(lookahead, Messages.StrictOctalLiteral); - } - idMarker = markerCreate(); - id = markerApply(idMarker, delegate.createLiteral(lex())); - } else { - id = parseVariableIdentifier(); - } - - bodyMarker = markerCreate(); - expect('{'); - while (index < length && !match('}')) { - token = lookahead2(); - switch (token.value) { - case 'class': - body.push(parseDeclareClass()); - break; - case 'function': - body.push(parseDeclareFunction()); - break; - case 'var': - body.push(parseDeclareVariable()); - break; - default: - throwUnexpected(lookahead); - } - } - expect('}'); - - return markerApply(marker, delegate.createDeclareModule( - id, - markerApply(bodyMarker, delegate.createBlockStatement(body)) - )); - } - - function collectToken() { - var loc, token, range, value, entry; - - /* istanbul ignore else */ - if (!state.inJSXChild) { - skipComment(); - } - - loc = { - start: { - line: lineNumber, - column: index - lineStart - } - }; - - token = extra.advance(); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - - if (token.type !== Token.EOF) { - range = [token.range[0], token.range[1]]; - value = source.slice(token.range[0], token.range[1]); - entry = { - type: TokenName[token.type], - value: value, - range: range, - loc: loc - }; - if (token.regex) { - entry.regex = { - pattern: token.regex.pattern, - flags: token.regex.flags - }; - } - extra.tokens.push(entry); - } - - return token; - } - - function collectRegex() { - var pos, loc, regex, token; - - skipComment(); - - pos = index; - loc = { - start: { - line: lineNumber, - column: index - lineStart - } - }; - - regex = extra.scanRegExp(); - loc.end = { - line: lineNumber, - column: index - lineStart - }; - - if (!extra.tokenize) { - /* istanbul ignore next */ - // Pop the previous token, which is likely '/' or '/=' - if (extra.tokens.length > 0) { - token = extra.tokens[extra.tokens.length - 1]; - if (token.range[0] === pos && token.type === 'Punctuator') { - if (token.value === '/' || token.value === '/=') { - extra.tokens.pop(); - } - } - } - - extra.tokens.push({ - type: 'RegularExpression', - value: regex.literal, - regex: regex.regex, - range: [pos, index], - loc: loc - }); - } - - return regex; - } - - function filterTokenLocation() { - var i, entry, token, tokens = []; - - for (i = 0; i < extra.tokens.length; ++i) { - entry = extra.tokens[i]; - token = { - type: entry.type, - value: entry.value - }; - if (entry.regex) { - token.regex = { - pattern: entry.regex.pattern, - flags: entry.regex.flags - }; - } - if (extra.range) { - token.range = entry.range; - } - if (extra.loc) { - token.loc = entry.loc; - } - tokens.push(token); - } - - extra.tokens = tokens; - } - - function patch() { - if (typeof extra.tokens !== 'undefined') { - extra.advance = advance; - extra.scanRegExp = scanRegExp; - - advance = collectToken; - scanRegExp = collectRegex; - } - } - - function unpatch() { - if (typeof extra.scanRegExp === 'function') { - advance = extra.advance; - scanRegExp = extra.scanRegExp; - } - } - - // This is used to modify the delegate. - - function extend(object, properties) { - var entry, result = {}; - - for (entry in object) { - /* istanbul ignore else */ - if (object.hasOwnProperty(entry)) { - result[entry] = object[entry]; - } - } - - for (entry in properties) { - /* istanbul ignore else */ - if (properties.hasOwnProperty(entry)) { - result[entry] = properties[entry]; - } - } - - return result; - } - - function tokenize(code, options) { - var toString, - token, - tokens; - - toString = String; - if (typeof code !== 'string' && !(code instanceof String)) { - code = toString(code); - } - - delegate = SyntaxTreeDelegate; - source = code; - index = 0; - lineNumber = (source.length > 0) ? 1 : 0; - lineStart = 0; - length = source.length; - lookahead = null; - state = { - allowKeyword: true, - allowIn: true, - labelSet: new StringMap(), - inFunctionBody: false, - inIteration: false, - inSwitch: false, - lastCommentStart: -1 - }; - - extra = {}; - - // Options matching. - options = options || {}; - - // Of course we collect tokens here. - options.tokens = true; - extra.tokens = []; - extra.tokenize = true; - // The following two fields are necessary to compute the Regex tokens. - extra.openParenToken = -1; - extra.openCurlyToken = -1; - - extra.range = (typeof options.range === 'boolean') && options.range; - extra.loc = (typeof options.loc === 'boolean') && options.loc; - - if (typeof options.comment === 'boolean' && options.comment) { - extra.comments = []; - } - if (typeof options.tolerant === 'boolean' && options.tolerant) { - extra.errors = []; - } - - patch(); - - try { - peek(); - if (lookahead.type === Token.EOF) { - return extra.tokens; - } - - token = lex(); - while (lookahead.type !== Token.EOF) { - try { - token = lex(); - } catch (lexError) { - token = lookahead; - if (extra.errors) { - extra.errors.push(lexError); - // We have to break on the first error - // to avoid infinite loops. - break; - } else { - throw lexError; - } - } - } - - filterTokenLocation(); - tokens = extra.tokens; - if (typeof extra.comments !== 'undefined') { - tokens.comments = extra.comments; - } - if (typeof extra.errors !== 'undefined') { - tokens.errors = extra.errors; - } - } catch (e) { - throw e; - } finally { - unpatch(); - extra = {}; - } - return tokens; - } - - function parse(code, options) { - var program, toString; - - toString = String; - if (typeof code !== 'string' && !(code instanceof String)) { - code = toString(code); - } - - delegate = SyntaxTreeDelegate; - source = code; - index = 0; - lineNumber = (source.length > 0) ? 1 : 0; - lineStart = 0; - length = source.length; - lookahead = null; - state = { - allowKeyword: false, - allowIn: true, - labelSet: new StringMap(), - parenthesizedCount: 0, - inFunctionBody: false, - inIteration: false, - inSwitch: false, - inJSXChild: false, - inJSXTag: false, - inType: false, - lastCommentStart: -1, - yieldAllowed: false, - awaitAllowed: false - }; - - extra = {}; - if (typeof options !== 'undefined') { - extra.range = (typeof options.range === 'boolean') && options.range; - extra.loc = (typeof options.loc === 'boolean') && options.loc; - extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; - - if (extra.loc && options.source !== null && options.source !== undefined) { - delegate = extend(delegate, { - 'postProcess': function (node) { - node.loc.source = toString(options.source); - return node; - } - }); - } - - extra.sourceType = options.sourceType; - if (typeof options.tokens === 'boolean' && options.tokens) { - extra.tokens = []; - } - if (typeof options.comment === 'boolean' && options.comment) { - extra.comments = []; - } - if (typeof options.tolerant === 'boolean' && options.tolerant) { - extra.errors = []; - } - if (extra.attachComment) { - extra.range = true; - extra.comments = []; - extra.bottomRightStack = []; - extra.trailingComments = []; - extra.leadingComments = []; - } - } - - patch(); - try { - program = parseProgram(); - if (typeof extra.comments !== 'undefined') { - program.comments = extra.comments; - } - if (typeof extra.tokens !== 'undefined') { - filterTokenLocation(); - program.tokens = extra.tokens; - } - if (typeof extra.errors !== 'undefined') { - program.errors = extra.errors; - } - } catch (e) { - throw e; - } finally { - unpatch(); - extra = {}; - } - - return program; - } - - // Sync with *.json manifests. - exports.version = '13001.1001.0-dev-harmony-fb'; - - exports.tokenize = tokenize; - - exports.parse = parse; - - // Deep copy. - /* istanbul ignore next */ - exports.Syntax = (function () { - var name, types = {}; - - if (typeof Object.create === 'function') { - types = Object.create(null); - } - - for (name in Syntax) { - if (Syntax.hasOwnProperty(name)) { - types[name] = Syntax[name]; - } - } - - if (typeof Object.freeze === 'function') { - Object.freeze(types); - } - - return types; - }()); - -})); -/* vim: set sw=4 ts=4 et tw=80 : */ - -},{}],10:[function(_dereq_,module,exports){ -var Base62 = (function (my) { - my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] - - my.encode = function(i){ - if (i === 0) {return '0'} - var s = '' - while (i > 0) { - s = this.chars[i % 62] + s - i = Math.floor(i/62) - } - return s - }; - my.decode = function(a,b,c,d){ - for ( - b = c = ( - a === (/\W|_|^$/.test(a += "") || a) - ) - 1; - d = a.charCodeAt(c++); - ) - b = b * 62 + d - [, 48, 29, 87][d >> 5]; - return b - }; - - return my; -}({})); - -module.exports = Base62 -},{}],11:[function(_dereq_,module,exports){ -/* - * Copyright 2009-2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE.txt or: - * http://opensource.org/licenses/BSD-3-Clause - */ -exports.SourceMapGenerator = _dereq_('./source-map/source-map-generator').SourceMapGenerator; -exports.SourceMapConsumer = _dereq_('./source-map/source-map-consumer').SourceMapConsumer; -exports.SourceNode = _dereq_('./source-map/source-node').SourceNode; - -},{"./source-map/source-map-consumer":16,"./source-map/source-map-generator":17,"./source-map/source-node":18}],12:[function(_dereq_,module,exports){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = _dereq_('amdefine')(module, _dereq_); -} -define(function (_dereq_, exports, module) { - - var util = _dereq_('./util'); - - /** - * A data structure which is a combination of an array and a set. Adding a new - * member is O(1), testing for membership is O(1), and finding the index of an - * element is O(1). Removing elements from the set is not supported. Only - * strings are supported for membership. - */ - function ArraySet() { - this._array = []; - this._set = {}; - } - - /** - * Static method for creating ArraySet instances from an existing array. - */ - ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { - var set = new ArraySet(); - for (var i = 0, len = aArray.length; i < len; i++) { - set.add(aArray[i], aAllowDuplicates); - } - return set; - }; - - /** - * Add the given string to this set. - * - * @param String aStr - */ - ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { - var isDuplicate = this.has(aStr); - var idx = this._array.length; - if (!isDuplicate || aAllowDuplicates) { - this._array.push(aStr); - } - if (!isDuplicate) { - this._set[util.toSetString(aStr)] = idx; - } - }; - - /** - * Is the given string a member of this set? - * - * @param String aStr - */ - ArraySet.prototype.has = function ArraySet_has(aStr) { - return Object.prototype.hasOwnProperty.call(this._set, - util.toSetString(aStr)); - }; - - /** - * What is the index of the given string in the array? - * - * @param String aStr - */ - ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { - if (this.has(aStr)) { - return this._set[util.toSetString(aStr)]; - } - throw new Error('"' + aStr + '" is not in the set.'); - }; - - /** - * What is the element at the given index? - * - * @param Number aIdx - */ - ArraySet.prototype.at = function ArraySet_at(aIdx) { - if (aIdx >= 0 && aIdx < this._array.length) { - return this._array[aIdx]; - } - throw new Error('No element indexed by ' + aIdx); - }; - - /** - * Returns the array representation of this set (which has the proper indices - * indicated by indexOf). Note that this is a copy of the internal array used - * for storing the members so that no one can mess with internal state. - */ - ArraySet.prototype.toArray = function ArraySet_toArray() { - return this._array.slice(); - }; - - exports.ArraySet = ArraySet; - -}); - -},{"./util":19,"amdefine":20}],13:[function(_dereq_,module,exports){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - * - * Based on the Base 64 VLQ implementation in Closure Compiler: - * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java - * - * Copyright 2011 The Closure Compiler Authors. All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -if (typeof define !== 'function') { - var define = _dereq_('amdefine')(module, _dereq_); -} -define(function (_dereq_, exports, module) { - - var base64 = _dereq_('./base64'); - - // A single base 64 digit can contain 6 bits of data. For the base 64 variable - // length quantities we use in the source map spec, the first bit is the sign, - // the next four bits are the actual value, and the 6th bit is the - // continuation bit. The continuation bit tells us whether there are more - // digits in this value following this digit. - // - // Continuation - // | Sign - // | | - // V V - // 101011 - - var VLQ_BASE_SHIFT = 5; - - // binary: 100000 - var VLQ_BASE = 1 << VLQ_BASE_SHIFT; - - // binary: 011111 - var VLQ_BASE_MASK = VLQ_BASE - 1; - - // binary: 100000 - var VLQ_CONTINUATION_BIT = VLQ_BASE; - - /** - * Converts from a two-complement value to a value where the sign bit is - * is placed in the least significant bit. For example, as decimals: - * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) - * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) - */ - function toVLQSigned(aValue) { - return aValue < 0 - ? ((-aValue) << 1) + 1 - : (aValue << 1) + 0; - } - - /** - * Converts to a two-complement value from a value where the sign bit is - * is placed in the least significant bit. For example, as decimals: - * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 - * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 - */ - function fromVLQSigned(aValue) { - var isNegative = (aValue & 1) === 1; - var shifted = aValue >> 1; - return isNegative - ? -shifted - : shifted; - } - - /** - * Returns the base 64 VLQ encoded value. - */ - exports.encode = function base64VLQ_encode(aValue) { - var encoded = ""; - var digit; - - var vlq = toVLQSigned(aValue); - - do { - digit = vlq & VLQ_BASE_MASK; - vlq >>>= VLQ_BASE_SHIFT; - if (vlq > 0) { - // There are still more digits in this value, so we must make sure the - // continuation bit is marked. - digit |= VLQ_CONTINUATION_BIT; - } - encoded += base64.encode(digit); - } while (vlq > 0); - - return encoded; - }; - - /** - * Decodes the next base 64 VLQ value from the given string and returns the - * value and the rest of the string. - */ - exports.decode = function base64VLQ_decode(aStr) { - var i = 0; - var strLen = aStr.length; - var result = 0; - var shift = 0; - var continuation, digit; - - do { - if (i >= strLen) { - throw new Error("Expected more digits in base 64 VLQ value."); - } - digit = base64.decode(aStr.charAt(i++)); - continuation = !!(digit & VLQ_CONTINUATION_BIT); - digit &= VLQ_BASE_MASK; - result = result + (digit << shift); - shift += VLQ_BASE_SHIFT; - } while (continuation); - - return { - value: fromVLQSigned(result), - rest: aStr.slice(i) - }; - }; - -}); - -},{"./base64":14,"amdefine":20}],14:[function(_dereq_,module,exports){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = _dereq_('amdefine')(module, _dereq_); -} -define(function (_dereq_, exports, module) { - - var charToIntMap = {}; - var intToCharMap = {}; - - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' - .split('') - .forEach(function (ch, index) { - charToIntMap[ch] = index; - intToCharMap[index] = ch; - }); - - /** - * Encode an integer in the range of 0 to 63 to a single base 64 digit. - */ - exports.encode = function base64_encode(aNumber) { - if (aNumber in intToCharMap) { - return intToCharMap[aNumber]; - } - throw new TypeError("Must be between 0 and 63: " + aNumber); - }; - - /** - * Decode a single base 64 digit to an integer. - */ - exports.decode = function base64_decode(aChar) { - if (aChar in charToIntMap) { - return charToIntMap[aChar]; - } - throw new TypeError("Not a valid base 64 digit: " + aChar); - }; - -}); - -},{"amdefine":20}],15:[function(_dereq_,module,exports){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = _dereq_('amdefine')(module, _dereq_); -} -define(function (_dereq_, exports, module) { - - /** - * Recursive implementation of binary search. - * - * @param aLow Indices here and lower do not contain the needle. - * @param aHigh Indices here and higher do not contain the needle. - * @param aNeedle The element being searched for. - * @param aHaystack The non-empty array being searched. - * @param aCompare Function which takes two elements and returns -1, 0, or 1. - */ - function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) { - // This function terminates when one of the following is true: - // - // 1. We find the exact element we are looking for. - // - // 2. We did not find the exact element, but we can return the next - // closest element that is less than that element. - // - // 3. We did not find the exact element, and there is no next-closest - // element which is less than the one we are searching for, so we - // return null. - var mid = Math.floor((aHigh - aLow) / 2) + aLow; - var cmp = aCompare(aNeedle, aHaystack[mid], true); - if (cmp === 0) { - // Found the element we are looking for. - return aHaystack[mid]; - } - else if (cmp > 0) { - // aHaystack[mid] is greater than our needle. - if (aHigh - mid > 1) { - // The element is in the upper half. - return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare); - } - // We did not find an exact match, return the next closest one - // (termination case 2). - return aHaystack[mid]; - } - else { - // aHaystack[mid] is less than our needle. - if (mid - aLow > 1) { - // The element is in the lower half. - return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare); - } - // The exact needle element was not found in this haystack. Determine if - // we are in termination case (2) or (3) and return the appropriate thing. - return aLow < 0 - ? null - : aHaystack[aLow]; - } - } - - /** - * This is an implementation of binary search which will always try and return - * the next lowest value checked if there is no exact hit. This is because - * mappings between original and generated line/col pairs are single points, - * and there is an implicit region between each of them, so a miss just means - * that you aren't on the very start of a region. - * - * @param aNeedle The element you are looking for. - * @param aHaystack The array that is being searched. - * @param aCompare A function which takes the needle and an element in the - * array and returns -1, 0, or 1 depending on whether the needle is less - * than, equal to, or greater than the element, respectively. - */ - exports.search = function search(aNeedle, aHaystack, aCompare) { - return aHaystack.length > 0 - ? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare) - : null; - }; - -}); - -},{"amdefine":20}],16:[function(_dereq_,module,exports){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = _dereq_('amdefine')(module, _dereq_); -} -define(function (_dereq_, exports, module) { - - var util = _dereq_('./util'); - var binarySearch = _dereq_('./binary-search'); - var ArraySet = _dereq_('./array-set').ArraySet; - var base64VLQ = _dereq_('./base64-vlq'); - - /** - * A SourceMapConsumer instance represents a parsed source map which we can - * query for information about the original file positions by giving it a file - * position in the generated source. - * - * The only parameter is the raw source map (either as a JSON string, or - * already parsed to an object). According to the spec, source maps have the - * following attributes: - * - * - version: Which version of the source map spec this map is following. - * - sources: An array of URLs to the original source files. - * - names: An array of identifiers which can be referrenced by individual mappings. - * - sourceRoot: Optional. The URL root from which all sources are relative. - * - sourcesContent: Optional. An array of contents of the original source files. - * - mappings: A string of base64 VLQs which contain the actual mappings. - * - file: The generated file this source map is associated with. - * - * Here is an example source map, taken from the source map spec[0]: - * - * { - * version : 3, - * file: "out.js", - * sourceRoot : "", - * sources: ["foo.js", "bar.js"], - * names: ["src", "maps", "are", "fun"], - * mappings: "AA,AB;;ABCDE;" - * } - * - * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# - */ - function SourceMapConsumer(aSourceMap) { - var sourceMap = aSourceMap; - if (typeof aSourceMap === 'string') { - sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); - } - - var version = util.getArg(sourceMap, 'version'); - var sources = util.getArg(sourceMap, 'sources'); - // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which - // requires the array) to play nice here. - var names = util.getArg(sourceMap, 'names', []); - var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); - var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); - var mappings = util.getArg(sourceMap, 'mappings'); - var file = util.getArg(sourceMap, 'file', null); - - // Once again, Sass deviates from the spec and supplies the version as a - // string rather than a number, so we use loose equality checking here. - if (version != this._version) { - throw new Error('Unsupported version: ' + version); - } - - // Pass `true` below to allow duplicate names and sources. While source maps - // are intended to be compressed and deduplicated, the TypeScript compiler - // sometimes generates source maps with duplicates in them. See Github issue - // #72 and bugzil.la/889492. - this._names = ArraySet.fromArray(names, true); - this._sources = ArraySet.fromArray(sources, true); - - this.sourceRoot = sourceRoot; - this.sourcesContent = sourcesContent; - this._mappings = mappings; - this.file = file; - } - - /** - * Create a SourceMapConsumer from a SourceMapGenerator. - * - * @param SourceMapGenerator aSourceMap - * The source map that will be consumed. - * @returns SourceMapConsumer - */ - SourceMapConsumer.fromSourceMap = - function SourceMapConsumer_fromSourceMap(aSourceMap) { - var smc = Object.create(SourceMapConsumer.prototype); - - smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); - smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); - smc.sourceRoot = aSourceMap._sourceRoot; - smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), - smc.sourceRoot); - smc.file = aSourceMap._file; - - smc.__generatedMappings = aSourceMap._mappings.slice() - .sort(util.compareByGeneratedPositions); - smc.__originalMappings = aSourceMap._mappings.slice() - .sort(util.compareByOriginalPositions); - - return smc; - }; - - /** - * The version of the source mapping spec that we are consuming. - */ - SourceMapConsumer.prototype._version = 3; - - /** - * The list of original sources. - */ - Object.defineProperty(SourceMapConsumer.prototype, 'sources', { - get: function () { - return this._sources.toArray().map(function (s) { - return this.sourceRoot ? util.join(this.sourceRoot, s) : s; - }, this); - } - }); - - // `__generatedMappings` and `__originalMappings` are arrays that hold the - // parsed mapping coordinates from the source map's "mappings" attribute. They - // are lazily instantiated, accessed via the `_generatedMappings` and - // `_originalMappings` getters respectively, and we only parse the mappings - // and create these arrays once queried for a source location. We jump through - // these hoops because there can be many thousands of mappings, and parsing - // them is expensive, so we only want to do it if we must. - // - // Each object in the arrays is of the form: - // - // { - // generatedLine: The line number in the generated code, - // generatedColumn: The column number in the generated code, - // source: The path to the original source file that generated this - // chunk of code, - // originalLine: The line number in the original source that - // corresponds to this chunk of generated code, - // originalColumn: The column number in the original source that - // corresponds to this chunk of generated code, - // name: The name of the original symbol which generated this chunk of - // code. - // } - // - // All properties except for `generatedLine` and `generatedColumn` can be - // `null`. - // - // `_generatedMappings` is ordered by the generated positions. - // - // `_originalMappings` is ordered by the original positions. - - SourceMapConsumer.prototype.__generatedMappings = null; - Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { - get: function () { - if (!this.__generatedMappings) { - this.__generatedMappings = []; - this.__originalMappings = []; - this._parseMappings(this._mappings, this.sourceRoot); - } - - return this.__generatedMappings; - } - }); - - SourceMapConsumer.prototype.__originalMappings = null; - Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { - get: function () { - if (!this.__originalMappings) { - this.__generatedMappings = []; - this.__originalMappings = []; - this._parseMappings(this._mappings, this.sourceRoot); - } - - return this.__originalMappings; - } - }); - - /** - * Parse the mappings in a string in to a data structure which we can easily - * query (the ordered arrays in the `this.__generatedMappings` and - * `this.__originalMappings` properties). - */ - SourceMapConsumer.prototype._parseMappings = - function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { - var generatedLine = 1; - var previousGeneratedColumn = 0; - var previousOriginalLine = 0; - var previousOriginalColumn = 0; - var previousSource = 0; - var previousName = 0; - var mappingSeparator = /^[,;]/; - var str = aStr; - var mapping; - var temp; - - while (str.length > 0) { - if (str.charAt(0) === ';') { - generatedLine++; - str = str.slice(1); - previousGeneratedColumn = 0; - } - else if (str.charAt(0) === ',') { - str = str.slice(1); - } - else { - mapping = {}; - mapping.generatedLine = generatedLine; - - // Generated column. - temp = base64VLQ.decode(str); - mapping.generatedColumn = previousGeneratedColumn + temp.value; - previousGeneratedColumn = mapping.generatedColumn; - str = temp.rest; - - if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) { - // Original source. - temp = base64VLQ.decode(str); - mapping.source = this._sources.at(previousSource + temp.value); - previousSource += temp.value; - str = temp.rest; - if (str.length === 0 || mappingSeparator.test(str.charAt(0))) { - throw new Error('Found a source, but no line and column'); - } - - // Original line. - temp = base64VLQ.decode(str); - mapping.originalLine = previousOriginalLine + temp.value; - previousOriginalLine = mapping.originalLine; - // Lines are stored 0-based - mapping.originalLine += 1; - str = temp.rest; - if (str.length === 0 || mappingSeparator.test(str.charAt(0))) { - throw new Error('Found a source and line, but no column'); - } - - // Original column. - temp = base64VLQ.decode(str); - mapping.originalColumn = previousOriginalColumn + temp.value; - previousOriginalColumn = mapping.originalColumn; - str = temp.rest; - - if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) { - // Original name. - temp = base64VLQ.decode(str); - mapping.name = this._names.at(previousName + temp.value); - previousName += temp.value; - str = temp.rest; - } - } - - this.__generatedMappings.push(mapping); - if (typeof mapping.originalLine === 'number') { - this.__originalMappings.push(mapping); - } - } - } - - this.__originalMappings.sort(util.compareByOriginalPositions); - }; - - /** - * Find the mapping that best matches the hypothetical "needle" mapping that - * we are searching for in the given "haystack" of mappings. - */ - SourceMapConsumer.prototype._findMapping = - function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, - aColumnName, aComparator) { - // To return the position we are searching for, we must first find the - // mapping for the given position and then return the opposite position it - // points to. Because the mappings are sorted, we can use binary search to - // find the best mapping. - - if (aNeedle[aLineName] <= 0) { - throw new TypeError('Line must be greater than or equal to 1, got ' - + aNeedle[aLineName]); - } - if (aNeedle[aColumnName] < 0) { - throw new TypeError('Column must be greater than or equal to 0, got ' - + aNeedle[aColumnName]); - } - - return binarySearch.search(aNeedle, aMappings, aComparator); - }; - - /** - * Returns the original source, line, and column information for the generated - * source's line and column positions provided. The only argument is an object - * with the following properties: - * - * - line: The line number in the generated source. - * - column: The column number in the generated source. - * - * and an object is returned with the following properties: - * - * - source: The original source file, or null. - * - line: The line number in the original source, or null. - * - column: The column number in the original source, or null. - * - name: The original identifier, or null. - */ - SourceMapConsumer.prototype.originalPositionFor = - function SourceMapConsumer_originalPositionFor(aArgs) { - var needle = { - generatedLine: util.getArg(aArgs, 'line'), - generatedColumn: util.getArg(aArgs, 'column') - }; - - var mapping = this._findMapping(needle, - this._generatedMappings, - "generatedLine", - "generatedColumn", - util.compareByGeneratedPositions); - - if (mapping) { - var source = util.getArg(mapping, 'source', null); - if (source && this.sourceRoot) { - source = util.join(this.sourceRoot, source); - } - return { - source: source, - line: util.getArg(mapping, 'originalLine', null), - column: util.getArg(mapping, 'originalColumn', null), - name: util.getArg(mapping, 'name', null) - }; - } - - return { - source: null, - line: null, - column: null, - name: null - }; - }; - - /** - * Returns the original source content. The only argument is the url of the - * original source file. Returns null if no original source content is - * availible. - */ - SourceMapConsumer.prototype.sourceContentFor = - function SourceMapConsumer_sourceContentFor(aSource) { - if (!this.sourcesContent) { - return null; - } - - if (this.sourceRoot) { - aSource = util.relative(this.sourceRoot, aSource); - } - - if (this._sources.has(aSource)) { - return this.sourcesContent[this._sources.indexOf(aSource)]; - } - - var url; - if (this.sourceRoot - && (url = util.urlParse(this.sourceRoot))) { - // XXX: file:// URIs and absolute paths lead to unexpected behavior for - // many users. We can help them out when they expect file:// URIs to - // behave like it would if they were running a local HTTP server. See - // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. - var fileUriAbsPath = aSource.replace(/^file:\/\//, ""); - if (url.scheme == "file" - && this._sources.has(fileUriAbsPath)) { - return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] - } - - if ((!url.path || url.path == "/") - && this._sources.has("/" + aSource)) { - return this.sourcesContent[this._sources.indexOf("/" + aSource)]; - } - } - - throw new Error('"' + aSource + '" is not in the SourceMap.'); - }; - - /** - * Returns the generated line and column information for the original source, - * line, and column positions provided. The only argument is an object with - * the following properties: - * - * - source: The filename of the original source. - * - line: The line number in the original source. - * - column: The column number in the original source. - * - * and an object is returned with the following properties: - * - * - line: The line number in the generated source, or null. - * - column: The column number in the generated source, or null. - */ - SourceMapConsumer.prototype.generatedPositionFor = - function SourceMapConsumer_generatedPositionFor(aArgs) { - var needle = { - source: util.getArg(aArgs, 'source'), - originalLine: util.getArg(aArgs, 'line'), - originalColumn: util.getArg(aArgs, 'column') - }; - - if (this.sourceRoot) { - needle.source = util.relative(this.sourceRoot, needle.source); - } - - var mapping = this._findMapping(needle, - this._originalMappings, - "originalLine", - "originalColumn", - util.compareByOriginalPositions); - - if (mapping) { - return { - line: util.getArg(mapping, 'generatedLine', null), - column: util.getArg(mapping, 'generatedColumn', null) - }; - } - - return { - line: null, - column: null - }; - }; - - SourceMapConsumer.GENERATED_ORDER = 1; - SourceMapConsumer.ORIGINAL_ORDER = 2; - - /** - * Iterate over each mapping between an original source/line/column and a - * generated line/column in this source map. - * - * @param Function aCallback - * The function that is called with each mapping. - * @param Object aContext - * Optional. If specified, this object will be the value of `this` every - * time that `aCallback` is called. - * @param aOrder - * Either `SourceMapConsumer.GENERATED_ORDER` or - * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to - * iterate over the mappings sorted by the generated file's line/column - * order or the original's source/line/column order, respectively. Defaults to - * `SourceMapConsumer.GENERATED_ORDER`. - */ - SourceMapConsumer.prototype.eachMapping = - function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { - var context = aContext || null; - var order = aOrder || SourceMapConsumer.GENERATED_ORDER; - - var mappings; - switch (order) { - case SourceMapConsumer.GENERATED_ORDER: - mappings = this._generatedMappings; - break; - case SourceMapConsumer.ORIGINAL_ORDER: - mappings = this._originalMappings; - break; - default: - throw new Error("Unknown order of iteration."); - } - - var sourceRoot = this.sourceRoot; - mappings.map(function (mapping) { - var source = mapping.source; - if (source && sourceRoot) { - source = util.join(sourceRoot, source); - } - return { - source: source, - generatedLine: mapping.generatedLine, - generatedColumn: mapping.generatedColumn, - originalLine: mapping.originalLine, - originalColumn: mapping.originalColumn, - name: mapping.name - }; - }).forEach(aCallback, context); - }; - - exports.SourceMapConsumer = SourceMapConsumer; - -}); - -},{"./array-set":12,"./base64-vlq":13,"./binary-search":15,"./util":19,"amdefine":20}],17:[function(_dereq_,module,exports){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = _dereq_('amdefine')(module, _dereq_); -} -define(function (_dereq_, exports, module) { - - var base64VLQ = _dereq_('./base64-vlq'); - var util = _dereq_('./util'); - var ArraySet = _dereq_('./array-set').ArraySet; - - /** - * An instance of the SourceMapGenerator represents a source map which is - * being built incrementally. To create a new one, you must pass an object - * with the following properties: - * - * - file: The filename of the generated source. - * - sourceRoot: An optional root for all URLs in this source map. - */ - function SourceMapGenerator(aArgs) { - this._file = util.getArg(aArgs, 'file'); - this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); - this._sources = new ArraySet(); - this._names = new ArraySet(); - this._mappings = []; - this._sourcesContents = null; - } - - SourceMapGenerator.prototype._version = 3; - - /** - * Creates a new SourceMapGenerator based on a SourceMapConsumer - * - * @param aSourceMapConsumer The SourceMap. - */ - SourceMapGenerator.fromSourceMap = - function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { - var sourceRoot = aSourceMapConsumer.sourceRoot; - var generator = new SourceMapGenerator({ - file: aSourceMapConsumer.file, - sourceRoot: sourceRoot - }); - aSourceMapConsumer.eachMapping(function (mapping) { - var newMapping = { - generated: { - line: mapping.generatedLine, - column: mapping.generatedColumn - } - }; - - if (mapping.source) { - newMapping.source = mapping.source; - if (sourceRoot) { - newMapping.source = util.relative(sourceRoot, newMapping.source); - } - - newMapping.original = { - line: mapping.originalLine, - column: mapping.originalColumn - }; - - if (mapping.name) { - newMapping.name = mapping.name; - } - } - - generator.addMapping(newMapping); - }); - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content) { - generator.setSourceContent(sourceFile, content); - } - }); - return generator; - }; - - /** - * Add a single mapping from original source line and column to the generated - * source's line and column for this source map being created. The mapping - * object should have the following properties: - * - * - generated: An object with the generated line and column positions. - * - original: An object with the original line and column positions. - * - source: The original source file (relative to the sourceRoot). - * - name: An optional original token name for this mapping. - */ - SourceMapGenerator.prototype.addMapping = - function SourceMapGenerator_addMapping(aArgs) { - var generated = util.getArg(aArgs, 'generated'); - var original = util.getArg(aArgs, 'original', null); - var source = util.getArg(aArgs, 'source', null); - var name = util.getArg(aArgs, 'name', null); - - this._validateMapping(generated, original, source, name); - - if (source && !this._sources.has(source)) { - this._sources.add(source); - } - - if (name && !this._names.has(name)) { - this._names.add(name); - } - - this._mappings.push({ - generatedLine: generated.line, - generatedColumn: generated.column, - originalLine: original != null && original.line, - originalColumn: original != null && original.column, - source: source, - name: name - }); - }; - - /** - * Set the source content for a source file. - */ - SourceMapGenerator.prototype.setSourceContent = - function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { - var source = aSourceFile; - if (this._sourceRoot) { - source = util.relative(this._sourceRoot, source); - } - - if (aSourceContent !== null) { - // Add the source content to the _sourcesContents map. - // Create a new _sourcesContents map if the property is null. - if (!this._sourcesContents) { - this._sourcesContents = {}; - } - this._sourcesContents[util.toSetString(source)] = aSourceContent; - } else { - // Remove the source file from the _sourcesContents map. - // If the _sourcesContents map is empty, set the property to null. - delete this._sourcesContents[util.toSetString(source)]; - if (Object.keys(this._sourcesContents).length === 0) { - this._sourcesContents = null; - } - } - }; - - /** - * Applies the mappings of a sub-source-map for a specific source file to the - * source map being generated. Each mapping to the supplied source file is - * rewritten using the supplied source map. Note: The resolution for the - * resulting mappings is the minimium of this map and the supplied map. - * - * @param aSourceMapConsumer The source map to be applied. - * @param aSourceFile Optional. The filename of the source file. - * If omitted, SourceMapConsumer's file property will be used. - */ - SourceMapGenerator.prototype.applySourceMap = - function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile) { - // If aSourceFile is omitted, we will use the file property of the SourceMap - if (!aSourceFile) { - aSourceFile = aSourceMapConsumer.file; - } - var sourceRoot = this._sourceRoot; - // Make "aSourceFile" relative if an absolute Url is passed. - if (sourceRoot) { - aSourceFile = util.relative(sourceRoot, aSourceFile); - } - // Applying the SourceMap can add and remove items from the sources and - // the names array. - var newSources = new ArraySet(); - var newNames = new ArraySet(); - - // Find mappings for the "aSourceFile" - this._mappings.forEach(function (mapping) { - if (mapping.source === aSourceFile && mapping.originalLine) { - // Check if it can be mapped by the source map, then update the mapping. - var original = aSourceMapConsumer.originalPositionFor({ - line: mapping.originalLine, - column: mapping.originalColumn - }); - if (original.source !== null) { - // Copy mapping - if (sourceRoot) { - mapping.source = util.relative(sourceRoot, original.source); - } else { - mapping.source = original.source; - } - mapping.originalLine = original.line; - mapping.originalColumn = original.column; - if (original.name !== null && mapping.name !== null) { - // Only use the identifier name if it's an identifier - // in both SourceMaps - mapping.name = original.name; - } - } - } - - var source = mapping.source; - if (source && !newSources.has(source)) { - newSources.add(source); - } - - var name = mapping.name; - if (name && !newNames.has(name)) { - newNames.add(name); - } - - }, this); - this._sources = newSources; - this._names = newNames; - - // Copy sourcesContents of applied map. - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content) { - if (sourceRoot) { - sourceFile = util.relative(sourceRoot, sourceFile); - } - this.setSourceContent(sourceFile, content); - } - }, this); - }; - - /** - * A mapping can have one of the three levels of data: - * - * 1. Just the generated position. - * 2. The Generated position, original position, and original source. - * 3. Generated and original position, original source, as well as a name - * token. - * - * To maintain consistency, we validate that any new mapping being added falls - * in to one of these categories. - */ - SourceMapGenerator.prototype._validateMapping = - function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, - aName) { - if (aGenerated && 'line' in aGenerated && 'column' in aGenerated - && aGenerated.line > 0 && aGenerated.column >= 0 - && !aOriginal && !aSource && !aName) { - // Case 1. - return; - } - else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated - && aOriginal && 'line' in aOriginal && 'column' in aOriginal - && aGenerated.line > 0 && aGenerated.column >= 0 - && aOriginal.line > 0 && aOriginal.column >= 0 - && aSource) { - // Cases 2 and 3. - return; - } - else { - throw new Error('Invalid mapping: ' + JSON.stringify({ - generated: aGenerated, - source: aSource, - orginal: aOriginal, - name: aName - })); - } - }; - - /** - * Serialize the accumulated mappings in to the stream of base 64 VLQs - * specified by the source map format. - */ - SourceMapGenerator.prototype._serializeMappings = - function SourceMapGenerator_serializeMappings() { - var previousGeneratedColumn = 0; - var previousGeneratedLine = 1; - var previousOriginalColumn = 0; - var previousOriginalLine = 0; - var previousName = 0; - var previousSource = 0; - var result = ''; - var mapping; - - // The mappings must be guaranteed to be in sorted order before we start - // serializing them or else the generated line numbers (which are defined - // via the ';' separators) will be all messed up. Note: it might be more - // performant to maintain the sorting as we insert them, rather than as we - // serialize them, but the big O is the same either way. - this._mappings.sort(util.compareByGeneratedPositions); - - for (var i = 0, len = this._mappings.length; i < len; i++) { - mapping = this._mappings[i]; - - if (mapping.generatedLine !== previousGeneratedLine) { - previousGeneratedColumn = 0; - while (mapping.generatedLine !== previousGeneratedLine) { - result += ';'; - previousGeneratedLine++; - } - } - else { - if (i > 0) { - if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) { - continue; - } - result += ','; - } - } - - result += base64VLQ.encode(mapping.generatedColumn - - previousGeneratedColumn); - previousGeneratedColumn = mapping.generatedColumn; - - if (mapping.source) { - result += base64VLQ.encode(this._sources.indexOf(mapping.source) - - previousSource); - previousSource = this._sources.indexOf(mapping.source); - - // lines are stored 0-based in SourceMap spec version 3 - result += base64VLQ.encode(mapping.originalLine - 1 - - previousOriginalLine); - previousOriginalLine = mapping.originalLine - 1; - - result += base64VLQ.encode(mapping.originalColumn - - previousOriginalColumn); - previousOriginalColumn = mapping.originalColumn; - - if (mapping.name) { - result += base64VLQ.encode(this._names.indexOf(mapping.name) - - previousName); - previousName = this._names.indexOf(mapping.name); - } - } - } - - return result; - }; - - SourceMapGenerator.prototype._generateSourcesContent = - function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { - return aSources.map(function (source) { - if (!this._sourcesContents) { - return null; - } - if (aSourceRoot) { - source = util.relative(aSourceRoot, source); - } - var key = util.toSetString(source); - return Object.prototype.hasOwnProperty.call(this._sourcesContents, - key) - ? this._sourcesContents[key] - : null; - }, this); - }; - - /** - * Externalize the source map. - */ - SourceMapGenerator.prototype.toJSON = - function SourceMapGenerator_toJSON() { - var map = { - version: this._version, - file: this._file, - sources: this._sources.toArray(), - names: this._names.toArray(), - mappings: this._serializeMappings() - }; - if (this._sourceRoot) { - map.sourceRoot = this._sourceRoot; - } - if (this._sourcesContents) { - map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); - } - - return map; - }; - - /** - * Render the source map being generated to a string. - */ - SourceMapGenerator.prototype.toString = - function SourceMapGenerator_toString() { - return JSON.stringify(this); - }; - - exports.SourceMapGenerator = SourceMapGenerator; - -}); - -},{"./array-set":12,"./base64-vlq":13,"./util":19,"amdefine":20}],18:[function(_dereq_,module,exports){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = _dereq_('amdefine')(module, _dereq_); -} -define(function (_dereq_, exports, module) { - - var SourceMapGenerator = _dereq_('./source-map-generator').SourceMapGenerator; - var util = _dereq_('./util'); - - /** - * SourceNodes provide a way to abstract over interpolating/concatenating - * snippets of generated JavaScript source code while maintaining the line and - * column information associated with the original source code. - * - * @param aLine The original line number. - * @param aColumn The original column number. - * @param aSource The original source's filename. - * @param aChunks Optional. An array of strings which are snippets of - * generated JS, or other SourceNodes. - * @param aName The original identifier. - */ - function SourceNode(aLine, aColumn, aSource, aChunks, aName) { - this.children = []; - this.sourceContents = {}; - this.line = aLine === undefined ? null : aLine; - this.column = aColumn === undefined ? null : aColumn; - this.source = aSource === undefined ? null : aSource; - this.name = aName === undefined ? null : aName; - if (aChunks != null) this.add(aChunks); - } - - /** - * Creates a SourceNode from generated code and a SourceMapConsumer. - * - * @param aGeneratedCode The generated code - * @param aSourceMapConsumer The SourceMap for the generated code - */ - SourceNode.fromStringWithSourceMap = - function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer) { - // The SourceNode we want to fill with the generated code - // and the SourceMap - var node = new SourceNode(); - - // The generated code - // Processed fragments are removed from this array. - var remainingLines = aGeneratedCode.split('\n'); - - // We need to remember the position of "remainingLines" - var lastGeneratedLine = 1, lastGeneratedColumn = 0; - - // The generate SourceNodes we need a code range. - // To extract it current and last mapping is used. - // Here we store the last mapping. - var lastMapping = null; - - aSourceMapConsumer.eachMapping(function (mapping) { - if (lastMapping === null) { - // We add the generated code until the first mapping - // to the SourceNode without any mapping. - // Each line is added as separate string. - while (lastGeneratedLine < mapping.generatedLine) { - node.add(remainingLines.shift() + "\n"); - lastGeneratedLine++; - } - if (lastGeneratedColumn < mapping.generatedColumn) { - var nextLine = remainingLines[0]; - node.add(nextLine.substr(0, mapping.generatedColumn)); - remainingLines[0] = nextLine.substr(mapping.generatedColumn); - lastGeneratedColumn = mapping.generatedColumn; - } - } else { - // We add the code from "lastMapping" to "mapping": - // First check if there is a new line in between. - if (lastGeneratedLine < mapping.generatedLine) { - var code = ""; - // Associate full lines with "lastMapping" - do { - code += remainingLines.shift() + "\n"; - lastGeneratedLine++; - lastGeneratedColumn = 0; - } while (lastGeneratedLine < mapping.generatedLine); - // When we reached the correct line, we add code until we - // reach the correct column too. - if (lastGeneratedColumn < mapping.generatedColumn) { - var nextLine = remainingLines[0]; - code += nextLine.substr(0, mapping.generatedColumn); - remainingLines[0] = nextLine.substr(mapping.generatedColumn); - lastGeneratedColumn = mapping.generatedColumn; - } - // Create the SourceNode. - addMappingWithCode(lastMapping, code); - } else { - // There is no new line in between. - // Associate the code between "lastGeneratedColumn" and - // "mapping.generatedColumn" with "lastMapping" - var nextLine = remainingLines[0]; - var code = nextLine.substr(0, mapping.generatedColumn - - lastGeneratedColumn); - remainingLines[0] = nextLine.substr(mapping.generatedColumn - - lastGeneratedColumn); - lastGeneratedColumn = mapping.generatedColumn; - addMappingWithCode(lastMapping, code); - } - } - lastMapping = mapping; - }, this); - // We have processed all mappings. - // Associate the remaining code in the current line with "lastMapping" - // and add the remaining lines without any mapping - addMappingWithCode(lastMapping, remainingLines.join("\n")); - - // Copy sourcesContent into SourceNode - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content) { - node.setSourceContent(sourceFile, content); - } - }); - - return node; - - function addMappingWithCode(mapping, code) { - if (mapping === null || mapping.source === undefined) { - node.add(code); - } else { - node.add(new SourceNode(mapping.originalLine, - mapping.originalColumn, - mapping.source, - code, - mapping.name)); - } - } - }; - - /** - * Add a chunk of generated JS to this source node. - * - * @param aChunk A string snippet of generated JS code, another instance of - * SourceNode, or an array where each member is one of those things. - */ - SourceNode.prototype.add = function SourceNode_add(aChunk) { - if (Array.isArray(aChunk)) { - aChunk.forEach(function (chunk) { - this.add(chunk); - }, this); - } - else if (aChunk instanceof SourceNode || typeof aChunk === "string") { - if (aChunk) { - this.children.push(aChunk); - } - } - else { - throw new TypeError( - "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk - ); - } - return this; - }; - - /** - * Add a chunk of generated JS to the beginning of this source node. - * - * @param aChunk A string snippet of generated JS code, another instance of - * SourceNode, or an array where each member is one of those things. - */ - SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { - if (Array.isArray(aChunk)) { - for (var i = aChunk.length-1; i >= 0; i--) { - this.prepend(aChunk[i]); - } - } - else if (aChunk instanceof SourceNode || typeof aChunk === "string") { - this.children.unshift(aChunk); - } - else { - throw new TypeError( - "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk - ); - } - return this; - }; - - /** - * Walk over the tree of JS snippets in this node and its children. The - * walking function is called once for each snippet of JS and is passed that - * snippet and the its original associated source's line/column location. - * - * @param aFn The traversal function. - */ - SourceNode.prototype.walk = function SourceNode_walk(aFn) { - var chunk; - for (var i = 0, len = this.children.length; i < len; i++) { - chunk = this.children[i]; - if (chunk instanceof SourceNode) { - chunk.walk(aFn); - } - else { - if (chunk !== '') { - aFn(chunk, { source: this.source, - line: this.line, - column: this.column, - name: this.name }); - } - } - } - }; - - /** - * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between - * each of `this.children`. - * - * @param aSep The separator. - */ - SourceNode.prototype.join = function SourceNode_join(aSep) { - var newChildren; - var i; - var len = this.children.length; - if (len > 0) { - newChildren = []; - for (i = 0; i < len-1; i++) { - newChildren.push(this.children[i]); - newChildren.push(aSep); - } - newChildren.push(this.children[i]); - this.children = newChildren; - } - return this; - }; - - /** - * Call String.prototype.replace on the very right-most source snippet. Useful - * for trimming whitespace from the end of a source node, etc. - * - * @param aPattern The pattern to replace. - * @param aReplacement The thing to replace the pattern with. - */ - SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { - var lastChild = this.children[this.children.length - 1]; - if (lastChild instanceof SourceNode) { - lastChild.replaceRight(aPattern, aReplacement); - } - else if (typeof lastChild === 'string') { - this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); - } - else { - this.children.push(''.replace(aPattern, aReplacement)); - } - return this; - }; - - /** - * Set the source content for a source file. This will be added to the SourceMapGenerator - * in the sourcesContent field. - * - * @param aSourceFile The filename of the source file - * @param aSourceContent The content of the source file - */ - SourceNode.prototype.setSourceContent = - function SourceNode_setSourceContent(aSourceFile, aSourceContent) { - this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; - }; - - /** - * Walk over the tree of SourceNodes. The walking function is called for each - * source file content and is passed the filename and source content. - * - * @param aFn The traversal function. - */ - SourceNode.prototype.walkSourceContents = - function SourceNode_walkSourceContents(aFn) { - for (var i = 0, len = this.children.length; i < len; i++) { - if (this.children[i] instanceof SourceNode) { - this.children[i].walkSourceContents(aFn); - } - } - - var sources = Object.keys(this.sourceContents); - for (var i = 0, len = sources.length; i < len; i++) { - aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); - } - }; - - /** - * Return the string representation of this source node. Walks over the tree - * and concatenates all the various snippets together to one string. - */ - SourceNode.prototype.toString = function SourceNode_toString() { - var str = ""; - this.walk(function (chunk) { - str += chunk; - }); - return str; - }; - - /** - * Returns the string representation of this source node along with a source - * map. - */ - SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { - var generated = { - code: "", - line: 1, - column: 0 - }; - var map = new SourceMapGenerator(aArgs); - var sourceMappingActive = false; - var lastOriginalSource = null; - var lastOriginalLine = null; - var lastOriginalColumn = null; - var lastOriginalName = null; - this.walk(function (chunk, original) { - generated.code += chunk; - if (original.source !== null - && original.line !== null - && original.column !== null) { - if(lastOriginalSource !== original.source - || lastOriginalLine !== original.line - || lastOriginalColumn !== original.column - || lastOriginalName !== original.name) { - map.addMapping({ - source: original.source, - original: { - line: original.line, - column: original.column - }, - generated: { - line: generated.line, - column: generated.column - }, - name: original.name - }); - } - lastOriginalSource = original.source; - lastOriginalLine = original.line; - lastOriginalColumn = original.column; - lastOriginalName = original.name; - sourceMappingActive = true; - } else if (sourceMappingActive) { - map.addMapping({ - generated: { - line: generated.line, - column: generated.column - } - }); - lastOriginalSource = null; - sourceMappingActive = false; - } - chunk.split('').forEach(function (ch) { - if (ch === '\n') { - generated.line++; - generated.column = 0; - } else { - generated.column++; - } - }); - }); - this.walkSourceContents(function (sourceFile, sourceContent) { - map.setSourceContent(sourceFile, sourceContent); - }); - - return { code: generated.code, map: map }; - }; - - exports.SourceNode = SourceNode; - -}); - -},{"./source-map-generator":17,"./util":19,"amdefine":20}],19:[function(_dereq_,module,exports){ -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -if (typeof define !== 'function') { - var define = _dereq_('amdefine')(module, _dereq_); -} -define(function (_dereq_, exports, module) { - - /** - * This is a helper function for getting values from parameter/options - * objects. - * - * @param args The object we are extracting values from - * @param name The name of the property we are getting. - * @param defaultValue An optional value to return if the property is missing - * from the object. If this is not specified and the property is missing, an - * error will be thrown. - */ - function getArg(aArgs, aName, aDefaultValue) { - if (aName in aArgs) { - return aArgs[aName]; - } else if (arguments.length === 3) { - return aDefaultValue; - } else { - throw new Error('"' + aName + '" is a required argument.'); - } - } - exports.getArg = getArg; - - var urlRegexp = /([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/; - var dataUrlRegexp = /^data:.+\,.+/; - - function urlParse(aUrl) { - var match = aUrl.match(urlRegexp); - if (!match) { - return null; - } - return { - scheme: match[1], - auth: match[3], - host: match[4], - port: match[6], - path: match[7] - }; - } - exports.urlParse = urlParse; - - function urlGenerate(aParsedUrl) { - var url = aParsedUrl.scheme + "://"; - if (aParsedUrl.auth) { - url += aParsedUrl.auth + "@" - } - if (aParsedUrl.host) { - url += aParsedUrl.host; - } - if (aParsedUrl.port) { - url += ":" + aParsedUrl.port - } - if (aParsedUrl.path) { - url += aParsedUrl.path; - } - return url; - } - exports.urlGenerate = urlGenerate; - - function join(aRoot, aPath) { - var url; - - if (aPath.match(urlRegexp) || aPath.match(dataUrlRegexp)) { - return aPath; - } - - if (aPath.charAt(0) === '/' && (url = urlParse(aRoot))) { - url.path = aPath; - return urlGenerate(url); - } - - return aRoot.replace(/\/$/, '') + '/' + aPath; - } - exports.join = join; - - /** - * Because behavior goes wacky when you set `__proto__` on objects, we - * have to prefix all the strings in our set with an arbitrary character. - * - * See https://github.com/mozilla/source-map/pull/31 and - * https://github.com/mozilla/source-map/issues/30 - * - * @param String aStr - */ - function toSetString(aStr) { - return '$' + aStr; - } - exports.toSetString = toSetString; - - function fromSetString(aStr) { - return aStr.substr(1); - } - exports.fromSetString = fromSetString; - - function relative(aRoot, aPath) { - aRoot = aRoot.replace(/\/$/, ''); - - var url = urlParse(aRoot); - if (aPath.charAt(0) == "/" && url && url.path == "/") { - return aPath.slice(1); - } - - return aPath.indexOf(aRoot + '/') === 0 - ? aPath.substr(aRoot.length + 1) - : aPath; - } - exports.relative = relative; - - function strcmp(aStr1, aStr2) { - var s1 = aStr1 || ""; - var s2 = aStr2 || ""; - return (s1 > s2) - (s1 < s2); - } - - /** - * Comparator between two mappings where the original positions are compared. - * - * Optionally pass in `true` as `onlyCompareGenerated` to consider two - * mappings with the same original source/line/column, but different generated - * line and column the same. Useful when searching for a mapping with a - * stubbed out mapping. - */ - function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { - var cmp; - - cmp = strcmp(mappingA.source, mappingB.source); - if (cmp) { - return cmp; - } - - cmp = mappingA.originalLine - mappingB.originalLine; - if (cmp) { - return cmp; - } - - cmp = mappingA.originalColumn - mappingB.originalColumn; - if (cmp || onlyCompareOriginal) { - return cmp; - } - - cmp = strcmp(mappingA.name, mappingB.name); - if (cmp) { - return cmp; - } - - cmp = mappingA.generatedLine - mappingB.generatedLine; - if (cmp) { - return cmp; - } - - return mappingA.generatedColumn - mappingB.generatedColumn; - }; - exports.compareByOriginalPositions = compareByOriginalPositions; - - /** - * Comparator between two mappings where the generated positions are - * compared. - * - * Optionally pass in `true` as `onlyCompareGenerated` to consider two - * mappings with the same generated line and column, but different - * source/name/original line and column the same. Useful when searching for a - * mapping with a stubbed out mapping. - */ - function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) { - var cmp; - - cmp = mappingA.generatedLine - mappingB.generatedLine; - if (cmp) { - return cmp; - } - - cmp = mappingA.generatedColumn - mappingB.generatedColumn; - if (cmp || onlyCompareGenerated) { - return cmp; - } - - cmp = strcmp(mappingA.source, mappingB.source); - if (cmp) { - return cmp; - } - - cmp = mappingA.originalLine - mappingB.originalLine; - if (cmp) { - return cmp; - } - - cmp = mappingA.originalColumn - mappingB.originalColumn; - if (cmp) { - return cmp; - } - - return strcmp(mappingA.name, mappingB.name); - }; - exports.compareByGeneratedPositions = compareByGeneratedPositions; - -}); - -},{"amdefine":20}],20:[function(_dereq_,module,exports){ -(function (process,__filename){ -/** vim: et:ts=4:sw=4:sts=4 - * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved. - * Available via the MIT or new BSD license. - * see: http://github.com/jrburke/amdefine for details - */ - -/*jslint node: true */ -/*global module, process */ -'use strict'; - -/** - * Creates a define for node. - * @param {Object} module the "module" object that is defined by Node for the - * current module. - * @param {Function} [requireFn]. Node's require function for the current module. - * It only needs to be passed in Node versions before 0.5, when module.require - * did not exist. - * @returns {Function} a define function that is usable for the current node - * module. - */ -function amdefine(module, requireFn) { - 'use strict'; - var defineCache = {}, - loaderCache = {}, - alreadyCalled = false, - path = _dereq_('path'), - makeRequire, stringRequire; - - /** - * Trims the . and .. from an array of path segments. - * It will keep a leading path segment if a .. will become - * the first path segment, to help with module name lookups, - * which act like paths, but can be remapped. But the end result, - * all paths that use this function should look normalized. - * NOTE: this method MODIFIES the input array. - * @param {Array} ary the array of path segments. - */ - function trimDots(ary) { - var i, part; - for (i = 0; ary[i]; i+= 1) { - part = ary[i]; - if (part === '.') { - ary.splice(i, 1); - i -= 1; - } else if (part === '..') { - if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { - //End of the line. Keep at least one non-dot - //path segment at the front so it can be mapped - //correctly to disk. Otherwise, there is likely - //no path mapping for a path starting with '..'. - //This can still fail, but catches the most reasonable - //uses of .. - break; - } else if (i > 0) { - ary.splice(i - 1, 2); - i -= 2; - } - } - } - } - - function normalize(name, baseName) { - var baseParts; - - //Adjust any relative paths. - if (name && name.charAt(0) === '.') { - //If have a base name, try to normalize against it, - //otherwise, assume it is a top-level require that will - //be relative to baseUrl in the end. - if (baseName) { - baseParts = baseName.split('/'); - baseParts = baseParts.slice(0, baseParts.length - 1); - baseParts = baseParts.concat(name.split('/')); - trimDots(baseParts); - name = baseParts.join('/'); - } - } - - return name; - } - - /** - * Create the normalize() function passed to a loader plugin's - * normalize method. - */ - function makeNormalize(relName) { - return function (name) { - return normalize(name, relName); - }; - } - - function makeLoad(id) { - function load(value) { - loaderCache[id] = value; - } - - load.fromText = function (id, text) { - //This one is difficult because the text can/probably uses - //define, and any relative paths and requires should be relative - //to that id was it would be found on disk. But this would require - //bootstrapping a module/require fairly deeply from node core. - //Not sure how best to go about that yet. - throw new Error('amdefine does not implement load.fromText'); - }; - - return load; - } - - makeRequire = function (systemRequire, exports, module, relId) { - function amdRequire(deps, callback) { - if (typeof deps === 'string') { - //Synchronous, single module require('') - return stringRequire(systemRequire, exports, module, deps, relId); - } else { - //Array of dependencies with a callback. - - //Convert the dependencies to modules. - deps = deps.map(function (depName) { - return stringRequire(systemRequire, exports, module, depName, relId); - }); - - //Wait for next tick to call back the require call. - process.nextTick(function () { - callback.apply(null, deps); - }); - } - } - - amdRequire.toUrl = function (filePath) { - if (filePath.indexOf('.') === 0) { - return normalize(filePath, path.dirname(module.filename)); - } else { - return filePath; - } - }; - - return amdRequire; - }; - - //Favor explicit value, passed in if the module wants to support Node 0.4. - requireFn = requireFn || function req() { - return module.require.apply(module, arguments); - }; - - function runFactory(id, deps, factory) { - var r, e, m, result; - - if (id) { - e = loaderCache[id] = {}; - m = { - id: id, - uri: __filename, - exports: e - }; - r = makeRequire(requireFn, e, m, id); - } else { - //Only support one define call per file - if (alreadyCalled) { - throw new Error('amdefine with no module ID cannot be called more than once per file.'); - } - alreadyCalled = true; - - //Use the real variables from node - //Use module.exports for exports, since - //the exports in here is amdefine exports. - e = module.exports; - m = module; - r = makeRequire(requireFn, e, m, module.id); - } - - //If there are dependencies, they are strings, so need - //to convert them to dependency values. - if (deps) { - deps = deps.map(function (depName) { - return r(depName); - }); - } - - //Call the factory with the right dependencies. - if (typeof factory === 'function') { - result = factory.apply(m.exports, deps); - } else { - result = factory; - } - - if (result !== undefined) { - m.exports = result; - if (id) { - loaderCache[id] = m.exports; - } - } - } - - stringRequire = function (systemRequire, exports, module, id, relId) { - //Split the ID by a ! so that - var index = id.indexOf('!'), - originalId = id, - prefix, plugin; - - if (index === -1) { - id = normalize(id, relId); - - //Straight module lookup. If it is one of the special dependencies, - //deal with it, otherwise, delegate to node. - if (id === 'require') { - return makeRequire(systemRequire, exports, module, relId); - } else if (id === 'exports') { - return exports; - } else if (id === 'module') { - return module; - } else if (loaderCache.hasOwnProperty(id)) { - return loaderCache[id]; - } else if (defineCache[id]) { - runFactory.apply(null, defineCache[id]); - return loaderCache[id]; - } else { - if(systemRequire) { - return systemRequire(originalId); - } else { - throw new Error('No module with ID: ' + id); - } - } - } else { - //There is a plugin in play. - prefix = id.substring(0, index); - id = id.substring(index + 1, id.length); - - plugin = stringRequire(systemRequire, exports, module, prefix, relId); - - if (plugin.normalize) { - id = plugin.normalize(id, makeNormalize(relId)); - } else { - //Normalize the ID normally. - id = normalize(id, relId); - } - - if (loaderCache[id]) { - return loaderCache[id]; - } else { - plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {}); - - return loaderCache[id]; - } - } - }; - - //Create a define function specific to the module asking for amdefine. - function define(id, deps, factory) { - if (Array.isArray(id)) { - factory = deps; - deps = id; - id = undefined; - } else if (typeof id !== 'string') { - factory = id; - id = deps = undefined; - } - - if (deps && !Array.isArray(deps)) { - factory = deps; - deps = undefined; - } - - if (!deps) { - deps = ['require', 'exports', 'module']; - } - - //Set up properties for this module. If an ID, then use - //internal cache. If no ID, then use the external variables - //for this node module. - if (id) { - //Put the module in deep freeze until there is a - //require call for it. - defineCache[id] = [id, deps, factory]; - } else { - runFactory(id, deps, factory); - } - } - - //define.require, which has access to all the values in the - //cache. Useful for AMD modules that all have IDs in the file, - //but need to finally export a value to node based on one of those - //IDs. - define.require = function (id) { - if (loaderCache[id]) { - return loaderCache[id]; - } - - if (defineCache[id]) { - runFactory.apply(null, defineCache[id]); - return loaderCache[id]; - } - }; - - define.amd = {}; - - return define; -} - -module.exports = amdefine; - -}).call(this,_dereq_('_process'),"/node_modules/jstransform/node_modules/source-map/node_modules/amdefine/amdefine.js") -},{"_process":8,"path":7}],21:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var docblockRe = /^\s*(\/\*\*(.|\r?\n)*?\*\/)/; -var ltrimRe = /^\s*/; -/** - * @param {String} contents - * @return {String} - */ -function extract(contents) { - var match = contents.match(docblockRe); - if (match) { - return match[0].replace(ltrimRe, '') || ''; - } - return ''; -} - - -var commentStartRe = /^\/\*\*?/; -var commentEndRe = /\*+\/$/; -var wsRe = /[\t ]+/g; -var stringStartRe = /(\r?\n|^) *\*/g; -var multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *([^@\r\n\s][^@\r\n]+?) *\r?\n/g; -var propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g; - -/** - * @param {String} contents - * @return {Array} - */ -function parse(docblock) { - docblock = docblock - .replace(commentStartRe, '') - .replace(commentEndRe, '') - .replace(wsRe, ' ') - .replace(stringStartRe, '$1'); - - // Normalize multi-line directives - var prev = ''; - while (prev != docblock) { - prev = docblock; - docblock = docblock.replace(multilineRe, "\n$1 $2\n"); - } - docblock = docblock.trim(); - - var result = []; - var match; - while (match = propertyRe.exec(docblock)) { - result.push([match[1], match[2]]); - } - - return result; -} - -/** - * Same as parse but returns an object of prop: value instead of array of paris - * If a property appers more than once the last one will be returned - * - * @param {String} contents - * @return {Object} - */ -function parseAsObject(docblock) { - var pairs = parse(docblock); - var result = {}; - for (var i = 0; i < pairs.length; i++) { - result[pairs[i][0]] = pairs[i][1]; - } - return result; -} - - -exports.extract = extract; -exports.parse = parse; -exports.parseAsObject = parseAsObject; - -},{}],22:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/*jslint node: true*/ -"use strict"; - -var esprima = _dereq_('esprima-fb'); -var utils = _dereq_('./utils'); - -var getBoundaryNode = utils.getBoundaryNode; -var declareIdentInScope = utils.declareIdentInLocalScope; -var initScopeMetadata = utils.initScopeMetadata; -var Syntax = esprima.Syntax; - -/** - * @param {object} node - * @param {object} parentNode - * @return {boolean} - */ -function _nodeIsClosureScopeBoundary(node, parentNode) { - if (node.type === Syntax.Program) { - return true; - } - - var parentIsFunction = - parentNode.type === Syntax.FunctionDeclaration - || parentNode.type === Syntax.FunctionExpression - || parentNode.type === Syntax.ArrowFunctionExpression; - - var parentIsCurlylessArrowFunc = - parentNode.type === Syntax.ArrowFunctionExpression - && node === parentNode.body; - - return parentIsFunction - && (node.type === Syntax.BlockStatement || parentIsCurlylessArrowFunc); -} - -function _nodeIsBlockScopeBoundary(node, parentNode) { - if (node.type === Syntax.Program) { - return false; - } - - return node.type === Syntax.BlockStatement - && parentNode.type === Syntax.CatchClause; -} - -/** - * @param {object} node - * @param {array} path - * @param {object} state - */ -function traverse(node, path, state) { - /*jshint -W004*/ - // Create a scope stack entry if this is the first node we've encountered in - // its local scope - var startIndex = null; - var parentNode = path[0]; - if (!Array.isArray(node) && state.localScope.parentNode !== parentNode) { - if (_nodeIsClosureScopeBoundary(node, parentNode)) { - var scopeIsStrict = state.scopeIsStrict; - if (!scopeIsStrict - && (node.type === Syntax.BlockStatement - || node.type === Syntax.Program)) { - scopeIsStrict = - node.body.length > 0 - && node.body[0].type === Syntax.ExpressionStatement - && node.body[0].expression.type === Syntax.Literal - && node.body[0].expression.value === 'use strict'; - } - - if (node.type === Syntax.Program) { - startIndex = state.g.buffer.length; - state = utils.updateState(state, { - scopeIsStrict: scopeIsStrict - }); - } else { - startIndex = state.g.buffer.length + 1; - state = utils.updateState(state, { - localScope: { - parentNode: parentNode, - parentScope: state.localScope, - identifiers: {}, - tempVarIndex: 0, - tempVars: [] - }, - scopeIsStrict: scopeIsStrict - }); - - // All functions have an implicit 'arguments' object in scope - declareIdentInScope('arguments', initScopeMetadata(node), state); - - // Include function arg identifiers in the scope boundaries of the - // function - if (parentNode.params.length > 0) { - var param; - var metadata = initScopeMetadata(parentNode, path.slice(1), path[0]); - for (var i = 0; i < parentNode.params.length; i++) { - param = parentNode.params[i]; - if (param.type === Syntax.Identifier) { - declareIdentInScope(param.name, metadata, state); - } - } - } - - // Include rest arg identifiers in the scope boundaries of their - // functions - if (parentNode.rest) { - var metadata = initScopeMetadata( - parentNode, - path.slice(1), - path[0] - ); - declareIdentInScope(parentNode.rest.name, metadata, state); - } - - // Named FunctionExpressions scope their name within the body block of - // themselves only - if (parentNode.type === Syntax.FunctionExpression && parentNode.id) { - var metaData = - initScopeMetadata(parentNode, path.parentNodeslice, parentNode); - declareIdentInScope(parentNode.id.name, metaData, state); - } - } - - // Traverse and find all local identifiers in this closure first to - // account for function/variable declaration hoisting - collectClosureIdentsAndTraverse(node, path, state); - } - - if (_nodeIsBlockScopeBoundary(node, parentNode)) { - startIndex = state.g.buffer.length; - state = utils.updateState(state, { - localScope: { - parentNode: parentNode, - parentScope: state.localScope, - identifiers: {}, - tempVarIndex: 0, - tempVars: [] - } - }); - - if (parentNode.type === Syntax.CatchClause) { - var metadata = initScopeMetadata( - parentNode, - path.slice(1), - parentNode - ); - declareIdentInScope(parentNode.param.name, metadata, state); - } - collectBlockIdentsAndTraverse(node, path, state); - } - } - - // Only catchup() before and after traversing a child node - function traverser(node, path, state) { - node.range && utils.catchup(node.range[0], state); - traverse(node, path, state); - node.range && utils.catchup(node.range[1], state); - } - - utils.analyzeAndTraverse(walker, traverser, node, path, state); - - // Inject temp variables into the scope. - if (startIndex !== null) { - utils.injectTempVarDeclarations(state, startIndex); - } -} - -function collectClosureIdentsAndTraverse(node, path, state) { - utils.analyzeAndTraverse( - visitLocalClosureIdentifiers, - collectClosureIdentsAndTraverse, - node, - path, - state - ); -} - -function collectBlockIdentsAndTraverse(node, path, state) { - utils.analyzeAndTraverse( - visitLocalBlockIdentifiers, - collectBlockIdentsAndTraverse, - node, - path, - state - ); -} - -function visitLocalClosureIdentifiers(node, path, state) { - var metaData; - switch (node.type) { - case Syntax.ArrowFunctionExpression: - case Syntax.FunctionExpression: - // Function expressions don't get their names (if there is one) added to - // the closure scope they're defined in - return false; - case Syntax.ClassDeclaration: - case Syntax.ClassExpression: - case Syntax.FunctionDeclaration: - if (node.id) { - metaData = initScopeMetadata(getBoundaryNode(path), path.slice(), node); - declareIdentInScope(node.id.name, metaData, state); - } - return false; - case Syntax.VariableDeclarator: - // Variables have function-local scope - if (path[0].kind === 'var') { - metaData = initScopeMetadata(getBoundaryNode(path), path.slice(), node); - declareIdentInScope(node.id.name, metaData, state); - } - break; - } -} - -function visitLocalBlockIdentifiers(node, path, state) { - // TODO: Support 'let' here...maybe...one day...or something... - if (node.type === Syntax.CatchClause) { - return false; - } -} - -function walker(node, path, state) { - var visitors = state.g.visitors; - for (var i = 0; i < visitors.length; i++) { - if (visitors[i].test(node, path, state)) { - return visitors[i](traverse, node, path, state); - } - } -} - -var _astCache = {}; - -function getAstForSource(source, options) { - if (_astCache[source] && !options.disableAstCache) { - return _astCache[source]; - } - var ast = esprima.parse(source, { - comment: true, - loc: true, - range: true, - sourceType: options.sourceType - }); - if (!options.disableAstCache) { - _astCache[source] = ast; - } - return ast; -} - -/** - * Applies all available transformations to the source - * @param {array} visitors - * @param {string} source - * @param {?object} options - * @return {object} - */ -function transform(visitors, source, options) { - options = options || {}; - var ast; - try { - ast = getAstForSource(source, options); - } catch (e) { - e.message = 'Parse Error: ' + e.message; - throw e; - } - var state = utils.createState(source, ast, options); - state.g.visitors = visitors; - - if (options.sourceMap) { - var SourceMapGenerator = _dereq_('source-map').SourceMapGenerator; - state.g.sourceMap = new SourceMapGenerator({file: options.filename || 'transformed.js'}); - } - - traverse(ast, [], state); - utils.catchup(source.length, state); - - var ret = {code: state.g.buffer, extra: state.g.extra}; - if (options.sourceMap) { - ret.sourceMap = state.g.sourceMap; - ret.sourceMapFilename = options.filename || 'source.js'; - } - return ret; -} - -exports.transform = transform; -exports.Syntax = Syntax; - -},{"./utils":23,"esprima-fb":9,"source-map":11}],23:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/*jslint node: true*/ -var Syntax = _dereq_('esprima-fb').Syntax; -var leadingIndentRegexp = /(^|\n)( {2}|\t)/g; -var nonWhiteRegexp = /(\S)/g; - -/** - * A `state` object represents the state of the parser. It has "local" and - * "global" parts. Global contains parser position, source, etc. Local contains - * scope based properties like current class name. State should contain all the - * info required for transformation. It's the only mandatory object that is - * being passed to every function in transform chain. - * - * @param {string} source - * @param {object} transformOptions - * @return {object} - */ -function createState(source, rootNode, transformOptions) { - return { - /** - * A tree representing the current local scope (and its lexical scope chain) - * Useful for tracking identifiers from parent scopes, etc. - * @type {Object} - */ - localScope: { - parentNode: rootNode, - parentScope: null, - identifiers: {}, - tempVarIndex: 0, - tempVars: [] - }, - /** - * The name (and, if applicable, expression) of the super class - * @type {Object} - */ - superClass: null, - /** - * The namespace to use when munging identifiers - * @type {String} - */ - mungeNamespace: '', - /** - * Ref to the node for the current MethodDefinition - * @type {Object} - */ - methodNode: null, - /** - * Ref to the node for the FunctionExpression of the enclosing - * MethodDefinition - * @type {Object} - */ - methodFuncNode: null, - /** - * Name of the enclosing class - * @type {String} - */ - className: null, - /** - * Whether we're currently within a `strict` scope - * @type {Bool} - */ - scopeIsStrict: null, - /** - * Indentation offset - * @type {Number} - */ - indentBy: 0, - /** - * Global state (not affected by updateState) - * @type {Object} - */ - g: { - /** - * A set of general options that transformations can consider while doing - * a transformation: - * - * - minify - * Specifies that transformation steps should do their best to minify - * the output source when possible. This is useful for places where - * minification optimizations are possible with higher-level context - * info than what jsxmin can provide. - * - * For example, the ES6 class transform will minify munged private - * variables if this flag is set. - */ - opts: transformOptions, - /** - * Current position in the source code - * @type {Number} - */ - position: 0, - /** - * Auxiliary data to be returned by transforms - * @type {Object} - */ - extra: {}, - /** - * Buffer containing the result - * @type {String} - */ - buffer: '', - /** - * Source that is being transformed - * @type {String} - */ - source: source, - - /** - * Cached parsed docblock (see getDocblock) - * @type {object} - */ - docblock: null, - - /** - * Whether the thing was used - * @type {Boolean} - */ - tagNamespaceUsed: false, - - /** - * If using bolt xjs transformation - * @type {Boolean} - */ - isBolt: undefined, - - /** - * Whether to record source map (expensive) or not - * @type {SourceMapGenerator|null} - */ - sourceMap: null, - - /** - * Filename of the file being processed. Will be returned as a source - * attribute in the source map - */ - sourceMapFilename: 'source.js', - - /** - * Only when source map is used: last line in the source for which - * source map was generated - * @type {Number} - */ - sourceLine: 1, - - /** - * Only when source map is used: last line in the buffer for which - * source map was generated - * @type {Number} - */ - bufferLine: 1, - - /** - * The top-level Program AST for the original file. - */ - originalProgramAST: null, - - sourceColumn: 0, - bufferColumn: 0 - } - }; -} - -/** - * Updates a copy of a given state with "update" and returns an updated state. - * - * @param {object} state - * @param {object} update - * @return {object} - */ -function updateState(state, update) { - var ret = Object.create(state); - Object.keys(update).forEach(function(updatedKey) { - ret[updatedKey] = update[updatedKey]; - }); - return ret; -} - -/** - * Given a state fill the resulting buffer from the original source up to - * the end - * - * @param {number} end - * @param {object} state - * @param {?function} contentTransformer Optional callback to transform newly - * added content. - */ -function catchup(end, state, contentTransformer) { - if (end < state.g.position) { - // cannot move backwards - return; - } - var source = state.g.source.substring(state.g.position, end); - var transformed = updateIndent(source, state); - if (state.g.sourceMap && transformed) { - // record where we are - state.g.sourceMap.addMapping({ - generated: { line: state.g.bufferLine, column: state.g.bufferColumn }, - original: { line: state.g.sourceLine, column: state.g.sourceColumn }, - source: state.g.sourceMapFilename - }); - - // record line breaks in transformed source - var sourceLines = source.split('\n'); - var transformedLines = transformed.split('\n'); - // Add line break mappings between last known mapping and the end of the - // added piece. So for the code piece - // (foo, bar); - // > var x = 2; - // > var b = 3; - // var c = - // only add lines marked with ">": 2, 3. - for (var i = 1; i < sourceLines.length - 1; i++) { - state.g.sourceMap.addMapping({ - generated: { line: state.g.bufferLine, column: 0 }, - original: { line: state.g.sourceLine, column: 0 }, - source: state.g.sourceMapFilename - }); - state.g.sourceLine++; - state.g.bufferLine++; - } - // offset for the last piece - if (sourceLines.length > 1) { - state.g.sourceLine++; - state.g.bufferLine++; - state.g.sourceColumn = 0; - state.g.bufferColumn = 0; - } - state.g.sourceColumn += sourceLines[sourceLines.length - 1].length; - state.g.bufferColumn += - transformedLines[transformedLines.length - 1].length; - } - state.g.buffer += - contentTransformer ? contentTransformer(transformed) : transformed; - state.g.position = end; -} - -/** - * Returns original source for an AST node. - * @param {object} node - * @param {object} state - * @return {string} - */ -function getNodeSourceText(node, state) { - return state.g.source.substring(node.range[0], node.range[1]); -} - -function _replaceNonWhite(value) { - return value.replace(nonWhiteRegexp, ' '); -} - -/** - * Removes all non-whitespace characters - */ -function _stripNonWhite(value) { - return value.replace(nonWhiteRegexp, ''); -} - -/** - * Finds the position of the next instance of the specified syntactic char in - * the pending source. - * - * NOTE: This will skip instances of the specified char if they sit inside a - * comment body. - * - * NOTE: This function also assumes that the buffer's current position is not - * already within a comment or a string. This is rarely the case since all - * of the buffer-advancement utility methods tend to be used on syntactic - * nodes' range values -- but it's a small gotcha that's worth mentioning. - */ -function getNextSyntacticCharOffset(char, state) { - var pendingSource = state.g.source.substring(state.g.position); - var pendingSourceLines = pendingSource.split('\n'); - - var charOffset = 0; - var line; - var withinBlockComment = false; - var withinString = false; - lineLoop: while ((line = pendingSourceLines.shift()) !== undefined) { - var lineEndPos = charOffset + line.length; - charLoop: for (; charOffset < lineEndPos; charOffset++) { - var currChar = pendingSource[charOffset]; - if (currChar === '"' || currChar === '\'') { - withinString = !withinString; - continue charLoop; - } else if (withinString) { - continue charLoop; - } else if (charOffset + 1 < lineEndPos) { - var nextTwoChars = currChar + line[charOffset + 1]; - if (nextTwoChars === '//') { - charOffset = lineEndPos + 1; - continue lineLoop; - } else if (nextTwoChars === '/*') { - withinBlockComment = true; - charOffset += 1; - continue charLoop; - } else if (nextTwoChars === '*/') { - withinBlockComment = false; - charOffset += 1; - continue charLoop; - } - } - - if (!withinBlockComment && currChar === char) { - return charOffset + state.g.position; - } - } - - // Account for '\n' - charOffset++; - withinString = false; - } - - throw new Error('`' + char + '` not found!'); -} - -/** - * Catches up as `catchup` but replaces non-whitespace chars with spaces. - */ -function catchupWhiteOut(end, state) { - catchup(end, state, _replaceNonWhite); -} - -/** - * Catches up as `catchup` but removes all non-whitespace characters. - */ -function catchupWhiteSpace(end, state) { - catchup(end, state, _stripNonWhite); -} - -/** - * Removes all non-newline characters - */ -var reNonNewline = /[^\n]/g; -function stripNonNewline(value) { - return value.replace(reNonNewline, function() { - return ''; - }); -} - -/** - * Catches up as `catchup` but removes all non-newline characters. - * - * Equivalent to appending as many newlines as there are in the original source - * between the current position and `end`. - */ -function catchupNewlines(end, state) { - catchup(end, state, stripNonNewline); -} - - -/** - * Same as catchup but does not touch the buffer - * - * @param {number} end - * @param {object} state - */ -function move(end, state) { - // move the internal cursors - if (state.g.sourceMap) { - if (end < state.g.position) { - state.g.position = 0; - state.g.sourceLine = 1; - state.g.sourceColumn = 0; - } - - var source = state.g.source.substring(state.g.position, end); - var sourceLines = source.split('\n'); - if (sourceLines.length > 1) { - state.g.sourceLine += sourceLines.length - 1; - state.g.sourceColumn = 0; - } - state.g.sourceColumn += sourceLines[sourceLines.length - 1].length; - } - state.g.position = end; -} - -/** - * Appends a string of text to the buffer - * - * @param {string} str - * @param {object} state - */ -function append(str, state) { - if (state.g.sourceMap && str) { - state.g.sourceMap.addMapping({ - generated: { line: state.g.bufferLine, column: state.g.bufferColumn }, - original: { line: state.g.sourceLine, column: state.g.sourceColumn }, - source: state.g.sourceMapFilename - }); - var transformedLines = str.split('\n'); - if (transformedLines.length > 1) { - state.g.bufferLine += transformedLines.length - 1; - state.g.bufferColumn = 0; - } - state.g.bufferColumn += - transformedLines[transformedLines.length - 1].length; - } - state.g.buffer += str; -} - -/** - * Update indent using state.indentBy property. Indent is measured in - * double spaces. Updates a single line only. - * - * @param {string} str - * @param {object} state - * @return {string} - */ -function updateIndent(str, state) { - /*jshint -W004*/ - var indentBy = state.indentBy; - if (indentBy < 0) { - for (var i = 0; i < -indentBy; i++) { - str = str.replace(leadingIndentRegexp, '$1'); - } - } else { - for (var i = 0; i < indentBy; i++) { - str = str.replace(leadingIndentRegexp, '$1$2$2'); - } - } - return str; -} - -/** - * Calculates indent from the beginning of the line until "start" or the first - * character before start. - * @example - * " foo.bar()" - * ^ - * start - * indent will be " " - * - * @param {number} start - * @param {object} state - * @return {string} - */ -function indentBefore(start, state) { - var end = start; - start = start - 1; - - while (start > 0 && state.g.source[start] != '\n') { - if (!state.g.source[start].match(/[ \t]/)) { - end = start; - } - start--; - } - return state.g.source.substring(start + 1, end); -} - -function getDocblock(state) { - if (!state.g.docblock) { - var docblock = _dereq_('./docblock'); - state.g.docblock = - docblock.parseAsObject(docblock.extract(state.g.source)); - } - return state.g.docblock; -} - -function identWithinLexicalScope(identName, state, stopBeforeNode) { - var currScope = state.localScope; - while (currScope) { - if (currScope.identifiers[identName] !== undefined) { - return true; - } - - if (stopBeforeNode && currScope.parentNode === stopBeforeNode) { - break; - } - - currScope = currScope.parentScope; - } - return false; -} - -function identInLocalScope(identName, state) { - return state.localScope.identifiers[identName] !== undefined; -} - -/** - * @param {object} boundaryNode - * @param {?array} path - * @return {?object} node - */ -function initScopeMetadata(boundaryNode, path, node) { - return { - boundaryNode: boundaryNode, - bindingPath: path, - bindingNode: node - }; -} - -function declareIdentInLocalScope(identName, metaData, state) { - state.localScope.identifiers[identName] = { - boundaryNode: metaData.boundaryNode, - path: metaData.bindingPath, - node: metaData.bindingNode, - state: Object.create(state) - }; -} - -function getLexicalBindingMetadata(identName, state) { - var currScope = state.localScope; - while (currScope) { - if (currScope.identifiers[identName] !== undefined) { - return currScope.identifiers[identName]; - } - - currScope = currScope.parentScope; - } -} - -function getLocalBindingMetadata(identName, state) { - return state.localScope.identifiers[identName]; -} - -/** - * Apply the given analyzer function to the current node. If the analyzer - * doesn't return false, traverse each child of the current node using the given - * traverser function. - * - * @param {function} analyzer - * @param {function} traverser - * @param {object} node - * @param {array} path - * @param {object} state - */ -function analyzeAndTraverse(analyzer, traverser, node, path, state) { - if (node.type) { - if (analyzer(node, path, state) === false) { - return; - } - path.unshift(node); - } - - getOrderedChildren(node).forEach(function(child) { - traverser(child, path, state); - }); - - node.type && path.shift(); -} - -/** - * It is crucial that we traverse in order, or else catchup() on a later - * node that is processed out of order can move the buffer past a node - * that we haven't handled yet, preventing us from modifying that node. - * - * This can happen when a node has multiple properties containing children. - * For example, XJSElement nodes have `openingElement`, `closingElement` and - * `children`. If we traverse `openingElement`, then `closingElement`, then - * when we get to `children`, the buffer has already caught up to the end of - * the closing element, after the children. - * - * This is basically a Schwartzian transform. Collects an array of children, - * each one represented as [child, startIndex]; sorts the array by start - * index; then traverses the children in that order. - */ -function getOrderedChildren(node) { - var queue = []; - for (var key in node) { - if (node.hasOwnProperty(key)) { - enqueueNodeWithStartIndex(queue, node[key]); - } - } - queue.sort(function(a, b) { return a[1] - b[1]; }); - return queue.map(function(pair) { return pair[0]; }); -} - -/** - * Helper function for analyzeAndTraverse which queues up all of the children - * of the given node. - * - * Children can also be found in arrays, so we basically want to merge all of - * those arrays together so we can sort them and then traverse the children - * in order. - * - * One example is the Program node. It contains `body` and `comments`, both - * arrays. Lexographically, comments are interspersed throughout the body - * nodes, but esprima's AST groups them together. - */ -function enqueueNodeWithStartIndex(queue, node) { - if (typeof node !== 'object' || node === null) { - return; - } - if (node.range) { - queue.push([node, node.range[0]]); - } else if (Array.isArray(node)) { - for (var ii = 0; ii < node.length; ii++) { - enqueueNodeWithStartIndex(queue, node[ii]); - } - } -} - -/** - * Checks whether a node or any of its sub-nodes contains - * a syntactic construct of the passed type. - * @param {object} node - AST node to test. - * @param {string} type - node type to lookup. - */ -function containsChildOfType(node, type) { - return containsChildMatching(node, function(node) { - return node.type === type; - }); -} - -function containsChildMatching(node, matcher) { - var foundMatchingChild = false; - function nodeTypeAnalyzer(node) { - if (matcher(node) === true) { - foundMatchingChild = true; - return false; - } - } - function nodeTypeTraverser(child, path, state) { - if (!foundMatchingChild) { - foundMatchingChild = containsChildMatching(child, matcher); - } - } - analyzeAndTraverse( - nodeTypeAnalyzer, - nodeTypeTraverser, - node, - [] - ); - return foundMatchingChild; -} - -var scopeTypes = {}; -scopeTypes[Syntax.ArrowFunctionExpression] = true; -scopeTypes[Syntax.FunctionExpression] = true; -scopeTypes[Syntax.FunctionDeclaration] = true; -scopeTypes[Syntax.Program] = true; - -function getBoundaryNode(path) { - for (var ii = 0; ii < path.length; ++ii) { - if (scopeTypes[path[ii].type]) { - return path[ii]; - } - } - throw new Error( - 'Expected to find a node with one of the following types in path:\n' + - JSON.stringify(Object.keys(scopeTypes)) - ); -} - -function getTempVar(tempVarIndex) { - return '$__' + tempVarIndex; -} - -function injectTempVar(state) { - var tempVar = '$__' + (state.localScope.tempVarIndex++); - state.localScope.tempVars.push(tempVar); - return tempVar; -} - -function injectTempVarDeclarations(state, index) { - if (state.localScope.tempVars.length) { - state.g.buffer = - state.g.buffer.slice(0, index) + - 'var ' + state.localScope.tempVars.join(', ') + ';' + - state.g.buffer.slice(index); - state.localScope.tempVars = []; - } -} - -exports.analyzeAndTraverse = analyzeAndTraverse; -exports.append = append; -exports.catchup = catchup; -exports.catchupNewlines = catchupNewlines; -exports.catchupWhiteOut = catchupWhiteOut; -exports.catchupWhiteSpace = catchupWhiteSpace; -exports.containsChildMatching = containsChildMatching; -exports.containsChildOfType = containsChildOfType; -exports.createState = createState; -exports.declareIdentInLocalScope = declareIdentInLocalScope; -exports.getBoundaryNode = getBoundaryNode; -exports.getDocblock = getDocblock; -exports.getLexicalBindingMetadata = getLexicalBindingMetadata; -exports.getLocalBindingMetadata = getLocalBindingMetadata; -exports.getNextSyntacticCharOffset = getNextSyntacticCharOffset; -exports.getNodeSourceText = getNodeSourceText; -exports.getOrderedChildren = getOrderedChildren; -exports.getTempVar = getTempVar; -exports.identInLocalScope = identInLocalScope; -exports.identWithinLexicalScope = identWithinLexicalScope; -exports.indentBefore = indentBefore; -exports.initScopeMetadata = initScopeMetadata; -exports.injectTempVar = injectTempVar; -exports.injectTempVarDeclarations = injectTempVarDeclarations; -exports.move = move; -exports.scopeTypes = scopeTypes; -exports.updateIndent = updateIndent; -exports.updateState = updateState; - -},{"./docblock":21,"esprima-fb":9}],24:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*global exports:true*/ - -/** - * Desugars ES6 Arrow functions to ES3 function expressions. - * If the function contains `this` expression -- automatically - * binds the function to current value of `this`. - * - * Single parameter, simple expression: - * - * [1, 2, 3].map(x => x * x); - * - * [1, 2, 3].map(function(x) { return x * x; }); - * - * Several parameters, complex block: - * - * this.users.forEach((user, idx) => { - * return this.isActive(idx) && this.send(user); - * }); - * - * this.users.forEach(function(user, idx) { - * return this.isActive(idx) && this.send(user); - * }.bind(this)); - * - */ -var restParamVisitors = _dereq_('./es6-rest-param-visitors'); -var destructuringVisitors = _dereq_('./es6-destructuring-visitors'); - -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); - -/** - * @public - */ -function visitArrowFunction(traverse, node, path, state) { - var notInExpression = (path[0].type === Syntax.ExpressionStatement); - - // Wrap a function into a grouping operator, if it's not - // in the expression position. - if (notInExpression) { - utils.append('(', state); - } - - utils.append('function', state); - renderParams(traverse, node, path, state); - - // Skip arrow. - utils.catchupWhiteSpace(node.body.range[0], state); - - var renderBody = node.body.type == Syntax.BlockStatement - ? renderStatementBody - : renderExpressionBody; - - path.unshift(node); - renderBody(traverse, node, path, state); - path.shift(); - - // Bind the function only if `this` value is used - // inside it or inside any sub-expression. - var containsBindingSyntax = - utils.containsChildMatching(node.body, function(node) { - return node.type === Syntax.ThisExpression - || (node.type === Syntax.Identifier - && node.name === "super"); - }); - - if (containsBindingSyntax) { - utils.append('.bind(this)', state); - } - - utils.catchupWhiteSpace(node.range[1], state); - - // Close wrapper if not in the expression. - if (notInExpression) { - utils.append(')', state); - } - - return false; -} - -function renderParams(traverse, node, path, state) { - // To preserve inline typechecking directives, we - // distinguish between parens-free and paranthesized single param. - if (isParensFreeSingleParam(node, state) || !node.params.length) { - utils.append('(', state); - } - if (node.params.length !== 0) { - path.unshift(node); - traverse(node.params, path, state); - path.unshift(); - } - utils.append(')', state); -} - -function isParensFreeSingleParam(node, state) { - return node.params.length === 1 && - state.g.source[state.g.position] !== '('; -} - -function renderExpressionBody(traverse, node, path, state) { - // Wrap simple expression bodies into a block - // with explicit return statement. - utils.append('{', state); - - // Special handling of rest param. - if (node.rest) { - utils.append( - restParamVisitors.renderRestParamSetup(node, state), - state - ); - } - - // Special handling of destructured params. - destructuringVisitors.renderDestructuredComponents( - node, - utils.updateState(state, { - localScope: { - parentNode: state.parentNode, - parentScope: state.parentScope, - identifiers: state.identifiers, - tempVarIndex: 0 - } - }) - ); - - utils.append('return ', state); - renderStatementBody(traverse, node, path, state); - utils.append(';}', state); -} - -function renderStatementBody(traverse, node, path, state) { - traverse(node.body, path, state); - utils.catchup(node.body.range[1], state); -} - -visitArrowFunction.test = function(node, path, state) { - return node.type === Syntax.ArrowFunctionExpression; -}; - -exports.visitorList = [ - visitArrowFunction -]; - - -},{"../src/utils":23,"./es6-destructuring-visitors":27,"./es6-rest-param-visitors":30,"esprima-fb":9}],25:[function(_dereq_,module,exports){ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - */ -/*global exports:true*/ - -/** - * Implements ES6 call spread. - * - * instance.method(a, b, c, ...d) - * - * instance.method.apply(instance, [a, b, c].concat(d)) - * - */ - -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); - -function process(traverse, node, path, state) { - utils.move(node.range[0], state); - traverse(node, path, state); - utils.catchup(node.range[1], state); -} - -function visitCallSpread(traverse, node, path, state) { - utils.catchup(node.range[0], state); - - if (node.type === Syntax.NewExpression) { - // Input = new Set(1, 2, ...list) - // Output = new (Function.prototype.bind.apply(Set, [null, 1, 2].concat(list))) - utils.append('new (Function.prototype.bind.apply(', state); - process(traverse, node.callee, path, state); - } else if (node.callee.type === Syntax.MemberExpression) { - // Input = get().fn(1, 2, ...more) - // Output = (_ = get()).fn.apply(_, [1, 2].apply(more)) - var tempVar = utils.injectTempVar(state); - utils.append('(' + tempVar + ' = ', state); - process(traverse, node.callee.object, path, state); - utils.append(')', state); - if (node.callee.property.type === Syntax.Identifier) { - utils.append('.', state); - process(traverse, node.callee.property, path, state); - } else { - utils.append('[', state); - process(traverse, node.callee.property, path, state); - utils.append(']', state); - } - utils.append('.apply(' + tempVar, state); - } else { - // Input = max(1, 2, ...list) - // Output = max.apply(null, [1, 2].concat(list)) - var needsToBeWrappedInParenthesis = - node.callee.type === Syntax.FunctionDeclaration || - node.callee.type === Syntax.FunctionExpression; - if (needsToBeWrappedInParenthesis) { - utils.append('(', state); - } - process(traverse, node.callee, path, state); - if (needsToBeWrappedInParenthesis) { - utils.append(')', state); - } - utils.append('.apply(null', state); - } - utils.append(', ', state); - - var args = node.arguments.slice(); - var spread = args.pop(); - if (args.length || node.type === Syntax.NewExpression) { - utils.append('[', state); - if (node.type === Syntax.NewExpression) { - utils.append('null' + (args.length ? ', ' : ''), state); - } - while (args.length) { - var arg = args.shift(); - utils.move(arg.range[0], state); - traverse(arg, path, state); - if (args.length) { - utils.catchup(args[0].range[0], state); - } else { - utils.catchup(arg.range[1], state); - } - } - utils.append('].concat(', state); - process(traverse, spread.argument, path, state); - utils.append(')', state); - } else { - process(traverse, spread.argument, path, state); - } - utils.append(node.type === Syntax.NewExpression ? '))' : ')', state); - - utils.move(node.range[1], state); - return false; -} - -visitCallSpread.test = function(node, path, state) { - return ( - ( - node.type === Syntax.CallExpression || - node.type === Syntax.NewExpression - ) && - node.arguments.length > 0 && - node.arguments[node.arguments.length - 1].type === Syntax.SpreadElement - ); -}; - -exports.visitorList = [ - visitCallSpread -]; - -},{"../src/utils":23,"esprima-fb":9}],26:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*jslint node:true*/ - -/** - * @typechecks - */ -'use strict'; - -var base62 = _dereq_('base62'); -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); -var reservedWordsHelper = _dereq_('./reserved-words-helper'); - -var declareIdentInLocalScope = utils.declareIdentInLocalScope; -var initScopeMetadata = utils.initScopeMetadata; - -var SUPER_PROTO_IDENT_PREFIX = '____SuperProtoOf'; - -var _anonClassUUIDCounter = 0; -var _mungedSymbolMaps = {}; - -function resetSymbols() { - _anonClassUUIDCounter = 0; - _mungedSymbolMaps = {}; -} - -/** - * Used to generate a unique class for use with code-gens for anonymous class - * expressions. - * - * @param {object} state - * @return {string} - */ -function _generateAnonymousClassName(state) { - var mungeNamespace = state.mungeNamespace || ''; - return '____Class' + mungeNamespace + base62.encode(_anonClassUUIDCounter++); -} - -/** - * Given an identifier name, munge it using the current state's mungeNamespace. - * - * @param {string} identName - * @param {object} state - * @return {string} - */ -function _getMungedName(identName, state) { - var mungeNamespace = state.mungeNamespace; - var shouldMinify = state.g.opts.minify; - - if (shouldMinify) { - if (!_mungedSymbolMaps[mungeNamespace]) { - _mungedSymbolMaps[mungeNamespace] = { - symbolMap: {}, - identUUIDCounter: 0 - }; - } - - var symbolMap = _mungedSymbolMaps[mungeNamespace].symbolMap; - if (!symbolMap[identName]) { - symbolMap[identName] = - base62.encode(_mungedSymbolMaps[mungeNamespace].identUUIDCounter++); - } - identName = symbolMap[identName]; - } - return '$' + mungeNamespace + identName; -} - -/** - * Extracts super class information from a class node. - * - * Information includes name of the super class and/or the expression string - * (if extending from an expression) - * - * @param {object} node - * @param {object} state - * @return {object} - */ -function _getSuperClassInfo(node, state) { - var ret = { - name: null, - expression: null - }; - if (node.superClass) { - if (node.superClass.type === Syntax.Identifier) { - ret.name = node.superClass.name; - } else { - // Extension from an expression - ret.name = _generateAnonymousClassName(state); - ret.expression = state.g.source.substring( - node.superClass.range[0], - node.superClass.range[1] - ); - } - } - return ret; -} - -/** - * Used with .filter() to find the constructor method in a list of - * MethodDefinition nodes. - * - * @param {object} classElement - * @return {boolean} - */ -function _isConstructorMethod(classElement) { - return classElement.type === Syntax.MethodDefinition && - classElement.key.type === Syntax.Identifier && - classElement.key.name === 'constructor'; -} - -/** - * @param {object} node - * @param {object} state - * @return {boolean} - */ -function _shouldMungeIdentifier(node, state) { - return ( - !!state.methodFuncNode && - !utils.getDocblock(state).hasOwnProperty('preventMunge') && - /^_(?!_)/.test(node.name) - ); -} - -/** - * @param {function} traverse - * @param {object} node - * @param {array} path - * @param {object} state - */ -function visitClassMethod(traverse, node, path, state) { - if (!state.g.opts.es5 && (node.kind === 'get' || node.kind === 'set')) { - throw new Error( - 'This transform does not support ' + node.kind + 'ter methods for ES6 ' + - 'classes. (line: ' + node.loc.start.line + ', col: ' + - node.loc.start.column + ')' - ); - } - state = utils.updateState(state, { - methodNode: node - }); - utils.catchup(node.range[0], state); - path.unshift(node); - traverse(node.value, path, state); - path.shift(); - return false; -} -visitClassMethod.test = function(node, path, state) { - return node.type === Syntax.MethodDefinition; -}; - -/** - * @param {function} traverse - * @param {object} node - * @param {array} path - * @param {object} state - */ -function visitClassFunctionExpression(traverse, node, path, state) { - var methodNode = path[0]; - var isGetter = methodNode.kind === 'get'; - var isSetter = methodNode.kind === 'set'; - - state = utils.updateState(state, { - methodFuncNode: node - }); - - if (methodNode.key.name === 'constructor') { - utils.append('function ' + state.className, state); - } else { - var methodAccessorComputed = false; - var methodAccessor; - var prototypeOrStatic = methodNode["static"] ? '' : '.prototype'; - var objectAccessor = state.className + prototypeOrStatic; - - if (methodNode.key.type === Syntax.Identifier) { - // foo() {} - methodAccessor = methodNode.key.name; - if (_shouldMungeIdentifier(methodNode.key, state)) { - methodAccessor = _getMungedName(methodAccessor, state); - } - if (isGetter || isSetter) { - methodAccessor = JSON.stringify(methodAccessor); - } else if (reservedWordsHelper.isReservedWord(methodAccessor)) { - methodAccessorComputed = true; - methodAccessor = JSON.stringify(methodAccessor); - } - } else if (methodNode.key.type === Syntax.Literal) { - // 'foo bar'() {} | get 'foo bar'() {} | set 'foo bar'() {} - methodAccessor = JSON.stringify(methodNode.key.value); - methodAccessorComputed = true; - } - - if (isSetter || isGetter) { - utils.append( - 'Object.defineProperty(' + - objectAccessor + ',' + - methodAccessor + ',' + - '{configurable:true,' + - methodNode.kind + ':function', - state - ); - } else { - if (state.g.opts.es3) { - if (methodAccessorComputed) { - methodAccessor = '[' + methodAccessor + ']'; - } else { - methodAccessor = '.' + methodAccessor; - } - utils.append( - objectAccessor + - methodAccessor + '=function' + (node.generator ? '*' : ''), - state - ); - } else { - if (!methodAccessorComputed) { - methodAccessor = JSON.stringify(methodAccessor); - } - utils.append( - 'Object.defineProperty(' + - objectAccessor + ',' + - methodAccessor + ',' + - '{writable:true,configurable:true,' + - 'value:function' + (node.generator ? '*' : ''), - state - ); - } - } - } - utils.move(methodNode.key.range[1], state); - utils.append('(', state); - - var params = node.params; - if (params.length > 0) { - utils.catchupNewlines(params[0].range[0], state); - for (var i = 0; i < params.length; i++) { - utils.catchup(node.params[i].range[0], state); - path.unshift(node); - traverse(params[i], path, state); - path.shift(); - } - } - - var closingParenPosition = utils.getNextSyntacticCharOffset(')', state); - utils.catchupWhiteSpace(closingParenPosition, state); - - var openingBracketPosition = utils.getNextSyntacticCharOffset('{', state); - utils.catchup(openingBracketPosition + 1, state); - - if (!state.scopeIsStrict) { - utils.append('"use strict";', state); - state = utils.updateState(state, { - scopeIsStrict: true - }); - } - utils.move(node.body.range[0] + '{'.length, state); - - path.unshift(node); - traverse(node.body, path, state); - path.shift(); - utils.catchup(node.body.range[1], state); - - if (methodNode.key.name !== 'constructor') { - if (isGetter || isSetter || !state.g.opts.es3) { - utils.append('})', state); - } - utils.append(';', state); - } - return false; -} -visitClassFunctionExpression.test = function(node, path, state) { - return node.type === Syntax.FunctionExpression - && path[0].type === Syntax.MethodDefinition; -}; - -function visitClassMethodParam(traverse, node, path, state) { - var paramName = node.name; - if (_shouldMungeIdentifier(node, state)) { - paramName = _getMungedName(node.name, state); - } - utils.append(paramName, state); - utils.move(node.range[1], state); -} -visitClassMethodParam.test = function(node, path, state) { - if (!path[0] || !path[1]) { - return; - } - - var parentFuncExpr = path[0]; - var parentClassMethod = path[1]; - - return parentFuncExpr.type === Syntax.FunctionExpression - && parentClassMethod.type === Syntax.MethodDefinition - && node.type === Syntax.Identifier; -}; - -/** - * @param {function} traverse - * @param {object} node - * @param {array} path - * @param {object} state - */ -function _renderClassBody(traverse, node, path, state) { - var className = state.className; - var superClass = state.superClass; - - // Set up prototype of constructor on same line as `extends` for line-number - // preservation. This relies on function-hoisting if a constructor function is - // defined in the class body. - if (superClass.name) { - // If the super class is an expression, we need to memoize the output of the - // expression into the generated class name variable and use that to refer - // to the super class going forward. Example: - // - // class Foo extends mixin(Bar, Baz) {} - // --transforms to-- - // function Foo() {} var ____Class0Blah = mixin(Bar, Baz); - if (superClass.expression !== null) { - utils.append( - 'var ' + superClass.name + '=' + superClass.expression + ';', - state - ); - } - - var keyName = superClass.name + '____Key'; - var keyNameDeclarator = ''; - if (!utils.identWithinLexicalScope(keyName, state)) { - keyNameDeclarator = 'var '; - declareIdentInLocalScope(keyName, initScopeMetadata(node), state); - } - utils.append( - 'for(' + keyNameDeclarator + keyName + ' in ' + superClass.name + '){' + - 'if(' + superClass.name + '.hasOwnProperty(' + keyName + ')){' + - className + '[' + keyName + ']=' + - superClass.name + '[' + keyName + '];' + - '}' + - '}', - state - ); - - var superProtoIdentStr = SUPER_PROTO_IDENT_PREFIX + superClass.name; - if (!utils.identWithinLexicalScope(superProtoIdentStr, state)) { - utils.append( - 'var ' + superProtoIdentStr + '=' + superClass.name + '===null?' + - 'null:' + superClass.name + '.prototype;', - state - ); - declareIdentInLocalScope(superProtoIdentStr, initScopeMetadata(node), state); - } - - utils.append( - className + '.prototype=Object.create(' + superProtoIdentStr + ');', - state - ); - utils.append( - className + '.prototype.constructor=' + className + ';', - state - ); - utils.append( - className + '.__superConstructor__=' + superClass.name + ';', - state - ); - } - - // If there's no constructor method specified in the class body, create an - // empty constructor function at the top (same line as the class keyword) - if (!node.body.body.filter(_isConstructorMethod).pop()) { - utils.append('function ' + className + '(){', state); - if (!state.scopeIsStrict) { - utils.append('"use strict";', state); - } - if (superClass.name) { - utils.append( - 'if(' + superClass.name + '!==null){' + - superClass.name + '.apply(this,arguments);}', - state - ); - } - utils.append('}', state); - } - - utils.move(node.body.range[0] + '{'.length, state); - traverse(node.body, path, state); - utils.catchupWhiteSpace(node.range[1], state); -} - -/** - * @param {function} traverse - * @param {object} node - * @param {array} path - * @param {object} state - */ -function visitClassDeclaration(traverse, node, path, state) { - var className = node.id.name; - var superClass = _getSuperClassInfo(node, state); - - state = utils.updateState(state, { - mungeNamespace: className, - className: className, - superClass: superClass - }); - - _renderClassBody(traverse, node, path, state); - - return false; -} -visitClassDeclaration.test = function(node, path, state) { - return node.type === Syntax.ClassDeclaration; -}; - -/** - * @param {function} traverse - * @param {object} node - * @param {array} path - * @param {object} state - */ -function visitClassExpression(traverse, node, path, state) { - var className = node.id && node.id.name || _generateAnonymousClassName(state); - var superClass = _getSuperClassInfo(node, state); - - utils.append('(function(){', state); - - state = utils.updateState(state, { - mungeNamespace: className, - className: className, - superClass: superClass - }); - - _renderClassBody(traverse, node, path, state); - - utils.append('return ' + className + ';})()', state); - return false; -} -visitClassExpression.test = function(node, path, state) { - return node.type === Syntax.ClassExpression; -}; - -/** - * @param {function} traverse - * @param {object} node - * @param {array} path - * @param {object} state - */ -function visitPrivateIdentifier(traverse, node, path, state) { - utils.append(_getMungedName(node.name, state), state); - utils.move(node.range[1], state); -} -visitPrivateIdentifier.test = function(node, path, state) { - if (node.type === Syntax.Identifier && _shouldMungeIdentifier(node, state)) { - // Always munge non-computed properties of MemberExpressions - // (a la preventing access of properties of unowned objects) - if (path[0].type === Syntax.MemberExpression && path[0].object !== node - && path[0].computed === false) { - return true; - } - - // Always munge identifiers that were declared within the method function - // scope - if (utils.identWithinLexicalScope(node.name, state, state.methodFuncNode)) { - return true; - } - - // Always munge private keys on object literals defined within a method's - // scope. - if (path[0].type === Syntax.Property - && path[1].type === Syntax.ObjectExpression) { - return true; - } - - // Always munge function parameters - if (path[0].type === Syntax.FunctionExpression - || path[0].type === Syntax.FunctionDeclaration - || path[0].type === Syntax.ArrowFunctionExpression) { - for (var i = 0; i < path[0].params.length; i++) { - if (path[0].params[i] === node) { - return true; - } - } - } - } - return false; -}; - -/** - * @param {function} traverse - * @param {object} node - * @param {array} path - * @param {object} state - */ -function visitSuperCallExpression(traverse, node, path, state) { - var superClassName = state.superClass.name; - - if (node.callee.type === Syntax.Identifier) { - if (_isConstructorMethod(state.methodNode)) { - utils.append(superClassName + '.call(', state); - } else { - var protoProp = SUPER_PROTO_IDENT_PREFIX + superClassName; - if (state.methodNode.key.type === Syntax.Identifier) { - protoProp += '.' + state.methodNode.key.name; - } else if (state.methodNode.key.type === Syntax.Literal) { - protoProp += '[' + JSON.stringify(state.methodNode.key.value) + ']'; - } - utils.append(protoProp + ".call(", state); - } - utils.move(node.callee.range[1], state); - } else if (node.callee.type === Syntax.MemberExpression) { - utils.append(SUPER_PROTO_IDENT_PREFIX + superClassName, state); - utils.move(node.callee.object.range[1], state); - - if (node.callee.computed) { - // ["a" + "b"] - utils.catchup(node.callee.property.range[1] + ']'.length, state); - } else { - // .ab - utils.append('.' + node.callee.property.name, state); - } - - utils.append('.call(', state); - utils.move(node.callee.range[1], state); - } - - utils.append('this', state); - if (node.arguments.length > 0) { - utils.append(',', state); - utils.catchupWhiteSpace(node.arguments[0].range[0], state); - traverse(node.arguments, path, state); - } - - utils.catchupWhiteSpace(node.range[1], state); - utils.append(')', state); - return false; -} -visitSuperCallExpression.test = function(node, path, state) { - if (state.superClass && node.type === Syntax.CallExpression) { - var callee = node.callee; - if (callee.type === Syntax.Identifier && callee.name === 'super' - || callee.type == Syntax.MemberExpression - && callee.object.name === 'super') { - return true; - } - } - return false; -}; - -/** - * @param {function} traverse - * @param {object} node - * @param {array} path - * @param {object} state - */ -function visitSuperMemberExpression(traverse, node, path, state) { - var superClassName = state.superClass.name; - - utils.append(SUPER_PROTO_IDENT_PREFIX + superClassName, state); - utils.move(node.object.range[1], state); -} -visitSuperMemberExpression.test = function(node, path, state) { - return state.superClass - && node.type === Syntax.MemberExpression - && node.object.type === Syntax.Identifier - && node.object.name === 'super'; -}; - -exports.resetSymbols = resetSymbols; - -exports.visitorList = [ - visitClassDeclaration, - visitClassExpression, - visitClassFunctionExpression, - visitClassMethod, - visitClassMethodParam, - visitPrivateIdentifier, - visitSuperCallExpression, - visitSuperMemberExpression -]; - -},{"../src/utils":23,"./reserved-words-helper":34,"base62":10,"esprima-fb":9}],27:[function(_dereq_,module,exports){ -/** - * Copyright 2014 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*global exports:true*/ - -/** - * Implements ES6 destructuring assignment and pattern matchng. - * - * function init({port, ip, coords: [x, y]}) { - * return (x && y) ? {id, port} : {ip}; - * }; - * - * function init($__0) { - * var - * port = $__0.port, - * ip = $__0.ip, - * $__1 = $__0.coords, - * x = $__1[0], - * y = $__1[1]; - * return (x && y) ? {id, port} : {ip}; - * } - * - * var x, {ip, port} = init({ip, port}); - * - * var x, $__0 = init({ip, port}), ip = $__0.ip, port = $__0.port; - * - */ -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); - -var reservedWordsHelper = _dereq_('./reserved-words-helper'); -var restParamVisitors = _dereq_('./es6-rest-param-visitors'); -var restPropertyHelpers = _dereq_('./es7-rest-property-helpers'); - -// ------------------------------------------------------- -// 1. Structured variable declarations. -// -// var [a, b] = [b, a]; -// var {x, y} = {y, x}; -// ------------------------------------------------------- - -function visitStructuredVariable(traverse, node, path, state) { - // Allocate new temp for the pattern. - utils.append(utils.getTempVar(state.localScope.tempVarIndex) + '=', state); - // Skip the pattern and assign the init to the temp. - utils.catchupWhiteSpace(node.init.range[0], state); - traverse(node.init, path, state); - utils.catchup(node.init.range[1], state); - // Render the destructured data. - utils.append(',' + getDestructuredComponents(node.id, state), state); - state.localScope.tempVarIndex++; - return false; -} - -visitStructuredVariable.test = function(node, path, state) { - return node.type === Syntax.VariableDeclarator && - isStructuredPattern(node.id); -}; - -function isStructuredPattern(node) { - return node.type === Syntax.ObjectPattern || - node.type === Syntax.ArrayPattern; -} - -// Main function which does actual recursive destructuring -// of nested complex structures. -function getDestructuredComponents(node, state) { - var tmpIndex = state.localScope.tempVarIndex; - var components = []; - var patternItems = getPatternItems(node); - - for (var idx = 0; idx < patternItems.length; idx++) { - var item = patternItems[idx]; - if (!item) { - continue; - } - - if (item.type === Syntax.SpreadElement) { - // Spread/rest of an array. - // TODO(dmitrys): support spread in the middle of a pattern - // and also for function param patterns: [x, ...xs, y] - components.push(item.argument.name + - '=Array.prototype.slice.call(' + - utils.getTempVar(tmpIndex) + ',' + idx + ')' - ); - continue; - } - - if (item.type === Syntax.SpreadProperty) { - var restExpression = restPropertyHelpers.renderRestExpression( - utils.getTempVar(tmpIndex), - patternItems - ); - components.push(item.argument.name + '=' + restExpression); - continue; - } - - // Depending on pattern type (Array or Object), we get - // corresponding pattern item parts. - var accessor = getPatternItemAccessor(node, item, tmpIndex, idx); - var value = getPatternItemValue(node, item); - - // TODO(dmitrys): implement default values: {x, y=5} - if (value.type === Syntax.Identifier) { - // Simple pattern item. - components.push(value.name + '=' + accessor); - } else { - // Complex sub-structure. - components.push( - utils.getTempVar(++state.localScope.tempVarIndex) + '=' + accessor + - ',' + getDestructuredComponents(value, state) - ); - } - } - - return components.join(','); -} - -function getPatternItems(node) { - return node.properties || node.elements; -} - -function getPatternItemAccessor(node, patternItem, tmpIndex, idx) { - var tmpName = utils.getTempVar(tmpIndex); - if (node.type === Syntax.ObjectPattern) { - if (reservedWordsHelper.isReservedWord(patternItem.key.name)) { - return tmpName + '["' + patternItem.key.name + '"]'; - } else if (patternItem.key.type === Syntax.Literal) { - return tmpName + '[' + JSON.stringify(patternItem.key.value) + ']'; - } else if (patternItem.key.type === Syntax.Identifier) { - return tmpName + '.' + patternItem.key.name; - } - } else if (node.type === Syntax.ArrayPattern) { - return tmpName + '[' + idx + ']'; - } -} - -function getPatternItemValue(node, patternItem) { - return node.type === Syntax.ObjectPattern - ? patternItem.value - : patternItem; -} - -// ------------------------------------------------------- -// 2. Assignment expression. -// -// [a, b] = [b, a]; -// ({x, y} = {y, x}); -// ------------------------------------------------------- - -function visitStructuredAssignment(traverse, node, path, state) { - var exprNode = node.expression; - utils.append('var ' + utils.getTempVar(state.localScope.tempVarIndex) + '=', state); - - utils.catchupWhiteSpace(exprNode.right.range[0], state); - traverse(exprNode.right, path, state); - utils.catchup(exprNode.right.range[1], state); - - utils.append( - ';' + getDestructuredComponents(exprNode.left, state) + ';', - state - ); - - utils.catchupWhiteSpace(node.range[1], state); - state.localScope.tempVarIndex++; - return false; -} - -visitStructuredAssignment.test = function(node, path, state) { - // We consider the expression statement rather than just assignment - // expression to cover case with object patters which should be - // wrapped in grouping operator: ({x, y} = {y, x}); - return node.type === Syntax.ExpressionStatement && - node.expression.type === Syntax.AssignmentExpression && - isStructuredPattern(node.expression.left); -}; - -// ------------------------------------------------------- -// 3. Structured parameter. -// -// function foo({x, y}) { ... } -// ------------------------------------------------------- - -function visitStructuredParameter(traverse, node, path, state) { - utils.append(utils.getTempVar(getParamIndex(node, path)), state); - utils.catchupWhiteSpace(node.range[1], state); - return true; -} - -function getParamIndex(paramNode, path) { - var funcNode = path[0]; - var tmpIndex = 0; - for (var k = 0; k < funcNode.params.length; k++) { - var param = funcNode.params[k]; - if (param === paramNode) { - break; - } - if (isStructuredPattern(param)) { - tmpIndex++; - } - } - return tmpIndex; -} - -visitStructuredParameter.test = function(node, path, state) { - return isStructuredPattern(node) && isFunctionNode(path[0]); -}; - -function isFunctionNode(node) { - return (node.type == Syntax.FunctionDeclaration || - node.type == Syntax.FunctionExpression || - node.type == Syntax.MethodDefinition || - node.type == Syntax.ArrowFunctionExpression); -} - -// ------------------------------------------------------- -// 4. Function body for structured parameters. -// -// function foo({x, y}) { x; y; } -// ------------------------------------------------------- - -function visitFunctionBodyForStructuredParameter(traverse, node, path, state) { - var funcNode = path[0]; - - utils.catchup(funcNode.body.range[0] + 1, state); - renderDestructuredComponents(funcNode, state); - - if (funcNode.rest) { - utils.append( - restParamVisitors.renderRestParamSetup(funcNode, state), - state - ); - } - - return true; -} - -function renderDestructuredComponents(funcNode, state) { - var destructuredComponents = []; - - for (var k = 0; k < funcNode.params.length; k++) { - var param = funcNode.params[k]; - if (isStructuredPattern(param)) { - destructuredComponents.push( - getDestructuredComponents(param, state) - ); - state.localScope.tempVarIndex++; - } - } - - if (destructuredComponents.length) { - utils.append('var ' + destructuredComponents.join(',') + ';', state); - } -} - -visitFunctionBodyForStructuredParameter.test = function(node, path, state) { - return node.type === Syntax.BlockStatement && isFunctionNode(path[0]); -}; - -exports.visitorList = [ - visitStructuredVariable, - visitStructuredAssignment, - visitStructuredParameter, - visitFunctionBodyForStructuredParameter -]; - -exports.renderDestructuredComponents = renderDestructuredComponents; - - -},{"../src/utils":23,"./es6-rest-param-visitors":30,"./es7-rest-property-helpers":32,"./reserved-words-helper":34,"esprima-fb":9}],28:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*jslint node:true*/ - -/** - * Desugars concise methods of objects to function expressions. - * - * var foo = { - * method(x, y) { ... } - * }; - * - * var foo = { - * method: function(x, y) { ... } - * }; - * - */ - -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); -var reservedWordsHelper = _dereq_('./reserved-words-helper'); - -function visitObjectConciseMethod(traverse, node, path, state) { - var isGenerator = node.value.generator; - if (isGenerator) { - utils.catchupWhiteSpace(node.range[0] + 1, state); - } - if (node.computed) { // []() { ...} - utils.catchup(node.key.range[1] + 1, state); - } else if (reservedWordsHelper.isReservedWord(node.key.name)) { - utils.catchup(node.key.range[0], state); - utils.append('"', state); - utils.catchup(node.key.range[1], state); - utils.append('"', state); - } - - utils.catchup(node.key.range[1], state); - utils.append( - ':function' + (isGenerator ? '*' : ''), - state - ); - path.unshift(node); - traverse(node.value, path, state); - path.shift(); - return false; -} - -visitObjectConciseMethod.test = function(node, path, state) { - return node.type === Syntax.Property && - node.value.type === Syntax.FunctionExpression && - node.method === true; -}; - -exports.visitorList = [ - visitObjectConciseMethod -]; - -},{"../src/utils":23,"./reserved-words-helper":34,"esprima-fb":9}],29:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*jslint node: true*/ - -/** - * Desugars ES6 Object Literal short notations into ES3 full notation. - * - * // Easier return values. - * function foo(x, y) { - * return {x, y}; // {x: x, y: y} - * }; - * - * // Destructuring. - * function init({port, ip, coords: {x, y}}) { ... } - * - */ -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); - -/** - * @public - */ -function visitObjectLiteralShortNotation(traverse, node, path, state) { - utils.catchup(node.key.range[1], state); - utils.append(':' + node.key.name, state); - return false; -} - -visitObjectLiteralShortNotation.test = function(node, path, state) { - return node.type === Syntax.Property && - node.kind === 'init' && - node.shorthand === true && - path[0].type !== Syntax.ObjectPattern; -}; - -exports.visitorList = [ - visitObjectLiteralShortNotation -]; - - -},{"../src/utils":23,"esprima-fb":9}],30:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*jslint node:true*/ - -/** - * Desugars ES6 rest parameters into an ES3 arguments array. - * - * function printf(template, ...args) { - * args.forEach(...); - * } - * - * We could use `Array.prototype.slice.call`, but that usage of arguments causes - * functions to be deoptimized in V8, so instead we use a for-loop. - * - * function printf(template) { - * for (var args = [], $__0 = 1, $__1 = arguments.length; $__0 < $__1; $__0++) - * args.push(arguments[$__0]); - * args.forEach(...); - * } - * - */ -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); - - - -function _nodeIsFunctionWithRestParam(node) { - return (node.type === Syntax.FunctionDeclaration - || node.type === Syntax.FunctionExpression - || node.type === Syntax.ArrowFunctionExpression) - && node.rest; -} - -function visitFunctionParamsWithRestParam(traverse, node, path, state) { - if (node.parametricType) { - utils.catchup(node.parametricType.range[0], state); - path.unshift(node); - traverse(node.parametricType, path, state); - path.shift(); - } - - // Render params. - if (node.params.length) { - path.unshift(node); - traverse(node.params, path, state); - path.shift(); - } else { - // -3 is for ... of the rest. - utils.catchup(node.rest.range[0] - 3, state); - } - utils.catchupWhiteSpace(node.rest.range[1], state); - - path.unshift(node); - traverse(node.body, path, state); - path.shift(); - - return false; -} - -visitFunctionParamsWithRestParam.test = function(node, path, state) { - return _nodeIsFunctionWithRestParam(node); -}; - -function renderRestParamSetup(functionNode, state) { - var idx = state.localScope.tempVarIndex++; - var len = state.localScope.tempVarIndex++; - - return 'for (var ' + functionNode.rest.name + '=[],' + - utils.getTempVar(idx) + '=' + functionNode.params.length + ',' + - utils.getTempVar(len) + '=arguments.length;' + - utils.getTempVar(idx) + '<' + utils.getTempVar(len) + ';' + - utils.getTempVar(idx) + '++) ' + - functionNode.rest.name + '.push(arguments[' + utils.getTempVar(idx) + ']);'; -} - -function visitFunctionBodyWithRestParam(traverse, node, path, state) { - utils.catchup(node.range[0] + 1, state); - var parentNode = path[0]; - utils.append(renderRestParamSetup(parentNode, state), state); - return true; -} - -visitFunctionBodyWithRestParam.test = function(node, path, state) { - return node.type === Syntax.BlockStatement - && _nodeIsFunctionWithRestParam(path[0]); -}; - -exports.renderRestParamSetup = renderRestParamSetup; -exports.visitorList = [ - visitFunctionParamsWithRestParam, - visitFunctionBodyWithRestParam -]; - -},{"../src/utils":23,"esprima-fb":9}],31:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*jslint node:true*/ - -/** - * @typechecks - */ -'use strict'; - -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); - -/** - * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-12.1.9 - */ -function visitTemplateLiteral(traverse, node, path, state) { - var templateElements = node.quasis; - - utils.append('(', state); - for (var ii = 0; ii < templateElements.length; ii++) { - var templateElement = templateElements[ii]; - if (templateElement.value.raw !== '') { - utils.append(getCookedValue(templateElement), state); - if (!templateElement.tail) { - // + between element and substitution - utils.append(' + ', state); - } - // maintain line numbers - utils.move(templateElement.range[0], state); - utils.catchupNewlines(templateElement.range[1], state); - } else { // templateElement.value.raw === '' - // Concatenat adjacent substitutions, e.g. `${x}${y}`. Empty templates - // appear before the first and after the last element - nothing to add in - // those cases. - if (ii > 0 && !templateElement.tail) { - // + between substitution and substitution - utils.append(' + ', state); - } - } - - utils.move(templateElement.range[1], state); - if (!templateElement.tail) { - var substitution = node.expressions[ii]; - if (substitution.type === Syntax.Identifier || - substitution.type === Syntax.MemberExpression || - substitution.type === Syntax.CallExpression) { - utils.catchup(substitution.range[1], state); - } else { - utils.append('(', state); - traverse(substitution, path, state); - utils.catchup(substitution.range[1], state); - utils.append(')', state); - } - // if next templateElement isn't empty... - if (templateElements[ii + 1].value.cooked !== '') { - utils.append(' + ', state); - } - } - } - utils.move(node.range[1], state); - utils.append(')', state); - return false; -} - -visitTemplateLiteral.test = function(node, path, state) { - return node.type === Syntax.TemplateLiteral; -}; - -/** - * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-12.2.6 - */ -function visitTaggedTemplateExpression(traverse, node, path, state) { - var template = node.quasi; - var numQuasis = template.quasis.length; - - // print the tag - utils.move(node.tag.range[0], state); - traverse(node.tag, path, state); - utils.catchup(node.tag.range[1], state); - - // print array of template elements - utils.append('(function() { var siteObj = [', state); - for (var ii = 0; ii < numQuasis; ii++) { - utils.append(getCookedValue(template.quasis[ii]), state); - if (ii !== numQuasis - 1) { - utils.append(', ', state); - } - } - utils.append(']; siteObj.raw = [', state); - for (ii = 0; ii < numQuasis; ii++) { - utils.append(getRawValue(template.quasis[ii]), state); - if (ii !== numQuasis - 1) { - utils.append(', ', state); - } - } - utils.append( - ']; Object.freeze(siteObj.raw); Object.freeze(siteObj); return siteObj; }()', - state - ); - - // print substitutions - if (numQuasis > 1) { - for (ii = 0; ii < template.expressions.length; ii++) { - var expression = template.expressions[ii]; - utils.append(', ', state); - - // maintain line numbers by calling catchupWhiteSpace over the whole - // previous TemplateElement - utils.move(template.quasis[ii].range[0], state); - utils.catchupNewlines(template.quasis[ii].range[1], state); - - utils.move(expression.range[0], state); - traverse(expression, path, state); - utils.catchup(expression.range[1], state); - } - } - - // print blank lines to push the closing ) down to account for the final - // TemplateElement. - utils.catchupNewlines(node.range[1], state); - - utils.append(')', state); - - return false; -} - -visitTaggedTemplateExpression.test = function(node, path, state) { - return node.type === Syntax.TaggedTemplateExpression; -}; - -function getCookedValue(templateElement) { - return JSON.stringify(templateElement.value.cooked); -} - -function getRawValue(templateElement) { - return JSON.stringify(templateElement.value.raw); -} - -exports.visitorList = [ - visitTemplateLiteral, - visitTaggedTemplateExpression -]; - -},{"../src/utils":23,"esprima-fb":9}],32:[function(_dereq_,module,exports){ -/** - * Copyright 2013 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*jslint node:true*/ - -/** - * Desugars ES7 rest properties into ES5 object iteration. - */ - -var Syntax = _dereq_('esprima-fb').Syntax; - -// TODO: This is a pretty massive helper, it should only be defined once, in the -// transform's runtime environment. We don't currently have a runtime though. -var restFunction = - '(function(source, exclusion) {' + - 'var rest = {};' + - 'var hasOwn = Object.prototype.hasOwnProperty;' + - 'if (source == null) {' + - 'throw new TypeError();' + - '}' + - 'for (var key in source) {' + - 'if (hasOwn.call(source, key) && !hasOwn.call(exclusion, key)) {' + - 'rest[key] = source[key];' + - '}' + - '}' + - 'return rest;' + - '})'; - -function getPropertyNames(properties) { - var names = []; - for (var i = 0; i < properties.length; i++) { - var property = properties[i]; - if (property.type === Syntax.SpreadProperty) { - continue; - } - if (property.type === Syntax.Identifier) { - names.push(property.name); - } else { - names.push(property.key.name); - } - } - return names; -} - -function getRestFunctionCall(source, exclusion) { - return restFunction + '(' + source + ',' + exclusion + ')'; -} - -function getSimpleShallowCopy(accessorExpression) { - // This could be faster with 'Object.assign({}, ' + accessorExpression + ')' - // but to unify code paths and avoid a ES6 dependency we use the same - // helper as for the exclusion case. - return getRestFunctionCall(accessorExpression, '{}'); -} - -function renderRestExpression(accessorExpression, excludedProperties) { - var excludedNames = getPropertyNames(excludedProperties); - if (!excludedNames.length) { - return getSimpleShallowCopy(accessorExpression); - } - return getRestFunctionCall( - accessorExpression, - '{' + excludedNames.join(':1,') + ':1}' - ); -} - -exports.renderRestExpression = renderRestExpression; - -},{"esprima-fb":9}],33:[function(_dereq_,module,exports){ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - */ -/*global exports:true*/ - -/** - * Implements ES7 object spread property. - * https://gist.github.com/sebmarkbage/aa849c7973cb4452c547 - * - * { ...a, x: 1 } - * - * Object.assign({}, a, {x: 1 }) - * - */ - -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); - -function visitObjectLiteralSpread(traverse, node, path, state) { - utils.catchup(node.range[0], state); - - utils.append('Object.assign({', state); - - // Skip the original { - utils.move(node.range[0] + 1, state); - - var previousWasSpread = false; - - for (var i = 0; i < node.properties.length; i++) { - var property = node.properties[i]; - if (property.type === Syntax.SpreadProperty) { - - // Close the previous object or initial object - if (!previousWasSpread) { - utils.append('}', state); - } - - if (i === 0) { - // Normally there will be a comma when we catch up, but not before - // the first property. - utils.append(',', state); - } - - utils.catchup(property.range[0], state); - - // skip ... - utils.move(property.range[0] + 3, state); - - traverse(property.argument, path, state); - - utils.catchup(property.range[1], state); - - previousWasSpread = true; - - } else { - - utils.catchup(property.range[0], state); - - if (previousWasSpread) { - utils.append('{', state); - } - - traverse(property, path, state); - - utils.catchup(property.range[1], state); - - previousWasSpread = false; - - } - } - - // Strip any non-whitespace between the last item and the end. - // We only catch up on whitespace so that we ignore any trailing commas which - // are stripped out for IE8 support. Unfortunately, this also strips out any - // trailing comments. - utils.catchupWhiteSpace(node.range[1] - 1, state); - - // Skip the trailing } - utils.move(node.range[1], state); - - if (!previousWasSpread) { - utils.append('}', state); - } - - utils.append(')', state); - return false; -} - -visitObjectLiteralSpread.test = function(node, path, state) { - if (node.type !== Syntax.ObjectExpression) { - return false; - } - // Tight loop optimization - var hasAtLeastOneSpreadProperty = false; - for (var i = 0; i < node.properties.length; i++) { - var property = node.properties[i]; - if (property.type === Syntax.SpreadProperty) { - hasAtLeastOneSpreadProperty = true; - } else if (property.kind !== 'init') { - return false; - } - } - return hasAtLeastOneSpreadProperty; -}; - -exports.visitorList = [ - visitObjectLiteralSpread -]; - -},{"../src/utils":23,"esprima-fb":9}],34:[function(_dereq_,module,exports){ -/** - * Copyright 2014 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var KEYWORDS = [ - 'break', 'do', 'in', 'typeof', 'case', 'else', 'instanceof', 'var', 'catch', - 'export', 'new', 'void', 'class', 'extends', 'return', 'while', 'const', - 'finally', 'super', 'with', 'continue', 'for', 'switch', 'yield', 'debugger', - 'function', 'this', 'default', 'if', 'throw', 'delete', 'import', 'try' -]; - -var FUTURE_RESERVED_WORDS = [ - 'enum', 'await', 'implements', 'package', 'protected', 'static', 'interface', - 'private', 'public' -]; - -var LITERALS = [ - 'null', - 'true', - 'false' -]; - -// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-reserved-words -var RESERVED_WORDS = [].concat( - KEYWORDS, - FUTURE_RESERVED_WORDS, - LITERALS -); - -var reservedWordsMap = Object.create(null); -RESERVED_WORDS.forEach(function(k) { - reservedWordsMap[k] = true; -}); - -/** - * This list should not grow as new reserved words are introdued. This list is - * of words that need to be quoted because ES3-ish browsers do not allow their - * use as identifier names. - */ -var ES3_FUTURE_RESERVED_WORDS = [ - 'enum', 'implements', 'package', 'protected', 'static', 'interface', - 'private', 'public' -]; - -var ES3_RESERVED_WORDS = [].concat( - KEYWORDS, - ES3_FUTURE_RESERVED_WORDS, - LITERALS -); - -var es3ReservedWordsMap = Object.create(null); -ES3_RESERVED_WORDS.forEach(function(k) { - es3ReservedWordsMap[k] = true; -}); - -exports.isReservedWord = function(word) { - return !!reservedWordsMap[word]; -}; - -exports.isES3ReservedWord = function(word) { - return !!es3ReservedWordsMap[word]; -}; - -},{}],35:[function(_dereq_,module,exports){ -/** - * Copyright 2014 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -/*global exports:true*/ - -var Syntax = _dereq_('esprima-fb').Syntax; -var utils = _dereq_('../src/utils'); -var reserverdWordsHelper = _dereq_('./reserved-words-helper'); - -/** - * Code adapted from https://github.com/spicyj/es3ify - * The MIT License (MIT) - * Copyright (c) 2014 Ben Alpert - */ - -function visitProperty(traverse, node, path, state) { - utils.catchup(node.key.range[0], state); - utils.append('"', state); - utils.catchup(node.key.range[1], state); - utils.append('"', state); - utils.catchup(node.value.range[0], state); - traverse(node.value, path, state); - return false; -} - -visitProperty.test = function(node) { - return node.type === Syntax.Property && - node.key.type === Syntax.Identifier && - !node.method && - !node.shorthand && - !node.computed && - reserverdWordsHelper.isES3ReservedWord(node.key.name); -}; - -function visitMemberExpression(traverse, node, path, state) { - traverse(node.object, path, state); - utils.catchup(node.property.range[0] - 1, state); - utils.append('[', state); - utils.catchupWhiteSpace(node.property.range[0], state); - utils.append('"', state); - utils.catchup(node.property.range[1], state); - utils.append('"]', state); - return false; -} - -visitMemberExpression.test = function(node) { - return node.type === Syntax.MemberExpression && - node.property.type === Syntax.Identifier && - reserverdWordsHelper.isES3ReservedWord(node.property.name); -}; - -exports.visitorList = [ - visitProperty, - visitMemberExpression -]; - -},{"../src/utils":23,"./reserved-words-helper":34,"esprima-fb":9}],36:[function(_dereq_,module,exports){ -var esprima = _dereq_('esprima-fb'); -var utils = _dereq_('../src/utils'); - -var Syntax = esprima.Syntax; - -function _isFunctionNode(node) { - return node.type === Syntax.FunctionDeclaration - || node.type === Syntax.FunctionExpression - || node.type === Syntax.ArrowFunctionExpression; -} - -function visitClassProperty(traverse, node, path, state) { - utils.catchup(node.range[0], state); - utils.catchupWhiteOut(node.range[1], state); - return false; -} -visitClassProperty.test = function(node, path, state) { - return node.type === Syntax.ClassProperty; -}; - -function visitTypeAlias(traverse, node, path, state) { - utils.catchupWhiteOut(node.range[1], state); - return false; -} -visitTypeAlias.test = function(node, path, state) { - return node.type === Syntax.TypeAlias; -}; - -function visitTypeCast(traverse, node, path, state) { - path.unshift(node); - traverse(node.expression, path, state); - path.shift(); - - utils.catchup(node.typeAnnotation.range[0], state); - utils.catchupWhiteOut(node.typeAnnotation.range[1], state); - return false; -} -visitTypeCast.test = function(node, path, state) { - return node.type === Syntax.TypeCastExpression; -}; - -function visitInterfaceDeclaration(traverse, node, path, state) { - utils.catchupWhiteOut(node.range[1], state); - return false; -} -visitInterfaceDeclaration.test = function(node, path, state) { - return node.type === Syntax.InterfaceDeclaration; -}; - -function visitDeclare(traverse, node, path, state) { - utils.catchupWhiteOut(node.range[1], state); - return false; -} -visitDeclare.test = function(node, path, state) { - switch (node.type) { - case Syntax.DeclareVariable: - case Syntax.DeclareFunction: - case Syntax.DeclareClass: - case Syntax.DeclareModule: - return true; - } - return false; -}; - -function visitFunctionParametricAnnotation(traverse, node, path, state) { - utils.catchup(node.range[0], state); - utils.catchupWhiteOut(node.range[1], state); - return false; -} -visitFunctionParametricAnnotation.test = function(node, path, state) { - return node.type === Syntax.TypeParameterDeclaration - && path[0] - && _isFunctionNode(path[0]) - && node === path[0].typeParameters; -}; - -function visitFunctionReturnAnnotation(traverse, node, path, state) { - utils.catchup(node.range[0], state); - utils.catchupWhiteOut(node.range[1], state); - return false; -} -visitFunctionReturnAnnotation.test = function(node, path, state) { - return path[0] && _isFunctionNode(path[0]) && node === path[0].returnType; -}; - -function visitOptionalFunctionParameterAnnotation(traverse, node, path, state) { - utils.catchup(node.range[0] + node.name.length, state); - utils.catchupWhiteOut(node.range[1], state); - return false; -} -visitOptionalFunctionParameterAnnotation.test = function(node, path, state) { - return node.type === Syntax.Identifier - && node.optional - && path[0] - && _isFunctionNode(path[0]); -}; - -function visitTypeAnnotatedIdentifier(traverse, node, path, state) { - utils.catchup(node.typeAnnotation.range[0], state); - utils.catchupWhiteOut(node.typeAnnotation.range[1], state); - return false; -} -visitTypeAnnotatedIdentifier.test = function(node, path, state) { - return node.type === Syntax.Identifier && node.typeAnnotation; -}; - -function visitTypeAnnotatedObjectOrArrayPattern(traverse, node, path, state) { - utils.catchup(node.typeAnnotation.range[0], state); - utils.catchupWhiteOut(node.typeAnnotation.range[1], state); - return false; -} -visitTypeAnnotatedObjectOrArrayPattern.test = function(node, path, state) { - var rightType = node.type === Syntax.ObjectPattern - || node.type === Syntax.ArrayPattern; - return rightType && node.typeAnnotation; -}; - -/** - * Methods cause trouble, since esprima parses them as a key/value pair, where - * the location of the value starts at the method body. For example - * { bar(x:number,...y:Array):number {} } - * is parsed as - * { bar: function(x: number, ...y:Array): number {} } - * except that the location of the FunctionExpression value is 40-something, - * which is the location of the function body. This means that by the time we - * visit the params, rest param, and return type organically, we've already - * catchup()'d passed them. - */ -function visitMethod(traverse, node, path, state) { - path.unshift(node); - traverse(node.key, path, state); - - path.unshift(node.value); - traverse(node.value.params, path, state); - node.value.rest && traverse(node.value.rest, path, state); - node.value.returnType && traverse(node.value.returnType, path, state); - traverse(node.value.body, path, state); - - path.shift(); - - path.shift(); - return false; -} - -visitMethod.test = function(node, path, state) { - return (node.type === "Property" && (node.method || node.kind === "set" || node.kind === "get")) - || (node.type === "MethodDefinition"); -}; - -function visitImportType(traverse, node, path, state) { - utils.catchupWhiteOut(node.range[1], state); - return false; -} -visitImportType.test = function(node, path, state) { - return node.type === 'ImportDeclaration' - && node.isType; -}; - -exports.visitorList = [ - visitClassProperty, - visitDeclare, - visitImportType, - visitInterfaceDeclaration, - visitFunctionParametricAnnotation, - visitFunctionReturnAnnotation, - visitMethod, - visitOptionalFunctionParameterAnnotation, - visitTypeAlias, - visitTypeCast, - visitTypeAnnotatedIdentifier, - visitTypeAnnotatedObjectOrArrayPattern -]; - -},{"../src/utils":23,"esprima-fb":9}],37:[function(_dereq_,module,exports){ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -/*global exports:true*/ -'use strict'; -var Syntax = _dereq_('jstransform').Syntax; -var utils = _dereq_('jstransform/src/utils'); - -function renderJSXLiteral(object, isLast, state, start, end) { - var lines = object.value.split(/\r\n|\n|\r/); - - if (start) { - utils.append(start, state); - } - - var lastNonEmptyLine = 0; - - lines.forEach(function(line, index) { - if (line.match(/[^ \t]/)) { - lastNonEmptyLine = index; - } - }); - - lines.forEach(function(line, index) { - var isFirstLine = index === 0; - var isLastLine = index === lines.length - 1; - var isLastNonEmptyLine = index === lastNonEmptyLine; - - // replace rendered whitespace tabs with spaces - var trimmedLine = line.replace(/\t/g, ' '); - - // trim whitespace touching a newline - if (!isFirstLine) { - trimmedLine = trimmedLine.replace(/^[ ]+/, ''); - } - if (!isLastLine) { - trimmedLine = trimmedLine.replace(/[ ]+$/, ''); - } - - if (!isFirstLine) { - utils.append(line.match(/^[ \t]*/)[0], state); - } - - if (trimmedLine || isLastNonEmptyLine) { - utils.append( - JSON.stringify(trimmedLine) + - (!isLastNonEmptyLine ? ' + \' \' +' : ''), - state); - - if (isLastNonEmptyLine) { - if (end) { - utils.append(end, state); - } - if (!isLast) { - utils.append(', ', state); - } - } - - // only restore tail whitespace if line had literals - if (trimmedLine && !isLastLine) { - utils.append(line.match(/[ \t]*$/)[0], state); - } - } - - if (!isLastLine) { - utils.append('\n', state); - } - }); - - utils.move(object.range[1], state); -} - -function renderJSXExpressionContainer(traverse, object, isLast, path, state) { - // Plus 1 to skip `{`. - utils.move(object.range[0] + 1, state); - utils.catchup(object.expression.range[0], state); - traverse(object.expression, path, state); - - if (!isLast && object.expression.type !== Syntax.JSXEmptyExpression) { - // If we need to append a comma, make sure to do so after the expression. - utils.catchup(object.expression.range[1], state, trimLeft); - utils.append(', ', state); - } - - // Minus 1 to skip `}`. - utils.catchup(object.range[1] - 1, state, trimLeft); - utils.move(object.range[1], state); - return false; -} - -function quoteAttrName(attr) { - // Quote invalid JS identifiers. - if (!/^[a-z_$][a-z\d_$]*$/i.test(attr)) { - return '"' + attr + '"'; - } - return attr; -} - -function trimLeft(value) { - return value.replace(/^[ ]+/, ''); -} - -exports.renderJSXExpressionContainer = renderJSXExpressionContainer; -exports.renderJSXLiteral = renderJSXLiteral; -exports.quoteAttrName = quoteAttrName; -exports.trimLeft = trimLeft; - -},{"jstransform":22,"jstransform/src/utils":23}],38:[function(_dereq_,module,exports){ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -/*global exports:true*/ -'use strict'; - -var Syntax = _dereq_('jstransform').Syntax; -var utils = _dereq_('jstransform/src/utils'); - -var renderJSXExpressionContainer = - _dereq_('./jsx').renderJSXExpressionContainer; -var renderJSXLiteral = _dereq_('./jsx').renderJSXLiteral; -var quoteAttrName = _dereq_('./jsx').quoteAttrName; - -var trimLeft = _dereq_('./jsx').trimLeft; - -/** - * Customized desugar processor for React JSX. Currently: - * - * => React.createElement(X, null) - * => React.createElement(X, {prop: '1'}, null) - * => React.createElement(X, {prop:'2'}, - * React.createElement(Y, null) - * ) - *
=> React.createElement("div", null) - */ - -/** - * Removes all non-whitespace/parenthesis characters - */ -var reNonWhiteParen = /([^\s\(\)])/g; -function stripNonWhiteParen(value) { - return value.replace(reNonWhiteParen, ''); -} - -var tagConvention = /^[a-z]|\-/; -function isTagName(name) { - return tagConvention.test(name); -} - -function visitReactTag(traverse, object, path, state) { - var openingElement = object.openingElement; - var nameObject = openingElement.name; - var attributesObject = openingElement.attributes; - - utils.catchup(openingElement.range[0], state, trimLeft); - - if (nameObject.type === Syntax.JSXNamespacedName && nameObject.namespace) { - throw new Error('Namespace tags are not supported. ReactJSX is not XML.'); - } - - // We assume that the React runtime is already in scope - utils.append('React.createElement(', state); - - if (nameObject.type === Syntax.JSXIdentifier && isTagName(nameObject.name)) { - utils.append('"' + nameObject.name + '"', state); - utils.move(nameObject.range[1], state); - } else { - // Use utils.catchup in this case so we can easily handle - // JSXMemberExpressions which look like Foo.Bar.Baz. This also handles - // JSXIdentifiers that aren't fallback tags. - utils.move(nameObject.range[0], state); - utils.catchup(nameObject.range[1], state); - } - - utils.append(', ', state); - - var hasAttributes = attributesObject.length; - - var hasAtLeastOneSpreadProperty = attributesObject.some(function(attr) { - return attr.type === Syntax.JSXSpreadAttribute; - }); - - // if we don't have any attributes, pass in null - if (hasAtLeastOneSpreadProperty) { - utils.append('React.__spread({', state); - } else if (hasAttributes) { - utils.append('{', state); - } else { - utils.append('null', state); - } - - // keep track of if the previous attribute was a spread attribute - var previousWasSpread = false; - - // write attributes - attributesObject.forEach(function(attr, index) { - var isLast = index === attributesObject.length - 1; - - if (attr.type === Syntax.JSXSpreadAttribute) { - // Close the previous object or initial object - if (!previousWasSpread) { - utils.append('}, ', state); - } - - // Move to the expression start, ignoring everything except parenthesis - // and whitespace. - utils.catchup(attr.range[0], state, stripNonWhiteParen); - // Plus 1 to skip `{`. - utils.move(attr.range[0] + 1, state); - utils.catchup(attr.argument.range[0], state, stripNonWhiteParen); - - traverse(attr.argument, path, state); - - utils.catchup(attr.argument.range[1], state); - - // Move to the end, ignoring parenthesis and the closing `}` - utils.catchup(attr.range[1] - 1, state, stripNonWhiteParen); - - if (!isLast) { - utils.append(', ', state); - } - - utils.move(attr.range[1], state); - - previousWasSpread = true; - - return; - } - - // If the next attribute is a spread, we're effective last in this object - if (!isLast) { - isLast = attributesObject[index + 1].type === Syntax.JSXSpreadAttribute; - } - - if (attr.name.namespace) { - throw new Error( - 'Namespace attributes are not supported. ReactJSX is not XML.'); - } - var name = attr.name.name; - - utils.catchup(attr.range[0], state, trimLeft); - - if (previousWasSpread) { - utils.append('{', state); - } - - utils.append(quoteAttrName(name), state); - utils.append(': ', state); - - if (!attr.value) { - state.g.buffer += 'true'; - state.g.position = attr.name.range[1]; - if (!isLast) { - utils.append(', ', state); - } - } else { - utils.move(attr.name.range[1], state); - // Use catchupNewlines to skip over the '=' in the attribute - utils.catchupNewlines(attr.value.range[0], state); - if (attr.value.type === Syntax.Literal) { - renderJSXLiteral(attr.value, isLast, state); - } else { - renderJSXExpressionContainer(traverse, attr.value, isLast, path, state); - } - } - - utils.catchup(attr.range[1], state, trimLeft); - - previousWasSpread = false; - - }); - - if (!openingElement.selfClosing) { - utils.catchup(openingElement.range[1] - 1, state, trimLeft); - utils.move(openingElement.range[1], state); - } - - if (hasAttributes && !previousWasSpread) { - utils.append('}', state); - } - - if (hasAtLeastOneSpreadProperty) { - utils.append(')', state); - } - - // filter out whitespace - var childrenToRender = object.children.filter(function(child) { - return !(child.type === Syntax.Literal - && typeof child.value === 'string' - && child.value.match(/^[ \t]*[\r\n][ \t\r\n]*$/)); - }); - if (childrenToRender.length > 0) { - var lastRenderableIndex; - - childrenToRender.forEach(function(child, index) { - if (child.type !== Syntax.JSXExpressionContainer || - child.expression.type !== Syntax.JSXEmptyExpression) { - lastRenderableIndex = index; - } - }); - - if (lastRenderableIndex !== undefined) { - utils.append(', ', state); - } - - childrenToRender.forEach(function(child, index) { - utils.catchup(child.range[0], state, trimLeft); - - var isLast = index >= lastRenderableIndex; - - if (child.type === Syntax.Literal) { - renderJSXLiteral(child, isLast, state); - } else if (child.type === Syntax.JSXExpressionContainer) { - renderJSXExpressionContainer(traverse, child, isLast, path, state); - } else { - traverse(child, path, state); - if (!isLast) { - utils.append(', ', state); - } - } - - utils.catchup(child.range[1], state, trimLeft); - }); - } - - if (openingElement.selfClosing) { - // everything up to /> - utils.catchup(openingElement.range[1] - 2, state, trimLeft); - utils.move(openingElement.range[1], state); - } else { - // everything up to - utils.catchup(object.closingElement.range[0], state, trimLeft); - utils.move(object.closingElement.range[1], state); - } - - utils.append(')', state); - return false; -} - -visitReactTag.test = function(object, path, state) { - return object.type === Syntax.JSXElement; -}; - -exports.visitorList = [ - visitReactTag -]; - -},{"./jsx":37,"jstransform":22,"jstransform/src/utils":23}],39:[function(_dereq_,module,exports){ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -/*global exports:true*/ -'use strict'; - -var Syntax = _dereq_('jstransform').Syntax; -var utils = _dereq_('jstransform/src/utils'); - -function addDisplayName(displayName, object, state) { - if (object && - object.type === Syntax.CallExpression && - object.callee.type === Syntax.MemberExpression && - object.callee.object.type === Syntax.Identifier && - object.callee.object.name === 'React' && - object.callee.property.type === Syntax.Identifier && - object.callee.property.name === 'createClass' && - object.arguments.length === 1 && - object.arguments[0].type === Syntax.ObjectExpression) { - // Verify that the displayName property isn't already set - var properties = object.arguments[0].properties; - var safe = properties.every(function(property) { - var value = property.key.type === Syntax.Identifier ? - property.key.name : - property.key.value; - return value !== 'displayName'; - }); - - if (safe) { - utils.catchup(object.arguments[0].range[0] + 1, state); - utils.append('displayName: "' + displayName + '",', state); - } - } -} - -/** - * Transforms the following: - * - * var MyComponent = React.createClass({ - * render: ... - * }); - * - * into: - * - * var MyComponent = React.createClass({ - * displayName: 'MyComponent', - * render: ... - * }); - * - * Also catches: - * - * MyComponent = React.createClass(...); - * exports.MyComponent = React.createClass(...); - * module.exports = {MyComponent: React.createClass(...)}; - */ -function visitReactDisplayName(traverse, object, path, state) { - var left, right; - - if (object.type === Syntax.AssignmentExpression) { - left = object.left; - right = object.right; - } else if (object.type === Syntax.Property) { - left = object.key; - right = object.value; - } else if (object.type === Syntax.VariableDeclarator) { - left = object.id; - right = object.init; - } - - if (left && left.type === Syntax.MemberExpression) { - left = left.property; - } - if (left && left.type === Syntax.Identifier) { - addDisplayName(left.name, right, state); - } -} - -visitReactDisplayName.test = function(object, path, state) { - return ( - object.type === Syntax.AssignmentExpression || - object.type === Syntax.Property || - object.type === Syntax.VariableDeclarator - ); -}; - -exports.visitorList = [ - visitReactDisplayName -]; - -},{"jstransform":22,"jstransform/src/utils":23}],40:[function(_dereq_,module,exports){ -/*global exports:true*/ - -'use strict'; - -var es6ArrowFunctions = - _dereq_('jstransform/visitors/es6-arrow-function-visitors'); -var es6Classes = _dereq_('jstransform/visitors/es6-class-visitors'); -var es6Destructuring = - _dereq_('jstransform/visitors/es6-destructuring-visitors'); -var es6ObjectConciseMethod = - _dereq_('jstransform/visitors/es6-object-concise-method-visitors'); -var es6ObjectShortNotation = - _dereq_('jstransform/visitors/es6-object-short-notation-visitors'); -var es6RestParameters = _dereq_('jstransform/visitors/es6-rest-param-visitors'); -var es6Templates = _dereq_('jstransform/visitors/es6-template-visitors'); -var es6CallSpread = - _dereq_('jstransform/visitors/es6-call-spread-visitors'); -var es7SpreadProperty = - _dereq_('jstransform/visitors/es7-spread-property-visitors'); -var react = _dereq_('./transforms/react'); -var reactDisplayName = _dereq_('./transforms/reactDisplayName'); -var reservedWords = _dereq_('jstransform/visitors/reserved-words-visitors'); - -/** - * Map from transformName => orderedListOfVisitors. - */ -var transformVisitors = { - 'es6-arrow-functions': es6ArrowFunctions.visitorList, - 'es6-classes': es6Classes.visitorList, - 'es6-destructuring': es6Destructuring.visitorList, - 'es6-object-concise-method': es6ObjectConciseMethod.visitorList, - 'es6-object-short-notation': es6ObjectShortNotation.visitorList, - 'es6-rest-params': es6RestParameters.visitorList, - 'es6-templates': es6Templates.visitorList, - 'es6-call-spread': es6CallSpread.visitorList, - 'es7-spread-property': es7SpreadProperty.visitorList, - 'react': react.visitorList.concat(reactDisplayName.visitorList), - 'reserved-words': reservedWords.visitorList -}; - -var transformSets = { - 'harmony': [ - 'es6-arrow-functions', - 'es6-object-concise-method', - 'es6-object-short-notation', - 'es6-classes', - 'es6-rest-params', - 'es6-templates', - 'es6-destructuring', - 'es6-call-spread', - 'es7-spread-property' - ], - 'es3': [ - 'reserved-words' - ], - 'react': [ - 'react' - ] -}; - -/** - * Specifies the order in which each transform should run. - */ -var transformRunOrder = [ - 'reserved-words', - 'es6-arrow-functions', - 'es6-object-concise-method', - 'es6-object-short-notation', - 'es6-classes', - 'es6-rest-params', - 'es6-templates', - 'es6-destructuring', - 'es6-call-spread', - 'es7-spread-property', - 'react' -]; - -/** - * Given a list of transform names, return the ordered list of visitors to be - * passed to the transform() function. - * - * @param {array?} excludes - * @return {array} - */ -function getAllVisitors(excludes) { - var ret = []; - for (var i = 0, il = transformRunOrder.length; i < il; i++) { - if (!excludes || excludes.indexOf(transformRunOrder[i]) === -1) { - ret = ret.concat(transformVisitors[transformRunOrder[i]]); - } - } - return ret; -} - -/** - * Given a list of visitor set names, return the ordered list of visitors to be - * passed to jstransform. - * - * @param {array} - * @return {array} - */ -function getVisitorsBySet(sets) { - var visitorsToInclude = sets.reduce(function(visitors, set) { - if (!transformSets.hasOwnProperty(set)) { - throw new Error('Unknown visitor set: ' + set); - } - transformSets[set].forEach(function(visitor) { - visitors[visitor] = true; - }); - return visitors; - }, {}); - - var visitorList = []; - for (var i = 0; i < transformRunOrder.length; i++) { - if (visitorsToInclude.hasOwnProperty(transformRunOrder[i])) { - visitorList = visitorList.concat(transformVisitors[transformRunOrder[i]]); - } - } - - return visitorList; -} - -exports.getVisitorsBySet = getVisitorsBySet; -exports.getAllVisitors = getAllVisitors; -exports.transformVisitors = transformVisitors; - -},{"./transforms/react":38,"./transforms/reactDisplayName":39,"jstransform/visitors/es6-arrow-function-visitors":24,"jstransform/visitors/es6-call-spread-visitors":25,"jstransform/visitors/es6-class-visitors":26,"jstransform/visitors/es6-destructuring-visitors":27,"jstransform/visitors/es6-object-concise-method-visitors":28,"jstransform/visitors/es6-object-short-notation-visitors":29,"jstransform/visitors/es6-rest-param-visitors":30,"jstransform/visitors/es6-template-visitors":31,"jstransform/visitors/es7-spread-property-visitors":33,"jstransform/visitors/reserved-words-visitors":35}],41:[function(_dereq_,module,exports){ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; -/*eslint-disable no-undef*/ -var Buffer = _dereq_('buffer').Buffer; - -function inlineSourceMap(sourceMap, sourceCode, sourceFilename) { - // This can be used with a sourcemap that has already has toJSON called on it. - // Check first. - var json = sourceMap; - if (typeof sourceMap.toJSON === 'function') { - json = sourceMap.toJSON(); - } - json.sources = [sourceFilename]; - json.sourcesContent = [sourceCode]; - var base64 = Buffer(JSON.stringify(json)).toString('base64'); - return '//# sourceMappingURL=data:application/json;base64,' + base64; -} - -module.exports = inlineSourceMap; - -},{"buffer":3}]},{},[1])(1) -}); \ No newline at end of file diff --git a/public/javascripts/wechat/ReactRouter.js b/public/javascripts/wechat/ReactRouter.js deleted file mode 100644 index 810fd7ddc..000000000 --- a/public/javascripts/wechat/ReactRouter.js +++ /dev/null @@ -1,5064 +0,0 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("react")); - else if(typeof define === 'function' && define.amd) - define(["react"], factory); - else if(typeof exports === 'object') - exports["ReactRouter"] = factory(require("react")); - else - root["ReactRouter"] = factory(root["React"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; - -/******/ // The require function -/******/ function __webpack_require__(moduleId) { - -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; - -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; - -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - -/******/ // Flag the module as loaded -/******/ module.loaded = true; - -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } - - -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; - -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; - -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; - -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - /* components */ - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _Router2 = __webpack_require__(37); - - var _Router3 = _interopRequireDefault(_Router2); - - exports.Router = _Router3['default']; - - var _Link2 = __webpack_require__(18); - - var _Link3 = _interopRequireDefault(_Link2); - - exports.Link = _Link3['default']; - - var _IndexLink2 = __webpack_require__(31); - - var _IndexLink3 = _interopRequireDefault(_IndexLink2); - - exports.IndexLink = _IndexLink3['default']; - - /* components (configuration) */ - - var _IndexRedirect2 = __webpack_require__(32); - - var _IndexRedirect3 = _interopRequireDefault(_IndexRedirect2); - - exports.IndexRedirect = _IndexRedirect3['default']; - - var _IndexRoute2 = __webpack_require__(33); - - var _IndexRoute3 = _interopRequireDefault(_IndexRoute2); - - exports.IndexRoute = _IndexRoute3['default']; - - var _Redirect2 = __webpack_require__(19); - - var _Redirect3 = _interopRequireDefault(_Redirect2); - - exports.Redirect = _Redirect3['default']; - - var _Route2 = __webpack_require__(35); - - var _Route3 = _interopRequireDefault(_Route2); - - exports.Route = _Route3['default']; - - /* mixins */ - - var _History2 = __webpack_require__(30); - - var _History3 = _interopRequireDefault(_History2); - - exports.History = _History3['default']; - - var _Lifecycle2 = __webpack_require__(34); - - var _Lifecycle3 = _interopRequireDefault(_Lifecycle2); - - exports.Lifecycle = _Lifecycle3['default']; - - var _RouteContext2 = __webpack_require__(36); - - var _RouteContext3 = _interopRequireDefault(_RouteContext2); - - exports.RouteContext = _RouteContext3['default']; - - /* utils */ - - var _useRoutes2 = __webpack_require__(48); - - var _useRoutes3 = _interopRequireDefault(_useRoutes2); - - exports.useRoutes = _useRoutes3['default']; - - var _RouteUtils = __webpack_require__(5); - - exports.createRoutes = _RouteUtils.createRoutes; - - var _RouterContext2 = __webpack_require__(13); - - var _RouterContext3 = _interopRequireDefault(_RouterContext2); - - exports.RouterContext = _RouterContext3['default']; - - var _RoutingContext2 = __webpack_require__(38); - - var _RoutingContext3 = _interopRequireDefault(_RoutingContext2); - - exports.RoutingContext = _RoutingContext3['default']; - - var _PropTypes2 = __webpack_require__(6); - - var _PropTypes3 = _interopRequireDefault(_PropTypes2); - - exports.PropTypes = _PropTypes3['default']; - - var _match2 = __webpack_require__(46); - - var _match3 = _interopRequireDefault(_match2); - - exports.match = _match3['default']; - - var _useRouterHistory2 = __webpack_require__(24); - - var _useRouterHistory3 = _interopRequireDefault(_useRouterHistory2); - - exports.useRouterHistory = _useRouterHistory3['default']; - - var _PatternUtils = __webpack_require__(8); - - exports.formatPattern = _PatternUtils.formatPattern; - - /* histories */ - - var _browserHistory2 = __webpack_require__(40); - - var _browserHistory3 = _interopRequireDefault(_browserHistory2); - - exports.browserHistory = _browserHistory3['default']; - - var _hashHistory2 = __webpack_require__(44); - - var _hashHistory3 = _interopRequireDefault(_hashHistory2); - - exports.hashHistory = _hashHistory3['default']; - - var _createMemoryHistory2 = __webpack_require__(21); - - var _createMemoryHistory3 = _interopRequireDefault(_createMemoryHistory2); - - exports.createMemoryHistory = _createMemoryHistory3['default']; - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - exports['default'] = routerWarning; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - function routerWarning(falseToWarn, message) { - message = '[react-router] ' + message; - - for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - args[_key - 2] = arguments[_key]; - } - - false ? _warning2['default'].apply(undefined, [falseToWarn, message].concat(args)) : undefined; - } - - module.exports = exports['default']; - -/***/ }, -/* 2 */ -/***/ function(module, exports) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_2__; - -/***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - - 'use strict'; - - /** - * Use invariant() to assert state which your program assumes to be true. - * - * Provide sprintf-style format (only %s is supported) and arguments - * to provide information about what broke and what you were - * expecting. - * - * The invariant message will be stripped in production, but the invariant - * will remain to ensure logic does not differ in production. - */ - - var invariant = function(condition, format, a, b, c, d, e, f) { - if (false) { - if (format === undefined) { - throw new Error('invariant requires an error message argument'); - } - } - - if (!condition) { - var error; - if (format === undefined) { - error = new Error( - 'Minified exception occurred; use the non-minified dev environment ' + - 'for the full error message and additional helpful warnings.' - ); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error( - format.replace(/%s/g, function() { return args[argIndex++]; }) - ); - error.name = 'Invariant Violation'; - } - - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; - } - }; - - module.exports = invariant; - - -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * Copyright 2014-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - - 'use strict'; - - /** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - - var warning = function() {}; - - if (false) { - warning = function(condition, format, args) { - var len = arguments.length; - args = new Array(len > 2 ? len - 2 : 0); - for (var key = 2; key < len; key++) { - args[key - 2] = arguments[key]; - } - if (format === undefined) { - throw new Error( - '`warning(condition, format, ...args)` requires a warning ' + - 'message argument' - ); - } - - if (format.length < 10 || (/^[s\W]*$/).test(format)) { - throw new Error( - 'The warning format should be able to uniquely identify this ' + - 'warning. Please, use a more descriptive format than: ' + format - ); - } - - if (!condition) { - var argIndex = 0; - var message = 'Warning: ' + - format.replace(/%s/g, function() { - return args[argIndex++]; - }); - if (typeof console !== 'undefined') { - console.error(message); - } - try { - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch(x) {} - } - }; - } - - module.exports = warning; - - -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - exports.isReactChildren = isReactChildren; - exports.createRouteFromReactElement = createRouteFromReactElement; - exports.createRoutesFromReactChildren = createRoutesFromReactChildren; - exports.createRoutes = createRoutes; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - function isValidChild(object) { - return object == null || _react2['default'].isValidElement(object); - } - - function isReactChildren(object) { - return isValidChild(object) || Array.isArray(object) && object.every(isValidChild); - } - - function checkPropTypes(componentName, propTypes, props) { - componentName = componentName || 'UnknownComponent'; - - for (var propName in propTypes) { - if (propTypes.hasOwnProperty(propName)) { - var error = propTypes[propName](props, propName, componentName); - - /* istanbul ignore if: error logging */ - if (error instanceof Error) false ? _routerWarning2['default'](false, error.message) : undefined; - } - } - } - - function createRoute(defaultProps, props) { - return _extends({}, defaultProps, props); - } - - function createRouteFromReactElement(element) { - var type = element.type; - var route = createRoute(type.defaultProps, element.props); - - if (type.propTypes) checkPropTypes(type.displayName || type.name, type.propTypes, route); - - if (route.children) { - var childRoutes = createRoutesFromReactChildren(route.children, route); - - if (childRoutes.length) route.childRoutes = childRoutes; - - delete route.children; - } - - return route; - } - - /** - * Creates and returns a routes object from the given ReactChildren. JSX - * provides a convenient way to visualize how routes in the hierarchy are - * nested. - * - * import { Route, createRoutesFromReactChildren } from 'react-router' - * - * const routes = createRoutesFromReactChildren( - * - * - * - * - * ) - * - * Note: This method is automatically used when you provide children - * to a component. - */ - - function createRoutesFromReactChildren(children, parentRoute) { - var routes = []; - - _react2['default'].Children.forEach(children, function (element) { - if (_react2['default'].isValidElement(element)) { - // Component classes may have a static create* method. - if (element.type.createRouteFromReactElement) { - var route = element.type.createRouteFromReactElement(element, parentRoute); - - if (route) routes.push(route); - } else { - routes.push(createRouteFromReactElement(element)); - } - } - }); - - return routes; - } - - /** - * Creates and returns an array of routes from the given object which - * may be a JSX route, a plain object route, or an array of either. - */ - - function createRoutes(routes) { - if (isReactChildren(routes)) { - routes = createRoutesFromReactChildren(routes); - } else if (routes && !Array.isArray(routes)) { - routes = [routes]; - } - - return routes; - } - -/***/ }, -/* 6 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - exports.falsy = falsy; - - var _react = __webpack_require__(2); - - var func = _react.PropTypes.func; - var object = _react.PropTypes.object; - var arrayOf = _react.PropTypes.arrayOf; - var oneOfType = _react.PropTypes.oneOfType; - var element = _react.PropTypes.element; - var shape = _react.PropTypes.shape; - var string = _react.PropTypes.string; - - function falsy(props, propName, componentName) { - if (props[propName]) return new Error('<' + componentName + '> should not have a "' + propName + '" prop'); - } - - var history = shape({ - listen: func.isRequired, - pushState: func.isRequired, - replaceState: func.isRequired, - go: func.isRequired - }); - - exports.history = history; - var location = shape({ - pathname: string.isRequired, - search: string.isRequired, - state: object, - action: string.isRequired, - key: string - }); - - exports.location = location; - var component = oneOfType([func, string]); - exports.component = component; - var components = oneOfType([component, object]); - exports.components = components; - var route = oneOfType([object, element]); - exports.route = route; - var routes = oneOfType([route, arrayOf(route)]); - - exports.routes = routes; - exports['default'] = { - falsy: falsy, - history: history, - location: location, - component: component, - components: components, - route: route - }; - -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - exports.extractPath = extractPath; - exports.parsePath = parsePath; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - function extractPath(string) { - var match = string.match(/^https?:\/\/[^\/]*/); - - if (match == null) return string; - - return string.substring(match[0].length); - } - - function parsePath(path) { - var pathname = extractPath(path); - var search = ''; - var hash = ''; - - false ? _warning2['default'](path === pathname, 'A path must be pathname + search + hash only, not a fully qualified URL like "%s"', path) : undefined; - - var hashIndex = pathname.indexOf('#'); - if (hashIndex !== -1) { - hash = pathname.substring(hashIndex); - pathname = pathname.substring(0, hashIndex); - } - - var searchIndex = pathname.indexOf('?'); - if (searchIndex !== -1) { - search = pathname.substring(searchIndex); - pathname = pathname.substring(0, searchIndex); - } - - if (pathname === '') pathname = '/'; - - return { - pathname: pathname, - search: search, - hash: hash - }; - } - -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - exports.compilePattern = compilePattern; - exports.matchPattern = matchPattern; - exports.getParamNames = getParamNames; - exports.getParams = getParams; - exports.formatPattern = formatPattern; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - function escapeRegExp(string) { - return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - } - - function escapeSource(string) { - return escapeRegExp(string).replace(/\/+/g, '/+'); - } - - function _compilePattern(pattern) { - var regexpSource = ''; - var paramNames = []; - var tokens = []; - - var match = undefined, - lastIndex = 0, - matcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|\*\*|\*|\(|\)/g; - while (match = matcher.exec(pattern)) { - if (match.index !== lastIndex) { - tokens.push(pattern.slice(lastIndex, match.index)); - regexpSource += escapeSource(pattern.slice(lastIndex, match.index)); - } - - if (match[1]) { - regexpSource += '([^/?#]+)'; - paramNames.push(match[1]); - } else if (match[0] === '**') { - regexpSource += '([\\s\\S]*)'; - paramNames.push('splat'); - } else if (match[0] === '*') { - regexpSource += '([\\s\\S]*?)'; - paramNames.push('splat'); - } else if (match[0] === '(') { - regexpSource += '(?:'; - } else if (match[0] === ')') { - regexpSource += ')?'; - } - - tokens.push(match[0]); - - lastIndex = matcher.lastIndex; - } - - if (lastIndex !== pattern.length) { - tokens.push(pattern.slice(lastIndex, pattern.length)); - regexpSource += escapeSource(pattern.slice(lastIndex, pattern.length)); - } - - return { - pattern: pattern, - regexpSource: regexpSource, - paramNames: paramNames, - tokens: tokens - }; - } - - var CompiledPatternsCache = {}; - - function compilePattern(pattern) { - if (!(pattern in CompiledPatternsCache)) CompiledPatternsCache[pattern] = _compilePattern(pattern); - - return CompiledPatternsCache[pattern]; - } - - /** - * Attempts to match a pattern on the given pathname. Patterns may use - * the following special characters: - * - * - :paramName Matches a URL segment up to the next /, ?, or #. The - * captured string is considered a "param" - * - () Wraps a segment of the URL that is optional - * - * Consumes (non-greedy) all characters up to the next - * character in the pattern, or to the end of the URL if - * there is none - * - ** Consumes (greedy) all characters up to the next character - * in the pattern, or to the end of the URL if there is none - * - * The return value is an object with the following properties: - * - * - remainingPathname - * - paramNames - * - paramValues - */ - - function matchPattern(pattern, pathname) { - // Make leading slashes consistent between pattern and pathname. - if (pattern.charAt(0) !== '/') { - pattern = '/' + pattern; - } - if (pathname.charAt(0) !== '/') { - pathname = '/' + pathname; - } - - var _compilePattern2 = compilePattern(pattern); - - var regexpSource = _compilePattern2.regexpSource; - var paramNames = _compilePattern2.paramNames; - var tokens = _compilePattern2.tokens; - - regexpSource += '/*'; // Capture path separators - - // Special-case patterns like '*' for catch-all routes. - var captureRemaining = tokens[tokens.length - 1] !== '*'; - - if (captureRemaining) { - // This will match newlines in the remaining path. - regexpSource += '([\\s\\S]*?)'; - } - - var match = pathname.match(new RegExp('^' + regexpSource + '$', 'i')); - - var remainingPathname = undefined, - paramValues = undefined; - if (match != null) { - if (captureRemaining) { - remainingPathname = match.pop(); - var matchedPath = match[0].substr(0, match[0].length - remainingPathname.length); - - // If we didn't match the entire pathname, then make sure that the match - // we did get ends at a path separator (potentially the one we added - // above at the beginning of the path, if the actual match was empty). - if (remainingPathname && matchedPath.charAt(matchedPath.length - 1) !== '/') { - return { - remainingPathname: null, - paramNames: paramNames, - paramValues: null - }; - } - } else { - // If this matched at all, then the match was the entire pathname. - remainingPathname = ''; - } - - paramValues = match.slice(1).map(function (v) { - return v != null ? decodeURIComponent(v) : v; - }); - } else { - remainingPathname = paramValues = null; - } - - return { - remainingPathname: remainingPathname, - paramNames: paramNames, - paramValues: paramValues - }; - } - - function getParamNames(pattern) { - return compilePattern(pattern).paramNames; - } - - function getParams(pattern, pathname) { - var _matchPattern = matchPattern(pattern, pathname); - - var paramNames = _matchPattern.paramNames; - var paramValues = _matchPattern.paramValues; - - if (paramValues != null) { - return paramNames.reduce(function (memo, paramName, index) { - memo[paramName] = paramValues[index]; - return memo; - }, {}); - } - - return null; - } - - /** - * Returns a version of the given pattern with params interpolated. Throws - * if there is a dynamic segment of the pattern for which there is no param. - */ - - function formatPattern(pattern, params) { - params = params || {}; - - var _compilePattern3 = compilePattern(pattern); - - var tokens = _compilePattern3.tokens; - - var parenCount = 0, - pathname = '', - splatIndex = 0; - - var token = undefined, - paramName = undefined, - paramValue = undefined; - for (var i = 0, len = tokens.length; i < len; ++i) { - token = tokens[i]; - - if (token === '*' || token === '**') { - paramValue = Array.isArray(params.splat) ? params.splat[splatIndex++] : params.splat; - - !(paramValue != null || parenCount > 0) ? false ? _invariant2['default'](false, 'Missing splat #%s for path "%s"', splatIndex, pattern) : _invariant2['default'](false) : undefined; - - if (paramValue != null) pathname += encodeURI(paramValue); - } else if (token === '(') { - parenCount += 1; - } else if (token === ')') { - parenCount -= 1; - } else if (token.charAt(0) === ':') { - paramName = token.substring(1); - paramValue = params[paramName]; - - !(paramValue != null || parenCount > 0) ? false ? _invariant2['default'](false, 'Missing "%s" parameter for path "%s"', paramName, pattern) : _invariant2['default'](false) : undefined; - - if (paramValue != null) pathname += encodeURIComponent(paramValue); - } else { - pathname += token; - } - } - - return pathname.replace(/\/+/g, '/'); - } - -/***/ }, -/* 9 */ -/***/ function(module, exports) { - - /** - * Indicates that navigation was caused by a call to history.push. - */ - 'use strict'; - - exports.__esModule = true; - var PUSH = 'PUSH'; - - exports.PUSH = PUSH; - /** - * Indicates that navigation was caused by a call to history.replace. - */ - var REPLACE = 'REPLACE'; - - exports.REPLACE = REPLACE; - /** - * Indicates that navigation was caused by some other action such - * as using a browser's back/forward buttons and/or manually manipulating - * the URL in a browser's location bar. This is the default. - * - * See https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate - * for more information. - */ - var POP = 'POP'; - - exports.POP = POP; - exports['default'] = { - PUSH: PUSH, - REPLACE: REPLACE, - POP: POP - }; - -/***/ }, -/* 10 */ -/***/ function(module, exports) { - - 'use strict'; - - exports.__esModule = true; - var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); - exports.canUseDOM = canUseDOM; - -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - var _queryString = __webpack_require__(56); - - var _runTransitionHook = __webpack_require__(17); - - var _runTransitionHook2 = _interopRequireDefault(_runTransitionHook); - - var _PathUtils = __webpack_require__(7); - - var _deprecate = __webpack_require__(16); - - var _deprecate2 = _interopRequireDefault(_deprecate); - - var SEARCH_BASE_KEY = '$searchBase'; - - function defaultStringifyQuery(query) { - return _queryString.stringify(query).replace(/%20/g, '+'); - } - - var defaultParseQueryString = _queryString.parse; - - function isNestedObject(object) { - for (var p in object) { - if (object.hasOwnProperty(p) && typeof object[p] === 'object' && !Array.isArray(object[p]) && object[p] !== null) return true; - }return false; - } - - /** - * Returns a new createHistory function that may be used to create - * history objects that know how to handle URL queries. - */ - function useQueries(createHistory) { - return function () { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - var stringifyQuery = options.stringifyQuery; - var parseQueryString = options.parseQueryString; - - var historyOptions = _objectWithoutProperties(options, ['stringifyQuery', 'parseQueryString']); - - var history = createHistory(historyOptions); - - if (typeof stringifyQuery !== 'function') stringifyQuery = defaultStringifyQuery; - - if (typeof parseQueryString !== 'function') parseQueryString = defaultParseQueryString; - - function addQuery(location) { - if (location.query == null) { - var search = location.search; - - location.query = parseQueryString(search.substring(1)); - location[SEARCH_BASE_KEY] = { search: search, searchBase: '' }; - } - - // TODO: Instead of all the book-keeping here, this should just strip the - // stringified query from the search. - - return location; - } - - function appendQuery(location, query) { - var _extends2; - - var searchBaseSpec = location[SEARCH_BASE_KEY]; - var queryString = query ? stringifyQuery(query) : ''; - if (!searchBaseSpec && !queryString) { - return location; - } - - false ? _warning2['default'](stringifyQuery !== defaultStringifyQuery || !isNestedObject(query), 'useQueries does not stringify nested query objects by default; ' + 'use a custom stringifyQuery function') : undefined; - - if (typeof location === 'string') location = _PathUtils.parsePath(location); - - var searchBase = undefined; - if (searchBaseSpec && location.search === searchBaseSpec.search) { - searchBase = searchBaseSpec.searchBase; - } else { - searchBase = location.search || ''; - } - - var search = searchBase; - if (queryString) { - search += (search ? '&' : '?') + queryString; - } - - return _extends({}, location, (_extends2 = { - search: search - }, _extends2[SEARCH_BASE_KEY] = { search: search, searchBase: searchBase }, _extends2)); - } - - // Override all read methods with query-aware versions. - function listenBefore(hook) { - return history.listenBefore(function (location, callback) { - _runTransitionHook2['default'](hook, addQuery(location), callback); - }); - } - - function listen(listener) { - return history.listen(function (location) { - listener(addQuery(location)); - }); - } - - // Override all write methods with query-aware versions. - function push(location) { - history.push(appendQuery(location, location.query)); - } - - function replace(location) { - history.replace(appendQuery(location, location.query)); - } - - function createPath(location, query) { - false ? _warning2['default'](!query, 'the query argument to createPath is deprecated; use a location descriptor instead') : undefined; - - return history.createPath(appendQuery(location, query || location.query)); - } - - function createHref(location, query) { - false ? _warning2['default'](!query, 'the query argument to createHref is deprecated; use a location descriptor instead') : undefined; - - return history.createHref(appendQuery(location, query || location.query)); - } - - function createLocation(location) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - var fullLocation = history.createLocation.apply(history, [appendQuery(location, location.query)].concat(args)); - if (location.query) { - fullLocation.query = location.query; - } - return addQuery(fullLocation); - } - - // deprecated - function pushState(state, path, query) { - if (typeof path === 'string') path = _PathUtils.parsePath(path); - - push(_extends({ state: state }, path, { query: query })); - } - - // deprecated - function replaceState(state, path, query) { - if (typeof path === 'string') path = _PathUtils.parsePath(path); - - replace(_extends({ state: state }, path, { query: query })); - } - - return _extends({}, history, { - listenBefore: listenBefore, - listen: listen, - push: push, - replace: replace, - createPath: createPath, - createHref: createHref, - createLocation: createLocation, - - pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'), - replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead') - }); - }; - } - - exports['default'] = useQueries; - module.exports = exports['default']; - -/***/ }, -/* 12 */ -/***/ function(module, exports) { - - "use strict"; - - exports.__esModule = true; - var _slice = Array.prototype.slice; - exports.loopAsync = loopAsync; - exports.mapAsync = mapAsync; - - function loopAsync(turns, work, callback) { - var currentTurn = 0, - isDone = false; - var sync = false, - hasNext = false, - doneArgs = undefined; - - function done() { - isDone = true; - if (sync) { - // Iterate instead of recursing if possible. - doneArgs = [].concat(_slice.call(arguments)); - return; - } - - callback.apply(this, arguments); - } - - function next() { - if (isDone) { - return; - } - - hasNext = true; - if (sync) { - // Iterate instead of recursing if possible. - return; - } - - sync = true; - - while (!isDone && currentTurn < turns && hasNext) { - hasNext = false; - work.call(this, currentTurn++, next, done); - } - - sync = false; - - if (isDone) { - // This means the loop finished synchronously. - callback.apply(this, doneArgs); - return; - } - - if (currentTurn >= turns && hasNext) { - isDone = true; - callback(); - } - } - - next(); - } - - function mapAsync(array, work, callback) { - var length = array.length; - var values = []; - - if (length === 0) return callback(null, values); - - var isDone = false, - doneCount = 0; - - function done(index, error, value) { - if (isDone) return; - - if (error) { - isDone = true; - callback(error); - } else { - values[index] = value; - - isDone = ++doneCount === length; - - if (isDone) callback(null, values); - } - } - - array.forEach(function (item, index) { - work(item, index, function (error, value) { - done(index, error, value); - }); - }); - } - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _deprecateObjectProperties = __webpack_require__(23); - - var _deprecateObjectProperties2 = _interopRequireDefault(_deprecateObjectProperties); - - var _getRouteParams = __webpack_require__(43); - - var _getRouteParams2 = _interopRequireDefault(_getRouteParams); - - var _RouteUtils = __webpack_require__(5); - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var _React$PropTypes = _react2['default'].PropTypes; - var array = _React$PropTypes.array; - var func = _React$PropTypes.func; - var object = _React$PropTypes.object; - - /** - * A renders the component tree for a given router state - * and sets the history object and the current location in context. - */ - var RouterContext = _react2['default'].createClass({ - displayName: 'RouterContext', - - propTypes: { - history: object, - router: object.isRequired, - location: object.isRequired, - routes: array.isRequired, - params: object.isRequired, - components: array.isRequired, - createElement: func.isRequired - }, - - getDefaultProps: function getDefaultProps() { - return { - createElement: _react2['default'].createElement - }; - }, - - childContextTypes: { - history: object, - location: object.isRequired, - router: object.isRequired - }, - - getChildContext: function getChildContext() { - var _props = this.props; - var router = _props.router; - var history = _props.history; - var location = _props.location; - - if (!router) { - false ? _routerWarning2['default'](false, '`` expects a `router` rather than a `history`') : undefined; - - router = _extends({}, history, { - setRouteLeaveHook: history.listenBeforeLeavingRoute - }); - delete router.listenBeforeLeavingRoute; - } - - if (false) { - location = _deprecateObjectProperties2['default'](location, '`context.location` is deprecated, please use a route component\'s `props.location` instead. http://tiny.cc/router-accessinglocation'); - } - - return { history: history, location: location, router: router }; - }, - - createElement: function createElement(component, props) { - return component == null ? null : this.props.createElement(component, props); - }, - - render: function render() { - var _this = this; - - var _props2 = this.props; - var history = _props2.history; - var location = _props2.location; - var routes = _props2.routes; - var params = _props2.params; - var components = _props2.components; - - var element = null; - - if (components) { - element = components.reduceRight(function (element, components, index) { - if (components == null) return element; // Don't create new children; use the grandchildren. - - var route = routes[index]; - var routeParams = _getRouteParams2['default'](route, params); - var props = { - history: history, - location: location, - params: params, - route: route, - routeParams: routeParams, - routes: routes - }; - - if (_RouteUtils.isReactChildren(element)) { - props.children = element; - } else if (element) { - for (var prop in element) { - if (element.hasOwnProperty(prop)) props[prop] = element[prop]; - } - } - - if (typeof components === 'object') { - var elements = {}; - - for (var key in components) { - if (components.hasOwnProperty(key)) { - // Pass through the key as a prop to createElement to allow - // custom createElement functions to know which named component - // they're rendering, for e.g. matching up to fetched data. - elements[key] = _this.createElement(components[key], _extends({ - key: key }, props)); - } - } - - return elements; - } - - return _this.createElement(components, props); - }, element); - } - - !(element === null || element === false || _react2['default'].isValidElement(element)) ? false ? _invariant2['default'](false, 'The root route must render a single element') : _invariant2['default'](false) : undefined; - - return element; - } - - }); - - exports['default'] = RouterContext; - module.exports = exports['default']; - -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - exports['default'] = createTransitionManager; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var _historyLibActions = __webpack_require__(9); - - var _computeChangedRoutes2 = __webpack_require__(41); - - var _computeChangedRoutes3 = _interopRequireDefault(_computeChangedRoutes2); - - var _TransitionUtils = __webpack_require__(39); - - var _isActive2 = __webpack_require__(45); - - var _isActive3 = _interopRequireDefault(_isActive2); - - var _getComponents = __webpack_require__(42); - - var _getComponents2 = _interopRequireDefault(_getComponents); - - var _matchRoutes = __webpack_require__(47); - - var _matchRoutes2 = _interopRequireDefault(_matchRoutes); - - function hasAnyProperties(object) { - for (var p in object) { - if (object.hasOwnProperty(p)) return true; - }return false; - } - - function createTransitionManager(history, routes) { - var state = {}; - - // Signature should be (location, indexOnly), but needs to support (path, - // query, indexOnly) - function isActive(location) { - var indexOnlyOrDeprecatedQuery = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - var deprecatedIndexOnly = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - - var indexOnly = undefined; - if (indexOnlyOrDeprecatedQuery && indexOnlyOrDeprecatedQuery !== true || deprecatedIndexOnly !== null) { - false ? _routerWarning2['default'](false, '`isActive(pathname, query, indexOnly) is deprecated; use `isActive(location, indexOnly)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated') : undefined; - location = { pathname: location, query: indexOnlyOrDeprecatedQuery }; - indexOnly = deprecatedIndexOnly || false; - } else { - location = history.createLocation(location); - indexOnly = indexOnlyOrDeprecatedQuery; - } - - return _isActive3['default'](location, indexOnly, state.location, state.routes, state.params); - } - - function createLocationFromRedirectInfo(location) { - return history.createLocation(location, _historyLibActions.REPLACE); - } - - var partialNextState = undefined; - - function match(location, callback) { - if (partialNextState && partialNextState.location === location) { - // Continue from where we left off. - finishMatch(partialNextState, callback); - } else { - _matchRoutes2['default'](routes, location, function (error, nextState) { - if (error) { - callback(error); - } else if (nextState) { - finishMatch(_extends({}, nextState, { location: location }), callback); - } else { - callback(); - } - }); - } - } - - function finishMatch(nextState, callback) { - var _computeChangedRoutes = _computeChangedRoutes3['default'](state, nextState); - - var leaveRoutes = _computeChangedRoutes.leaveRoutes; - var enterRoutes = _computeChangedRoutes.enterRoutes; - - _TransitionUtils.runLeaveHooks(leaveRoutes); - - // Tear down confirmation hooks for left routes - leaveRoutes.filter(function (route) { - return enterRoutes.indexOf(route) === -1; - }).forEach(removeListenBeforeHooksForRoute); - - _TransitionUtils.runEnterHooks(enterRoutes, nextState, function (error, redirectInfo) { - if (error) { - callback(error); - } else if (redirectInfo) { - callback(null, createLocationFromRedirectInfo(redirectInfo)); - } else { - // TODO: Fetch components after state is updated. - _getComponents2['default'](nextState, function (error, components) { - if (error) { - callback(error); - } else { - // TODO: Make match a pure function and have some other API - // for "match and update state". - callback(null, null, state = _extends({}, nextState, { components: components })); - } - }); - } - }); - } - - var RouteGuid = 1; - - function getRouteID(route) { - var create = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; - - return route.__id__ || create && (route.__id__ = RouteGuid++); - } - - var RouteHooks = {}; - - function getRouteHooksForRoutes(routes) { - return routes.reduce(function (hooks, route) { - hooks.push.apply(hooks, RouteHooks[getRouteID(route)]); - return hooks; - }, []); - } - - function transitionHook(location, callback) { - _matchRoutes2['default'](routes, location, function (error, nextState) { - if (nextState == null) { - // TODO: We didn't actually match anything, but hang - // onto error/nextState so we don't have to matchRoutes - // again in the listen callback. - callback(); - return; - } - - // Cache some state here so we don't have to - // matchRoutes() again in the listen callback. - partialNextState = _extends({}, nextState, { location: location }); - - var hooks = getRouteHooksForRoutes(_computeChangedRoutes3['default'](state, partialNextState).leaveRoutes); - - var result = undefined; - for (var i = 0, len = hooks.length; result == null && i < len; ++i) { - // Passing the location arg here indicates to - // the user that this is a transition hook. - result = hooks[i](location); - } - - callback(result); - }); - } - - /* istanbul ignore next: untestable with Karma */ - function beforeUnloadHook() { - // Synchronously check to see if any route hooks want - // to prevent the current window/tab from closing. - if (state.routes) { - var hooks = getRouteHooksForRoutes(state.routes); - - var message = undefined; - for (var i = 0, len = hooks.length; typeof message !== 'string' && i < len; ++i) { - // Passing no args indicates to the user that this is a - // beforeunload hook. We don't know the next location. - message = hooks[i](); - } - - return message; - } - } - - var unlistenBefore = undefined, - unlistenBeforeUnload = undefined; - - function removeListenBeforeHooksForRoute(route) { - var routeID = getRouteID(route, false); - if (!routeID) { - return; - } - - delete RouteHooks[routeID]; - - if (!hasAnyProperties(RouteHooks)) { - // teardown transition & beforeunload hooks - if (unlistenBefore) { - unlistenBefore(); - unlistenBefore = null; - } - - if (unlistenBeforeUnload) { - unlistenBeforeUnload(); - unlistenBeforeUnload = null; - } - } - } - - /** - * Registers the given hook function to run before leaving the given route. - * - * During a normal transition, the hook function receives the next location - * as its only argument and must return either a) a prompt message to show - * the user, to make sure they want to leave the page or b) false, to prevent - * the transition. - * - * During the beforeunload event (in browsers) the hook receives no arguments. - * In this case it must return a prompt message to prevent the transition. - * - * Returns a function that may be used to unbind the listener. - */ - function listenBeforeLeavingRoute(route, hook) { - // TODO: Warn if they register for a route that isn't currently - // active. They're probably doing something wrong, like re-creating - // route objects on every location change. - var routeID = getRouteID(route); - var hooks = RouteHooks[routeID]; - - if (!hooks) { - var thereWereNoRouteHooks = !hasAnyProperties(RouteHooks); - - RouteHooks[routeID] = [hook]; - - if (thereWereNoRouteHooks) { - // setup transition & beforeunload hooks - unlistenBefore = history.listenBefore(transitionHook); - - if (history.listenBeforeUnload) unlistenBeforeUnload = history.listenBeforeUnload(beforeUnloadHook); - } - } else { - if (hooks.indexOf(hook) === -1) { - false ? _routerWarning2['default'](false, 'adding multiple leave hooks for the same route is deprecated; manage multiple confirmations in your own code instead') : undefined; - - hooks.push(hook); - } - } - - return function () { - var hooks = RouteHooks[routeID]; - - if (hooks) { - var newHooks = hooks.filter(function (item) { - return item !== hook; - }); - - if (newHooks.length === 0) { - removeListenBeforeHooksForRoute(route); - } else { - RouteHooks[routeID] = newHooks; - } - } - }; - } - - /** - * This is the API for stateful environments. As the location - * changes, we update state and call the listener. We can also - * gracefully handle errors and redirects. - */ - function listen(listener) { - // TODO: Only use a single history listener. Otherwise we'll - // end up with multiple concurrent calls to match. - return history.listen(function (location) { - if (state.location === location) { - listener(null, state); - } else { - match(location, function (error, redirectLocation, nextState) { - if (error) { - listener(error); - } else if (redirectLocation) { - history.transitionTo(redirectLocation); - } else if (nextState) { - listener(null, nextState); - } else { - false ? _routerWarning2['default'](false, 'Location "%s" did not match any routes', location.pathname + location.search + location.hash) : undefined; - } - }); - } - }); - } - - return { - isActive: isActive, - match: match, - listenBeforeLeavingRoute: listenBeforeLeavingRoute, - listen: listen - }; - } - - //export default useRoutes - module.exports = exports['default']; - -/***/ }, -/* 15 */ -/***/ function(module, exports) { - - 'use strict'; - - exports.__esModule = true; - exports.addEventListener = addEventListener; - exports.removeEventListener = removeEventListener; - exports.getHashPath = getHashPath; - exports.replaceHashPath = replaceHashPath; - exports.getWindowPath = getWindowPath; - exports.go = go; - exports.getUserConfirmation = getUserConfirmation; - exports.supportsHistory = supportsHistory; - exports.supportsGoWithoutReloadUsingHash = supportsGoWithoutReloadUsingHash; - - function addEventListener(node, event, listener) { - if (node.addEventListener) { - node.addEventListener(event, listener, false); - } else { - node.attachEvent('on' + event, listener); - } - } - - function removeEventListener(node, event, listener) { - if (node.removeEventListener) { - node.removeEventListener(event, listener, false); - } else { - node.detachEvent('on' + event, listener); - } - } - - function getHashPath() { - // We can't use window.location.hash here because it's not - // consistent across browsers - Firefox will pre-decode it! - return window.location.href.split('#')[1] || ''; - } - - function replaceHashPath(path) { - window.location.replace(window.location.pathname + window.location.search + '#' + path); - } - - function getWindowPath() { - return window.location.pathname + window.location.search + window.location.hash; - } - - function go(n) { - if (n) window.history.go(n); - } - - function getUserConfirmation(message, callback) { - callback(window.confirm(message)); - } - - /** - * Returns true if the HTML5 history API is supported. Taken from Modernizr. - * - * https://github.com/Modernizr/Modernizr/blob/master/LICENSE - * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js - * changed to avoid false negatives for Windows Phones: https://github.com/rackt/react-router/issues/586 - */ - - function supportsHistory() { - var ua = navigator.userAgent; - if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) { - return false; - } - return window.history && 'pushState' in window.history; - } - - /** - * Returns false if using go(n) with hash history causes a full page reload. - */ - - function supportsGoWithoutReloadUsingHash() { - var ua = navigator.userAgent; - return ua.indexOf('Firefox') === -1; - } - -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - function deprecate(fn, message) { - return function () { - false ? _warning2['default'](false, '[history] ' + message) : undefined; - return fn.apply(this, arguments); - }; - } - - exports['default'] = deprecate; - module.exports = exports['default']; - -/***/ }, -/* 17 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - function runTransitionHook(hook, location, callback) { - var result = hook(location, callback); - - if (hook.length < 2) { - // Assume the hook runs synchronously and automatically - // call the callback with the return value. - callback(result); - } else { - false ? _warning2['default'](result === undefined, 'You should not "return" in a transition hook with a callback argument; call the callback instead') : undefined; - } - } - - exports['default'] = runTransitionHook; - module.exports = exports['default']; - -/***/ }, -/* 18 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var _React$PropTypes = _react2['default'].PropTypes; - var bool = _React$PropTypes.bool; - var object = _React$PropTypes.object; - var string = _React$PropTypes.string; - var func = _React$PropTypes.func; - var oneOfType = _React$PropTypes.oneOfType; - - function isLeftClickEvent(event) { - return event.button === 0; - } - - function isModifiedEvent(event) { - return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey); - } - - function isEmptyObject(object) { - for (var p in object) { - if (object.hasOwnProperty(p)) return false; - }return true; - } - - function createLocationDescriptor(to, _ref) { - var query = _ref.query; - var hash = _ref.hash; - var state = _ref.state; - - if (query || hash || state) { - return { pathname: to, query: query, hash: hash, state: state }; - } - - return to; - } - - /** - * A is used to create an element that links to a route. - * When that route is active, the link gets the value of its - * activeClassName prop. - * - * For example, assuming you have the following route: - * - * - * - * You could use the following component to link to that route: - * - * - * - * Links may pass along location state and/or query string parameters - * in the state/query props, respectively. - * - * - */ - var Link = _react2['default'].createClass({ - displayName: 'Link', - - contextTypes: { - router: object - }, - - propTypes: { - to: oneOfType([string, object]).isRequired, - query: object, - hash: string, - state: object, - activeStyle: object, - activeClassName: string, - onlyActiveOnIndex: bool.isRequired, - onClick: func - }, - - getDefaultProps: function getDefaultProps() { - return { - onlyActiveOnIndex: false, - className: '', - style: {} - }; - }, - - handleClick: function handleClick(event) { - var allowTransition = true; - - if (this.props.onClick) this.props.onClick(event); - - if (isModifiedEvent(event) || !isLeftClickEvent(event)) return; - - if (event.defaultPrevented === true) allowTransition = false; - - // If target prop is set (e.g. to "_blank") let browser handle link. - /* istanbul ignore if: untestable with Karma */ - if (this.props.target) { - if (!allowTransition) event.preventDefault(); - - return; - } - - event.preventDefault(); - - if (allowTransition) { - var _props = this.props; - var to = _props.to; - var query = _props.query; - var hash = _props.hash; - var state = _props.state; - - var _location = createLocationDescriptor(to, { query: query, hash: hash, state: state }); - - this.context.router.push(_location); - } - }, - - render: function render() { - var _props2 = this.props; - var to = _props2.to; - var query = _props2.query; - var hash = _props2.hash; - var state = _props2.state; - var activeClassName = _props2.activeClassName; - var activeStyle = _props2.activeStyle; - var onlyActiveOnIndex = _props2.onlyActiveOnIndex; - - var props = _objectWithoutProperties(_props2, ['to', 'query', 'hash', 'state', 'activeClassName', 'activeStyle', 'onlyActiveOnIndex']); - - false ? _routerWarning2['default'](!(query || hash || state), 'the `query`, `hash`, and `state` props on `` are deprecated, use `. http://tiny.cc/router-isActivedeprecated') : undefined; - - // Ignore if rendered outside the context of router, simplifies unit testing. - var router = this.context.router; - - if (router) { - var _location2 = createLocationDescriptor(to, { query: query, hash: hash, state: state }); - props.href = router.createHref(_location2); - - if (activeClassName || activeStyle != null && !isEmptyObject(activeStyle)) { - if (router.isActive(_location2, onlyActiveOnIndex)) { - if (activeClassName) props.className += props.className === '' ? activeClassName : ' ' + activeClassName; - - if (activeStyle) props.style = _extends({}, props.style, activeStyle); - } - } - } - - return _react2['default'].createElement('a', _extends({}, props, { onClick: this.handleClick })); - } - - }); - - exports['default'] = Link; - module.exports = exports['default']; - -/***/ }, -/* 19 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _RouteUtils = __webpack_require__(5); - - var _PatternUtils = __webpack_require__(8); - - var _PropTypes = __webpack_require__(6); - - var _React$PropTypes = _react2['default'].PropTypes; - var string = _React$PropTypes.string; - var object = _React$PropTypes.object; - - /** - * A is used to declare another URL path a client should - * be sent to when they request a given URL. - * - * Redirects are placed alongside routes in the route configuration - * and are traversed in the same manner. - */ - var Redirect = _react2['default'].createClass({ - displayName: 'Redirect', - - statics: { - - createRouteFromReactElement: function createRouteFromReactElement(element) { - var route = _RouteUtils.createRouteFromReactElement(element); - - if (route.from) route.path = route.from; - - route.onEnter = function (nextState, replace) { - var location = nextState.location; - var params = nextState.params; - - var pathname = undefined; - if (route.to.charAt(0) === '/') { - pathname = _PatternUtils.formatPattern(route.to, params); - } else if (!route.to) { - pathname = location.pathname; - } else { - var routeIndex = nextState.routes.indexOf(route); - var parentPattern = Redirect.getRoutePattern(nextState.routes, routeIndex - 1); - var pattern = parentPattern.replace(/\/*$/, '/') + route.to; - pathname = _PatternUtils.formatPattern(pattern, params); - } - - replace({ - pathname: pathname, - query: route.query || location.query, - state: route.state || location.state - }); - }; - - return route; - }, - - getRoutePattern: function getRoutePattern(routes, routeIndex) { - var parentPattern = ''; - - for (var i = routeIndex; i >= 0; i--) { - var route = routes[i]; - var pattern = route.path || ''; - - parentPattern = pattern.replace(/\/*$/, '/') + parentPattern; - - if (pattern.indexOf('/') === 0) break; - } - - return '/' + parentPattern; - } - - }, - - propTypes: { - path: string, - from: string, // Alias for path - to: string.isRequired, - query: object, - state: object, - onEnter: _PropTypes.falsy, - children: _PropTypes.falsy - }, - - /* istanbul ignore next: sanity check */ - render: function render() { - true ? false ? _invariant2['default'](false, ' elements are for router configuration only and should not be rendered') : _invariant2['default'](false) : undefined; - } - - }); - - exports['default'] = Redirect; - module.exports = exports['default']; - -/***/ }, -/* 20 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - exports.createRouterObject = createRouterObject; - exports.createRoutingHistory = createRoutingHistory; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _deprecateObjectProperties = __webpack_require__(23); - - var _deprecateObjectProperties2 = _interopRequireDefault(_deprecateObjectProperties); - - function createRouterObject(history, transitionManager) { - return _extends({}, history, { - setRouteLeaveHook: transitionManager.listenBeforeLeavingRoute, - isActive: transitionManager.isActive - }); - } - - // deprecated - - function createRoutingHistory(history, transitionManager) { - history = _extends({}, history, transitionManager); - - if (false) { - history = _deprecateObjectProperties2['default'](history, '`props.history` and `context.history` are deprecated. Please use `context.router`. http://tiny.cc/router-contextchanges'); - } - - return history; - } - -/***/ }, -/* 21 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - exports['default'] = createMemoryHistory; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _historyLibUseQueries = __webpack_require__(11); - - var _historyLibUseQueries2 = _interopRequireDefault(_historyLibUseQueries); - - var _historyLibUseBasename = __webpack_require__(29); - - var _historyLibUseBasename2 = _interopRequireDefault(_historyLibUseBasename); - - var _historyLibCreateMemoryHistory = __webpack_require__(55); - - var _historyLibCreateMemoryHistory2 = _interopRequireDefault(_historyLibCreateMemoryHistory); - - function createMemoryHistory(options) { - // signatures and type checking differ between `useRoutes` and - // `createMemoryHistory`, have to create `memoryHistory` first because - // `useQueries` doesn't understand the signature - var memoryHistory = _historyLibCreateMemoryHistory2['default'](options); - var createHistory = function createHistory() { - return memoryHistory; - }; - var history = _historyLibUseQueries2['default'](_historyLibUseBasename2['default'](createHistory))(options); - history.__v2_compatible__ = true; - return history; - } - - module.exports = exports['default']; - -/***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _useRouterHistory = __webpack_require__(24); - - var _useRouterHistory2 = _interopRequireDefault(_useRouterHistory); - - var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); - - exports['default'] = function (createHistory) { - var history = undefined; - if (canUseDOM) history = _useRouterHistory2['default'](createHistory)(); - return history; - }; - - module.exports = exports['default']; - -/***/ }, -/* 23 */ -/***/ function(module, exports, __webpack_require__) { - - /*eslint no-empty: 0*/ - 'use strict'; - - exports.__esModule = true; - exports['default'] = deprecateObjectProperties; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var useMembrane = false; - - if (false) { - try { - if (Object.defineProperty({}, 'x', { get: function get() { - return true; - } }).x) { - useMembrane = true; - } - } catch (e) {} - } - - // wraps an object in a membrane to warn about deprecated property access - - function deprecateObjectProperties(object, message) { - if (!useMembrane) return object; - - var membrane = {}; - - var _loop = function (prop) { - if (typeof object[prop] === 'function') { - membrane[prop] = function () { - false ? _routerWarning2['default'](false, message) : undefined; - return object[prop].apply(object, arguments); - }; - } else { - Object.defineProperty(membrane, prop, { - configurable: false, - enumerable: false, - get: function get() { - false ? _routerWarning2['default'](false, message) : undefined; - return object[prop]; - } - }); - } - }; - - for (var prop in object) { - _loop(prop); - } - - return membrane; - } - - module.exports = exports['default']; - -/***/ }, -/* 24 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - exports['default'] = useRouterHistory; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _historyLibUseQueries = __webpack_require__(11); - - var _historyLibUseQueries2 = _interopRequireDefault(_historyLibUseQueries); - - var _historyLibUseBasename = __webpack_require__(29); - - var _historyLibUseBasename2 = _interopRequireDefault(_historyLibUseBasename); - - function useRouterHistory(createHistory) { - return function (options) { - var history = _historyLibUseQueries2['default'](_historyLibUseBasename2['default'](createHistory))(options); - history.__v2_compatible__ = true; - return history; - }; - } - - module.exports = exports['default']; - -/***/ }, -/* 25 */ -/***/ function(module, exports, __webpack_require__) { - - /*eslint-disable no-empty */ - 'use strict'; - - exports.__esModule = true; - exports.saveState = saveState; - exports.readState = readState; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - var KeyPrefix = '@@History/'; - var QuotaExceededErrors = ['QuotaExceededError', 'QUOTA_EXCEEDED_ERR']; - - var SecurityError = 'SecurityError'; - - function createKey(key) { - return KeyPrefix + key; - } - - function saveState(key, state) { - try { - if (state == null) { - window.sessionStorage.removeItem(createKey(key)); - } else { - window.sessionStorage.setItem(createKey(key), JSON.stringify(state)); - } - } catch (error) { - if (error.name === SecurityError) { - // Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any - // attempt to access window.sessionStorage. - false ? _warning2['default'](false, '[history] Unable to save state; sessionStorage is not available due to security settings') : undefined; - - return; - } - - if (QuotaExceededErrors.indexOf(error.name) >= 0 && window.sessionStorage.length === 0) { - // Safari "private mode" throws QuotaExceededError. - false ? _warning2['default'](false, '[history] Unable to save state; sessionStorage is not available in Safari private mode') : undefined; - - return; - } - - throw error; - } - } - - function readState(key) { - var json = undefined; - try { - json = window.sessionStorage.getItem(createKey(key)); - } catch (error) { - if (error.name === SecurityError) { - // Blocking cookies in Chrome/Firefox/Safari throws SecurityError on any - // attempt to access window.sessionStorage. - false ? _warning2['default'](false, '[history] Unable to read state; sessionStorage is not available due to security settings') : undefined; - - return null; - } - } - - if (json) { - try { - return JSON.parse(json); - } catch (error) { - // Ignore invalid JSON. - } - } - - return null; - } - -/***/ }, -/* 26 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _ExecutionEnvironment = __webpack_require__(10); - - var _DOMUtils = __webpack_require__(15); - - var _createHistory = __webpack_require__(28); - - var _createHistory2 = _interopRequireDefault(_createHistory); - - function createDOMHistory(options) { - var history = _createHistory2['default'](_extends({ - getUserConfirmation: _DOMUtils.getUserConfirmation - }, options, { - go: _DOMUtils.go - })); - - function listen(listener) { - !_ExecutionEnvironment.canUseDOM ? false ? _invariant2['default'](false, 'DOM history needs a DOM') : _invariant2['default'](false) : undefined; - - return history.listen(listener); - } - - return _extends({}, history, { - listen: listen - }); - } - - exports['default'] = createDOMHistory; - module.exports = exports['default']; - -/***/ }, -/* 27 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _Actions = __webpack_require__(9); - - var _PathUtils = __webpack_require__(7); - - var _ExecutionEnvironment = __webpack_require__(10); - - var _DOMUtils = __webpack_require__(15); - - var _DOMStateStorage = __webpack_require__(25); - - var _createDOMHistory = __webpack_require__(26); - - var _createDOMHistory2 = _interopRequireDefault(_createDOMHistory); - - function isAbsolutePath(path) { - return typeof path === 'string' && path.charAt(0) === '/'; - } - - function ensureSlash() { - var path = _DOMUtils.getHashPath(); - - if (isAbsolutePath(path)) return true; - - _DOMUtils.replaceHashPath('/' + path); - - return false; - } - - function addQueryStringValueToPath(path, key, value) { - return path + (path.indexOf('?') === -1 ? '?' : '&') + (key + '=' + value); - } - - function stripQueryStringValueFromPath(path, key) { - return path.replace(new RegExp('[?&]?' + key + '=[a-zA-Z0-9]+'), ''); - } - - function getQueryStringValueFromPath(path, key) { - var match = path.match(new RegExp('\\?.*?\\b' + key + '=(.+?)\\b')); - return match && match[1]; - } - - var DefaultQueryKey = '_k'; - - function createHashHistory() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - - !_ExecutionEnvironment.canUseDOM ? false ? _invariant2['default'](false, 'Hash history needs a DOM') : _invariant2['default'](false) : undefined; - - var queryKey = options.queryKey; - - if (queryKey === undefined || !!queryKey) queryKey = typeof queryKey === 'string' ? queryKey : DefaultQueryKey; - - function getCurrentLocation() { - var path = _DOMUtils.getHashPath(); - - var key = undefined, - state = undefined; - if (queryKey) { - key = getQueryStringValueFromPath(path, queryKey); - path = stripQueryStringValueFromPath(path, queryKey); - - if (key) { - state = _DOMStateStorage.readState(key); - } else { - state = null; - key = history.createKey(); - _DOMUtils.replaceHashPath(addQueryStringValueToPath(path, queryKey, key)); - } - } else { - key = state = null; - } - - var location = _PathUtils.parsePath(path); - - return history.createLocation(_extends({}, location, { state: state }), undefined, key); - } - - function startHashChangeListener(_ref) { - var transitionTo = _ref.transitionTo; - - function hashChangeListener() { - if (!ensureSlash()) return; // Always make sure hashes are preceeded with a /. - - transitionTo(getCurrentLocation()); - } - - ensureSlash(); - _DOMUtils.addEventListener(window, 'hashchange', hashChangeListener); - - return function () { - _DOMUtils.removeEventListener(window, 'hashchange', hashChangeListener); - }; - } - - function finishTransition(location) { - var basename = location.basename; - var pathname = location.pathname; - var search = location.search; - var state = location.state; - var action = location.action; - var key = location.key; - - if (action === _Actions.POP) return; // Nothing to do. - - var path = (basename || '') + pathname + search; - - if (queryKey) { - path = addQueryStringValueToPath(path, queryKey, key); - _DOMStateStorage.saveState(key, state); - } else { - // Drop key and state. - location.key = location.state = null; - } - - var currentHash = _DOMUtils.getHashPath(); - - if (action === _Actions.PUSH) { - if (currentHash !== path) { - window.location.hash = path; - } else { - false ? _warning2['default'](false, 'You cannot PUSH the same path using hash history') : undefined; - } - } else if (currentHash !== path) { - // REPLACE - _DOMUtils.replaceHashPath(path); - } - } - - var history = _createDOMHistory2['default'](_extends({}, options, { - getCurrentLocation: getCurrentLocation, - finishTransition: finishTransition, - saveState: _DOMStateStorage.saveState - })); - - var listenerCount = 0, - stopHashChangeListener = undefined; - - function listenBefore(listener) { - if (++listenerCount === 1) stopHashChangeListener = startHashChangeListener(history); - - var unlisten = history.listenBefore(listener); - - return function () { - unlisten(); - - if (--listenerCount === 0) stopHashChangeListener(); - }; - } - - function listen(listener) { - if (++listenerCount === 1) stopHashChangeListener = startHashChangeListener(history); - - var unlisten = history.listen(listener); - - return function () { - unlisten(); - - if (--listenerCount === 0) stopHashChangeListener(); - }; - } - - function push(location) { - false ? _warning2['default'](queryKey || location.state == null, 'You cannot use state without a queryKey it will be dropped') : undefined; - - history.push(location); - } - - function replace(location) { - false ? _warning2['default'](queryKey || location.state == null, 'You cannot use state without a queryKey it will be dropped') : undefined; - - history.replace(location); - } - - var goIsSupportedWithoutReload = _DOMUtils.supportsGoWithoutReloadUsingHash(); - - function go(n) { - false ? _warning2['default'](goIsSupportedWithoutReload, 'Hash history go(n) causes a full page reload in this browser') : undefined; - - history.go(n); - } - - function createHref(path) { - return '#' + history.createHref(path); - } - - // deprecated - function registerTransitionHook(hook) { - if (++listenerCount === 1) stopHashChangeListener = startHashChangeListener(history); - - history.registerTransitionHook(hook); - } - - // deprecated - function unregisterTransitionHook(hook) { - history.unregisterTransitionHook(hook); - - if (--listenerCount === 0) stopHashChangeListener(); - } - - // deprecated - function pushState(state, path) { - false ? _warning2['default'](queryKey || state == null, 'You cannot use state without a queryKey it will be dropped') : undefined; - - history.pushState(state, path); - } - - // deprecated - function replaceState(state, path) { - false ? _warning2['default'](queryKey || state == null, 'You cannot use state without a queryKey it will be dropped') : undefined; - - history.replaceState(state, path); - } - - return _extends({}, history, { - listenBefore: listenBefore, - listen: listen, - push: push, - replace: replace, - go: go, - createHref: createHref, - - registerTransitionHook: registerTransitionHook, // deprecated - warning is in createHistory - unregisterTransitionHook: unregisterTransitionHook, // deprecated - warning is in createHistory - pushState: pushState, // deprecated - warning is in createHistory - replaceState: replaceState // deprecated - warning is in createHistory - }); - } - - exports['default'] = createHashHistory; - module.exports = exports['default']; - -/***/ }, -/* 28 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - var _deepEqual = __webpack_require__(49); - - var _deepEqual2 = _interopRequireDefault(_deepEqual); - - var _PathUtils = __webpack_require__(7); - - var _AsyncUtils = __webpack_require__(52); - - var _Actions = __webpack_require__(9); - - var _createLocation2 = __webpack_require__(54); - - var _createLocation3 = _interopRequireDefault(_createLocation2); - - var _runTransitionHook = __webpack_require__(17); - - var _runTransitionHook2 = _interopRequireDefault(_runTransitionHook); - - var _deprecate = __webpack_require__(16); - - var _deprecate2 = _interopRequireDefault(_deprecate); - - function createRandomKey(length) { - return Math.random().toString(36).substr(2, length); - } - - function locationsAreEqual(a, b) { - return a.pathname === b.pathname && a.search === b.search && - //a.action === b.action && // Different action !== location change. - a.key === b.key && _deepEqual2['default'](a.state, b.state); - } - - var DefaultKeyLength = 6; - - function createHistory() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - var getCurrentLocation = options.getCurrentLocation; - var finishTransition = options.finishTransition; - var saveState = options.saveState; - var go = options.go; - var keyLength = options.keyLength; - var getUserConfirmation = options.getUserConfirmation; - - if (typeof keyLength !== 'number') keyLength = DefaultKeyLength; - - var transitionHooks = []; - - function listenBefore(hook) { - transitionHooks.push(hook); - - return function () { - transitionHooks = transitionHooks.filter(function (item) { - return item !== hook; - }); - }; - } - - var allKeys = []; - var changeListeners = []; - var location = undefined; - - function getCurrent() { - if (pendingLocation && pendingLocation.action === _Actions.POP) { - return allKeys.indexOf(pendingLocation.key); - } else if (location) { - return allKeys.indexOf(location.key); - } else { - return -1; - } - } - - function updateLocation(newLocation) { - var current = getCurrent(); - - location = newLocation; - - if (location.action === _Actions.PUSH) { - allKeys = [].concat(allKeys.slice(0, current + 1), [location.key]); - } else if (location.action === _Actions.REPLACE) { - allKeys[current] = location.key; - } - - changeListeners.forEach(function (listener) { - listener(location); - }); - } - - function listen(listener) { - changeListeners.push(listener); - - if (location) { - listener(location); - } else { - var _location = getCurrentLocation(); - allKeys = [_location.key]; - updateLocation(_location); - } - - return function () { - changeListeners = changeListeners.filter(function (item) { - return item !== listener; - }); - }; - } - - function confirmTransitionTo(location, callback) { - _AsyncUtils.loopAsync(transitionHooks.length, function (index, next, done) { - _runTransitionHook2['default'](transitionHooks[index], location, function (result) { - if (result != null) { - done(result); - } else { - next(); - } - }); - }, function (message) { - if (getUserConfirmation && typeof message === 'string') { - getUserConfirmation(message, function (ok) { - callback(ok !== false); - }); - } else { - callback(message !== false); - } - }); - } - - var pendingLocation = undefined; - - function transitionTo(nextLocation) { - if (location && locationsAreEqual(location, nextLocation)) return; // Nothing to do. - - pendingLocation = nextLocation; - - confirmTransitionTo(nextLocation, function (ok) { - if (pendingLocation !== nextLocation) return; // Transition was interrupted. - - if (ok) { - // treat PUSH to current path like REPLACE to be consistent with browsers - if (nextLocation.action === _Actions.PUSH) { - var prevPath = createPath(location); - var nextPath = createPath(nextLocation); - - if (nextPath === prevPath && _deepEqual2['default'](location.state, nextLocation.state)) nextLocation.action = _Actions.REPLACE; - } - - if (finishTransition(nextLocation) !== false) updateLocation(nextLocation); - } else if (location && nextLocation.action === _Actions.POP) { - var prevIndex = allKeys.indexOf(location.key); - var nextIndex = allKeys.indexOf(nextLocation.key); - - if (prevIndex !== -1 && nextIndex !== -1) go(prevIndex - nextIndex); // Restore the URL. - } - }); - } - - function push(location) { - transitionTo(createLocation(location, _Actions.PUSH, createKey())); - } - - function replace(location) { - transitionTo(createLocation(location, _Actions.REPLACE, createKey())); - } - - function goBack() { - go(-1); - } - - function goForward() { - go(1); - } - - function createKey() { - return createRandomKey(keyLength); - } - - function createPath(location) { - if (location == null || typeof location === 'string') return location; - - var pathname = location.pathname; - var search = location.search; - var hash = location.hash; - - var result = pathname; - - if (search) result += search; - - if (hash) result += hash; - - return result; - } - - function createHref(location) { - return createPath(location); - } - - function createLocation(location, action) { - var key = arguments.length <= 2 || arguments[2] === undefined ? createKey() : arguments[2]; - - if (typeof action === 'object') { - false ? _warning2['default'](false, 'The state (2nd) argument to history.createLocation is deprecated; use a ' + 'location descriptor instead') : undefined; - - if (typeof location === 'string') location = _PathUtils.parsePath(location); - - location = _extends({}, location, { state: action }); - - action = key; - key = arguments[3] || createKey(); - } - - return _createLocation3['default'](location, action, key); - } - - // deprecated - function setState(state) { - if (location) { - updateLocationState(location, state); - updateLocation(location); - } else { - updateLocationState(getCurrentLocation(), state); - } - } - - function updateLocationState(location, state) { - location.state = _extends({}, location.state, state); - saveState(location.key, location.state); - } - - // deprecated - function registerTransitionHook(hook) { - if (transitionHooks.indexOf(hook) === -1) transitionHooks.push(hook); - } - - // deprecated - function unregisterTransitionHook(hook) { - transitionHooks = transitionHooks.filter(function (item) { - return item !== hook; - }); - } - - // deprecated - function pushState(state, path) { - if (typeof path === 'string') path = _PathUtils.parsePath(path); - - push(_extends({ state: state }, path)); - } - - // deprecated - function replaceState(state, path) { - if (typeof path === 'string') path = _PathUtils.parsePath(path); - - replace(_extends({ state: state }, path)); - } - - return { - listenBefore: listenBefore, - listen: listen, - transitionTo: transitionTo, - push: push, - replace: replace, - go: go, - goBack: goBack, - goForward: goForward, - createKey: createKey, - createPath: createPath, - createHref: createHref, - createLocation: createLocation, - - setState: _deprecate2['default'](setState, 'setState is deprecated; use location.key to save state instead'), - registerTransitionHook: _deprecate2['default'](registerTransitionHook, 'registerTransitionHook is deprecated; use listenBefore instead'), - unregisterTransitionHook: _deprecate2['default'](unregisterTransitionHook, 'unregisterTransitionHook is deprecated; use the callback returned from listenBefore instead'), - pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'), - replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead') - }; - } - - exports['default'] = createHistory; - module.exports = exports['default']; - -/***/ }, -/* 29 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - - var _ExecutionEnvironment = __webpack_require__(10); - - var _PathUtils = __webpack_require__(7); - - var _runTransitionHook = __webpack_require__(17); - - var _runTransitionHook2 = _interopRequireDefault(_runTransitionHook); - - var _deprecate = __webpack_require__(16); - - var _deprecate2 = _interopRequireDefault(_deprecate); - - function useBasename(createHistory) { - return function () { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - var basename = options.basename; - - var historyOptions = _objectWithoutProperties(options, ['basename']); - - var history = createHistory(historyOptions); - - // Automatically use the value of in HTML - // documents as basename if it's not explicitly given. - if (basename == null && _ExecutionEnvironment.canUseDOM) { - var base = document.getElementsByTagName('base')[0]; - - if (base) basename = _PathUtils.extractPath(base.href); - } - - function addBasename(location) { - if (basename && location.basename == null) { - if (location.pathname.indexOf(basename) === 0) { - location.pathname = location.pathname.substring(basename.length); - location.basename = basename; - - if (location.pathname === '') location.pathname = '/'; - } else { - location.basename = ''; - } - } - - return location; - } - - function prependBasename(location) { - if (!basename) return location; - - if (typeof location === 'string') location = _PathUtils.parsePath(location); - - var pname = location.pathname; - var normalizedBasename = basename.slice(-1) === '/' ? basename : basename + '/'; - var normalizedPathname = pname.charAt(0) === '/' ? pname.slice(1) : pname; - var pathname = normalizedBasename + normalizedPathname; - - return _extends({}, location, { - pathname: pathname - }); - } - - // Override all read methods with basename-aware versions. - function listenBefore(hook) { - return history.listenBefore(function (location, callback) { - _runTransitionHook2['default'](hook, addBasename(location), callback); - }); - } - - function listen(listener) { - return history.listen(function (location) { - listener(addBasename(location)); - }); - } - - // Override all write methods with basename-aware versions. - function push(location) { - history.push(prependBasename(location)); - } - - function replace(location) { - history.replace(prependBasename(location)); - } - - function createPath(location) { - return history.createPath(prependBasename(location)); - } - - function createHref(location) { - return history.createHref(prependBasename(location)); - } - - function createLocation(location) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - return addBasename(history.createLocation.apply(history, [prependBasename(location)].concat(args))); - } - - // deprecated - function pushState(state, path) { - if (typeof path === 'string') path = _PathUtils.parsePath(path); - - push(_extends({ state: state }, path)); - } - - // deprecated - function replaceState(state, path) { - if (typeof path === 'string') path = _PathUtils.parsePath(path); - - replace(_extends({ state: state }, path)); - } - - return _extends({}, history, { - listenBefore: listenBefore, - listen: listen, - push: push, - replace: replace, - createPath: createPath, - createHref: createHref, - createLocation: createLocation, - - pushState: _deprecate2['default'](pushState, 'pushState is deprecated; use push instead'), - replaceState: _deprecate2['default'](replaceState, 'replaceState is deprecated; use replace instead') - }); - }; - } - - exports['default'] = useBasename; - module.exports = exports['default']; - -/***/ }, -/* 30 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var _PropTypes = __webpack_require__(6); - - /** - * A mixin that adds the "history" instance variable to components. - */ - var History = { - - contextTypes: { - history: _PropTypes.history - }, - - componentWillMount: function componentWillMount() { - false ? _routerWarning2['default'](false, 'the `History` mixin is deprecated, please access `context.router` with your own `contextTypes`. http://tiny.cc/router-historymixin') : undefined; - this.history = this.context.history; - } - - }; - - exports['default'] = History; - module.exports = exports['default']; - -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _Link = __webpack_require__(18); - - var _Link2 = _interopRequireDefault(_Link); - - /** - * An is used to link to an . - */ - var IndexLink = _react2['default'].createClass({ - displayName: 'IndexLink', - - render: function render() { - return _react2['default'].createElement(_Link2['default'], _extends({}, this.props, { onlyActiveOnIndex: true })); - } - - }); - - exports['default'] = IndexLink; - module.exports = exports['default']; - -/***/ }, -/* 32 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _Redirect = __webpack_require__(19); - - var _Redirect2 = _interopRequireDefault(_Redirect); - - var _PropTypes = __webpack_require__(6); - - var _React$PropTypes = _react2['default'].PropTypes; - var string = _React$PropTypes.string; - var object = _React$PropTypes.object; - - /** - * An is used to redirect from an indexRoute. - */ - var IndexRedirect = _react2['default'].createClass({ - displayName: 'IndexRedirect', - - statics: { - - createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) { - /* istanbul ignore else: sanity check */ - if (parentRoute) { - parentRoute.indexRoute = _Redirect2['default'].createRouteFromReactElement(element); - } else { - false ? _routerWarning2['default'](false, 'An does not make sense at the root of your route config') : undefined; - } - } - - }, - - propTypes: { - to: string.isRequired, - query: object, - state: object, - onEnter: _PropTypes.falsy, - children: _PropTypes.falsy - }, - - /* istanbul ignore next: sanity check */ - render: function render() { - true ? false ? _invariant2['default'](false, ' elements are for router configuration only and should not be rendered') : _invariant2['default'](false) : undefined; - } - - }); - - exports['default'] = IndexRedirect; - module.exports = exports['default']; - -/***/ }, -/* 33 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _RouteUtils = __webpack_require__(5); - - var _PropTypes = __webpack_require__(6); - - var func = _react2['default'].PropTypes.func; - - /** - * An is used to specify its parent's in - * a JSX route config. - */ - var IndexRoute = _react2['default'].createClass({ - displayName: 'IndexRoute', - - statics: { - - createRouteFromReactElement: function createRouteFromReactElement(element, parentRoute) { - /* istanbul ignore else: sanity check */ - if (parentRoute) { - parentRoute.indexRoute = _RouteUtils.createRouteFromReactElement(element); - } else { - false ? _routerWarning2['default'](false, 'An does not make sense at the root of your route config') : undefined; - } - } - - }, - - propTypes: { - path: _PropTypes.falsy, - component: _PropTypes.component, - components: _PropTypes.components, - getComponent: func, - getComponents: func - }, - - /* istanbul ignore next: sanity check */ - render: function render() { - true ? false ? _invariant2['default'](false, ' elements are for router configuration only and should not be rendered') : _invariant2['default'](false) : undefined; - } - - }); - - exports['default'] = IndexRoute; - module.exports = exports['default']; - -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var object = _react2['default'].PropTypes.object; - - /** - * The Lifecycle mixin adds the routerWillLeave lifecycle method to a - * component that may be used to cancel a transition or prompt the user - * for confirmation. - * - * On standard transitions, routerWillLeave receives a single argument: the - * location we're transitioning to. To cancel the transition, return false. - * To prompt the user for confirmation, return a prompt message (string). - * - * During the beforeunload event (assuming you're using the useBeforeUnload - * history enhancer), routerWillLeave does not receive a location object - * because it isn't possible for us to know the location we're transitioning - * to. In this case routerWillLeave must return a prompt message to prevent - * the user from closing the window/tab. - */ - var Lifecycle = { - - contextTypes: { - history: object.isRequired, - // Nested children receive the route as context, either - // set by the route component using the RouteContext mixin - // or by some other ancestor. - route: object - }, - - propTypes: { - // Route components receive the route object as a prop. - route: object - }, - - componentDidMount: function componentDidMount() { - false ? _routerWarning2['default'](false, 'the `Lifecycle` mixin is deprecated, please use `context.router.setRouteLeaveHook(route, hook)`. http://tiny.cc/router-lifecyclemixin') : undefined; - !this.routerWillLeave ? false ? _invariant2['default'](false, 'The Lifecycle mixin requires you to define a routerWillLeave method') : _invariant2['default'](false) : undefined; - - var route = this.props.route || this.context.route; - - !route ? false ? _invariant2['default'](false, 'The Lifecycle mixin must be used on either a) a or ' + 'b) a descendant of a that uses the RouteContext mixin') : _invariant2['default'](false) : undefined; - - this._unlistenBeforeLeavingRoute = this.context.history.listenBeforeLeavingRoute(route, this.routerWillLeave); - }, - - componentWillUnmount: function componentWillUnmount() { - if (this._unlistenBeforeLeavingRoute) this._unlistenBeforeLeavingRoute(); - } - - }; - - exports['default'] = Lifecycle; - module.exports = exports['default']; - -/***/ }, -/* 35 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _RouteUtils = __webpack_require__(5); - - var _PropTypes = __webpack_require__(6); - - var _React$PropTypes = _react2['default'].PropTypes; - var string = _React$PropTypes.string; - var func = _React$PropTypes.func; - - /** - * A is used to declare which components are rendered to the - * page when the URL matches a given pattern. - * - * Routes are arranged in a nested tree structure. When a new URL is - * requested, the tree is searched depth-first to find a route whose - * path matches the URL. When one is found, all routes in the tree - * that lead to it are considered "active" and their components are - * rendered into the DOM, nested in the same order as in the tree. - */ - var Route = _react2['default'].createClass({ - displayName: 'Route', - - statics: { - createRouteFromReactElement: _RouteUtils.createRouteFromReactElement - }, - - propTypes: { - path: string, - component: _PropTypes.component, - components: _PropTypes.components, - getComponent: func, - getComponents: func - }, - - /* istanbul ignore next: sanity check */ - render: function render() { - true ? false ? _invariant2['default'](false, ' elements are for router configuration only and should not be rendered') : _invariant2['default'](false) : undefined; - } - - }); - - exports['default'] = Route; - module.exports = exports['default']; - -/***/ }, -/* 36 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var object = _react2['default'].PropTypes.object; - - /** - * The RouteContext mixin provides a convenient way for route - * components to set the route in context. This is needed for - * routes that render elements that want to use the Lifecycle - * mixin to prevent transitions. - */ - var RouteContext = { - - propTypes: { - route: object.isRequired - }, - - childContextTypes: { - route: object.isRequired - }, - - getChildContext: function getChildContext() { - return { - route: this.props.route - }; - }, - - componentWillMount: function componentWillMount() { - false ? _routerWarning2['default'](false, 'The `RouteContext` mixin is deprecated. You can provide `this.props.route` on context with your own `contextTypes`. http://tiny.cc/router-routecontextmixin') : undefined; - } - - }; - - exports['default'] = RouteContext; - module.exports = exports['default']; - -/***/ }, -/* 37 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - - var _historyLibCreateHashHistory = __webpack_require__(27); - - var _historyLibCreateHashHistory2 = _interopRequireDefault(_historyLibCreateHashHistory); - - var _historyLibUseQueries = __webpack_require__(11); - - var _historyLibUseQueries2 = _interopRequireDefault(_historyLibUseQueries); - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _createTransitionManager = __webpack_require__(14); - - var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); - - var _PropTypes = __webpack_require__(6); - - var _RouterContext = __webpack_require__(13); - - var _RouterContext2 = _interopRequireDefault(_RouterContext); - - var _RouteUtils = __webpack_require__(5); - - var _RouterUtils = __webpack_require__(20); - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - function isDeprecatedHistory(history) { - return !history || !history.__v2_compatible__; - } - - var _React$PropTypes = _react2['default'].PropTypes; - var func = _React$PropTypes.func; - var object = _React$PropTypes.object; - - /** - * A is a high-level API for automatically setting up - * a router that renders a with all the props - * it needs each time the URL changes. - */ - var Router = _react2['default'].createClass({ - displayName: 'Router', - - propTypes: { - history: object, - children: _PropTypes.routes, - routes: _PropTypes.routes, // alias for children - render: func, - createElement: func, - onError: func, - onUpdate: func, - - // PRIVATE: For client-side rehydration of server match. - matchContext: object - }, - - getDefaultProps: function getDefaultProps() { - return { - render: function render(props) { - return _react2['default'].createElement(_RouterContext2['default'], props); - } - }; - }, - - getInitialState: function getInitialState() { - return { - location: null, - routes: null, - params: null, - components: null - }; - }, - - handleError: function handleError(error) { - if (this.props.onError) { - this.props.onError.call(this, error); - } else { - // Throw errors by default so we don't silently swallow them! - throw error; // This error probably occurred in getChildRoutes or getComponents. - } - }, - - componentWillMount: function componentWillMount() { - var _this = this; - - var _props = this.props; - var parseQueryString = _props.parseQueryString; - var stringifyQuery = _props.stringifyQuery; - - false ? _routerWarning2['default'](!(parseQueryString || stringifyQuery), '`parseQueryString` and `stringifyQuery` are deprecated. Please create a custom history. http://tiny.cc/router-customquerystring') : undefined; - - var _createRouterObjects = this.createRouterObjects(); - - var history = _createRouterObjects.history; - var transitionManager = _createRouterObjects.transitionManager; - var router = _createRouterObjects.router; - - this._unlisten = transitionManager.listen(function (error, state) { - if (error) { - _this.handleError(error); - } else { - _this.setState(state, _this.props.onUpdate); - } - }); - - this.history = history; - this.router = router; - }, - - createRouterObjects: function createRouterObjects() { - var matchContext = this.props.matchContext; - - if (matchContext) { - return matchContext; - } - - var history = this.props.history; - var _props2 = this.props; - var routes = _props2.routes; - var children = _props2.children; - - if (isDeprecatedHistory(history)) { - history = this.wrapDeprecatedHistory(history); - } - - var transitionManager = _createTransitionManager2['default'](history, _RouteUtils.createRoutes(routes || children)); - var router = _RouterUtils.createRouterObject(history, transitionManager); - var routingHistory = _RouterUtils.createRoutingHistory(history, transitionManager); - - return { history: routingHistory, transitionManager: transitionManager, router: router }; - }, - - wrapDeprecatedHistory: function wrapDeprecatedHistory(history) { - var _props3 = this.props; - var parseQueryString = _props3.parseQueryString; - var stringifyQuery = _props3.stringifyQuery; - - var createHistory = undefined; - if (history) { - false ? _routerWarning2['default'](false, 'It appears you have provided a deprecated history object to ``, please use a history provided by ' + 'React Router with `import { browserHistory } from \'react-router\'` or `import { hashHistory } from \'react-router\'`. ' + 'If you are using a custom history please create it with `useRouterHistory`, see http://tiny.cc/router-usinghistory for details.') : undefined; - createHistory = function () { - return history; - }; - } else { - false ? _routerWarning2['default'](false, '`Router` no longer defaults the history prop to hash history. Please use the `hashHistory` singleton instead. http://tiny.cc/router-defaulthistory') : undefined; - createHistory = _historyLibCreateHashHistory2['default']; - } - - return _historyLibUseQueries2['default'](createHistory)({ parseQueryString: parseQueryString, stringifyQuery: stringifyQuery }); - }, - - /* istanbul ignore next: sanity check */ - componentWillReceiveProps: function componentWillReceiveProps(nextProps) { - false ? _routerWarning2['default'](nextProps.history === this.props.history, 'You cannot change ; it will be ignored') : undefined; - - false ? _routerWarning2['default']((nextProps.routes || nextProps.children) === (this.props.routes || this.props.children), 'You cannot change ; it will be ignored') : undefined; - }, - - componentWillUnmount: function componentWillUnmount() { - if (this._unlisten) this._unlisten(); - }, - - render: function render() { - var _state = this.state; - var location = _state.location; - var routes = _state.routes; - var params = _state.params; - var components = _state.components; - var _props4 = this.props; - var createElement = _props4.createElement; - var render = _props4.render; - - var props = _objectWithoutProperties(_props4, ['createElement', 'render']); - - if (location == null) return null; // Async match - - // Only forward non-Router-specific props to routing context, as those are - // the only ones that might be custom routing context props. - Object.keys(Router.propTypes).forEach(function (propType) { - return delete props[propType]; - }); - - return render(_extends({}, props, { - history: this.history, - router: this.router, - location: location, - routes: routes, - params: params, - components: components, - createElement: createElement - })); - } - - }); - - exports['default'] = Router; - module.exports = exports['default']; - -/***/ }, -/* 38 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _RouterContext = __webpack_require__(13); - - var _RouterContext2 = _interopRequireDefault(_RouterContext); - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var RoutingContext = _react2['default'].createClass({ - displayName: 'RoutingContext', - - componentWillMount: function componentWillMount() { - false ? _routerWarning2['default'](false, '`RoutingContext` has been renamed to `RouterContext`. Please use `import { RouterContext } from \'react-router\'`. http://tiny.cc/router-routercontext') : undefined; - }, - - render: function render() { - return _react2['default'].createElement(_RouterContext2['default'], this.props); - } - }); - - exports['default'] = RoutingContext; - module.exports = exports['default']; - -/***/ }, -/* 39 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - exports.runEnterHooks = runEnterHooks; - exports.runLeaveHooks = runLeaveHooks; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _AsyncUtils = __webpack_require__(12); - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - function createEnterHook(hook, route) { - return function (a, b, callback) { - hook.apply(route, arguments); - - if (hook.length < 3) { - // Assume hook executes synchronously and - // automatically call the callback. - callback(); - } - }; - } - - function getEnterHooks(routes) { - return routes.reduce(function (hooks, route) { - if (route.onEnter) hooks.push(createEnterHook(route.onEnter, route)); - - return hooks; - }, []); - } - - /** - * Runs all onEnter hooks in the given array of routes in order - * with onEnter(nextState, replace, callback) and calls - * callback(error, redirectInfo) when finished. The first hook - * to use replace short-circuits the loop. - * - * If a hook needs to run asynchronously, it may use the callback - * function. However, doing so will cause the transition to pause, - * which could lead to a non-responsive UI if the hook is slow. - */ - - function runEnterHooks(routes, nextState, callback) { - var hooks = getEnterHooks(routes); - - if (!hooks.length) { - callback(); - return; - } - - var redirectInfo = undefined; - function replace(location, deprecatedPathname, deprecatedQuery) { - if (deprecatedPathname) { - false ? _routerWarning2['default'](false, '`replaceState(state, pathname, query) is deprecated; use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated') : undefined; - redirectInfo = { - pathname: deprecatedPathname, - query: deprecatedQuery, - state: location - }; - - return; - } - - redirectInfo = location; - } - - _AsyncUtils.loopAsync(hooks.length, function (index, next, done) { - hooks[index](nextState, replace, function (error) { - if (error || redirectInfo) { - done(error, redirectInfo); // No need to continue. - } else { - next(); - } - }); - }, callback); - } - - /** - * Runs all onLeave hooks in the given array of routes in order. - */ - - function runLeaveHooks(routes) { - for (var i = 0, len = routes.length; i < len; ++i) { - if (routes[i].onLeave) routes[i].onLeave.call(routes[i]); - } - } - -/***/ }, -/* 40 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _historyLibCreateBrowserHistory = __webpack_require__(53); - - var _historyLibCreateBrowserHistory2 = _interopRequireDefault(_historyLibCreateBrowserHistory); - - var _createRouterHistory = __webpack_require__(22); - - var _createRouterHistory2 = _interopRequireDefault(_createRouterHistory); - - exports['default'] = _createRouterHistory2['default'](_historyLibCreateBrowserHistory2['default']); - module.exports = exports['default']; - -/***/ }, -/* 41 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _PatternUtils = __webpack_require__(8); - - function routeParamsChanged(route, prevState, nextState) { - if (!route.path) return false; - - var paramNames = _PatternUtils.getParamNames(route.path); - - return paramNames.some(function (paramName) { - return prevState.params[paramName] !== nextState.params[paramName]; - }); - } - - /** - * Returns an object of { leaveRoutes, enterRoutes } determined by - * the change from prevState to nextState. We leave routes if either - * 1) they are not in the next state or 2) they are in the next state - * but their params have changed (i.e. /users/123 => /users/456). - * - * leaveRoutes are ordered starting at the leaf route of the tree - * we're leaving up to the common parent route. enterRoutes are ordered - * from the top of the tree we're entering down to the leaf route. - */ - function computeChangedRoutes(prevState, nextState) { - var prevRoutes = prevState && prevState.routes; - var nextRoutes = nextState.routes; - - var leaveRoutes = undefined, - enterRoutes = undefined; - if (prevRoutes) { - (function () { - var parentIsLeaving = false; - leaveRoutes = prevRoutes.filter(function (route) { - if (parentIsLeaving) { - return true; - } else { - var isLeaving = nextRoutes.indexOf(route) === -1 || routeParamsChanged(route, prevState, nextState); - if (isLeaving) parentIsLeaving = true; - return isLeaving; - } - }); - - // onLeave hooks start at the leaf route. - leaveRoutes.reverse(); - - enterRoutes = nextRoutes.filter(function (route) { - return prevRoutes.indexOf(route) === -1 || leaveRoutes.indexOf(route) !== -1; - }); - })(); - } else { - leaveRoutes = []; - enterRoutes = nextRoutes; - } - - return { - leaveRoutes: leaveRoutes, - enterRoutes: enterRoutes - }; - } - - exports['default'] = computeChangedRoutes; - module.exports = exports['default']; - -/***/ }, -/* 42 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _AsyncUtils = __webpack_require__(12); - - function getComponentsForRoute(location, route, callback) { - if (route.component || route.components) { - callback(null, route.component || route.components); - } else if (route.getComponent) { - route.getComponent(location, callback); - } else if (route.getComponents) { - route.getComponents(location, callback); - } else { - callback(); - } - } - - /** - * Asynchronously fetches all components needed for the given router - * state and calls callback(error, components) when finished. - * - * Note: This operation may finish synchronously if no routes have an - * asynchronous getComponents method. - */ - function getComponents(nextState, callback) { - _AsyncUtils.mapAsync(nextState.routes, function (route, index, callback) { - getComponentsForRoute(nextState.location, route, callback); - }, callback); - } - - exports['default'] = getComponents; - module.exports = exports['default']; - -/***/ }, -/* 43 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _PatternUtils = __webpack_require__(8); - - /** - * Extracts an object of params the given route cares about from - * the given params object. - */ - function getRouteParams(route, params) { - var routeParams = {}; - - if (!route.path) return routeParams; - - var paramNames = _PatternUtils.getParamNames(route.path); - - for (var p in params) { - if (params.hasOwnProperty(p) && paramNames.indexOf(p) !== -1) routeParams[p] = params[p]; - }return routeParams; - } - - exports['default'] = getRouteParams; - module.exports = exports['default']; - -/***/ }, -/* 44 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _historyLibCreateHashHistory = __webpack_require__(27); - - var _historyLibCreateHashHistory2 = _interopRequireDefault(_historyLibCreateHashHistory); - - var _createRouterHistory = __webpack_require__(22); - - var _createRouterHistory2 = _interopRequireDefault(_createRouterHistory); - - exports['default'] = _createRouterHistory2['default'](_historyLibCreateHashHistory2['default']); - module.exports = exports['default']; - -/***/ }, -/* 45 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - exports['default'] = isActive; - - var _PatternUtils = __webpack_require__(8); - - function deepEqual(a, b) { - if (a == b) return true; - - if (a == null || b == null) return false; - - if (Array.isArray(a)) { - return Array.isArray(b) && a.length === b.length && a.every(function (item, index) { - return deepEqual(item, b[index]); - }); - } - - if (typeof a === 'object') { - for (var p in a) { - if (!a.hasOwnProperty(p)) { - continue; - } - - if (a[p] === undefined) { - if (b[p] !== undefined) { - return false; - } - } else if (!b.hasOwnProperty(p)) { - return false; - } else if (!deepEqual(a[p], b[p])) { - return false; - } - } - - return true; - } - - return String(a) === String(b); - } - - function paramsAreActive(paramNames, paramValues, activeParams) { - // FIXME: This doesn't work on repeated params in activeParams. - return paramNames.every(function (paramName, index) { - return String(paramValues[index]) === String(activeParams[paramName]); - }); - } - - function getMatchingRouteIndex(pathname, activeRoutes, activeParams) { - var remainingPathname = pathname, - paramNames = [], - paramValues = []; - - for (var i = 0, len = activeRoutes.length; i < len; ++i) { - var route = activeRoutes[i]; - var pattern = route.path || ''; - - if (pattern.charAt(0) === '/') { - remainingPathname = pathname; - paramNames = []; - paramValues = []; - } - - if (remainingPathname !== null) { - var matched = _PatternUtils.matchPattern(pattern, remainingPathname); - remainingPathname = matched.remainingPathname; - paramNames = [].concat(paramNames, matched.paramNames); - paramValues = [].concat(paramValues, matched.paramValues); - } - - if (remainingPathname === '' && route.path && paramsAreActive(paramNames, paramValues, activeParams)) return i; - } - - return null; - } - - /** - * Returns true if the given pathname matches the active routes - * and params. - */ - function routeIsActive(pathname, routes, params, indexOnly) { - var i = getMatchingRouteIndex(pathname, routes, params); - - if (i === null) { - // No match. - return false; - } else if (!indexOnly) { - // Any match is good enough. - return true; - } - - // If any remaining routes past the match index have paths, then we can't - // be on the index route. - return routes.slice(i + 1).every(function (route) { - return !route.path; - }); - } - - /** - * Returns true if all key/value pairs in the given query are - * currently active. - */ - function queryIsActive(query, activeQuery) { - if (activeQuery == null) return query == null; - - if (query == null) return true; - - return deepEqual(query, activeQuery); - } - - /** - * Returns true if a to the given pathname/query combination is - * currently active. - */ - - function isActive(_ref, indexOnly, currentLocation, routes, params) { - var pathname = _ref.pathname; - var query = _ref.query; - - if (currentLocation == null) return false; - - if (!routeIsActive(pathname, routes, params, indexOnly)) return false; - - return queryIsActive(query, currentLocation.query); - } - - module.exports = exports['default']; - -/***/ }, -/* 46 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _createMemoryHistory = __webpack_require__(21); - - var _createMemoryHistory2 = _interopRequireDefault(_createMemoryHistory); - - var _createTransitionManager = __webpack_require__(14); - - var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); - - var _RouteUtils = __webpack_require__(5); - - var _RouterUtils = __webpack_require__(20); - - /** - * A high-level API to be used for server-side rendering. - * - * This function matches a location to a set of routes and calls - * callback(error, redirectLocation, renderProps) when finished. - * - * Note: You probably don't want to use this in a browser unless you're using - * server-side rendering with async routes. - */ - function match(_ref, callback) { - var history = _ref.history; - var routes = _ref.routes; - var location = _ref.location; - - var options = _objectWithoutProperties(_ref, ['history', 'routes', 'location']); - - !(history || location) ? false ? _invariant2['default'](false, 'match needs a history or a location') : _invariant2['default'](false) : undefined; - - history = history ? history : _createMemoryHistory2['default'](options); - var transitionManager = _createTransitionManager2['default'](history, _RouteUtils.createRoutes(routes)); - - var unlisten = undefined; - - if (location) { - // Allow match({ location: '/the/path', ... }) - location = history.createLocation(location); - } else { - // Pick up the location from the history via synchronous history.listen - // call if needed. - unlisten = history.listen(function (historyLocation) { - location = historyLocation; - }); - } - - var router = _RouterUtils.createRouterObject(history, transitionManager); - history = _RouterUtils.createRoutingHistory(history, transitionManager); - - transitionManager.match(location, function (error, redirectLocation, nextState) { - callback(error, redirectLocation, nextState && _extends({}, nextState, { - history: history, - router: router, - matchContext: { history: history, transitionManager: transitionManager, router: router } - })); - - // Defer removing the listener to here to prevent DOM histories from having - // to unwind DOM event listeners unnecessarily, in case callback renders a - // and attaches another history listener. - if (unlisten) { - unlisten(); - } - }); - } - - exports['default'] = match; - module.exports = exports['default']; - -/***/ }, -/* 47 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - var _AsyncUtils = __webpack_require__(12); - - var _PatternUtils = __webpack_require__(8); - - var _RouteUtils = __webpack_require__(5); - - function getChildRoutes(route, location, callback) { - if (route.childRoutes) { - return [null, route.childRoutes]; - } - if (!route.getChildRoutes) { - return []; - } - - var sync = true, - result = undefined; - - route.getChildRoutes(location, function (error, childRoutes) { - childRoutes = !error && _RouteUtils.createRoutes(childRoutes); - if (sync) { - result = [error, childRoutes]; - return; - } - - callback(error, childRoutes); - }); - - sync = false; - return result; // Might be undefined. - } - - function getIndexRoute(route, location, callback) { - if (route.indexRoute) { - callback(null, route.indexRoute); - } else if (route.getIndexRoute) { - route.getIndexRoute(location, function (error, indexRoute) { - callback(error, !error && _RouteUtils.createRoutes(indexRoute)[0]); - }); - } else if (route.childRoutes) { - (function () { - var pathless = route.childRoutes.filter(function (obj) { - return !obj.hasOwnProperty('path'); - }); - - _AsyncUtils.loopAsync(pathless.length, function (index, next, done) { - getIndexRoute(pathless[index], location, function (error, indexRoute) { - if (error || indexRoute) { - var routes = [pathless[index]].concat(Array.isArray(indexRoute) ? indexRoute : [indexRoute]); - done(error, routes); - } else { - next(); - } - }); - }, function (err, routes) { - callback(null, routes); - }); - })(); - } else { - callback(); - } - } - - function assignParams(params, paramNames, paramValues) { - return paramNames.reduce(function (params, paramName, index) { - var paramValue = paramValues && paramValues[index]; - - if (Array.isArray(params[paramName])) { - params[paramName].push(paramValue); - } else if (paramName in params) { - params[paramName] = [params[paramName], paramValue]; - } else { - params[paramName] = paramValue; - } - - return params; - }, params); - } - - function createParams(paramNames, paramValues) { - return assignParams({}, paramNames, paramValues); - } - - function matchRouteDeep(route, location, remainingPathname, paramNames, paramValues, callback) { - var pattern = route.path || ''; - - if (pattern.charAt(0) === '/') { - remainingPathname = location.pathname; - paramNames = []; - paramValues = []; - } - - if (remainingPathname !== null) { - var matched = _PatternUtils.matchPattern(pattern, remainingPathname); - remainingPathname = matched.remainingPathname; - paramNames = [].concat(paramNames, matched.paramNames); - paramValues = [].concat(paramValues, matched.paramValues); - - if (remainingPathname === '' && route.path) { - var _ret2 = (function () { - var match = { - routes: [route], - params: createParams(paramNames, paramValues) - }; - - getIndexRoute(route, location, function (error, indexRoute) { - if (error) { - callback(error); - } else { - if (Array.isArray(indexRoute)) { - var _match$routes; - - false ? _routerWarning2['default'](indexRoute.every(function (route) { - return !route.path; - }), 'Index routes should not have paths') : undefined; - (_match$routes = match.routes).push.apply(_match$routes, indexRoute); - } else if (indexRoute) { - false ? _routerWarning2['default'](!indexRoute.path, 'Index routes should not have paths') : undefined; - match.routes.push(indexRoute); - } - - callback(null, match); - } - }); - return { - v: undefined - }; - })(); - - if (typeof _ret2 === 'object') return _ret2.v; - } - } - - if (remainingPathname != null || route.childRoutes) { - // Either a) this route matched at least some of the path or b) - // we don't have to load this route's children asynchronously. In - // either case continue checking for matches in the subtree. - var onChildRoutes = function onChildRoutes(error, childRoutes) { - if (error) { - callback(error); - } else if (childRoutes) { - // Check the child routes to see if any of them match. - matchRoutes(childRoutes, location, function (error, match) { - if (error) { - callback(error); - } else if (match) { - // A child route matched! Augment the match and pass it up the stack. - match.routes.unshift(route); - callback(null, match); - } else { - callback(); - } - }, remainingPathname, paramNames, paramValues); - } else { - callback(); - } - }; - - var result = getChildRoutes(route, location, onChildRoutes); - if (result) { - onChildRoutes.apply(undefined, result); - } - } else { - callback(); - } - } - - /** - * Asynchronously matches the given location to a set of routes and calls - * callback(error, state) when finished. The state object will have the - * following properties: - * - * - routes An array of routes that matched, in hierarchical order - * - params An object of URL parameters - * - * Note: This operation may finish synchronously if no routes have an - * asynchronous getChildRoutes method. - */ - function matchRoutes(routes, location, callback) { - var remainingPathname = arguments.length <= 3 || arguments[3] === undefined ? location.pathname : arguments[3]; - var paramNames = arguments.length <= 4 || arguments[4] === undefined ? [] : arguments[4]; - var paramValues = arguments.length <= 5 || arguments[5] === undefined ? [] : arguments[5]; - return (function () { - _AsyncUtils.loopAsync(routes.length, function (index, next, done) { - matchRouteDeep(routes[index], location, remainingPathname, paramNames, paramValues, function (error, match) { - if (error || match) { - done(error, match); - } else { - next(); - } - }); - }, callback); - })(); - } - - exports['default'] = matchRoutes; - module.exports = exports['default']; - -/***/ }, -/* 48 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - - var _historyLibUseQueries = __webpack_require__(11); - - var _historyLibUseQueries2 = _interopRequireDefault(_historyLibUseQueries); - - var _createTransitionManager = __webpack_require__(14); - - var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); - - var _routerWarning = __webpack_require__(1); - - var _routerWarning2 = _interopRequireDefault(_routerWarning); - - /** - * Returns a new createHistory function that may be used to create - * history objects that know about routing. - * - * Enhances history objects with the following methods: - * - * - listen((error, nextState) => {}) - * - listenBeforeLeavingRoute(route, (nextLocation) => {}) - * - match(location, (error, redirectLocation, nextState) => {}) - * - isActive(pathname, query, indexOnly=false) - */ - function useRoutes(createHistory) { - false ? _routerWarning2['default'](false, '`useRoutes` is deprecated. Please use `createTransitionManager` instead.') : undefined; - - return function () { - var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - - var routes = _ref.routes; - - var options = _objectWithoutProperties(_ref, ['routes']); - - var history = _historyLibUseQueries2['default'](createHistory)(options); - var transitionManager = _createTransitionManager2['default'](history, routes); - return _extends({}, history, transitionManager); - }; - } - - exports['default'] = useRoutes; - module.exports = exports['default']; - -/***/ }, -/* 49 */ -/***/ function(module, exports, __webpack_require__) { - - var pSlice = Array.prototype.slice; - var objectKeys = __webpack_require__(51); - var isArguments = __webpack_require__(50); - - var deepEqual = module.exports = function (actual, expected, opts) { - if (!opts) opts = {}; - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - // 7.3. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') { - return opts.strict ? actual === expected : actual == expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected, opts); - } - } - - function isUndefinedOrNull(value) { - return value === null || value === undefined; - } - - function isBuffer (x) { - if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false; - if (typeof x.copy !== 'function' || typeof x.slice !== 'function') { - return false; - } - if (x.length > 0 && typeof x[0] !== 'number') return false; - return true; - } - - function objEquiv(a, b, opts) { - var i, key; - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - // an identical 'prototype' property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return deepEqual(a, b, opts); - } - if (isBuffer(a)) { - if (!isBuffer(b)) { - return false; - } - if (a.length !== b.length) return false; - for (i = 0; i < a.length; i++) { - if (a[i] !== b[i]) return false; - } - return true; - } - try { - var ka = objectKeys(a), - kb = objectKeys(b); - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!deepEqual(a[key], b[key], opts)) return false; - } - return typeof a === typeof b; - } - - -/***/ }, -/* 50 */ -/***/ function(module, exports) { - - var supportsArgumentsClass = (function(){ - return Object.prototype.toString.call(arguments) - })() == '[object Arguments]'; - - exports = module.exports = supportsArgumentsClass ? supported : unsupported; - - exports.supported = supported; - function supported(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; - }; - - exports.unsupported = unsupported; - function unsupported(object){ - return object && - typeof object == 'object' && - typeof object.length == 'number' && - Object.prototype.hasOwnProperty.call(object, 'callee') && - !Object.prototype.propertyIsEnumerable.call(object, 'callee') || - false; - }; - - -/***/ }, -/* 51 */ -/***/ function(module, exports) { - - exports = module.exports = typeof Object.keys === 'function' - ? Object.keys : shim; - - exports.shim = shim; - function shim (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; - } - - -/***/ }, -/* 52 */ -/***/ function(module, exports) { - - "use strict"; - - exports.__esModule = true; - exports.loopAsync = loopAsync; - - function loopAsync(turns, work, callback) { - var currentTurn = 0; - var isDone = false; - - function done() { - isDone = true; - callback.apply(this, arguments); - } - - function next() { - if (isDone) return; - - if (currentTurn < turns) { - work.call(this, currentTurn++, next, done); - } else { - done.apply(this, arguments); - } - } - - next(); - } - -/***/ }, -/* 53 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _Actions = __webpack_require__(9); - - var _PathUtils = __webpack_require__(7); - - var _ExecutionEnvironment = __webpack_require__(10); - - var _DOMUtils = __webpack_require__(15); - - var _DOMStateStorage = __webpack_require__(25); - - var _createDOMHistory = __webpack_require__(26); - - var _createDOMHistory2 = _interopRequireDefault(_createDOMHistory); - - /** - * Creates and returns a history object that uses HTML5's history API - * (pushState, replaceState, and the popstate event) to manage history. - * This is the recommended method of managing history in browsers because - * it provides the cleanest URLs. - * - * Note: In browsers that do not support the HTML5 history API full - * page reloads will be used to preserve URLs. - */ - function createBrowserHistory() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - - !_ExecutionEnvironment.canUseDOM ? false ? _invariant2['default'](false, 'Browser history needs a DOM') : _invariant2['default'](false) : undefined; - - var forceRefresh = options.forceRefresh; - - var isSupported = _DOMUtils.supportsHistory(); - var useRefresh = !isSupported || forceRefresh; - - function getCurrentLocation(historyState) { - historyState = historyState || window.history.state || {}; - - var path = _DOMUtils.getWindowPath(); - var _historyState = historyState; - var key = _historyState.key; - - var state = undefined; - if (key) { - state = _DOMStateStorage.readState(key); - } else { - state = null; - key = history.createKey(); - - if (isSupported) window.history.replaceState(_extends({}, historyState, { key: key }), null, path); - } - - var location = _PathUtils.parsePath(path); - - return history.createLocation(_extends({}, location, { state: state }), undefined, key); - } - - function startPopStateListener(_ref) { - var transitionTo = _ref.transitionTo; - - function popStateListener(event) { - if (event.state === undefined) return; // Ignore extraneous popstate events in WebKit. - - transitionTo(getCurrentLocation(event.state)); - } - - _DOMUtils.addEventListener(window, 'popstate', popStateListener); - - return function () { - _DOMUtils.removeEventListener(window, 'popstate', popStateListener); - }; - } - - function finishTransition(location) { - var basename = location.basename; - var pathname = location.pathname; - var search = location.search; - var hash = location.hash; - var state = location.state; - var action = location.action; - var key = location.key; - - if (action === _Actions.POP) return; // Nothing to do. - - _DOMStateStorage.saveState(key, state); - - var path = (basename || '') + pathname + search + hash; - var historyState = { - key: key - }; - - if (action === _Actions.PUSH) { - if (useRefresh) { - window.location.href = path; - return false; // Prevent location update. - } else { - window.history.pushState(historyState, null, path); - } - } else { - // REPLACE - if (useRefresh) { - window.location.replace(path); - return false; // Prevent location update. - } else { - window.history.replaceState(historyState, null, path); - } - } - } - - var history = _createDOMHistory2['default'](_extends({}, options, { - getCurrentLocation: getCurrentLocation, - finishTransition: finishTransition, - saveState: _DOMStateStorage.saveState - })); - - var listenerCount = 0, - stopPopStateListener = undefined; - - function listenBefore(listener) { - if (++listenerCount === 1) stopPopStateListener = startPopStateListener(history); - - var unlisten = history.listenBefore(listener); - - return function () { - unlisten(); - - if (--listenerCount === 0) stopPopStateListener(); - }; - } - - function listen(listener) { - if (++listenerCount === 1) stopPopStateListener = startPopStateListener(history); - - var unlisten = history.listen(listener); - - return function () { - unlisten(); - - if (--listenerCount === 0) stopPopStateListener(); - }; - } - - // deprecated - function registerTransitionHook(hook) { - if (++listenerCount === 1) stopPopStateListener = startPopStateListener(history); - - history.registerTransitionHook(hook); - } - - // deprecated - function unregisterTransitionHook(hook) { - history.unregisterTransitionHook(hook); - - if (--listenerCount === 0) stopPopStateListener(); - } - - return _extends({}, history, { - listenBefore: listenBefore, - listen: listen, - registerTransitionHook: registerTransitionHook, - unregisterTransitionHook: unregisterTransitionHook - }); - } - - exports['default'] = createBrowserHistory; - module.exports = exports['default']; - -/***/ }, -/* 54 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - var _Actions = __webpack_require__(9); - - var _PathUtils = __webpack_require__(7); - - function createLocation() { - var location = arguments.length <= 0 || arguments[0] === undefined ? '/' : arguments[0]; - var action = arguments.length <= 1 || arguments[1] === undefined ? _Actions.POP : arguments[1]; - var key = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2]; - - var _fourthArg = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; - - if (typeof location === 'string') location = _PathUtils.parsePath(location); - - if (typeof action === 'object') { - false ? _warning2['default'](false, 'The state (2nd) argument to createLocation is deprecated; use a ' + 'location descriptor instead') : undefined; - - location = _extends({}, location, { state: action }); - - action = key || _Actions.POP; - key = _fourthArg; - } - - var pathname = location.pathname || '/'; - var search = location.search || ''; - var hash = location.hash || ''; - var state = location.state || null; - - return { - pathname: pathname, - search: search, - hash: hash, - state: state, - action: action, - key: key - }; - } - - exports['default'] = createLocation; - module.exports = exports['default']; - -/***/ }, -/* 55 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.__esModule = true; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _warning = __webpack_require__(4); - - var _warning2 = _interopRequireDefault(_warning); - - var _invariant = __webpack_require__(3); - - var _invariant2 = _interopRequireDefault(_invariant); - - var _PathUtils = __webpack_require__(7); - - var _Actions = __webpack_require__(9); - - var _createHistory = __webpack_require__(28); - - var _createHistory2 = _interopRequireDefault(_createHistory); - - function createStateStorage(entries) { - return entries.filter(function (entry) { - return entry.state; - }).reduce(function (memo, entry) { - memo[entry.key] = entry.state; - return memo; - }, {}); - } - - function createMemoryHistory() { - var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - - if (Array.isArray(options)) { - options = { entries: options }; - } else if (typeof options === 'string') { - options = { entries: [options] }; - } - - var history = _createHistory2['default'](_extends({}, options, { - getCurrentLocation: getCurrentLocation, - finishTransition: finishTransition, - saveState: saveState, - go: go - })); - - var _options = options; - var entries = _options.entries; - var current = _options.current; - - if (typeof entries === 'string') { - entries = [entries]; - } else if (!Array.isArray(entries)) { - entries = ['/']; - } - - entries = entries.map(function (entry) { - var key = history.createKey(); - - if (typeof entry === 'string') return { pathname: entry, key: key }; - - if (typeof entry === 'object' && entry) return _extends({}, entry, { key: key }); - - true ? false ? _invariant2['default'](false, 'Unable to create history entry from %s', entry) : _invariant2['default'](false) : undefined; - }); - - if (current == null) { - current = entries.length - 1; - } else { - !(current >= 0 && current < entries.length) ? false ? _invariant2['default'](false, 'Current index must be >= 0 and < %s, was %s', entries.length, current) : _invariant2['default'](false) : undefined; - } - - var storage = createStateStorage(entries); - - function saveState(key, state) { - storage[key] = state; - } - - function readState(key) { - return storage[key]; - } - - function getCurrentLocation() { - var entry = entries[current]; - var key = entry.key; - var basename = entry.basename; - var pathname = entry.pathname; - var search = entry.search; - - var path = (basename || '') + pathname + (search || ''); - - var state = undefined; - if (key) { - state = readState(key); - } else { - state = null; - key = history.createKey(); - entry.key = key; - } - - var location = _PathUtils.parsePath(path); - - return history.createLocation(_extends({}, location, { state: state }), undefined, key); - } - - function canGo(n) { - var index = current + n; - return index >= 0 && index < entries.length; - } - - function go(n) { - if (n) { - if (!canGo(n)) { - false ? _warning2['default'](false, 'Cannot go(%s) there is not enough history', n) : undefined; - return; - } - - current += n; - - var currentLocation = getCurrentLocation(); - - // change action to POP - history.transitionTo(_extends({}, currentLocation, { action: _Actions.POP })); - } - } - - function finishTransition(location) { - switch (location.action) { - case _Actions.PUSH: - current += 1; - - // if we are not on the top of stack - // remove rest and push new - if (current < entries.length) entries.splice(current); - - entries.push(location); - saveState(location.key, location.state); - break; - case _Actions.REPLACE: - entries[current] = location; - saveState(location.key, location.state); - break; - } - } - - return history; - } - - exports['default'] = createMemoryHistory; - module.exports = exports['default']; - -/***/ }, -/* 56 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - var strictUriEncode = __webpack_require__(57); - - exports.extract = function (str) { - return str.split('?')[1] || ''; - }; - - exports.parse = function (str) { - if (typeof str !== 'string') { - return {}; - } - - str = str.trim().replace(/^(\?|#|&)/, ''); - - if (!str) { - return {}; - } - - return str.split('&').reduce(function (ret, param) { - var parts = param.replace(/\+/g, ' ').split('='); - // Firefox (pre 40) decodes `%3D` to `=` - // https://github.com/sindresorhus/query-string/pull/37 - var key = parts.shift(); - var val = parts.length > 0 ? parts.join('=') : undefined; - - key = decodeURIComponent(key); - - // missing `=` should be `null`: - // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters - val = val === undefined ? null : decodeURIComponent(val); - - if (!ret.hasOwnProperty(key)) { - ret[key] = val; - } else if (Array.isArray(ret[key])) { - ret[key].push(val); - } else { - ret[key] = [ret[key], val]; - } - - return ret; - }, {}); - }; - - exports.stringify = function (obj) { - return obj ? Object.keys(obj).sort().map(function (key) { - var val = obj[key]; - - if (val === undefined) { - return ''; - } - - if (val === null) { - return key; - } - - if (Array.isArray(val)) { - return val.sort().map(function (val2) { - return strictUriEncode(key) + '=' + strictUriEncode(val2); - }).join('&'); - } - - return strictUriEncode(key) + '=' + strictUriEncode(val); - }).filter(function (x) { - return x.length > 0; - }).join('&') : ''; - }; - - -/***/ }, -/* 57 */ -/***/ function(module, exports) { - - 'use strict'; - module.exports = function (str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { - return '%' + c.charCodeAt(0).toString(16).toUpperCase(); - }); - }; - - -/***/ } -/******/ ]) -}); -; \ No newline at end of file diff --git a/public/javascripts/wechat/ReactRouter.min.js b/public/javascripts/wechat/ReactRouter.min.js deleted file mode 100644 index af370173e..000000000 --- a/public/javascripts/wechat/ReactRouter.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactRouter=t(require("react")):e.ReactRouter=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(37),a=r(o);t.Router=a["default"];var u=n(18),i=r(u);t.Link=i["default"];var s=n(31),c=r(s);t.IndexLink=c["default"];var f=n(32),l=r(f);t.IndexRedirect=l["default"];var d=n(33),p=r(d);t.IndexRoute=p["default"];var h=n(19),v=r(h);t.Redirect=v["default"];var y=n(35),g=r(y);t.Route=g["default"];var m=n(30),_=r(m);t.History=_["default"];var P=n(34),O=r(P);t.Lifecycle=O["default"];var R=n(36),x=r(R);t.RouteContext=x["default"];var w=n(48),b=r(w);t.useRoutes=b["default"];var M=n(5);t.createRoutes=M.createRoutes;var E=n(13),j=r(E);t.RouterContext=j["default"];var S=n(38),A=r(S);t.RoutingContext=A["default"];var C=n(6),k=r(C);t.PropTypes=k["default"];var T=n(46),H=r(T);t.match=H["default"];var L=n(24),q=r(L);t.useRouterHistory=q["default"];var U=n(8);t.formatPattern=U.formatPattern;var N=n(40),B=r(N);t.browserHistory=B["default"];var I=n(44),D=r(I);t.hashHistory=D["default"];var F=n(21),W=r(F);t.createMemoryHistory=W["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){t="[react-router] "+t;for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o]}t.__esModule=!0,t["default"]=o;var a=n(4);r(a);e.exports=t["default"]},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=function(e,t,n,r,o,a,u,i){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,a,u,i],f=0;s=new Error(t.replace(/%s/g,function(){return c[f++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}};e.exports=r},function(e,t,n){"use strict";var r=function(){};e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return null==e||p["default"].isValidElement(e)}function a(e){return o(e)||Array.isArray(e)&&e.every(o)}function u(e,t,n){e=e||"UnknownComponent";for(var r in t)if(t.hasOwnProperty(r)){var o=t[r](n,r,e);o instanceof Error}}function i(e,t){return l({},e,t)}function s(e){var t=e.type,n=i(t.defaultProps,e.props);if(t.propTypes&&u(t.displayName||t.name,t.propTypes,n),n.children){var r=c(n.children,n);r.length&&(n.childRoutes=r),delete n.children}return n}function c(e,t){var n=[];return p["default"].Children.forEach(e,function(e){if(p["default"].isValidElement(e))if(e.type.createRouteFromReactElement){var r=e.type.createRouteFromReactElement(e,t);r&&n.push(r)}else n.push(s(e))}),n}function f(e){return a(e)?e=c(e):e&&!Array.isArray(e)&&(e=[e]),e}t.__esModule=!0;var l=Object.assign||function(e){for(var t=1;t should not have a "'+t+'" prop'):void 0}t.__esModule=!0,t.falsy=r;var o=n(2),a=o.PropTypes.func,u=o.PropTypes.object,i=o.PropTypes.arrayOf,s=o.PropTypes.oneOfType,c=o.PropTypes.element,f=o.PropTypes.shape,l=o.PropTypes.string,d=f({listen:a.isRequired,pushState:a.isRequired,replaceState:a.isRequired,go:a.isRequired});t.history=d;var p=f({pathname:l.isRequired,search:l.isRequired,state:u,action:l.isRequired,key:l});t.location=p;var h=s([a,l]);t.component=h;var v=s([h,u]);t.components=v;var y=s([u,c]);t.route=y;var g=s([y,i(y)]);t.routes=g,t["default"]={falsy:r,history:d,location:p,component:h,components:v,route:y}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=e.match(/^https?:\/\/[^\/]*/);return null==t?e:e.substring(t[0].length)}function a(e){var t=o(e),n="",r="",a=t.indexOf("#");-1!==a&&(r=t.substring(a),t=t.substring(0,a));var u=t.indexOf("?");return-1!==u&&(n=t.substring(u),t=t.substring(0,u)),""===t&&(t="/"),{pathname:t,search:n,hash:r}}t.__esModule=!0,t.extractPath=o,t.parsePath=a;var u=n(4);r(u)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function a(e){return o(e).replace(/\/+/g,"/+")}function u(e){for(var t="",n=[],r=[],o=void 0,u=0,i=/:([a-zA-Z_$][a-zA-Z0-9_$]*)|\*\*|\*|\(|\)/g;o=i.exec(e);)o.index!==u&&(r.push(e.slice(u,o.index)),t+=a(e.slice(u,o.index))),o[1]?(t+="([^/?#]+)",n.push(o[1])):"**"===o[0]?(t+="([\\s\\S]*)",n.push("splat")):"*"===o[0]?(t+="([\\s\\S]*?)",n.push("splat")):"("===o[0]?t+="(?:":")"===o[0]&&(t+=")?"),r.push(o[0]),u=i.lastIndex;return u!==e.length&&(r.push(e.slice(u,e.length)),t+=a(e.slice(u,e.length))),{pattern:e,regexpSource:t,paramNames:n,tokens:r}}function i(e){return e in h||(h[e]=u(e)),h[e]}function s(e,t){"/"!==e.charAt(0)&&(e="/"+e),"/"!==t.charAt(0)&&(t="/"+t);var n=i(e),r=n.regexpSource,o=n.paramNames,a=n.tokens;r+="/*";var u="*"!==a[a.length-1];u&&(r+="([\\s\\S]*?)");var s=t.match(new RegExp("^"+r+"$","i")),c=void 0,f=void 0;if(null!=s){if(u){c=s.pop();var l=s[0].substr(0,s[0].length-c.length);if(c&&"/"!==l.charAt(l.length-1))return{remainingPathname:null,paramNames:o,paramValues:null}}else c="";f=s.slice(1).map(function(e){return null!=e?decodeURIComponent(e):e})}else c=f=null;return{remainingPathname:c,paramNames:o,paramValues:f}}function c(e){return i(e).paramNames}function f(e,t){var n=s(e,t),r=n.paramNames,o=n.paramValues;return null!=o?r.reduce(function(e,t,n){return e[t]=o[n],e},{}):null}function l(e,t){t=t||{};for(var n=i(e),r=n.tokens,o=0,a="",u=0,s=void 0,c=void 0,f=void 0,l=0,d=r.length;d>l;++l)s=r[l],"*"===s||"**"===s?(f=Array.isArray(t.splat)?t.splat[u++]:t.splat,null!=f||o>0?void 0:p["default"](!1),null!=f&&(a+=encodeURI(f))):"("===s?o+=1:")"===s?o-=1:":"===s.charAt(0)?(c=s.substring(1),f=t[c],null!=f||o>0?void 0:p["default"](!1),null!=f&&(a+=encodeURIComponent(f))):a+=s;return a.replace(/\/+/g,"/")}t.__esModule=!0,t.compilePattern=i,t.matchPattern=s,t.getParamNames=c,t.getParams=f,t.formatPattern=l;var d=n(3),p=r(d),h={}},function(e,t){"use strict";t.__esModule=!0;var n="PUSH";t.PUSH=n;var r="REPLACE";t.REPLACE=r;var o="POP";t.POP=o,t["default"]={PUSH:n,REPLACE:r,POP:o}},function(e,t){"use strict";t.__esModule=!0;var n=!("undefined"==typeof window||!window.document||!window.document.createElement);t.canUseDOM=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return c.stringify(e).replace(/%20/g,"+")}function u(e){return function(){function t(e){if(null==e.query){var t=e.search;e.query=R(t.substring(1)),e[v]={search:t,searchBase:""}}return e}function n(e,t){var n,r=e[v],o=t?O(t):"";if(!r&&!o)return e;"string"==typeof e&&(e=d.parsePath(e));var a=void 0;a=r&&e.search===r.search?r.searchBase:e.search||"";var u=a;return o&&(u+=(u?"&":"?")+o),i({},e,(n={search:u},n[v]={search:u,searchBase:a},n))}function r(e){return w.listenBefore(function(n,r){l["default"](e,t(n),r)})}function u(e){return w.listen(function(n){e(t(n))})}function s(e){w.push(n(e,e.query))}function c(e){w.replace(n(e,e.query))}function f(e,t){return w.createPath(n(e,t||e.query))}function p(e,t){return w.createHref(n(e,t||e.query))}function g(e){for(var r=arguments.length,o=Array(r>1?r-1:0),a=1;r>a;a++)o[a-1]=arguments[a];var u=w.createLocation.apply(w,[n(e,e.query)].concat(o));return e.query&&(u.query=e.query),t(u)}function m(e,t,n){"string"==typeof t&&(t=d.parsePath(t)),s(i({state:e},t,{query:n}))}function _(e,t,n){"string"==typeof t&&(t=d.parsePath(t)),c(i({state:e},t,{query:n}))}var P=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],O=P.stringifyQuery,R=P.parseQueryString,x=o(P,["stringifyQuery","parseQueryString"]),w=e(x);return"function"!=typeof O&&(O=a),"function"!=typeof R&&(R=y),i({},w,{listenBefore:r,listen:u,push:s,replace:c,createPath:f,createHref:p,createLocation:g,pushState:h["default"](m,"pushState is deprecated; use push instead"),replaceState:h["default"](_,"replaceState is deprecated; use replace instead")})}}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;tu&&c;)c=!1,t.call(this,u++,a,r);return s=!1,i?void n.apply(this,f):void(u>=e&&c&&(i=!0,n()))}}var u=0,i=!1,s=!1,c=!1,f=void 0;a()}function r(e,t,n){function r(e,t,r){u||(t?(u=!0,n(t)):(a[e]=r,u=++i===o,u&&n(null,a)))}var o=e.length,a=[];if(0===o)return n(null,a);var u=!1,i=0;e.forEach(function(e,n){t(e,n,function(e,t){r(n,e,t)})})}t.__esModule=!0;var o=Array.prototype.slice;t.loopAsync=n,t.mapAsync=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=Object.assign||function(e){for(var t=1;ti;++i)a=o[i](e);n(a)})}function y(){if(O.routes){for(var e=d(O.routes),t=void 0,n=0,r=e.length;"string"!=typeof t&&r>n;++n)t=e[n]();return t}}function m(e){var t=c(e,!1);t&&(delete w[t],o(w)||(b&&(b(),b=null),M&&(M(),M=null)))}function _(t,n){var r=c(t),a=w[r];if(a)-1===a.indexOf(n)&&a.push(n);else{var u=!o(w);w[r]=[n],u&&(b=e.listenBefore(h),e.listenBeforeUnload&&(M=e.listenBeforeUnload(y)))}return function(){var e=w[r];if(e){var o=e.filter(function(e){return e!==n});0===o.length?m(t):w[r]=o}}}function P(t){return e.listen(function(n){O.location===n?t(null,O):a(n,function(n,r,o){n?t(n):r?e.transitionTo(r):o&&t(null,o)})})}var O={},R=void 0,x=1,w={},b=void 0,M=void 0;return{isActive:n,match:a,listenBeforeLeavingRoute:_,listen:P}}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return 0===e.button}function u(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function i(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}function s(e,t){var n=t.query,r=t.hash,o=t.state;return n||r||o?{pathname:e,query:n,hash:r,state:o}:e}t.__esModule=!0;var c=Object.assign||function(e){for(var t=1;t=0;r--){var o=e[r],a=o.path||"";if(n=a.replace(/\/*$/,"/")+n,0===a.indexOf("/"))break}return"/"+n}},propTypes:{path:d,from:d,to:d.isRequired,query:p,state:p,onEnter:f.falsy,children:f.falsy},render:function(){i["default"](!1)}});t["default"]=h,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){return u({},e,{setRouteLeaveHook:t.listenBeforeLeavingRoute,isActive:t.isActive})}function a(e,t){return e=u({},e,t)}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t=0&&0===window.sessionStorage.length)return;throw n}}function u(e){var t=void 0;try{t=window.sessionStorage.getItem(o(e))}catch(n){if(n.name===f)return null}if(t)try{return JSON.parse(t)}catch(n){}return null}t.__esModule=!0,t.saveState=a,t.readState=u;var i=n(4),s=(r(i),"@@History/"),c=["QuotaExceededError","QUOTA_EXCEEDED_ERR"],f="SecurityError"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){function t(e){return s.canUseDOM?void 0:i["default"](!1),n.listen(e)}var n=l["default"](a({getUserConfirmation:c.getUserConfirmation},e,{go:c.go}));return a({},n,{listen:t})}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return function(){function t(e){return _&&null==e.basename&&(0===e.pathname.indexOf(_)?(e.pathname=e.pathname.substring(_.length),e.basename=_,""===e.pathname&&(e.pathname="/")):e.basename=""),e}function n(e){if(!_)return e;"string"==typeof e&&(e=s.parsePath(e));var t=e.pathname,n="/"===_.slice(-1)?_:_+"/",r="/"===t.charAt(0)?t.slice(1):t,o=n+r;return u({},e,{pathname:o})}function r(e){return O.listenBefore(function(n,r){f["default"](e,t(n),r)})}function a(e){return O.listen(function(n){e(t(n))})}function c(e){O.push(n(e))}function l(e){O.replace(n(e))}function p(e){return O.createPath(n(e))}function h(e){return O.createHref(n(e))}function v(e){for(var r=arguments.length,o=Array(r>1?r-1:0),a=1;r>a;a++)o[a-1]=arguments[a];return t(O.createLocation.apply(O,[n(e)].concat(o)))}function y(e,t){"string"==typeof t&&(t=s.parsePath(t)),c(u({state:e},t))}function g(e,t){"string"==typeof t&&(t=s.parsePath(t)),l(u({state:e},t))}var m=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],_=m.basename,P=o(m,["basename"]),O=e(P);if(null==_&&i.canUseDOM){var R=document.getElementsByTagName("base")[0];R&&(_=s.extractPath(R.href))}return u({},O,{listenBefore:r,listen:a,push:c,replace:l,createPath:p,createHref:h,createLocation:v,pushState:d["default"](y,"pushState is deprecated; use push instead"),replaceState:d["default"](g,"replaceState is deprecated; use replace instead")})}}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return!e||!e.__v2_compatible__}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;tt;++t)e[t].onLeave&&e[t].onLeave.call(e[t])}t.__esModule=!0,t.runEnterHooks=u,t.runLeaveHooks=i;var s=n(12),c=n(1);r(c)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(53),a=r(o),u=n(22),i=r(u);t["default"]=i["default"](a["default"]),e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t,n){if(!e.path)return!1;var r=a.getParamNames(e.path);return r.some(function(e){return t.params[e]!==n.params[e]})}function o(e,t){var n=e&&e.routes,o=t.routes,a=void 0,u=void 0;return n?!function(){var i=!1;a=n.filter(function(n){if(i)return!0;var a=-1===o.indexOf(n)||r(n,e,t);return a&&(i=!0),a}),a.reverse(),u=o.filter(function(e){return-1===n.indexOf(e)||-1!==a.indexOf(e)})}():(a=[],u=o),{leaveRoutes:a,enterRoutes:u}}t.__esModule=!0;var a=n(8);t["default"]=o,e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t,n){t.component||t.components?n(null,t.component||t.components):t.getComponent?t.getComponent(e,n):t.getComponents?t.getComponents(e,n):n()}function o(e,t){a.mapAsync(e.routes,function(t,n,o){r(e.location,t,o)},t)}t.__esModule=!0;var a=n(12);t["default"]=o,e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t){var n={};if(!e.path)return n;var r=o.getParamNames(e.path);for(var a in t)t.hasOwnProperty(a)&&-1!==r.indexOf(a)&&(n[a]=t[a]);return n}t.__esModule=!0;var o=n(8);t["default"]=r,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(27),a=r(o),u=n(22),i=r(u);t["default"]=i["default"](a["default"]),e.exports=t["default"]},function(e,t,n){"use strict";function r(e,t){if(e==t)return!0;if(null==e||null==t)return!1;if(Array.isArray(e))return Array.isArray(t)&&e.length===t.length&&e.every(function(e,n){return r(e,t[n])});if("object"==typeof e){for(var n in e)if(e.hasOwnProperty(n))if(void 0===e[n]){if(void 0!==t[n])return!1}else{if(!t.hasOwnProperty(n))return!1;if(!r(e[n],t[n]))return!1}return!0}return String(e)===String(t)}function o(e,t,n){return e.every(function(e,r){return String(t[r])===String(n[e])})}function a(e,t,n){for(var r=e,a=[],u=[],i=0,s=t.length;s>i;++i){var f=t[i],l=f.path||"";if("/"===l.charAt(0)&&(r=e,a=[],u=[]),null!==r){var d=c.matchPattern(l,r);r=d.remainingPathname,a=[].concat(a,d.paramNames),u=[].concat(u,d.paramValues)}if(""===r&&f.path&&o(a,u,n))return i}return null}function u(e,t,n,r){var o=a(e,t,n);return null===o?!1:r?t.slice(o+1).every(function(e){return!e.path}):!0}function i(e,t){return null==t?null==e:null==e?!0:r(e,t)}function s(e,t,n,r,o){var a=e.pathname,s=e.query;return null==n?!1:u(a,r,o,t)?i(s,n.query):!1}t.__esModule=!0,t["default"]=s;var c=n(8);e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e,t){var n=e.history,r=e.routes,a=e.location,i=o(e,["history","routes","location"]);n||a?void 0:s["default"](!1),n=n?n:f["default"](i);var c=d["default"](n,p.createRoutes(r)),l=void 0;a?a=n.createLocation(a):l=n.listen(function(e){a=e});var v=h.createRouterObject(n,c);n=h.createRoutingHistory(n,c),c.match(a,function(e,r,o){t(e,r,o&&u({},o,{history:n,router:v,matchContext:{history:n,transitionManager:c,router:v}})),l&&l()})}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(e){return function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=t.routes,r=o(t,["routes"]),a=s["default"](e)(r),i=f["default"](a,n);return u({},a,i)}}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t0&&"number"!=typeof e[0]?!1:!0:!1}function a(e,t,n){var a,f;if(r(e)||r(t))return!1;if(e.prototype!==t.prototype)return!1;if(s(e))return s(t)?(e=u.call(e),t=u.call(t),c(e,t,n)):!1;if(o(e)){if(!o(t))return!1;if(e.length!==t.length)return!1;for(a=0;a=0;a--)if(l[a]!=d[a])return!1;for(a=l.length-1;a>=0;a--)if(f=l[a],!c(e[f],t[f],n))return!1;return typeof e==typeof t}var u=Array.prototype.slice,i=n(51),s=n(50),c=e.exports=function(e,t,n){return n||(n={}),e===t?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():!e||!t||"object"!=typeof e&&"object"!=typeof t?n.strict?e===t:e==t:a(e,t,n)}},function(e,t){function n(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function r(e){return e&&"object"==typeof e&&"number"==typeof e.length&&Object.prototype.hasOwnProperty.call(e,"callee")&&!Object.prototype.propertyIsEnumerable.call(e,"callee")||!1}var o="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();t=e.exports=o?n:r,t.supported=n,t.unsupported=r},function(e,t){function n(e){var t=[];for(var n in e)t.push(n);return t}t=e.exports="function"==typeof Object.keys?Object.keys:n,t.shim=n},function(e,t){"use strict";function n(e,t,n){function r(){u=!0,n.apply(this,arguments)}function o(){u||(e>a?t.call(this,a++,o,r):r.apply(this,arguments))}var a=0,u=!1;o()}t.__esModule=!0,t.loopAsync=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){function e(e){e=e||window.history.state||{};var t=l.getWindowPath(),n=e,r=n.key,o=void 0;r?o=d.readState(r):(o=null,r=_.createKey(),g&&window.history.replaceState(a({},e,{key:r}),null,t));var u=c.parsePath(t);return _.createLocation(a({},u,{state:o}),void 0,r)}function t(t){function n(t){void 0!==t.state&&r(e(t.state))}var r=t.transitionTo;return l.addEventListener(window,"popstate",n),function(){l.removeEventListener(window,"popstate",n)}}function n(e){var t=e.basename,n=e.pathname,r=e.search,o=e.hash,a=e.state,u=e.action,i=e.key;if(u!==s.POP){d.saveState(i,a);var c=(t||"")+n+r+o,f={key:i};if(u===s.PUSH){if(m)return window.location.href=c,!1;window.history.pushState(f,null,c)}else{if(m)return window.location.replace(c),!1;window.history.replaceState(f,null,c)}}}function r(e){1===++P&&(O=t(_));var n=_.listenBefore(e);return function(){n(),0===--P&&O()}}function o(e){1===++P&&(O=t(_));var n=_.listen(e);return function(){n(),0===--P&&O()}}function u(e){1===++P&&(O=t(_)),_.registerTransitionHook(e)}function p(e){_.unregisterTransitionHook(e),0===--P&&O()}var v=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];f.canUseDOM?void 0:i["default"](!1);var y=v.forceRefresh,g=l.supportsHistory(),m=!g||y,_=h["default"](a({},v,{getCurrentLocation:e,finishTransition:n,saveState:d.saveState})),P=0,O=void 0;return a({},_,{listenBefore:r,listen:o,registerTransitionHook:u,unregisterTransitionHook:p})}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t=0&&t=0&&y 0) { + cb(_openid); + } + var code = $routeParams.code; + $http({ + url: '/wechat/get_open_id', + data: {code: code}, + method: 'POST' + }).then(function successCallback(response) { + _openid = data.openid; + cb(_openid); + }, function errorCallback(response) { + cb(null); + }); + + }; + + + var setOpenId = function(id){ + _openid = id; + } + return {getOpenId: getOpenId, setOpenId: setOpenId}; +}); + +app.controller('ActivityController',function($scope, $http, auth){ + $scope.repaceUrl = function(url){ + return "http://www.trustie.net/" + url; + } + + $scope.activities = []; + $scope.page = 1; + + auth.getOpenId(function(openid){ + if(!openid){ + alert("获取openid出错"); + } else { + openid = openid; + $scope.loadActData($scope.page); + } + }); + + $scope.loadActData = function(page){ + $scope.page = page; + $http({ + method: 'POST', + url: apiUrl+ "activities", + data: {openid: openid, page: page}, + }).then(function successCallback(response) { + $scope.activities = $scope.activities.concat(response.data.data); + }, function errorCallback(response) { + }); + } + +}); + +app.controller('IssueController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "issues/"+id, + }).then(function successCallback(response) { + console.log(response.data); + $scope.issue = response.data.data; + + }, function errorCallback(response) { + }); + } + + loadData($routeParams.id); + + + $scope.addIssueReply = function(data){ + console.log(data.comment); + + if(!data.comment || data.comment.length<=0){ + return; + } + + var userInfo = { + type: "Issue", + content: data.comment, + openid: openid, + }; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+$routeParams.id, + data: userInfo, + }).then(function successCallback(response) { + alert("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } + + console.log(auth.getOpenId()); + +}); + +app.filter('safeHtml', function ($sce) { + return function (input) { + return $sce.trustAsHtml(input); + } +}); + +app.config(['$routeProvider',function ($routeProvider) { + $routeProvider + .when('/activities', { + templateUrl: 'activities.html', + controller: 'ActivityController' + }) + .when('/issues/:id', { + templateUrl: 'issue_detail.html', + controller: 'IssueController' + }) + .otherwise({ + redirectTo: '/activities' + }); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/browser.min.js b/public/javascripts/wechat/browser.min.js deleted file mode 100644 index 7566e1a59..000000000 --- a/public/javascripts/wechat/browser.min.js +++ /dev/null @@ -1,44 +0,0 @@ - -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.babel=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=0){var next_line=out.indexOf("\n",idx+1);out=out.substring(next_line+1)}this.stack=out}}};util.inherits(assert.AssertionError,Error);function replacer(key,value){if(util.isUndefined(value)){return""+value}if(util.isNumber(value)&&!isFinite(value)){return value.toString()}if(util.isFunction(value)||util.isRegExp(value)){return value.toString()}return value}function truncate(s,n){if(util.isString(s)){return s.length=0;i--){if(ka[i]!=kb[i])return false}for(i=ka.length-1;i>=0;i--){key=ka[i];if(!_deepEqual(a[key],b[key]))return false}return true}assert.notDeepEqual=function notDeepEqual(actual,expected,message){if(_deepEqual(actual,expected)){fail(actual,expected,message,"notDeepEqual",assert.notDeepEqual)}};assert.strictEqual=function strictEqual(actual,expected,message){if(actual!==expected){fail(actual,expected,message,"===",assert.strictEqual)}};assert.notStrictEqual=function notStrictEqual(actual,expected,message){if(actual===expected){fail(actual,expected,message,"!==",assert.notStrictEqual)}};function expectedException(actual,expected){if(!actual||!expected){return false}if(Object.prototype.toString.call(expected)=="[object RegExp]"){return expected.test(actual)}else if(actual instanceof expected){return true}else if(expected.call({},actual)===true){return true}return false}function _throws(shouldThrow,block,expected,message){var actual;if(util.isString(expected)){message=expected;expected=null}try{block()}catch(e){actual=e}message=(expected&&expected.name?" ("+expected.name+").":".")+(message?" "+message:".");if(shouldThrow&&!actual){fail(actual,expected,"Missing expected exception"+message)}if(!shouldThrow&&expectedException(actual,expected)){fail(actual,expected,"Got unwanted exception"+message)}if(shouldThrow&&actual&&expected&&!expectedException(actual,expected)||!shouldThrow&&actual){throw actual}}assert.throws=function(block,error,message){_throws.apply(this,[true].concat(pSlice.call(arguments)))};assert.doesNotThrow=function(block,message){_throws.apply(this,[false].concat(pSlice.call(arguments)))};assert.ifError=function(err){if(err){throw err}};var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj){if(hasOwn.call(obj,key))keys.push(key)}return keys}},{"util/":30}],3:[function(require,module,exports){arguments[4][1][0].apply(exports,arguments)},{dup:1}],4:[function(require,module,exports){var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("is-array");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=function(){function Bar(){}try{var arr=new Uint8Array(1);arr.foo=function(){return 42};arr.constructor=Bar;return arr.foo()===42&&arr.constructor===Bar&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}();function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Buffer(arg){if(!(this instanceof Buffer)){if(arguments.length>1)return new Buffer(arg,arguments[1]);return new Buffer(arg)}this.length=0;this.parent=undefined;if(typeof arg==="number"){return fromNumber(this,arg)}if(typeof arg==="string"){return fromString(this,arg,arguments.length>1?arguments[1]:"utf8")}return fromObject(this,arg)}function fromNumber(that,length){that=allocate(that,length<0?0:checked(length)|0);if(!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i>>1;if(fromPool)that.parent=rootParent;return that}function checked(length){if(length>=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(subject,encoding){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding);var buf=new Buffer(subject,encoding);delete buf.parent;return buf}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;var i=0;var len=Math.min(x,y);while(i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;function slowToString(encoding,start,end){var loweredCase=false;start=start|0;end=end===undefined||end===Infinity?this.length:end|0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype.toString=function toString(){var length=this.length|0;if(length===0)return"";if(arguments.length===0)return utf8Slice(this,0,length);return slowToString.apply(this,arguments)};Buffer.prototype.equals=function equals(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(this===b)return true;return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function inspect(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return""};Buffer.prototype.compare=function compare(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(this===b)return 0;return Buffer.compare(this,b)};Buffer.prototype.indexOf=function indexOf(val,byteOffset){if(byteOffset>2147483647)byteOffset=2147483647;else if(byteOffset<-2147483648)byteOffset=-2147483648;byteOffset>>=0;if(this.length===0)return-1;if(byteOffset>=this.length)return-1;if(byteOffset<0)byteOffset=Math.max(this.length+byteOffset,0);if(typeof val==="string"){if(val.length===0)return-1;return String.prototype.indexOf.call(this,val,byteOffset)}if(Buffer.isBuffer(val)){return arrayIndexOf(this,val,byteOffset)}if(typeof val==="number"){if(Buffer.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,val,byteOffset)}return arrayIndexOf(this,[val],byteOffset)}function arrayIndexOf(arr,val,byteOffset){var foundIndex=-1;for(var i=0;byteOffset+iremaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;iremaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"binary":return binaryWrite(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||valuebuf.length)throw new RangeError("index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1;var i=0;this[offset]=value&255;while(++i=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=value<0?1:0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=value<0?1:0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||valuebuf.length)throw new RangeError("index out of range");if(offset<0)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;i--){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("end out of bounds");var i;if(typeof value==="number"){for(i=start;i55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}},{"base64-js":5,ieee754:6,"is-array":7}],5:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);var PLUS_URL_SAFE="-".charCodeAt(0);var SLASH_URL_SAFE="_".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS||code===PLUS_URL_SAFE)return 62;if(code===SLASH||code===SLASH_URL_SAFE)return 63;if(code0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(typeof exports==="undefined"?this.base64js={}:exports)},{}],6:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],7:[function(require,module,exports){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},{}],8:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}throw TypeError('Uncaught, unspecified "error" event.')}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:len=arguments.length;args=new Array(len-1);for(i=1;i0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-->0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1)}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else{while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.listenerCount=function(emitter,type){var ret;if(!emitter._events||!emitter._events[type])ret=0;else if(isFunction(emitter._events[type]))ret=1;else ret=emitter._events[type].length;return ret};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],9:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],10:[function(require,module,exports){module.exports=Array.isArray||function(arr){return Object.prototype.toString.call(arr)=="[object Array]"}},{}],11:[function(require,module,exports){(function(process){function normalizeArray(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(filename){return splitPathRe.exec(filename).slice(1)};exports.resolve=function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:process.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){continue}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=normalizeArray(filter(resolvedPath.split("/"),function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."};exports.normalize=function(path){var isAbsolute=exports.isAbsolute(path),trailingSlash=substr(path,-1)==="/";path=normalizeArray(filter(path.split("/"),function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path};exports.isAbsolute=function(path){return path.charAt(0)==="/"};exports.join=function(){var paths=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(paths,function(p,index){if(typeof p!=="string"){throw new TypeError("Arguments to path.join must be strings")}return p}).join("/"))};exports.relative=function(from,to){from=exports.resolve(from).substr(1);to=exports.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i1){for(var i=1;i0){if(state.ended&&!addToFront){var e=new Error("stream.push() after EOF");stream.emit("error",e)}else if(state.endEmitted&&addToFront){var e=new Error("stream.unshift() after end event");stream.emit("error",e)}else{if(state.decoder&&!addToFront&&!encoding)chunk=state.decoder.write(chunk);if(!addToFront)state.reading=false;if(state.flowing&&state.length===0&&!state.sync){stream.emit("data",chunk);stream.read(0)}else{state.length+=state.objectMode?1:chunk.length;if(addToFront)state.buffer.unshift(chunk);else state.buffer.push(chunk);if(state.needReadable)emitReadable(stream)}maybeReadMore(stream,state)}}else if(!addToFront){state.reading=false}return needMoreData(state)}function needMoreData(state){return!state.ended&&(state.needReadable||state.length=MAX_HWM){n=MAX_HWM}else{n--;for(var p=1;p<32;p<<=1)n|=n>>p;n++}return n}function howMuchToRead(n,state){if(state.length===0&&state.ended)return 0;if(state.objectMode)return n===0?0:1;if(n===null||isNaN(n)){if(state.flowing&&state.buffer.length)return state.buffer[0].length;else return state.length}if(n<=0)return 0;if(n>state.highWaterMark)state.highWaterMark=roundUpToNextPowerOf2(n);if(n>state.length){if(!state.ended){state.needReadable=true;return 0}else{return state.length}}return n}Readable.prototype.read=function(n){debug("read",n);var state=this._readableState;var nOrig=n;if(typeof n!=="number"||n>0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){debug("read: emitReadable",state.length,state.ended);if(state.length===0&&state.ended)endReadable(this);else emitReadable(this);return null}n=howMuchToRead(n,state);if(n===0&&state.ended){if(state.length===0)endReadable(this);return null}var doRead=state.needReadable;debug("need readable",doRead);if(state.length===0||state.length-n0)ret=fromList(n,state);else ret=null;if(ret===null){state.needReadable=true;n=0}state.length-=n;if(state.length===0&&!state.ended)state.needReadable=true;if(nOrig!==n&&state.ended&&state.length===0)endReadable(this);if(ret!==null)this.emit("data",ret);return ret};function chunkInvalid(state,chunk){var er=null;if(!Buffer.isBuffer(chunk)&&typeof chunk!=="string"&&chunk!==null&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}return er}function onEofChunk(stream,state){if(state.ended)return;if(state.decoder){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;emitReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(!state.emittedReadable){debug("emitReadable",state.flowing);state.emittedReadable=true;if(state.sync)processNextTick(emitReadable_,stream);else emitReadable_(stream)}}function emitReadable_(stream){debug("emit readable");stream.emit("readable");flow(stream)}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state)}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length=length){if(stringMode)ret=list.join("");else ret=Buffer.concat(list,length);list.length=0}else{if(n0)throw new Error("endReadable called on non-empty stream");if(!state.endEmitted){state.ended=true;processNextTick(endReadableNT,state,stream)}}function endReadableNT(state,stream){if(!state.endEmitted&&state.length===0){state.endEmitted=true;stream.readable=false;stream.emit("end")}}function forEach(xs,f){for(var i=0,l=xs.length;i-1))throw new TypeError("Unknown encoding: "+encoding);this._writableState.defaultEncoding=encoding};function decodeChunk(state,chunk,encoding){if(!state.objectMode&&state.decodeStrings!==false&&typeof chunk==="string"){chunk=new Buffer(chunk,encoding)}return chunk}function writeOrBuffer(stream,state,chunk,encoding,cb){chunk=decodeChunk(state,chunk,encoding);if(Buffer.isBuffer(chunk))encoding="buffer";var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length=this.charLength-this.charReceived?this.charLength-this.charReceived:buffer.length;buffer.copy(this.charBuffer,this.charReceived,0,available);this.charReceived+=available;if(this.charReceived=55296&&charCode<=56319){this.charLength+=this.surrogateSize;charStr="";continue}this.charReceived=this.charLength=0;if(buffer.length===0){return charStr}break}this.detectIncompleteChar(buffer);var end=buffer.length;if(this.charLength){buffer.copy(this.charBuffer,0,buffer.length-this.charReceived,end);end-=this.charReceived}charStr+=buffer.toString(this.encoding,0,end);var end=charStr.length-1;var charCode=charStr.charCodeAt(end);if(charCode>=55296&&charCode<=56319){var size=this.surrogateSize;this.charLength+=size;this.charReceived+=size;this.charBuffer.copy(this.charBuffer,size,0,size);buffer.copy(this.charBuffer,0,0,size);return charStr.substring(0,end)}return charStr};StringDecoder.prototype.detectIncompleteChar=function(buffer){var i=buffer.length>=3?3:buffer.length;for(;i>0;i--){var c=buffer[buffer.length-i];if(i==1&&c>>5==6){this.charLength=2;break}if(i<=2&&c>>4==14){this.charLength=3;break}if(i<=3&&c>>3==30){this.charLength=4;break}}this.charReceived=i};StringDecoder.prototype.end=function(buffer){var res="";if(buffer&&buffer.length)res=this.write(buffer);if(this.charReceived){var cr=this.charReceived;var buf=this.charBuffer;var enc=this.encoding;res+=buf.slice(0,cr).toString(enc)}return res};function passThroughWrite(buffer){return buffer.toString(this.encoding)}function utf16DetectIncompleteChar(buffer){this.charReceived=buffer.length%2;this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(buffer){this.charReceived=buffer.length%3;this.charLength=this.charReceived?3:0}},{buffer:4}],28:[function(require,module,exports){exports.isatty=function(){return false};function ReadStream(){throw new Error("tty.ReadStream is not implemented")}exports.ReadStream=ReadStream;function WriteStream(){throw new Error("tty.ReadStream is not implemented")}exports.WriteStream=WriteStream},{}],29:[function(require,module,exports){module.exports=function isBuffer(arg){return arg&&typeof arg==="object"&&typeof arg.copy==="function"&&typeof arg.fill==="function"&&typeof arg.readUInt8==="function"}},{}],30:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){var objects=[];for(var i=0;i=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}});for(var x=args[i];i=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts)){ctx.showHidden=opts}else if(opts){exports._extend(ctx,opts)}if(isUndefined(ctx.showHidden))ctx.showHidden=false;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=false;if(isUndefined(ctx.customInspect))ctx.customInspect=true;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style){return"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m"}else{return str}}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};array.forEach(function(val,idx){hash[val]=true});return hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret)){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}var keys=Object.keys(value);var visibleKeys=arrayToHash(keys);if(ctx.showHidden){keys=Object.getOwnPropertyNames(value)}if(isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0)){return formatError(value)}if(keys.length===0){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){base=" "+formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i-1){if(array){str=str.split("\n").map(function(line){return" "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return" "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(isUndefined(name)){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date;var time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))};exports.inherits=require("inherits");exports._extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":29,_process:12,inherits:9}],31:[function(require,module,exports){(function(global){"use strict";require("./node");var transform=module.exports=require("../transformation");transform.options=require("../transformation/file/options");transform.version=require("../../package").version;transform.transform=transform;transform.run=function(code){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];opts.sourceMaps="inline";return new Function(transform(code,opts).code)()};transform.load=function(url,callback,opts,hold){if(opts===undefined)opts={};opts.filename=opts.filename||url;var xhr=global.ActiveXObject?new global.ActiveXObject("Microsoft.XMLHTTP"):new global.XMLHttpRequest;xhr.open("GET",url,true);if("overrideMimeType"in xhr)xhr.overrideMimeType("text/plain");xhr.onreadystatechange=function(){if(xhr.readyState!==4)return;var status=xhr.status;if(status===0||status===200){var param=[xhr.responseText,opts];if(!hold)transform.run.apply(transform,param);if(callback)callback(param)}else{throw new Error("Could not load "+url)}};xhr.send(null)};var runScripts=function runScripts(){var scripts=[];var types=["text/ecmascript-6","text/6to5","text/babel","module"];var index=0;var exec=function exec(){var param=scripts[index];if(param instanceof Array){transform.run.apply(transform,param);index++;exec()}};var run=function run(script,i){var opts={};if(script.src){transform.load(script.src,function(param){scripts[i]=param;exec()},opts,true)}else{opts.filename="embedded";scripts[i]=[script.innerHTML,opts]}};var _scripts=global.document.getElementsByTagName("script");for(var i=0;i<_scripts.length;++i){var _script=_scripts[i];if(types.indexOf(_script.type)>=0)scripts.push(_script)}for(i in scripts){run(scripts[i],i)}exec()};if(global.addEventListener){global.addEventListener("DOMContentLoaded",runScripts,false)}else if(global.attachEvent){global.attachEvent("onload",runScripts)}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"../../package":631,"../transformation":83,"../transformation/file/options":66,"./node":32}],32:[function(require,module,exports){"use strict";exports.__esModule=true;exports.register=register;exports.polyfill=polyfill;exports.transformFile=transformFile;exports.transformFileSync=transformFileSync;exports.parse=parse;function _interopRequire(obj){return obj&&obj.__esModule?obj["default"]:obj}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashLangIsFunction=require("lodash/lang/isFunction");var _lodashLangIsFunction2=_interopRequireDefault(_lodashLangIsFunction);var _transformation=require("../transformation");var _transformation2=_interopRequireDefault(_transformation);var _babylon=require("babylon");var babylon=_interopRequireWildcard(_babylon);var _util=require("../util");var util=_interopRequireWildcard(_util);var _fs=require("fs");var _fs2=_interopRequireDefault(_fs);var _types=require("../types");var t=_interopRequireWildcard(_types);exports.util=util;exports.acorn=babylon;exports.transform=_transformation2["default"];exports.pipeline=_transformation.pipeline;exports.canCompile=_util.canCompile;var _transformationFile=require("../transformation/file");exports.File=_interopRequire(_transformationFile);var _transformationFileOptionsConfig=require("../transformation/file/options/config");exports.options=_interopRequire(_transformationFileOptionsConfig);var _transformationPlugin=require("../transformation/plugin");exports.Plugin=_interopRequire(_transformationPlugin);var _transformationTransformer=require("../transformation/transformer");exports.Transformer=_interopRequire(_transformationTransformer);var _transformationPipeline=require("../transformation/pipeline");exports.Pipeline=_interopRequire(_transformationPipeline);var _traversal=require("../traversal");exports.traverse=_interopRequire(_traversal);var _toolsBuildExternalHelpers=require("../tools/build-external-helpers");exports.buildExternalHelpers=_interopRequire(_toolsBuildExternalHelpers);var _package=require("../../package");exports.version=_package.version; -exports.types=t;function register(opts){var callback=require("./register/node-polyfill");if(opts!=null)callback(opts);return callback}function polyfill(){require("../polyfill")}function transformFile(filename,opts,callback){if(_lodashLangIsFunction2["default"](opts)){callback=opts;opts={}}opts.filename=filename;_fs2["default"].readFile(filename,function(err,code){if(err)return callback(err);var result;try{result=_transformation2["default"](code,opts)}catch(err){return callback(err)}callback(null,result)})}function transformFileSync(filename){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];opts.filename=filename;return _transformation2["default"](_fs2["default"].readFileSync(filename,"utf8"),opts)}function parse(code){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];opts.allowHashBang=true;opts.sourceType="module";opts.ecmaVersion=Infinity;opts.plugins={jsx:true,flow:true};opts.features={};for(var key in _transformation2["default"].pipeline.transformers){opts.features[key]=true}var ast=babylon.parse(code,opts);if(opts.onToken){var _opts$onToken;(_opts$onToken=opts.onToken).push.apply(_opts$onToken,ast.tokens)}if(opts.onComment){var _opts$onComment;(_opts$onComment=opts.onComment).push.apply(_opts$onComment,ast.comments)}return ast.program}},{"../../package":631,"../polyfill":61,"../tools/build-external-helpers":62,"../transformation":83,"../transformation/file":63,"../transformation/file/options/config":65,"../transformation/pipeline":97,"../transformation/plugin":99,"../transformation/transformer":100,"../traversal":165,"../types":196,"../util":199,"./register/node-polyfill":34,babylon:633,fs:1,"lodash/lang/isFunction":526}],33:[function(require,module,exports){"use strict";exports.__esModule=true;require("../../polyfill");exports["default"]=function(){};module.exports=exports["default"]},{"../../polyfill":61}],34:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequire(obj){return obj&&obj.__esModule?obj["default"]:obj}require("../../polyfill");var _node=require("./node");exports["default"]=_interopRequire(_node);module.exports=exports["default"]},{"../../polyfill":61,"./node":33}],35:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _repeating=require("repeating");var _repeating2=_interopRequireDefault(_repeating);var _trimRight=require("trim-right");var _trimRight2=_interopRequireDefault(_trimRight);var _lodashLangIsBoolean=require("lodash/lang/isBoolean");var _lodashLangIsBoolean2=_interopRequireDefault(_lodashLangIsBoolean);var _lodashCollectionIncludes=require("lodash/collection/includes");var _lodashCollectionIncludes2=_interopRequireDefault(_lodashCollectionIncludes);var _lodashLangIsNumber=require("lodash/lang/isNumber");var _lodashLangIsNumber2=_interopRequireDefault(_lodashLangIsNumber);var Buffer=function(){function Buffer(position,format){_classCallCheck(this,Buffer);this.parenPushNewlineState=null;this.position=position;this._indent=format.indent.base;this.format=format;this.buf=""}Buffer.prototype.get=function get(){return _trimRight2["default"](this.buf)};Buffer.prototype.getIndent=function getIndent(){if(this.format.compact||this.format.concise){return""}else{return _repeating2["default"](this.format.indent.style,this._indent)}};Buffer.prototype.indentSize=function indentSize(){return this.getIndent().length};Buffer.prototype.indent=function indent(){this._indent++};Buffer.prototype.dedent=function dedent(){this._indent--};Buffer.prototype.semicolon=function semicolon(){this.push(";")};Buffer.prototype.ensureSemicolon=function ensureSemicolon(){if(!this.isLast(";"))this.semicolon()};Buffer.prototype.rightBrace=function rightBrace(){this.newline(true);this.push("}")};Buffer.prototype.keyword=function keyword(name){this.push(name);this.space()};Buffer.prototype.space=function space(force){if(!force&&this.format.compact)return;if(force||this.buf&&!this.isLast(" ")&&!this.isLast("\n")){this.push(" ")}};Buffer.prototype.removeLast=function removeLast(cha){if(this.format.compact)return;if(!this.isLast(cha))return;this.buf=this.buf.substr(0,this.buf.length-1);this.position.unshift(cha)};Buffer.prototype.startTerminatorless=function startTerminatorless(){return this.parenPushNewlineState={printed:false}};Buffer.prototype.endTerminatorless=function endTerminatorless(state){if(state.printed){this.dedent();this.newline();this.push(")")}};Buffer.prototype.newline=function newline(i,removeLast){if(this.format.compact||this.format.retainLines)return;if(this.format.concise){this.space();return}removeLast=removeLast||false;if(_lodashLangIsNumber2["default"](i)){i=Math.min(2,i);if(this.endsWith("{\n")||this.endsWith(":\n"))i--;if(i<=0)return;while(i>0){this._newline(removeLast);i--}return}if(_lodashLangIsBoolean2["default"](i)){removeLast=i}this._newline(removeLast)};Buffer.prototype._newline=function _newline(removeLast){if(this.endsWith("\n\n"))return;if(removeLast&&this.isLast("\n"))this.removeLast("\n");this.removeLast(" ");this._removeSpacesAfterLastNewline();this._push("\n")};Buffer.prototype._removeSpacesAfterLastNewline=function _removeSpacesAfterLastNewline(){var lastNewlineIndex=this.buf.lastIndexOf("\n");if(lastNewlineIndex===-1){return}var index=this.buf.length-1;while(index>lastNewlineIndex){if(this.buf[index]!==" "){break}index--}if(index===lastNewlineIndex){this.buf=this.buf.substring(0,index+1)}};Buffer.prototype.push=function push(str,noIndent){if(!this.format.compact&&this._indent&&!noIndent&&str!=="\n"){var indent=this.getIndent();str=str.replace(/\n/g,"\n"+indent);if(this.isLast("\n"))this._push(indent)}this._push(str)};Buffer.prototype._push=function _push(str){var parenPushNewlineState=this.parenPushNewlineState;if(parenPushNewlineState){for(var i=0;i")}this.space();print.plain(node.returnType)}function FunctionTypeParam(node,print){print.plain(node.name);if(node.optional)this.push("?");this.push(":");this.space();print.plain(node.typeAnnotation)}function InterfaceExtends(node,print){print.plain(node.id);print.plain(node.typeParameters)}exports.ClassImplements=InterfaceExtends;exports.GenericTypeAnnotation=InterfaceExtends;function _interfaceish(node,print){print.plain(node.id);print.plain(node.typeParameters);if(node["extends"].length){this.push(" extends ");print.join(node["extends"],{separator:", "})}this.space();print.plain(node.body)}function InterfaceDeclaration(node,print){this.push("interface ");this._interfaceish(node,print)}function IntersectionTypeAnnotation(node,print){print.join(node.types,{separator:" & "})}function MixedTypeAnnotation(){this.push("mixed")}function NullableTypeAnnotation(node,print){this.push("?");print.plain(node.typeAnnotation)}var _types2=require("./types");exports.NumberLiteralTypeAnnotation=_types2.Literal;function NumberTypeAnnotation(){this.push("number")}function StringLiteralTypeAnnotation(node){this.push(this._stringLiteral(node.value))}function StringTypeAnnotation(){this.push("string")}function TupleTypeAnnotation(node,print){this.push("[");print.join(node.types,{separator:", "});this.push("]")}function TypeofTypeAnnotation(node,print){this.push("typeof ");print.plain(node.argument)}function TypeAlias(node,print){this.push("type ");print.plain(node.id);print.plain(node.typeParameters);this.space();this.push("=");this.space();print.plain(node.right);this.semicolon()}function TypeAnnotation(node,print){this.push(":");this.space();if(node.optional)this.push("?");print.plain(node.typeAnnotation)}function TypeParameterInstantiation(node,print){this.push("<");print.join(node.params,{separator:", ",iterator:function iterator(node){print.plain(node.typeAnnotation)}});this.push(">")}exports.TypeParameterDeclaration=TypeParameterInstantiation;function ObjectTypeAnnotation(node,print){var _this=this;this.push("{");var props=node.properties.concat(node.callProperties,node.indexers);if(props.length){this.space();print.list(props,{separator:false,indent:true,iterator:function iterator(){if(props.length!==1){_this.semicolon();_this.space()}}});this.space()}this.push("}")}function ObjectTypeCallProperty(node,print){if(node["static"])this.push("static ");print.plain(node.value)}function ObjectTypeIndexer(node,print){if(node["static"])this.push("static ");this.push("[");print.plain(node.id);this.push(":");this.space();print.plain(node.key);this.push("]");this.push(":");this.space();print.plain(node.value)}function ObjectTypeProperty(node,print){if(node["static"])this.push("static ");print.plain(node.key);if(node.optional)this.push("?");if(!t.isFunctionTypeAnnotation(node.value)){this.push(":");this.space()}print.plain(node.value)}function QualifiedTypeIdentifier(node,print){print.plain(node.qualification);this.push(".");print.plain(node.id)}function UnionTypeAnnotation(node,print){print.join(node.types,{separator:" | "})}function TypeCastExpression(node,print){this.push("(");print.plain(node.expression);print.plain(node.typeAnnotation);this.push(")")}function VoidTypeAnnotation(){this.push("void")}},{"../../types":196,"./types":46}],41:[function(require,module,exports){"use strict";exports.__esModule=true;exports.JSXAttribute=JSXAttribute;exports.JSXIdentifier=JSXIdentifier;exports.JSXNamespacedName=JSXNamespacedName;exports.JSXMemberExpression=JSXMemberExpression;exports.JSXSpreadAttribute=JSXSpreadAttribute;exports.JSXExpressionContainer=JSXExpressionContainer;exports.JSXElement=JSXElement;exports.JSXOpeningElement=JSXOpeningElement;exports.JSXClosingElement=JSXClosingElement;exports.JSXEmptyExpression=JSXEmptyExpression;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);function JSXAttribute(node,print){print.plain(node.name);if(node.value){this.push("=");print.plain(node.value)}}function JSXIdentifier(node){this.push(node.name)}function JSXNamespacedName(node,print){print.plain(node.namespace);this.push(":");print.plain(node.name)}function JSXMemberExpression(node,print){print.plain(node.object);this.push(".");print.plain(node.property)}function JSXSpreadAttribute(node,print){this.push("{...");print.plain(node.argument);this.push("}")}function JSXExpressionContainer(node,print){this.push("{");print.plain(node.expression);this.push("}")}function JSXElement(node,print){var open=node.openingElement;print.plain(open);if(open.selfClosing)return;this.indent();var _arr=node.children;for(var _i=0;_i<_arr.length;_i++){var child=_arr[_i];if(t.isLiteral(child)){this.push(child.value,true)}else{print.plain(child)}}this.dedent();print.plain(node.closingElement)}function JSXOpeningElement(node,print){this.push("<");print.plain(node.name);if(node.attributes.length>0){this.push(" ");print.join(node.attributes,{separator:" "})}this.push(node.selfClosing?" />":">")}function JSXClosingElement(node,print){this.push("")}function JSXEmptyExpression(){}},{"../../types":196}],42:[function(require,module,exports){"use strict";exports.__esModule=true;exports._params=_params;exports._method=_method;exports.FunctionExpression=FunctionExpression;exports.ArrowFunctionExpression=ArrowFunctionExpression;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);function _params(node,print){var _this=this;print.plain(node.typeParameters);this.push("(");print.list(node.params,{iterator:function iterator(node){if(node.optional)_this.push("?");print.plain(node.typeAnnotation)}});this.push(")");if(node.returnType){print.plain(node.returnType)}}function _method(node,print){var value=node.value;var kind=node.kind;var key=node.key;if(kind==="method"||kind==="init"){if(value.generator){this.push("*")}}if(kind==="get"||kind==="set"){this.push(kind+" ")}if(value.async)this.push("async ");if(node.computed){this.push("[");print.plain(key);this.push("]")}else{print.plain(key)}this._params(value,print);this.space();print.plain(value.body)}function FunctionExpression(node,print){if(node.async)this.push("async ");this.push("function");if(node.generator)this.push("*");if(node.id){this.push(" ");print.plain(node.id)}else{this.space()}this._params(node,print);this.space();print.plain(node.body)}exports.FunctionDeclaration=FunctionExpression;function ArrowFunctionExpression(node,print){if(node.async)this.push("async ");if(node.params.length===1&&t.isIdentifier(node.params[0])){print.plain(node.params[0])}else{this._params(node,print)}this.push(" => ");var bodyNeedsParens=t.isObjectExpression(node.body);if(bodyNeedsParens){this.push("(")}print.plain(node.body);if(bodyNeedsParens){this.push(")")}}},{"../../types":196}],43:[function(require,module,exports){"use strict";exports.__esModule=true;exports.ImportSpecifier=ImportSpecifier;exports.ImportDefaultSpecifier=ImportDefaultSpecifier;exports.ExportDefaultSpecifier=ExportDefaultSpecifier;exports.ExportSpecifier=ExportSpecifier;exports.ExportNamespaceSpecifier=ExportNamespaceSpecifier;exports.ExportAllDeclaration=ExportAllDeclaration;exports.ExportNamedDeclaration=ExportNamedDeclaration;exports.ExportDefaultDeclaration=ExportDefaultDeclaration;exports.ImportDeclaration=ImportDeclaration;exports.ImportNamespaceSpecifier=ImportNamespaceSpecifier;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);function ImportSpecifier(node,print){print.plain(node.imported);if(node.local&&node.local.name!==node.imported.name){this.push(" as ");print.plain(node.local)}}function ImportDefaultSpecifier(node,print){print.plain(node.local)}function ExportDefaultSpecifier(node,print){print.plain(node.exported)}function ExportSpecifier(node,print){print.plain(node.local);if(node.exported&&node.local.name!==node.exported.name){this.push(" as ");print.plain(node.exported)}}function ExportNamespaceSpecifier(node,print){this.push("* as ");print.plain(node.exported)}function ExportAllDeclaration(node,print){this.push("export *");if(node.exported){this.push(" as ");print.plain(node.exported)}this.push(" from ");print.plain(node.source);this.semicolon()}function ExportNamedDeclaration(node,print){this.push("export ");ExportDeclaration.call(this,node,print)}function ExportDefaultDeclaration(node,print){this.push("export default ");ExportDeclaration.call(this,node,print)}function ExportDeclaration(node,print){var specifiers=node.specifiers;if(node.declaration){var declar=node.declaration;print.plain(declar);if(t.isStatement(declar)||t.isFunction(declar)||t.isClass(declar))return}else{if(node.exportKind==="type"){this.push("type ")}var first=specifiers[0];var hasSpecial=false;if(t.isExportDefaultSpecifier(first)||t.isExportNamespaceSpecifier(first)){hasSpecial=true;print.plain(specifiers.shift());if(specifiers.length){this.push(", ")}}if(specifiers.length||!specifiers.length&&!hasSpecial){this.push("{");if(specifiers.length){this.space();print.join(specifiers,{separator:", "});this.space()}this.push("}")}if(node.source){this.push(" from ");print.plain(node.source)}}this.ensureSemicolon()}function ImportDeclaration(node,print){this.push("import ");if(node.importKind==="type"||node.importKind==="typeof"){this.push(node.importKind+" ")}var specfiers=node.specifiers;if(specfiers&&specfiers.length){var first=node.specifiers[0];if(t.isImportDefaultSpecifier(first)||t.isImportNamespaceSpecifier(first)){print.plain(node.specifiers.shift());if(node.specifiers.length){this.push(", ")}}if(node.specifiers.length){this.push("{");this.space();print.join(node.specifiers,{separator:", "});this.space();this.push("}")}this.push(" from ")}print.plain(node.source);this.semicolon()}function ImportNamespaceSpecifier(node,print){this.push("* as ");print.plain(node.local)}},{"../../types":196}],44:[function(require,module,exports){"use strict";exports.__esModule=true;exports.WithStatement=WithStatement;exports.IfStatement=IfStatement;exports.ForStatement=ForStatement;exports.WhileStatement=WhileStatement;exports.DoWhileStatement=DoWhileStatement;exports.LabeledStatement=LabeledStatement;exports.TryStatement=TryStatement;exports.CatchClause=CatchClause;exports.SwitchStatement=SwitchStatement;exports.SwitchCase=SwitchCase;exports.DebuggerStatement=DebuggerStatement;exports.VariableDeclaration=VariableDeclaration;exports.VariableDeclarator=VariableDeclarator;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _repeating=require("repeating");var _repeating2=_interopRequireDefault(_repeating);var _types=require("../../types");var t=_interopRequireWildcard(_types);function WithStatement(node,print){this.keyword("with");this.push("(");print.plain(node.object);this.push(")");print.block(node.body)}function IfStatement(node,print){this.keyword("if");this.push("(");print.plain(node.test);this.push(")");this.space();print.indentOnComments(node.consequent);if(node.alternate){if(this.isLast("}"))this.space();this.push("else ");print.indentOnComments(node.alternate)}}function ForStatement(node,print){this.keyword("for");this.push("(");print.plain(node.init);this.push(";");if(node.test){this.space();print.plain(node.test)}this.push(";");if(node.update){this.space();print.plain(node.update)}this.push(")");print.block(node.body)}function WhileStatement(node,print){this.keyword("while");this.push("(");print.plain(node.test);this.push(")");print.block(node.body)}var buildForXStatement=function buildForXStatement(op){return function(node,print){this.keyword("for");this.push("(");print.plain(node.left);this.push(" "+op+" ");print.plain(node.right);this.push(")");print.block(node.body)}};var ForInStatement=buildForXStatement("in");exports.ForInStatement=ForInStatement;var ForOfStatement=buildForXStatement("of");exports.ForOfStatement=ForOfStatement;function DoWhileStatement(node,print){this.push("do ");print.plain(node.body);this.space();this.keyword("while");this.push("(");print.plain(node.test);this.push(");")}var buildLabelStatement=function buildLabelStatement(prefix){var key=arguments.length<=1||arguments[1]===undefined?"label":arguments[1];return function(node,print){this.push(prefix);var label=node[key];if(label){this.push(" ");var terminatorState=this.startTerminatorless();print.plain(label);this.endTerminatorless(terminatorState)}this.semicolon()}};var ContinueStatement=buildLabelStatement("continue");exports.ContinueStatement=ContinueStatement;var ReturnStatement=buildLabelStatement("return","argument");exports.ReturnStatement=ReturnStatement;var BreakStatement=buildLabelStatement("break");exports.BreakStatement=BreakStatement;var ThrowStatement=buildLabelStatement("throw","argument");exports.ThrowStatement=ThrowStatement;function LabeledStatement(node,print){print.plain(node.label);this.push(": ");print.plain(node.body)}function TryStatement(node,print){this.keyword("try");print.plain(node.block);this.space();if(node.handlers){print.plain(node.handlers[0])}else{print.plain(node.handler)}if(node.finalizer){this.space();this.push("finally ");print.plain(node.finalizer)}}function CatchClause(node,print){this.keyword("catch");this.push("(");print.plain(node.param);this.push(") ");print.plain(node.body)}function SwitchStatement(node,print){this.keyword("switch");this.push("(");print.plain(node.discriminant);this.push(")");this.space();this.push("{");print.sequence(node.cases,{indent:true,addNewlines:function addNewlines(leading,cas){if(!leading&&node.cases[node.cases.length-1]===cas)return-1}});this.push("}"); -}function SwitchCase(node,print){if(node.test){this.push("case ");print.plain(node.test);this.push(":")}else{this.push("default:")}if(node.consequent.length){this.newline();print.sequence(node.consequent,{indent:true})}}function DebuggerStatement(){this.push("debugger;")}function VariableDeclaration(node,print,parent){this.push(node.kind+" ");var hasInits=false;if(!t.isFor(parent)){var _arr=node.declarations;for(var _i=0;_i<_arr.length;_i++){var declar=_arr[_i];if(declar.init){hasInits=true}}}var sep;if(!this.format.compact&&!this.format.concise&&hasInits&&!this.format.retainLines){sep=",\n"+_repeating2["default"](" ",node.kind.length+1)}print.list(node.declarations,{separator:sep});if(t.isFor(parent)){if(parent.left===node||parent.init===node)return}this.semicolon()}function VariableDeclarator(node,print){print.plain(node.id);print.plain(node.id.typeAnnotation);if(node.init){this.space();this.push("=");this.space();print.plain(node.init)}}},{"../../types":196,repeating:611}],45:[function(require,module,exports){"use strict";exports.__esModule=true;exports.TaggedTemplateExpression=TaggedTemplateExpression;exports.TemplateElement=TemplateElement;exports.TemplateLiteral=TemplateLiteral;function TaggedTemplateExpression(node,print){print.plain(node.tag);print.plain(node.quasi)}function TemplateElement(node){this._push(node.value.raw)}function TemplateLiteral(node,print){this.push("`");var quasis=node.quasis;var len=quasis.length;for(var i=0;i0)this.space();print.plain(elem);if(i1e5;if(format.compact){console.error("[BABEL] "+messages.get("codeGeneratorDeopt",opts.filename,"100KB"))}}if(format.compact){format.indent.adjustMultilineComment=false}return format};CodeGenerator.findCommonStringDelimiter=function findCommonStringDelimiter(code,tokens){var occurences={single:0,"double":0};var checked=0;for(var i=0;i=3)break}if(occurences.single>occurences.double){return"single"}else{return"double"}};CodeGenerator.prototype.generate=function generate(){var ast=this.ast;this.print(ast);if(ast.comments){var comments=[];var _arr=ast.comments;for(var _i=0;_i<_arr.length;_i++){var comment=_arr[_i];if(!comment._displayed)comments.push(comment)}this._printComments(comments)}return{map:this.map.get(),code:this.buffer.get()}};CodeGenerator.prototype.buildPrint=function buildPrint(parent){return new _nodePrinter2["default"](this,parent)};CodeGenerator.prototype.catchUp=function catchUp(node){if(node.loc&&this.format.retainLines&&this.buffer.buf){while(this.position.line=0||comment.value.indexOf("@preserve")>=0){return true}else{return this.format.comments}}};CodeGenerator.prototype._printComments=function _printComments(comments){if(!comments||!comments.length)return;var _arr3=comments;for(var _i3=0;_i3<_arr3.length;_i3++){var comment=_arr3[_i3];if(!this.shouldPrintComment(comment))continue;if(comment._displayed)continue;comment._displayed=true;this.catchUp(comment);this.newline(this.whitespace.getNewlinesBefore(comment));var column=this.position.column;var val=this.generateComment(comment);if(column&&!this.isLast(["\n"," ","[","{"])){this._push(" ");column++}if(comment.type==="CommentBlock"&&this.format.indent.adjustMultilineComment){var offset=comment.loc&&comment.loc.start.column;if(offset){var newlineRegex=new RegExp("\\n\\s{1,"+offset+"}","g");val=val.replace(newlineRegex,"\n")}var indent=Math.max(this.indentSize(),column);val=val.replace(/\n/g,"\n"+_repeating2["default"](" ",indent))}if(column===0){val=this.getIndent()+val}if((this.format.compact||this.format.retainLines)&&comment.type==="CommentLine"){val+="\n"}this._push(val);this.newline(this.whitespace.getNewlinesAfter(comment))}};_createClass(CodeGenerator,null,[{key:"generators",value:{templateLiterals:require("./generators/template-literals"),comprehensions:require("./generators/comprehensions"),expressions:require("./generators/expressions"),statements:require("./generators/statements"),classes:require("./generators/classes"),methods:require("./generators/methods"),modules:require("./generators/modules"),types:require("./generators/types"),flow:require("./generators/flow"),base:require("./generators/base"),jsx:require("./generators/jsx")},enumerable:true}]);return CodeGenerator}();_lodashCollectionEach2["default"](_buffer2["default"].prototype,function(fn,key){CodeGenerator.prototype[key]=function(){return fn.apply(this.buffer,arguments)}});_lodashCollectionEach2["default"](CodeGenerator.generators,function(generator){_lodashObjectExtend2["default"](CodeGenerator.prototype,generator)});module.exports=function(ast,opts,code){var gen=new CodeGenerator(ast,opts,code);return gen.generate()};module.exports.CodeGenerator=CodeGenerator},{"../messages":60,"../types":196,"./buffer":35,"./generators/base":36,"./generators/classes":37,"./generators/comprehensions":38,"./generators/expressions":39,"./generators/flow":40,"./generators/jsx":41,"./generators/methods":42,"./generators/modules":43,"./generators/statements":44,"./generators/template-literals":45,"./generators/types":46,"./node":48,"./node/printer":50,"./position":52,"./source-map":53,"./whitespace":54,"detect-indent":409,"lodash/collection/each":437,"lodash/object/extend":537,repeating:611}],48:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _whitespace=require("./whitespace");var _whitespace2=_interopRequireDefault(_whitespace);var _parentheses=require("./parentheses");var parens=_interopRequireWildcard(_parentheses);var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _lodashCollectionSome=require("lodash/collection/some");var _lodashCollectionSome2=_interopRequireDefault(_lodashCollectionSome);var _types=require("../../types");var t=_interopRequireWildcard(_types);var find=function find(obj,node,parent){if(!obj)return;var result;var types=Object.keys(obj);for(var i=0;i","<=",">=","in","instanceof"],[">>","<<",">>>"],["+","-"],["*","/","%"],["**"]],function(tier,i){_lodashCollectionEach2["default"](tier,function(op){PRECEDENCE[op]=i})});function NullableTypeAnnotation(node,parent){return t.isArrayTypeAnnotation(parent)}exports.FunctionTypeAnnotation=NullableTypeAnnotation;function UpdateExpression(node,parent){if(t.isMemberExpression(parent)&&parent.object===node){return true}}function ObjectExpression(node,parent){if(t.isExpressionStatement(parent)){return true}if(t.isMemberExpression(parent)&&parent.object===node){return true}return false}function Binary(node,parent){if((t.isCallExpression(parent)||t.isNewExpression(parent))&&parent.callee===node){return true}if(t.isUnaryLike(parent)){return true}if(t.isMemberExpression(parent)&&parent.object===node){return true}if(t.isBinary(parent)){var parentOp=parent.operator;var parentPos=PRECEDENCE[parentOp];var nodeOp=node.operator;var nodePos=PRECEDENCE[nodeOp];if(parentPos>nodePos){return true}if(parentPos===nodePos&&parent.right===node){return true}}}function BinaryExpression(node,parent){if(node.operator==="in"){if(t.isVariableDeclarator(parent)){return true}if(t.isFor(parent)){return true}}}function SequenceExpression(node,parent){if(t.isForStatement(parent)){return false}if(t.isExpressionStatement(parent)&&parent.expression===node){return false}return true}function YieldExpression(node,parent){return t.isBinary(parent)||t.isUnaryLike(parent)||t.isCallExpression(parent)||t.isMemberExpression(parent)||t.isNewExpression(parent)||t.isConditionalExpression(parent)||t.isYieldExpression(parent)}function ClassExpression(node,parent){return t.isExpressionStatement(parent)}function UnaryLike(node,parent){return t.isMemberExpression(parent)&&parent.object===node}function FunctionExpression(node,parent){if(t.isExpressionStatement(parent)){return true}if(t.isMemberExpression(parent)&&parent.object===node){return true}if(t.isCallExpression(parent)&&parent.callee===node){return true}}function ConditionalExpression(node,parent){if(t.isUnaryLike(parent)){return true}if(t.isBinary(parent)){return true}if(t.isCallExpression(parent)||t.isNewExpression(parent)){if(parent.callee===node){return true}}if(t.isConditionalExpression(parent)&&parent.test===node){return true}if(t.isMemberExpression(parent)&&parent.object===node){return true}return false}function AssignmentExpression(node){if(t.isObjectPattern(node.left)){return true}else{return ConditionalExpression.apply(undefined,arguments)}}},{"../../types":196,"lodash/collection/each":437}],50:[function(require,module,exports){"use strict";exports.__esModule=true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var NodePrinter=function(){function NodePrinter(generator,parent){_classCallCheck(this,NodePrinter);this.generator=generator;this.parent=parent}NodePrinter.prototype.printInnerComments=function printInnerComments(){if(!this.parent.innerComments)return;var gen=this.generator;gen.indent();gen._printComments(this.parent.innerComments);gen.dedent()};NodePrinter.prototype.plain=function plain(node,opts){return this.generator.print(node,this.parent,opts)};NodePrinter.prototype.sequence=function sequence(nodes){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];opts.statement=true;return this.generator.printJoin(this,nodes,opts)};NodePrinter.prototype.join=function join(nodes,opts){return this.generator.printJoin(this,nodes,opts)};NodePrinter.prototype.list=function list(items){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];if(opts.separator==null){opts.separator=",";if(!this.generator.format.compact)opts.separator+=" "}return this.join(items,opts)};NodePrinter.prototype.block=function block(node){return this.generator.printBlock(this,node)};NodePrinter.prototype.indentOnComments=function indentOnComments(node){return this.generator.printAndIndentOnComments(this,node)};return NodePrinter}();exports["default"]=NodePrinter;module.exports=exports["default"]},{}],51:[function(require,module,exports){"use strict";function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashLangIsBoolean=require("lodash/lang/isBoolean");var _lodashLangIsBoolean2=_interopRequireDefault(_lodashLangIsBoolean);var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _lodashCollectionMap=require("lodash/collection/map");var _lodashCollectionMap2=_interopRequireDefault(_lodashCollectionMap);var _types=require("../../types");var t=_interopRequireWildcard(_types);function crawl(node){var state=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];if(t.isMemberExpression(node)){crawl(node.object,state);if(node.computed)crawl(node.property,state)}else if(t.isBinary(node)||t.isAssignmentExpression(node)){crawl(node.left,state);crawl(node.right,state)}else if(t.isCallExpression(node)){state.hasCall=true;crawl(node.callee,state)}else if(t.isFunction(node)){state.hasFunction=true}else if(t.isIdentifier(node)){state.hasHelper=state.hasHelper||isHelper(node.callee)}return state}function isHelper(node){if(t.isMemberExpression(node)){return isHelper(node.object)||isHelper(node.property)}else if(t.isIdentifier(node)){return node.name==="require"||node.name[0]==="_"}else if(t.isCallExpression(node)){return isHelper(node.callee)}else if(t.isBinary(node)||t.isAssignmentExpression(node)){return t.isIdentifier(node.left)&&isHelper(node.left)||isHelper(node.right)}else{return false}}function isType(node){return t.isLiteral(node)||t.isObjectExpression(node)||t.isArrayExpression(node)||t.isIdentifier(node)||t.isMemberExpression(node)}exports.nodes={AssignmentExpression:function AssignmentExpression(node){var state=crawl(node.right);if(state.hasCall&&state.hasHelper||state.hasFunction){return{before:state.hasFunction,after:true}}},SwitchCase:function SwitchCase(node,parent){return{before:node.consequent.length||parent.cases[0]===node}},LogicalExpression:function LogicalExpression(node){if(t.isFunction(node.left)||t.isFunction(node.right)){return{after:true}}},Literal:function Literal(node){if(node.value==="use strict"){return{after:true}}},CallExpression:function CallExpression(node){if(t.isFunction(node.callee)||isHelper(node)){return{before:true,after:true}}},VariableDeclaration:function VariableDeclaration(node){for(var i=0;i=max){i-=max}return i}var Whitespace=function(){function Whitespace(tokens){_classCallCheck(this,Whitespace);this.tokens=tokens;this.used={};this._lastFoundIndex=0}Whitespace.prototype.getNewlinesBefore=function getNewlinesBefore(node){var startToken;var endToken;var tokens=this.tokens;for(var j=0;j")}}).join("\n");if(highlighted){return _chalk2["default"].reset(frame)}else{return frame}};module.exports=exports["default"]},{chalk:217,esutils:413,"js-tokens":427,"line-numbers":429,repeating:611}],56:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashObjectMerge=require("lodash/object/merge");var _lodashObjectMerge2=_interopRequireDefault(_lodashObjectMerge);exports["default"]=function(dest,src){if(!dest||!src)return;return _lodashObjectMerge2["default"](dest,src,function(a,b){if(b&&Array.isArray(a)){var c=a.slice(0);for(var _iterator=b,_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;){var _ref;if(_isArray){if(_i>=_iterator.length)break;_ref=_iterator[_i++]}else{_i=_iterator.next();if(_i.done)break;_ref=_i.value}var v=_ref;if(a.indexOf(v)<0){c.push(v)}}return c}})};module.exports=exports["default"]},{"lodash/object/merge":541}],57:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../types");var t=_interopRequireWildcard(_types);exports["default"]=function(ast,comments,tokens){if(ast&&ast.type==="Program"){return t.file(ast,comments||[],tokens||[])}else{throw new Error("Not a valid ast?")}};module.exports=exports["default"]},{"../types":196}],58:[function(require,module,exports){"use strict";exports.__esModule=true;exports["default"]=function(){return Object.create(null)};module.exports=exports["default"]},{}],59:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _babylon=require("babylon");var babylon=_interopRequireWildcard(_babylon);exports["default"]=function(code){var opts=arguments.length<=1||arguments[1]===undefined?{}:arguments[1];var parseOpts={allowImportExportEverywhere:opts.looseModules,allowReturnOutsideFunction:opts.looseModules,allowHashBang:true,ecmaVersion:6,strictMode:opts.strictMode,sourceType:opts.sourceType,locations:true,features:opts.features||{},plugins:opts.plugins||{}};if(opts.nonStandard){parseOpts.plugins.jsx=true;parseOpts.plugins.flow=true}return babylon.parse(code,parseOpts)};module.exports=exports["default"]},{babylon:633}],60:[function(require,module,exports){"use strict";exports.__esModule=true;exports.get=get;exports.parseArgs=parseArgs;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _util=require("util");var util=_interopRequireWildcard(_util);var MESSAGES={tailCallReassignmentDeopt:"Function reference has been reassigned, so it will probably be dereferenced, therefore we can't optimise this with confidence",JSXNamespacedTags:"Namespace tags are not supported. ReactJSX is not XML.",classesIllegalBareSuper:"Illegal use of bare super",classesIllegalSuperCall:"Direct super call is illegal in non-constructor, use super.$1() instead",scopeDuplicateDeclaration:"Duplicate declaration $1",settersNoRest:"Setters aren't allowed to have a rest",noAssignmentsInForHead:"No assignments allowed in for-in/of head",expectedMemberExpressionOrIdentifier:"Expected type MemberExpression or Identifier",invalidParentForThisNode:"We don't know how to handle this node within the current parent - please open an issue",readOnly:"$1 is read-only",unknownForHead:"Unknown node type $1 in ForStatement",didYouMean:"Did you mean $1?",codeGeneratorDeopt:"Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.",missingTemplatesDirectory:"no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues",unsupportedOutputType:"Unsupported output type $1",illegalMethodName:"Illegal method name $1",lostTrackNodePath:"We lost track of this node's position, likely because the AST was directly manipulated",modulesIllegalExportName:"Illegal export $1",modulesDuplicateDeclarations:"Duplicate module declarations with the same source but in different scopes",undeclaredVariable:"Reference to undeclared variable $1",undeclaredVariableType:"Referencing a type alias outside of a type annotation",undeclaredVariableSuggestion:"Reference to undeclared variable $1 - did you mean $2?",traverseNeedsParent:"You must pass a scope and parentPath unless traversing a Program/File got a $1 node",traverseVerifyRootFunction:"You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?",traverseVerifyVisitorProperty:"You passed `traverse()` a visitor object with the property $1 that has the invalid property $2",traverseVerifyNodeType:"You gave us a visitor for the node type $1 but it's not a valid type",pluginIllegalKind:"Illegal kind $1 for plugin $2",pluginIllegalPosition:"Illegal position $1 for plugin $2",pluginKeyCollision:"The plugin $1 collides with another of the same name",pluginNotTransformer:"The plugin $1 didn't export a Plugin instance",pluginUnknown:"Unknown plugin $1",pluginNotFile:"Plugin $1 is resolving to a different Babel version than what is performing the transformation.",pluginInvalidProperty:"Plugin $1 provided an invalid property of $2.",pluginInvalidPropertyVisitor:'Define your visitor methods inside a `visitor` property like so:\n\n new Plugin("foobar", {\n visitor: {\n // define your visitor methods here!\n }\n });\n'};exports.MESSAGES=MESSAGES;function get(key){for(var _len=arguments.length,args=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var msg=MESSAGES[key];if(!msg)throw new ReferenceError("Unknown message "+JSON.stringify(key));args=parseArgs(args);return msg.replace(/\$(\d+)/g,function(str,i){return args[--i]})}function parseArgs(args){return args.map(function(val){if(val!=null&&val.inspect){return val.inspect()}else{try{return JSON.stringify(val)||val+""}catch(e){return util.inspect(val)}}})}},{util:30}],61:[function(require,module,exports){(function(global){"use strict";require("core-js/shim");require("regenerator/runtime");if(global._babelPolyfill){throw new Error("only one instance of babel/polyfill is allowed")}global._babelPolyfill=true}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"core-js/shim":405,"regenerator/runtime":604}],62:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _generation=require("../generation");var _generation2=_interopRequireDefault(_generation);var _messages=require("../messages");var messages=_interopRequireWildcard(_messages);var _util=require("../util");var util=_interopRequireWildcard(_util);var _transformationFile=require("../transformation/file");var _transformationFile2=_interopRequireDefault(_transformationFile);var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _types=require("../types");var t=_interopRequireWildcard(_types);function buildGlobal(namespace,builder){var body=[];var container=t.functionExpression(null,[t.identifier("global")],t.blockStatement(body));var tree=t.program([t.expressionStatement(t.callExpression(container,[util.template("helper-self-global")]))]);body.push(t.variableDeclaration("var",[t.variableDeclarator(namespace,t.assignmentExpression("=",t.memberExpression(t.identifier("global"),namespace),t.objectExpression([])))]));builder(body);return tree}function buildUmd(namespace,builder){var body=[];body.push(t.variableDeclaration("var",[t.variableDeclarator(namespace,t.identifier("global"))]));builder(body);var container=util.template("umd-commonjs-strict",{FACTORY_PARAMETERS:t.identifier("global"),BROWSER_ARGUMENTS:t.assignmentExpression("=",t.memberExpression(t.identifier("root"),namespace),t.objectExpression({})),COMMON_ARGUMENTS:t.identifier("exports"),AMD_ARGUMENTS:t.arrayExpression([t.literal("exports")]),FACTORY_BODY:body,UMD_ROOT:t.identifier("this")});return t.program([container])}function buildVar(namespace,builder){var body=[];body.push(t.variableDeclaration("var",[t.variableDeclarator(namespace,t.objectExpression({}))]));builder(body);return t.program(body)}function buildHelpers(body,namespace,whitelist){_lodashCollectionEach2["default"](_transformationFile2["default"].helpers,function(name){if(whitelist&&whitelist.indexOf(name)===-1)return;var key=t.identifier(t.toIdentifier(name));body.push(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(namespace,key),util.template("helper-"+name))))})}exports["default"]=function(whitelist){var outputType=arguments.length<=1||arguments[1]===undefined?"global":arguments[1];var namespace=t.identifier("babelHelpers");var builder=function builder(body){return buildHelpers(body,namespace,whitelist)};var tree;var build={global:buildGlobal,umd:buildUmd,"var":buildVar}[outputType];if(build){tree=build(namespace,builder)}else{throw new Error(messages.get("unsupportedOutputType",outputType))}return _generation2["default"](tree).code};module.exports=exports["default"]},{"../generation":47,"../messages":60,"../transformation/file":63,"../types":196,"../util":199,"lodash/collection/each":437}],63:[function(require,module,exports){(function(process){"use strict";exports.__esModule=true;var _createClass=function(){function defineProperties(target,props){for(var i=0;i=0)continue;var group=pass.plugin.metadata.group;if(!pass.canTransform()||!group){stack.push(pass);continue}var mergeStack=[];var _arr4=_stack;for(var _i4=0;_i4<_arr4.length;_i4++){var _pass=_arr4[_i4];if(_pass.plugin.metadata.group===group){mergeStack.push(_pass);ignore.push(_pass)}}var visitors=[];var _arr5=mergeStack;for(var _i5=0;_i5<_arr5.length;_i5++){var _pass2=_arr5[_i5];visitors.push(_pass2.plugin.visitor)}var visitor=_traversal2["default"].visitors.merge(visitors);var mergePlugin=new _plugin2["default"](group,{visitor:visitor});stack.push(mergePlugin.buildPass(this))}return stack};File.prototype.set=function set(key,val){return this.data[key]=val};File.prototype.setDynamic=function setDynamic(key,fn){this.dynamicData[key]=fn};File.prototype.get=function get(key){var data=this.data[key];if(data){return data}else{var dynamic=this.dynamicData[key];if(dynamic){return this.set(key,dynamic())}}};File.prototype.resolveModuleSource=function resolveModuleSource(source){var resolveModuleSource=this.opts.resolveModuleSource;if(resolveModuleSource)source=resolveModuleSource(source,this.opts.filename);return source};File.prototype.addImport=function addImport(source,name,type){name=name||source;var id=this.dynamicImportIds[name];if(!id){source=this.resolveModuleSource(source);id=this.dynamicImportIds[name]=this.scope.generateUidIdentifier(name);var specifiers=[t.importDefaultSpecifier(id)];var declar=t.importDeclaration(specifiers,t.literal(source));declar._blockHoist=3;if(type){var modules=this.dynamicImportTypes[type]=this.dynamicImportTypes[type]||[];modules.push(declar)}if(this.transformers["es6.modules"].canTransform()){this.moduleFormatter.importSpecifier(specifiers[0],declar,this.dynamicImports,this.scope);this.moduleFormatter.hasLocalImports=true}else{this.dynamicImports.push(declar)}}return id};File.prototype.attachAuxiliaryComment=function attachAuxiliaryComment(node){var beforeComment=this.opts.auxiliaryCommentBefore;if(beforeComment){node.leadingComments=node.leadingComments||[];node.leadingComments.push({type:"CommentLine",value:" "+beforeComment})}var afterComment=this.opts.auxiliaryCommentAfter;if(afterComment){node.trailingComments=node.trailingComments||[];node.trailingComments.push({type:"CommentLine",value:" "+afterComment})}return node};File.prototype.addHelper=function addHelper(name){var isSolo=_lodashCollectionIncludes2["default"](File.soloHelpers,name);if(!isSolo&&!_lodashCollectionIncludes2["default"](File.helpers,name)){throw new ReferenceError("Unknown helper "+name)}var declar=this.declarations[name];if(declar)return declar;this.usedHelpers[name]=true;if(!isSolo){var generator=this.get("helperGenerator");var runtime=this.get("helpersNamespace");if(generator){return generator(name)}else if(runtime){var id=t.identifier(t.toIdentifier(name));return t.memberExpression(runtime,id)}}var ref=util.template("helper-"+name);var uid=this.declarations[name]=this.scope.generateUidIdentifier(name);if(t.isFunctionExpression(ref)&&!ref.id){ref.body._compact=true;ref._generated=true;ref.id=uid;ref.type="FunctionDeclaration";this.attachAuxiliaryComment(ref);this.path.unshiftContainer("body",ref)}else{ref._compact=true;this.scope.push({id:uid,init:ref,unique:true})}return uid};File.prototype.addTemplateObject=function addTemplateObject(helperName,strings,raw){var stringIds=raw.elements.map(function(string){return string.value});var name=helperName+"_"+raw.elements.length+"_"+stringIds.join(",");var declar=this.declarations[name];if(declar)return declar;var uid=this.declarations[name]=this.scope.generateUidIdentifier("templateObject");var helperId=this.addHelper(helperName);var init=t.callExpression(helperId,[strings,raw]);init._compact=true;this.scope.push({id:uid,init:init,_blockHoist:1.9});return uid};File.prototype.errorWithNode=function errorWithNode(node,msg){var Error=arguments.length<=2||arguments[2]===undefined?SyntaxError:arguments[2];var err;var loc=node&&(node.loc||node._loc);if(loc){err=new Error("Line "+loc.start.line+": "+msg);err.loc=loc.start}else{err=new Error("There's been an error on a dynamic node. This is almost certainly an internal error. Please report it.")}return err};File.prototype.mergeSourceMap=function mergeSourceMap(map){var opts=this.opts;var inputMap=opts.inputSourceMap;if(inputMap){map.sources[0]=inputMap.file;var inputMapConsumer=new _sourceMap2["default"].SourceMapConsumer(inputMap);var outputMapConsumer=new _sourceMap2["default"].SourceMapConsumer(map);var outputMapGenerator=_sourceMap2["default"].SourceMapGenerator.fromSourceMap(outputMapConsumer);outputMapGenerator.applySourceMap(inputMapConsumer);var mergedMap=outputMapGenerator.toJSON();mergedMap.sources=inputMap.sources;mergedMap.file=inputMap.file;return mergedMap}return map};File.prototype.getModuleFormatter=function getModuleFormatter(type){if(_lodashLangIsFunction2["default"](type)||!_modules2["default"][type]){this.log.deprecate("Custom module formatters are deprecated and will be removed in the next major. Please use Babel plugins instead.")}var ModuleFormatter=_lodashLangIsFunction2["default"](type)?type:_modules2["default"][type];if(!ModuleFormatter){var loc=_tryResolve2["default"].relative(type);if(loc)ModuleFormatter=require(loc)}if(!ModuleFormatter){throw new ReferenceError("Unknown module formatter type "+JSON.stringify(type))}return new ModuleFormatter(this)};File.prototype.parse=function parse(code){var opts=this.opts;var parseOpts={highlightCode:opts.highlightCode,nonStandard:opts.nonStandard,sourceType:opts.sourceType,filename:opts.filename,plugins:{}};var features=parseOpts.features={};for(var key in this.transformers){var transformer=this.transformers[key];features[key]=transformer.canTransform()}parseOpts.looseModules=this.isLoose("es6.modules");parseOpts.strictMode=features.strict;this.log.debug("Parse start");var ast=_helpersParse2["default"](code,parseOpts);this.log.debug("Parse stop");return ast};File.prototype._addAst=function _addAst(ast){this.path=_traversalPath2["default"].get({hub:this.hub,parentPath:null,parent:ast,container:ast,key:"program"}).setContext();this.scope=this.path.scope;this.ast=ast};File.prototype.addAst=function addAst(ast){this.log.debug("Start set AST");this._addAst(ast);this.log.debug("End set AST");this.log.debug("Start module formatter init");var modFormatter=this.moduleFormatter=this.getModuleFormatter(this.opts.modules);if(modFormatter.init&&this.transformers["es6.modules"].canTransform()){modFormatter.init()}this.log.debug("End module formatter init")};File.prototype.transform=function transform(){this.call("pre");var _arr6=this.transformerStack;for(var _i6=0;_i6<_arr6.length;_i6++){var pass=_arr6[_i6];pass.transform()}this.call("post");return this.generate()};File.prototype.wrap=function wrap(code,callback){code=code+"";try{if(this.shouldIgnore()){return this.makeResult({code:code,ignored:true})}else{return callback()}}catch(err){if(err._babel){throw err}else{err._babel=true}var message=err.message=this.opts.filename+": "+err.message;var loc=err.loc;if(loc){err.codeFrame=_helpersCodeFrame2["default"](code,loc.line,loc.column+1,this.opts);message+="\n"+err.codeFrame}if(process.browser){err.message=message}if(err.stack){var newStack=err.stack.replace(err.message,message);try{err.stack=newStack}catch(e){}}throw err}};File.prototype.addCode=function addCode(code){code=(code||"")+"";code=this.parseInputSourceMap(code);this.code=code};File.prototype.parseCode=function parseCode(){this.parseShebang();var ast=this.parse(this.code);this.addAst(ast)};File.prototype.shouldIgnore=function shouldIgnore(){var opts=this.opts;return util.shouldIgnore(opts.filename,opts.ignore,opts.only)};File.prototype.call=function call(key){var _arr7=this.uncollapsedTransformerStack;for(var _i7=0;_i7<_arr7.length;_i7++){var pass=_arr7[_i7];var fn=pass.plugin[key];if(fn)fn(this)}};File.prototype.parseInputSourceMap=function parseInputSourceMap(code){var opts=this.opts;if(opts.inputSourceMap!==false){var inputMap=_convertSourceMap2["default"].fromSource(code);if(inputMap){opts.inputSourceMap=inputMap.toObject();code=_convertSourceMap2["default"].removeComments(code)}}return code};File.prototype.parseShebang=function parseShebang(){var shebangMatch=_shebangRegex2["default"].exec(this.code);if(shebangMatch){this.shebang=shebangMatch[0];this.code=this.code.replace(_shebangRegex2["default"],"")}};File.prototype.makeResult=function makeResult(_ref){var code=_ref.code;var _ref$map=_ref.map;var map=_ref$map===undefined?null:_ref$map;var ast=_ref.ast;var ignored=_ref.ignored;var result={metadata:null,ignored:!!ignored,code:null,ast:null,map:map};if(this.opts.code){result.code=code}if(this.opts.ast){result.ast=ast}if(this.opts.metadata){result.metadata=this.metadata;result.metadata.usedHelpers=Object.keys(this.usedHelpers)}return result};File.prototype.generate=function generate(){var opts=this.opts;var ast=this.ast;var result={ast:ast};if(!opts.code)return this.makeResult(result);this.log.debug("Generation start");var _result=_generation2["default"](ast,opts,this.code);result.code=_result.code;result.map=_result.map;this.log.debug("Generation end");if(this.shebang){result.code=this.shebang+"\n"+result.code}if(result.map){result.map=this.mergeSourceMap(result.map)}if(opts.sourceMaps==="inline"||opts.sourceMaps==="both"){result.code+="\n"+_convertSourceMap2["default"].fromObject(result.map).toComment()}if(opts.sourceMaps==="inline"){result.map=null}return this.makeResult(result)};_createClass(File,null,[{key:"helpers",value:["inherits","defaults","create-class","create-decorated-class","create-decorated-object","define-decorated-property-descriptor","tagged-template-literal","tagged-template-literal-loose","to-array","to-consumable-array","sliced-to-array","sliced-to-array-loose","object-without-properties","has-own","slice","bind","define-property","async-to-generator","interop-export-wildcard","interop-require-wildcard","interop-require-default","typeof","extends","get","set","new-arrow-check","class-call-check","object-destructuring-empty","temporal-undefined","temporal-assert-defined","self-global","default-props","instanceof","interop-require"],enumerable:true},{key:"soloHelpers",value:[],enumerable:true}]);return File}();exports["default"]=File;module.exports=exports["default"]}).call(this,require("_process"))},{"../../generation":47,"../../helpers/code-frame":55,"../../helpers/parse":59,"../../traversal":165,"../../traversal/hub":164,"../../traversal/path":172,"../../types":196,"../../util":199,"../modules":91,"../plugin":99,"./logger":64,"./options/option-manager":67,"./plugin-manager":69,_process:12,"convert-source-map":225,"lodash/collection/includes":439,"lodash/lang/isFunction":526,"lodash/object/defaults":536,path:11,"shebang-regex":614,"source-map":616,"try-resolve":630}],64:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _debugNode=require("debug/node");var _debugNode2=_interopRequireDefault(_debugNode);var verboseDebug=_debugNode2["default"]("babel:verbose");var generalDebug=_debugNode2["default"]("babel");var seenDeprecatedMessages=[];var Logger=function(){function Logger(file,filename){_classCallCheck(this,Logger);this.filename=filename;this.file=file}Logger.prototype._buildMessage=function _buildMessage(msg){var parts="[BABEL] "+this.filename;if(msg)parts+=": "+msg;return parts};Logger.prototype.warn=function warn(msg){console.warn(this._buildMessage(msg))};Logger.prototype.error=function error(msg){var Constructor=arguments.length<=1||arguments[1]===undefined?Error:arguments[1];throw new Constructor(this._buildMessage(msg))};Logger.prototype.deprecate=function deprecate(msg){if(this.file.opts&&this.file.opts.suppressDeprecationMessages)return;msg=this._buildMessage(msg);if(seenDeprecatedMessages.indexOf(msg)>=0)return;seenDeprecatedMessages.push(msg);console.error(msg)};Logger.prototype.verbose=function verbose(msg){if(verboseDebug.enabled)verboseDebug(this._buildMessage(msg))};Logger.prototype.debug=function debug(msg){if(generalDebug.enabled)generalDebug(this._buildMessage(msg))};Logger.prototype.deopt=function deopt(node,msg){this.debug(msg)};return Logger}();exports["default"]=Logger;module.exports=exports["default"]},{"debug/node":407}],65:[function(require,module,exports){module.exports={filename:{type:"filename",description:"filename to use when reading from stdin - this will be used in source-maps, errors etc","default":"unknown",shorthand:"f"},filenameRelative:{hidden:true,type:"string"},inputSourceMap:{hidden:true},extra:{hidden:true,"default":{}},env:{hidden:true,"default":{}},moduleId:{description:"specify a custom name for module ids",type:"string"},getModuleId:{hidden:true},retainLines:{type:"boolean","default":false,description:"retain line numbers - will result in really ugly code"},nonStandard:{type:"boolean","default":true,description:"enable/disable support for JSX and Flow (on by default)"},experimental:{type:"boolean",description:"allow use of experimental transformers","default":false},highlightCode:{description:"enable/disable ANSI syntax highlighting of code frames (on by default)",type:"boolean","default":true},suppressDeprecationMessages:{type:"boolean","default":false,hidden:true},resolveModuleSource:{hidden:true},stage:{description:"ECMAScript proposal stage version to allow [0-4]",shorthand:"e",type:"number","default":2},blacklist:{type:"transformerList",description:"blacklist of transformers to NOT use",shorthand:"b","default":[]},whitelist:{type:"transformerList",optional:true,description:"whitelist of transformers to ONLY use",shorthand:"l"},optional:{type:"transformerList",description:"list of optional transformers to enable","default":[]},modules:{type:"string",description:"module formatter type to use [common]","default":"common",shorthand:"m"},moduleIds:{type:"boolean","default":false,shorthand:"M",description:"insert an explicit id for modules"},loose:{type:"transformerList",description:"list of transformers to enable loose mode ON",shorthand:"L"},jsxPragma:{type:"string",description:"custom pragma to use with JSX (same functionality as @jsx comments)", -"default":"React.createElement",shorthand:"P"},plugins:{type:"list",description:"","default":[]},ignore:{type:"list",description:"list of glob paths to **not** compile","default":[]},only:{type:"list",description:"list of glob paths to **only** compile"},code:{hidden:true,"default":true,type:"boolean"},metadata:{hidden:true,"default":true,type:"boolean"},ast:{hidden:true,"default":true,type:"boolean"},comments:{type:"boolean","default":true,description:"strip/output comments in generated output (on by default)"},shouldPrintComment:{hidden:true,description:"optional callback to control whether a comment should be inserted, when this is used the comments option is ignored"},compact:{type:"booleanString","default":"auto",description:"do not include superfluous whitespace characters and line terminators [true|false|auto]"},keepModuleIdExtensions:{type:"boolean",description:"keep extensions when generating module ids","default":false,shorthand:"k"},auxiliaryComment:{deprecated:"renamed to auxiliaryCommentBefore",shorthand:"a",alias:"auxiliaryCommentBefore"},auxiliaryCommentBefore:{type:"string","default":"",description:"attach a comment before all helper declarations and auxiliary code"},auxiliaryCommentAfter:{type:"string","default":"",description:"attach a comment after all helper declarations and auxiliary code"},externalHelpers:{type:"boolean","default":false,shorthand:"r",description:"uses a reference to `babelHelpers` instead of placing helpers at the top of your code."},metadataUsedHelpers:{deprecated:"Not required anymore as this is enabled by default",type:"boolean","default":false,hidden:true},sourceMap:{alias:"sourceMaps",hidden:true},sourceMaps:{type:"booleanString",description:"[true|false|inline]","default":false,shorthand:"s"},sourceMapName:{alias:"sourceMapTarget",description:"DEPRECATED - Please use sourceMapTarget"},sourceMapTarget:{type:"string",description:"set `file` on returned source map"},sourceFileName:{type:"string",description:"set `sources[0]` on returned source map"},sourceRoot:{type:"filename",description:"the root from which all sources are relative"},moduleRoot:{type:"filename",description:"optional prefix for the AMD module formatter that will be prepend to the filename on module definitions"},breakConfig:{type:"boolean","default":false,hidden:true,description:"stop trying to load .babelrc files"},babelrc:{description:"Specify a custom list of babelrc files to use",type:"list"},sourceType:{description:"","default":"module"}}},{}],66:[function(require,module,exports){"use strict";exports.__esModule=true;exports.validateOption=validateOption;exports.normaliseOptions=normaliseOptions;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _parsers=require("./parsers");var parsers=_interopRequireWildcard(_parsers);var _config=require("./config");var _config2=_interopRequireDefault(_config);exports.config=_config2["default"];function validateOption(key,val,pipeline){var opt=_config2["default"][key];var parser=opt&&parsers[opt.type];if(parser&&parser.validate){return parser.validate(key,val,pipeline)}else{return val}}function normaliseOptions(){var options=arguments.length<=0||arguments[0]===undefined?{}:arguments[0];for(var key in options){var val=options[key];if(val==null)continue;var opt=_config2["default"][key];if(!opt)continue;var parser=parsers[opt.type];if(parser)val=parser(val);options[key]=val}return options}},{"./config":65,"./parsers":68}],67:[function(require,module,exports){(function(process){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _index=require("./index");var _json5=require("json5");var _json52=_interopRequireDefault(_json5);var _pathIsAbsolute=require("path-is-absolute");var _pathIsAbsolute2=_interopRequireDefault(_pathIsAbsolute);var _pathExists=require("path-exists");var _pathExists2=_interopRequireDefault(_pathExists);var _lodashLangClone=require("lodash/lang/clone");var _lodashLangClone2=_interopRequireDefault(_lodashLangClone);var _helpersMerge=require("../../../helpers/merge");var _helpersMerge2=_interopRequireDefault(_helpersMerge);var _config=require("./config");var _config2=_interopRequireDefault(_config);var _path=require("path");var _path2=_interopRequireDefault(_path);var _fs=require("fs");var _fs2=_interopRequireDefault(_fs);var existsCache={};var jsonCache={};var BABELIGNORE_FILENAME=".babelignore";var BABELRC_FILENAME=".babelrc";var PACKAGE_FILENAME="package.json";function exists(filename){var cached=existsCache[filename];if(cached!=null){return cached}else{return existsCache[filename]=_pathExists2["default"].sync(filename)}}var OptionManager=function(){function OptionManager(log,pipeline){_classCallCheck(this,OptionManager);this.resolvedConfigs=[];this.options=OptionManager.createBareOptions();this.pipeline=pipeline;this.log=log}OptionManager.createBareOptions=function createBareOptions(){var opts={};for(var key in _config2["default"]){var opt=_config2["default"][key];opts[key]=_lodashLangClone2["default"](opt["default"])}return opts};OptionManager.prototype.addConfig=function addConfig(loc,key){var json=arguments.length<=2||arguments[2]===undefined?_json52["default"]:arguments[2];if(this.resolvedConfigs.indexOf(loc)>=0)return;var content=_fs2["default"].readFileSync(loc,"utf8");var opts;try{opts=jsonCache[content]=jsonCache[content]||json.parse(content);if(key)opts=opts[key]}catch(err){err.message=loc+": Error while parsing JSON - "+err.message;throw err}this.mergeOptions(opts,loc);this.resolvedConfigs.push(loc)};OptionManager.prototype.mergeOptions=function mergeOptions(opts){var alias=arguments.length<=1||arguments[1]===undefined?"foreign":arguments[1];if(!opts)return;for(var key in opts){if(key[0]==="_")continue;var option=_config2["default"][key];if(!option)this.log.error("Unknown option: "+alias+"."+key,ReferenceError)}_index.normaliseOptions(opts);_helpersMerge2["default"](this.options,opts)};OptionManager.prototype.addIgnoreConfig=function addIgnoreConfig(loc){var file=_fs2["default"].readFileSync(loc,"utf8");var lines=file.split("\n");lines=lines.map(function(line){return line.replace(/#(.*?)$/,"").trim()}).filter(function(line){return!!line});this.mergeOptions({ignore:lines},loc)};OptionManager.prototype.findConfigs=function findConfigs(loc){if(!loc)return;if(!_pathIsAbsolute2["default"](loc)){loc=_path2["default"].join(process.cwd(),loc)}while(loc!==(loc=_path2["default"].dirname(loc))){if(this.options.breakConfig)return;var configLoc=_path2["default"].join(loc,BABELRC_FILENAME);if(exists(configLoc))this.addConfig(configLoc);var pkgLoc=_path2["default"].join(loc,PACKAGE_FILENAME);if(exists(pkgLoc))this.addConfig(pkgLoc,"babel",JSON);var ignoreLoc=_path2["default"].join(loc,BABELIGNORE_FILENAME);if(exists(ignoreLoc))this.addIgnoreConfig(ignoreLoc)}};OptionManager.prototype.normaliseOptions=function normaliseOptions(){var opts=this.options;for(var key in _config2["default"]){var option=_config2["default"][key];var val=opts[key];if(!val&&option.optional)continue;if(this.log&&val&&option.deprecated){this.log.deprecate("Deprecated option "+key+": "+option.deprecated)}if(this.pipeline&&val){val=_index.validateOption(key,val,this.pipeline)}if(option.alias){opts[option.alias]=opts[option.alias]||val}else{opts[key]=val}}};OptionManager.prototype.init=function init(opts){this.mergeOptions(opts,"direct");if(opts.babelrc){var _arr=opts.babelrc;for(var _i=0;_i<_arr.length;_i++){var loc=_arr[_i];this.addConfig(loc)}}if(opts.babelrc!==false){this.findConfigs(opts.filename)}var envKey=process.env.BABEL_ENV||process.env.NODE_ENV||"development";if(this.options.env){this.mergeOptions(this.options.env[envKey],"direct.env."+envKey)}this.normaliseOptions(opts);return this.options};return OptionManager}();exports["default"]=OptionManager;module.exports=exports["default"]}).call(this,require("_process"))},{"../../../helpers/merge":56,"./config":65,"./index":66,_process:12,fs:1,json5:428,"lodash/lang/clone":520,path:11,"path-exists":552,"path-is-absolute":553}],68:[function(require,module,exports){"use strict";exports.__esModule=true;exports.transformerList=transformerList;exports.number=number;exports.boolean=boolean;exports.booleanString=booleanString;exports.list=list;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _slash=require("slash");var _slash2=_interopRequireDefault(_slash);var _util=require("../../../util");var util=_interopRequireWildcard(_util);function transformerList(val){return util.arrayify(val)}transformerList.validate=function(key,val,pipeline){if(val.indexOf("all")>=0||val.indexOf(true)>=0){val=Object.keys(pipeline.transformers)}return pipeline._ensureTransformerNames(key,val)};function number(val){return+val}var filename=_slash2["default"];exports.filename=filename;function boolean(val){return!!val}function booleanString(val){return util.booleanify(val)}function list(val){return util.list(val)}},{"../../../util":199,slash:615}],69:[function(require,module,exports){"use strict";exports.__esModule=true;var _createClass=function(){function defineProperties(target,props){for(var i=0;i=3){callExpr._prettyCall=true}return t.inherits(callExpr,node)}};return visitor};module.exports=exports["default"]},{"../../messages":60,"../../types":196,"./react":79,esutils:413,"lodash/lang/isString":532}],73:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);var visitor={enter:function enter(node,parent,scope,state){if(this.isThisExpression()||this.isReferencedIdentifier({name:"arguments"})){state.found=true;this.stop()}},Function:function Function(){this.skip()}};exports["default"]=function(node,scope){var container=t.functionExpression(null,[],node.body,node.generator,node.async);var callee=container;var args=[];var state={found:false};scope.traverse(node,visitor,state);if(state.found){callee=t.memberExpression(container,t.identifier("apply"));args=[t.thisExpression(),t.identifier("arguments")]}var call=t.callExpression(callee,args);if(node.generator)call=t.yieldExpression(call,true);return t.returnStatement(call)};module.exports=exports["default"]},{"../../types":196}],74:[function(require,module,exports){"use strict";exports.__esModule=true;exports.push=push;exports.hasComputed=hasComputed;exports.toComputedObjectFromClass=toComputedObjectFromClass;exports.toClassObject=toClassObject;exports.toDefineObject=toDefineObject;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _lodashObjectHas=require("lodash/object/has");var _lodashObjectHas2=_interopRequireDefault(_lodashObjectHas);var _types=require("../../types");var t=_interopRequireWildcard(_types);function push(mutatorMap,node,kind,file){var alias=t.toKeyAlias(node);var map={};if(_lodashObjectHas2["default"](mutatorMap,alias))map=mutatorMap[alias];mutatorMap[alias]=map;map._inherits=map._inherits||[];map._inherits.push(node);map._key=node.key;if(node.computed){map._computed=true}if(node.decorators){var decorators=map.decorators=map.decorators||t.arrayExpression([]);decorators.elements=decorators.elements.concat(node.decorators.map(function(dec){return dec.expression}).reverse())}if(map.value||map.initializer){throw file.errorWithNode(node,"Key conflict with sibling node")}if(node.value){if(node.kind==="init")kind="value";if(node.kind==="get")kind="get";if(node.kind==="set")kind="set";t.inheritsComments(node.value,node);map[kind]=node.value}return map}function hasComputed(mutatorMap){for(var key in mutatorMap){if(mutatorMap[key]._computed){return true}}return false}function toComputedObjectFromClass(obj){var objExpr=t.arrayExpression([]);for(var i=0;i=0}function pullFlag(node,flag){var flags=node.regex.flags.split("");if(node.regex.flags.indexOf(flag)<0)return;_lodashArrayPull2["default"](flags,flag);node.regex.flags=flags.join("")}},{"../../types":196,"lodash/array/pull":434}],81:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../types");var t=_interopRequireWildcard(_types);var awaitVisitor={Function:function Function(){this.skip()},AwaitExpression:function AwaitExpression(node){node.type="YieldExpression";if(node.all){node.all=false;node.argument=t.callExpression(t.memberExpression(t.identifier("Promise"),t.identifier("all")),[node.argument])}}};var referenceVisitor={ReferencedIdentifier:function ReferencedIdentifier(node,parent,scope,state){var name=state.id.name;if(node.name===name&&scope.bindingIdentifierEquals(name,state.id)){return state.ref=state.ref||scope.generateUidIdentifier(name)}}};exports["default"]=function(path,callId){var node=path.node;node.async=false;node.generator=true;path.traverse(awaitVisitor,state);var call=t.callExpression(callId,[node]);var id=node.id;node.id=null;if(t.isFunctionDeclaration(node)){var declar=t.variableDeclaration("let",[t.variableDeclarator(id,call)]);declar._blockHoist=true;return declar}else{if(id){var state={id:id};path.traverse(referenceVisitor,state);if(state.ref){path.scope.parent.push({id:state.ref});return t.assignmentExpression("=",state.ref,call)}}return call}};module.exports=exports["default"]},{"../../types":196}],82:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _messages=require("../../messages");var messages=_interopRequireWildcard(_messages);var _types=require("../../types");var t=_interopRequireWildcard(_types);function isIllegalBareSuper(node,parent){if(!t.isSuper(node))return false;if(t.isMemberExpression(parent,{computed:false}))return false;if(t.isCallExpression(parent,{callee:node}))return false;return true}function isMemberExpressionSuper(node){return t.isMemberExpression(node)&&t.isSuper(node.object)}var visitor={enter:function enter(node,parent,scope,state){var topLevel=state.topLevel;var self=state.self;if(t.isFunction(node)&&!t.isArrowFunctionExpression(node)){self.traverseLevel(this,false);return this.skip()}if(t.isProperty(node,{method:true})||t.isMethodDefinition(node)){return this.skip()}var getThisReference=topLevel?t.thisExpression:self.getThisReference.bind(self);var callback=self.specHandle;if(self.isLoose)callback=self.looseHandle;var result=callback.call(self,this,getThisReference);if(result)this.hasSuper=true;if(result===true)return;return result}};var ReplaceSupers=function(){function ReplaceSupers(opts){var inClass=arguments.length<=1||arguments[1]===undefined?false:arguments[1];_classCallCheck(this,ReplaceSupers);this.topLevelThisReference=opts.topLevelThisReference;this.methodPath=opts.methodPath;this.methodNode=opts.methodNode;this.superRef=opts.superRef;this.isStatic=opts.isStatic;this.hasSuper=false;this.inClass=inClass;this.isLoose=opts.isLoose;this.scope=opts.scope;this.file=opts.file;this.opts=opts}ReplaceSupers.prototype.getObjectRef=function getObjectRef(){return this.opts.objectRef||this.opts.getObjectRef()};ReplaceSupers.prototype.setSuperProperty=function setSuperProperty(property,value,isComputed,thisExpression){return t.callExpression(this.file.addHelper("set"),[t.callExpression(t.memberExpression(t.identifier("Object"),t.identifier("getPrototypeOf")),[this.isStatic?this.getObjectRef():t.memberExpression(this.getObjectRef(),t.identifier("prototype"))]),isComputed?property:t.literal(property.name),value,thisExpression])};ReplaceSupers.prototype.getSuperProperty=function getSuperProperty(property,isComputed,thisExpression){return t.callExpression(this.file.addHelper("get"),[t.callExpression(t.memberExpression(t.identifier("Object"),t.identifier("getPrototypeOf")),[this.isStatic?this.getObjectRef():t.memberExpression(this.getObjectRef(),t.identifier("prototype"))]),isComputed?property:t.literal(property.name),thisExpression])};ReplaceSupers.prototype.replace=function replace(){this.traverseLevel(this.methodPath.get("value"),true)};ReplaceSupers.prototype.traverseLevel=function traverseLevel(path,topLevel){var state={self:this,topLevel:topLevel};path.traverse(visitor,state)};ReplaceSupers.prototype.getThisReference=function getThisReference(){if(this.topLevelThisReference){return this.topLevelThisReference}else{var ref=this.topLevelThisReference=this.scope.generateUidIdentifier("this");this.methodNode.value.body.body.unshift(t.variableDeclaration("var",[t.variableDeclarator(this.topLevelThisReference,t.thisExpression())]));return ref}};ReplaceSupers.prototype.getLooseSuperProperty=function getLooseSuperProperty(id,parent){var methodNode=this.methodNode;var methodName=methodNode.key;var superRef=this.superRef||t.identifier("Function");if(parent.property===id){return}else if(t.isCallExpression(parent,{callee:id})){parent.arguments.unshift(t.thisExpression());if(methodName.name==="constructor"){if(parent.arguments.length===2&&t.isSpreadElement(parent.arguments[1])&&t.isIdentifier(parent.arguments[1].argument,{name:"arguments"})){parent.arguments[1]=parent.arguments[1].argument;return t.memberExpression(superRef,t.identifier("apply"))}else{return t.memberExpression(superRef,t.identifier("call"))}}else{id=superRef;if(!methodNode["static"]){id=t.memberExpression(id,t.identifier("prototype"))}id=t.memberExpression(id,methodName,methodNode.computed);return t.memberExpression(id,t.identifier("call"))}}else if(t.isMemberExpression(parent)&&!methodNode["static"]){return t.memberExpression(superRef,t.identifier("prototype"))}else{return superRef}};ReplaceSupers.prototype.looseHandle=function looseHandle(path,getThisReference){var node=path.node;if(path.isSuper()){return this.getLooseSuperProperty(node,path.parent)}else if(path.isCallExpression()){var callee=node.callee;if(!t.isMemberExpression(callee))return;if(!t.isSuper(callee.object))return;t.appendToMemberExpression(callee,t.identifier("call"));node.arguments.unshift(getThisReference());return true}};ReplaceSupers.prototype.specHandleAssignmentExpression=function specHandleAssignmentExpression(ref,path,node,getThisReference){if(node.operator==="="){return this.setSuperProperty(node.left.property,node.right,node.left.computed,getThisReference())}else{ref=ref||path.scope.generateUidIdentifier("ref");return[t.variableDeclaration("var",[t.variableDeclarator(ref,node.left)]),t.expressionStatement(t.assignmentExpression("=",node.left,t.binaryExpression(node.operator[0],ref,node.right)))]}};ReplaceSupers.prototype.specHandle=function specHandle(path,getThisReference){var methodNode=this.methodNode;var property;var computed;var args;var thisReference;var parent=path.parent;var node=path.node;if(isIllegalBareSuper(node,parent)){throw path.errorWithNode(messages.get("classesIllegalBareSuper"))}if(t.isCallExpression(node)){var callee=node.callee;if(t.isSuper(callee)){property=methodNode.key;computed=methodNode.computed;args=node.arguments;if(methodNode.key.name!=="constructor"||!this.inClass){var methodName=methodNode.key.name||"METHOD_NAME";throw this.file.errorWithNode(node,messages.get("classesIllegalSuperCall",methodName))}}else if(isMemberExpressionSuper(callee)){property=callee.property;computed=callee.computed;args=node.arguments}}else if(t.isMemberExpression(node)&&t.isSuper(node.object)){property=node.property;computed=node.computed}else if(t.isUpdateExpression(node)&&isMemberExpressionSuper(node.argument)){var binary=t.binaryExpression(node.operator[0],node.argument,t.literal(1));if(node.prefix){return this.specHandleAssignmentExpression(null,path,binary,getThisReference)}else{var ref=path.scope.generateUidIdentifier("ref");return this.specHandleAssignmentExpression(ref,path,binary,getThisReference).concat(t.expressionStatement(ref))}}else if(t.isAssignmentExpression(node)&&isMemberExpressionSuper(node.left)){return this.specHandleAssignmentExpression(null,path,node,getThisReference)}if(!property)return;thisReference=getThisReference();var superProperty=this.getSuperProperty(property,computed,thisReference);if(args){if(args.length===1&&t.isSpreadElement(args[0])){return t.callExpression(t.memberExpression(superProperty,t.identifier("apply")),[thisReference,args[0].argument])}else{return t.callExpression(t.memberExpression(superProperty,t.identifier("call")),[thisReference].concat(args))}}else{return superProperty}};return ReplaceSupers}();exports["default"]=ReplaceSupers;module.exports=exports["default"]},{"../../messages":60,"../../types":196}],83:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _pipeline=require("./pipeline");var _pipeline2=_interopRequireDefault(_pipeline);var _transformers=require("./transformers");var _transformers2=_interopRequireDefault(_transformers);var _transformersDeprecated=require("./transformers/deprecated");var _transformersDeprecated2=_interopRequireDefault(_transformersDeprecated);var _transformersAliases=require("./transformers/aliases");var _transformersAliases2=_interopRequireDefault(_transformersAliases);var _transformersFilters=require("./transformers/filters");var filters=_interopRequireWildcard(_transformersFilters);var pipeline=new _pipeline2["default"];for(var key in _transformers2["default"]){var transformer=_transformers2["default"][key];if(typeof transformer==="object"){var metadata=transformer.metadata=transformer.metadata||{};metadata.group=metadata.group||"builtin-basic"}}pipeline.addTransformers(_transformers2["default"]);pipeline.addDeprecated(_transformersDeprecated2["default"]);pipeline.addAliases(_transformersAliases2["default"]);pipeline.addFilter(filters.internal);pipeline.addFilter(filters.blacklist);pipeline.addFilter(filters.whitelist);pipeline.addFilter(filters.stage);pipeline.addFilter(filters.optional);var transform=pipeline.transform.bind(pipeline);transform.fromAst=pipeline.transformFromAst.bind(pipeline);transform.pipeline=pipeline;exports["default"]=transform;module.exports=exports["default"]},{"./pipeline":97,"./transformers":143,"./transformers/aliases":101,"./transformers/deprecated":102,"./transformers/filters":142}],84:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _libMetadata=require("./lib/metadata");var metadataVisitor=_interopRequireWildcard(_libMetadata);var _messages=require("../../messages");var messages=_interopRequireWildcard(_messages);var _libRemaps=require("./lib/remaps");var _libRemaps2=_interopRequireDefault(_libRemaps);var _helpersObject=require("../../helpers/object");var _helpersObject2=_interopRequireDefault(_helpersObject);var _util=require("../../util");var util=_interopRequireWildcard(_util);var _types=require("../../types");var t=_interopRequireWildcard(_types);var DefaultFormatter=function(){function DefaultFormatter(file){_classCallCheck(this,DefaultFormatter);this.sourceScopes=_helpersObject2["default"]();this.defaultIds=_helpersObject2["default"]();this.ids=_helpersObject2["default"]();this.remaps=new _libRemaps2["default"](file,this);this.scope=file.scope;this.file=file;this.hasNonDefaultExports=false;this.hasLocalExports=false;this.hasLocalImports=false;this.localExports=_helpersObject2["default"]();this.localImports=_helpersObject2["default"]();this.metadata=file.metadata.modules;this.getMetadata()}DefaultFormatter.prototype.addScope=function addScope(path){var source=path.node.source&&path.node.source.value;if(!source)return;var existingScope=this.sourceScopes[source];if(existingScope&&existingScope!==path.scope){throw path.errorWithNode(messages.get("modulesDuplicateDeclarations"))}this.sourceScopes[source]=path.scope};DefaultFormatter.prototype.isModuleType=function isModuleType(node,type){var modules=this.file.dynamicImportTypes[type];return modules&&modules.indexOf(node)>=0};DefaultFormatter.prototype.transform=function transform(){this.remapAssignments()};DefaultFormatter.prototype.doDefaultExportInterop=function doDefaultExportInterop(node){return(t.isExportDefaultDeclaration(node)||t.isSpecifierDefault(node))&&!this.noInteropRequireExport&&!this.hasNonDefaultExports};DefaultFormatter.prototype.getMetadata=function getMetadata(){var has=false;var _arr=this.file.ast.program.body;for(var _i=0;_i<_arr.length;_i++){var node=_arr[_i];if(t.isModuleDeclaration(node)){has=true;break}}if(has||this.isLoose()){this.file.path.traverse(metadataVisitor,this)}};DefaultFormatter.prototype.remapAssignments=function remapAssignments(){if(this.hasLocalExports||this.hasLocalImports){this.remaps.run()}};DefaultFormatter.prototype.remapExportAssignment=function remapExportAssignment(node,exported){var assign=node;for(var i=0;i=0)continue;var msgType="pluginInvalidProperty";if(t.TYPES.indexOf(key)>=0)msgType="pluginInvalidPropertyVisitor";throw new Error(messages.get(msgType,name,key))}for(var key in plugin.metadata){if(VALID_METADATA_PROPERTES.indexOf(key)>=0)continue;throw new Error(messages.get("pluginInvalidProperty",name,"metadata."+key))}};Plugin.prototype.normalize=function normalize(visitor){_traversal2["default"].explode(visitor);return visitor};Plugin.prototype.buildPass=function buildPass(file){if(!(file instanceof _file2["default"])){throw new TypeError(messages.get("pluginNotFile",this.key))}return new _pluginPass2["default"](file,this)};return Plugin}();exports["default"]=Plugin;module.exports=exports["default"]},{"../messages":60,"../traversal":165,"../types":196,"./file":63,"./plugin-pass":98,"lodash/lang/clone":520,"lodash/object/assign":535}],100:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _plugin=require("./plugin");var _plugin2=_interopRequireDefault(_plugin);var Transformer=function Transformer(key,obj){_classCallCheck(this,Transformer);var plugin={};plugin.metadata=obj.metadata;delete obj.metadata;plugin.visitor=obj;return new _plugin2["default"](key,plugin)};exports["default"]=Transformer;module.exports=exports["default"]},{"./plugin":99}],101:[function(require,module,exports){module.exports={useStrict:"strict","es5.runtime":"runtime","es6.runtime":"runtime","minification.inlineExpressions":"minification.constantFolding"}},{}],102:[function(require,module,exports){module.exports={selfContained:"runtime","unicode-regex":"regex.unicode","spec.typeofSymbol":"es6.spec.symbols","es6.symbols":"es6.spec.symbols","es6.blockScopingTDZ":"es6.spec.blockScoping","utility.inlineExpressions":"minification.constantFolding","utility.deadCodeElimination":"minification.deadCodeElimination","utility.removeConsoleCalls":"minification.removeConsole","utility.removeDebugger":"minification.removeDebugger","es6.parameters.rest":"es6.parameters","es6.parameters.default":"es6.parameters"}},{}],103:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-trailing"};exports.metadata=metadata;var visitor={MemberExpression:{exit:function exit(node){var prop=node.property;if(!node.computed&&t.isIdentifier(prop)&&!t.isValidIdentifier(prop.name)){node.property=t.literal(prop.name);node.computed=true}}}};exports.visitor=visitor},{"../../../types":196}],104:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-trailing"};exports.metadata=metadata;var visitor={Property:{exit:function exit(node){var key=node.key;if(!node.computed&&t.isIdentifier(key)&&!t.isValidIdentifier(key.name)){node.key=t.literal(key.name)}}}};exports.visitor=visitor},{"../../../types":196}],105:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _helpersDefineMap=require("../../helpers/define-map");var defineMap=_interopRequireWildcard(_helpersDefineMap);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var visitor={ObjectExpression:function ObjectExpression(node,parent,scope,file){var hasAny=false;var _arr=node.properties;for(var _i=0;_i<_arr.length;_i++){var prop=_arr[_i];if(prop.kind==="get"||prop.kind==="set"){hasAny=true;break}}if(!hasAny)return;var mutatorMap={};node.properties=node.properties.filter(function(prop){if(prop.kind==="get"||prop.kind==="set"){defineMap.push(mutatorMap,prop,prop.kind,file);return false}else{return true}});return t.callExpression(t.memberExpression(t.identifier("Object"),t.identifier("defineProperties")),[node,defineMap.toDefineObject(mutatorMap)])}};exports.visitor=visitor},{"../../../types":196,"../../helpers/define-map":74}],106:[function(require,module,exports){"use strict";exports.__esModule=true;var visitor={ArrowFunctionExpression:function ArrowFunctionExpression(node){this.ensureBlock();node.expression=false;node.type="FunctionExpression";node.shadow=node.shadow||true}};exports.visitor=visitor; -},{}],107:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _traversal=require("../../../traversal");var _traversal2=_interopRequireDefault(_traversal);var _helpersObject=require("../../../helpers/object");var _helpersObject2=_interopRequireDefault(_helpersObject);var _util=require("../../../util");var util=_interopRequireWildcard(_util);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var _lodashObjectValues=require("lodash/object/values");var _lodashObjectValues2=_interopRequireDefault(_lodashObjectValues);var _lodashObjectExtend=require("lodash/object/extend");var _lodashObjectExtend2=_interopRequireDefault(_lodashObjectExtend);function isLet(node,parent){if(!t.isVariableDeclaration(node))return false;if(node._let)return true;if(node.kind!=="let")return false;if(isLetInitable(node,parent)){for(var i=0;i=0){return}loopText=loopText+"|"+node.label.name}else{if(state.ignoreLabeless)return;if(state.inSwitchCase)return;if(t.isBreakStatement(node)&&t.isSwitchCase(parent))return}state.hasBreakContinue=true;state.map[loopText]=node;replace=t.literal(loopText)}if(this.isReturnStatement()){state.hasReturn=true;replace=t.objectExpression([t.property("init",t.identifier("v"),node.argument||t.identifier("undefined"))])}if(replace){replace=t.returnStatement(replace);this.skip();return t.inherits(replace,node)}}};var BlockScoping=function(){function BlockScoping(loopPath,blockPath,parent,scope,file){_classCallCheck(this,BlockScoping);this.parent=parent;this.scope=scope;this.file=file;this.blockPath=blockPath;this.block=blockPath.node;this.outsideLetReferences=_helpersObject2["default"]();this.hasLetReferences=false;this.letReferences=this.block._letReferences=_helpersObject2["default"]();this.body=[];if(loopPath){this.loopParent=loopPath.parent;this.loopLabel=t.isLabeledStatement(this.loopParent)&&this.loopParent.label;this.loopPath=loopPath;this.loop=loopPath.node}}BlockScoping.prototype.run=function run(){var block=this.block;if(block._letDone)return;block._letDone=true;var needsClosure=this.getLetReferences();if(t.isFunction(this.parent)||t.isProgram(this.block))return;if(!this.hasLetReferences)return;if(needsClosure){this.wrapClosure()}else{this.remap()}if(this.loopLabel&&!t.isLabeledStatement(this.loopParent)){return t.labeledStatement(this.loopLabel,this.loop)}};BlockScoping.prototype.remap=function remap(){var hasRemaps=false;var letRefs=this.letReferences;var scope=this.scope;var remaps=_helpersObject2["default"]();for(var key in letRefs){var ref=letRefs[key];if(scope.parentHasBinding(key)||scope.hasGlobal(key)){var uid=scope.generateUidIdentifier(ref.name).name;ref.name=uid;hasRemaps=true;remaps[key]=remaps[uid]={binding:ref,uid:uid}}}if(!hasRemaps)return;var loop=this.loop;if(loop){traverseReplace(loop.right,loop,scope,remaps);traverseReplace(loop.test,loop,scope,remaps);traverseReplace(loop.update,loop,scope,remaps)}this.blockPath.traverse(replaceVisitor,remaps)};BlockScoping.prototype.wrapClosure=function wrapClosure(){var block=this.block;var outsideRefs=this.outsideLetReferences;if(this.loop){for(var name in outsideRefs){var id=outsideRefs[name];if(this.scope.hasGlobal(id.name)||this.scope.parentHasBinding(id.name)){delete outsideRefs[id.name];delete this.letReferences[id.name];this.scope.rename(id.name);this.letReferences[id.name]=id;outsideRefs[id.name]=id}}}this.has=this.checkLoop();this.hoistVarDeclarations();var params=_lodashObjectValues2["default"](outsideRefs);var args=_lodashObjectValues2["default"](outsideRefs);var fn=t.functionExpression(null,params,t.blockStatement(block.body));fn.shadow=true;this.addContinuations(fn);block.body=this.body;var ref=fn;if(this.loop){ref=this.scope.generateUidIdentifier("loop");this.loopPath.insertBefore(t.variableDeclaration("var",[t.variableDeclarator(ref,fn)]))}var call=t.callExpression(ref,args);var ret=this.scope.generateUidIdentifier("ret");var hasYield=_traversal2["default"].hasType(fn.body,this.scope,"YieldExpression",t.FUNCTION_TYPES);if(hasYield){fn.generator=true;call=t.yieldExpression(call,true)}var hasAsync=_traversal2["default"].hasType(fn.body,this.scope,"AwaitExpression",t.FUNCTION_TYPES);if(hasAsync){fn.async=true;call=t.awaitExpression(call)}this.buildClosure(ret,call)};BlockScoping.prototype.buildClosure=function buildClosure(ret,call){var has=this.has;if(has.hasReturn||has.hasBreakContinue){this.buildHas(ret,call)}else{this.body.push(t.expressionStatement(call))}};BlockScoping.prototype.addContinuations=function addContinuations(fn){var state={reassignments:{},outsideReferences:this.outsideLetReferences};this.scope.traverse(fn,continuationVisitor,state);for(var i=0;i=spreadPropIndex)break;if(t.isSpreadProperty(prop))continue;var key=prop.key;if(t.isIdentifier(key)&&!prop.computed)key=t.literal(prop.key.name);keys.push(key)}keys=t.arrayExpression(keys);var value=t.callExpression(this.file.addHelper("object-without-properties"),[objRef,keys]);this.nodes.push(this.buildVariableAssignment(spreadProp.argument,value))};DestructuringTransformer.prototype.pushObjectProperty=function pushObjectProperty(prop,propRef){if(t.isLiteral(prop.key))prop.computed=true;var pattern=prop.value;var objRef=t.memberExpression(propRef,prop.key,prop.computed);if(t.isPattern(pattern)){this.push(pattern,objRef)}else{this.nodes.push(this.buildVariableAssignment(pattern,objRef))}};DestructuringTransformer.prototype.pushObjectPattern=function pushObjectPattern(pattern,objRef){if(!pattern.properties.length){this.nodes.push(t.expressionStatement(t.callExpression(this.file.addHelper("object-destructuring-empty"),[objRef])))}if(pattern.properties.length>1&&!this.scope.isStatic(objRef)){var temp=this.scope.generateUidIdentifierBasedOnNode(objRef);this.nodes.push(this.buildVariableDeclaration(temp,objRef));objRef=temp}for(var i=0;iarr.elements.length)return;if(pattern.elements.length0){elemRef=t.callExpression(t.memberExpression(elemRef,t.identifier("slice")),[t.literal(i)])}elem=elem.argument}else{elemRef=t.memberExpression(arrayRef,t.literal(i),true)}this.push(elem,elemRef)}};DestructuringTransformer.prototype.init=function init(pattern,ref){if(!t.isArrayExpression(ref)&&!t.isMemberExpression(ref)){var memo=this.scope.maybeGenerateMemoised(ref,true);if(memo){this.nodes.push(this.buildVariableDeclaration(memo,ref));ref=memo}}this.push(pattern,ref);return this.nodes};return DestructuringTransformer}()},{"../../../messages":60,"../../../types":196}],113:[function(require,module,exports){"use strict";exports.__esModule=true;exports._ForOfStatementArray=_ForOfStatementArray;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _messages=require("../../../messages");var messages=_interopRequireWildcard(_messages);var _util=require("../../../util");var util=_interopRequireWildcard(_util);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var visitor={ForOfStatement:function ForOfStatement(node,parent,scope,file){if(this.get("right").isArrayExpression()){return _ForOfStatementArray.call(this,node,scope,file)}var callback=spec;if(file.isLoose("es6.forOf"))callback=loose;var build=callback(node,parent,scope,file);var declar=build.declar;var loop=build.loop;var block=loop.body;this.ensureBlock();if(declar){block.body.push(declar)}block.body=block.body.concat(node.body.body);t.inherits(loop,node);t.inherits(loop.body,node.body);if(build.replaceParent){this.parentPath.replaceWithMultiple(build.node);this.dangerouslyRemove()}else{return build.node}}};exports.visitor=visitor;function _ForOfStatementArray(node,scope){var nodes=[];var right=node.right;if(!t.isIdentifier(right)||!scope.hasBinding(right.name)){var uid=scope.generateUidIdentifier("arr");nodes.push(t.variableDeclaration("var",[t.variableDeclarator(uid,right)]));right=uid}var iterationKey=scope.generateUidIdentifier("i");var loop=util.template("for-of-array",{BODY:node.body,KEY:iterationKey,ARR:right});t.inherits(loop,node);t.ensureBlock(loop);var iterationValue=t.memberExpression(right,iterationKey,true);var left=node.left;if(t.isVariableDeclaration(left)){left.declarations[0].init=iterationValue;loop.body.body.unshift(left)}else{loop.body.body.unshift(t.expressionStatement(t.assignmentExpression("=",left,iterationValue)))}if(this.parentPath.isLabeledStatement()){loop=t.labeledStatement(this.parentPath.node.label,loop)}nodes.push(loop);return nodes}var loose=function loose(node,parent,scope,file){var left=node.left;var declar,id;if(t.isIdentifier(left)||t.isPattern(left)||t.isMemberExpression(left)){id=left}else if(t.isVariableDeclaration(left)){id=scope.generateUidIdentifier("ref");declar=t.variableDeclaration(left.kind,[t.variableDeclarator(left.declarations[0].id,id)])}else{throw file.errorWithNode(left,messages.get("unknownForHead",left.type))}var iteratorKey=scope.generateUidIdentifier("iterator");var isArrayKey=scope.generateUidIdentifier("isArray");var loop=util.template("for-of-loose",{LOOP_OBJECT:iteratorKey,IS_ARRAY:isArrayKey,OBJECT:node.right,INDEX:scope.generateUidIdentifier("i"),ID:id});if(!declar){loop.body.body.shift()}return{declar:declar,node:loop,loop:loop}};var spec=function spec(node,parent,scope,file){var left=node.left;var declar;var stepKey=scope.generateUidIdentifier("step");var stepValue=t.memberExpression(stepKey,t.identifier("value"));if(t.isIdentifier(left)||t.isPattern(left)||t.isMemberExpression(left)){declar=t.expressionStatement(t.assignmentExpression("=",left,stepValue))}else if(t.isVariableDeclaration(left)){declar=t.variableDeclaration(left.kind,[t.variableDeclarator(left.declarations[0].id,stepValue)])}else{throw file.errorWithNode(left,messages.get("unknownForHead",left.type))}var iteratorKey=scope.generateUidIdentifier("iterator");var template=util.template("for-of",{ITERATOR_HAD_ERROR_KEY:scope.generateUidIdentifier("didIteratorError"),ITERATOR_COMPLETION:scope.generateUidIdentifier("iteratorNormalCompletion"),ITERATOR_ERROR_KEY:scope.generateUidIdentifier("iteratorError"),ITERATOR_KEY:iteratorKey,STEP_KEY:stepKey,OBJECT:node.right,BODY:null});var isLabeledParent=t.isLabeledStatement(parent);var tryBody=template[3].block.body;var loop=tryBody[0];if(isLabeledParent){tryBody[0]=t.labeledStatement(parent.label,loop)}return{replaceParent:isLabeledParent,declar:declar,loop:loop,node:template}}},{"../../../messages":60,"../../../types":196,"../../../util":199}],114:[function(require,module,exports){"use strict";exports.__esModule=true;var metadata={group:"builtin-pre"};exports.metadata=metadata;var visitor={Literal:function Literal(node){if(typeof node.value==="number"&&/^0[ob]/i.test(node.raw)){node.raw=undefined}if(typeof node.value==="string"&&/\\[u]/gi.test(node.raw)){node.raw=undefined}}};exports.visitor=visitor},{}],115:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);function keepBlockHoist(node,nodes){if(node._blockHoist){for(var i=0;ilastNonDefaultParam}var lastNonDefaultParam=_helpersGetFunctionArity2["default"](node);var params=this.get("params");for(var i=0;i",len,start),t.binaryExpression("-",len,start),t.literal(0))}var loop=util.template("rest",{ARRAY_TYPE:restParam.typeAnnotation,ARGUMENTS:argsId,ARRAY_KEY:arrKey,ARRAY_LEN:arrLen,START:start,ARRAY:rest,KEY:key,LEN:len});if(state.deopted){loop._blockHoist=node.params.length+1;node.body.body.unshift(loop)}else{loop._blockHoist=1;var target=this.getEarliestCommonAncestorFrom(state.references).getStatementParent();var highestLoop;target.findParent(function(path){if(path.isLoop()){highestLoop=path}else if(path.isFunction()){return true}});if(highestLoop)target=highestLoop;target.insertBefore(loop)}}};exports.visitor=visitor},{"../../../../types":196,"../../../../util":199}],120:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);function loose(node,body,objId){var _arr=node.properties;for(var _i=0;_i<_arr.length;_i++){var prop=_arr[_i];body.push(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(objId,prop.key,prop.computed||t.isLiteral(prop.key)),prop.value)))}}function spec(node,body,objId,initProps,file){var _arr2=node.properties;for(var _i2=0;_i2<_arr2.length;_i2++){var prop=_arr2[_i2];if(t.isLiteral(t.toComputedKey(prop),{value:"__proto__"})){initProps.push(prop);continue}var key=prop.key;if(t.isIdentifier(key)&&!prop.computed){key=t.literal(key.name)}var bodyNode=t.callExpression(file.addHelper("define-property"),[objId,key,prop.value]);body.push(t.expressionStatement(bodyNode))}if(body.length===1){var first=body[0].expression;if(t.isCallExpression(first)){first.arguments[0]=t.objectExpression(initProps);return first}}}var visitor={ObjectExpression:{exit:function exit(node,parent,scope,file){var hasComputed=false;var _arr3=node.properties;for(var _i3=0;_i3<_arr3.length;_i3++){var prop=_arr3[_i3];hasComputed=t.isProperty(prop,{computed:true,kind:"init"});if(hasComputed)break}if(!hasComputed)return;var initProps=[];var stopInits=false;node.properties=node.properties.filter(function(prop){if(prop.computed){stopInits=true}if(prop.kind!=="init"||!stopInits){initProps.push(prop);return false}else{return true}});var objId=scope.generateUidIdentifierBasedOnNode(parent);var body=[];var callback=spec;if(file.isLoose("es6.properties.computed"))callback=loose;var result=callback(node,body,objId,initProps,file);if(result)return result;body.unshift(t.variableDeclaration("var",[t.variableDeclarator(objId,t.objectExpression(initProps))]));body.push(t.expressionStatement(objId));return body}}};exports.visitor=visitor},{"../../../types":196}],121:[function(require,module,exports){"use strict";exports.__esModule=true;var visitor={Property:function Property(node){if(node.method){node.method=false}if(node.shorthand){node.shorthand=false}}};exports.visitor=visitor},{}],122:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _helpersRegex=require("../../helpers/regex");var regex=_interopRequireWildcard(_helpersRegex);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var visitor={Literal:function Literal(node){if(!regex.is(node,"y"))return;return t.newExpression(t.identifier("RegExp"),[t.literal(node.regex.pattern),t.literal(node.regex.flags)])}};exports.visitor=visitor},{"../../../types":196,"../../helpers/regex":80}],123:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _regexpuRewritePattern=require("regexpu/rewrite-pattern");var _regexpuRewritePattern2=_interopRequireDefault(_regexpuRewritePattern);var _helpersRegex=require("../../helpers/regex");var regex=_interopRequireWildcard(_helpersRegex);var visitor={Literal:function Literal(node){if(!regex.is(node,"u"))return;node.regex.pattern=_regexpuRewritePattern2["default"](node.regex.pattern,node.regex.flags);regex.pullFlag(node,"u")}};exports.visitor=visitor},{"../../helpers/regex":80,"regexpu/rewrite-pattern":610}],124:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-pre",optional:true};exports.metadata=metadata;var visitor={ArrowFunctionExpression:function ArrowFunctionExpression(node,parent,scope,file){if(node.shadow)return;node.shadow={"this":false};var boundThis=t.thisExpression();boundThis._forceShadow=this;t.ensureBlock(node);this.get("body").unshiftContainer("body",t.expressionStatement(t.callExpression(file.addHelper("new-arrow-check"),[t.thisExpression(),boundThis])));return t.callExpression(t.memberExpression(node,t.identifier("bind")),[t.thisExpression()])}};exports.visitor=visitor},{"../../../types":196}],125:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);function buildAssert(node,file){return t.callExpression(file.addHelper("temporal-assert-defined"),[node,t.literal(node.name),file.addHelper("temporal-undefined")])}function references(node,scope,state){var declared=state.letRefs[node.name];if(!declared)return false;return scope.getBindingIdentifier(node.name)===declared}var refVisitor={ReferencedIdentifier:function ReferencedIdentifier(node,parent,scope,state){if(t.isFor(parent)&&parent.left===node)return;if(!references(node,scope,state))return;var assert=buildAssert(node,state.file);this.skip();if(t.isUpdateExpression(parent)){if(parent._ignoreBlockScopingTDZ)return;this.parentPath.replaceWith(t.sequenceExpression([assert,parent]))}else{return t.logicalExpression("&&",assert,node)}},AssignmentExpression:{exit:function exit(node,parent,scope,state){if(node._ignoreBlockScopingTDZ)return;var nodes=[];var ids=this.getBindingIdentifiers();for(var name in ids){var id=ids[name];if(references(id,scope,state)){nodes.push(buildAssert(id,state.file))}}if(nodes.length){node._ignoreBlockScopingTDZ=true;nodes.push(node);return nodes.map(t.expressionStatement)}}}};var metadata={optional:true,group:"builtin-advanced"};exports.metadata=metadata;var visitor={"Program|Loop|BlockStatement":{exit:function exit(node,parent,scope,file){var letRefs=node._letReferences;if(!letRefs)return;this.traverse(refVisitor,{letRefs:letRefs,file:file})}}};exports.visitor=visitor},{"../../../types":196}],126:[function(require,module,exports){"use strict";exports.__esModule=true; -function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-pre",optional:true};exports.metadata=metadata;var visitor={Program:function Program(){var id=this.scope.generateUidIdentifier("null");this.unshiftContainer("body",[t.variableDeclaration("var",[t.variableDeclarator(id,t.literal(null))]),t.exportNamedDeclaration(null,[t.exportSpecifier(id,t.identifier("__proto__"))])])}};exports.visitor=visitor},{"../../../types":196}],127:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={optional:true};exports.metadata=metadata;var visitor={UnaryExpression:function UnaryExpression(node,parent,scope,file){if(node._ignoreSpecSymbols)return;if(this.parentPath.isBinaryExpression()&&t.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator)>=0){var opposite=this.getOpposite();if(opposite.isLiteral()&&opposite.node.value!=="symbol"&&opposite.node.value!=="object")return}if(node.operator==="typeof"){var call=t.callExpression(file.addHelper("typeof"),[node.argument]);if(this.get("argument").isIdentifier()){var undefLiteral=t.literal("undefined");var unary=t.unaryExpression("typeof",node.argument);unary._ignoreSpecSymbols=true;return t.conditionalExpression(t.binaryExpression("===",unary,undefLiteral),undefLiteral,call)}else{return call}}},BinaryExpression:function BinaryExpression(node,parent,scope,file){if(node.operator==="instanceof"){return t.callExpression(file.addHelper("instanceof"),[node.left,node.right])}},"VariableDeclaration|FunctionDeclaration":function VariableDeclarationFunctionDeclaration(node){if(node._generated)this.skip()}};exports.visitor=visitor},{"../../../types":196}],128:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={optional:true,group:"builtin-pre"};exports.metadata=metadata;var visitor={TemplateLiteral:function TemplateLiteral(node,parent){if(t.isTaggedTemplateExpression(parent))return;for(var i=0;i0){var declarations=_lodashArrayFlatten2["default"](_lodashCollectionMap2["default"](this.vars,function(decl){return decl.declarations}));var assignment=_lodashCollectionReduceRight2["default"](declarations,function(expr,decl){return t.assignmentExpression("=",decl.id,expr)},t.identifier("undefined"));var statement=t.expressionStatement(assignment);statement._blockHoist=Infinity;body.unshift(statement)}var paramDecls=this.paramDecls;if(paramDecls.length>0){var paramDecl=t.variableDeclaration("var",paramDecls);paramDecl._blockHoist=Infinity;body.unshift(paramDecl)}body.unshift(t.expressionStatement(t.assignmentExpression("=",this.getAgainId(),t.literal(false))));node.body=util.template("tail-call-body",{FUNCTION_ID:this.getFunctionId(),AGAIN_ID:this.getAgainId(),BLOCK:node.body});var topVars=[];if(this.needsThis){var _arr=this.thisPaths;for(var _i=0;_i<_arr.length;_i++){var path=_arr[_i];path.replaceWith(this.getThisId())}topVars.push(t.variableDeclarator(this.getThisId(),t.thisExpression()))}if(this.needsArguments||this.setsArguments){var _arr2=this.argumentsPaths;for(var _i2=0;_i2<_arr2.length;_i2++){var _path=_arr2[_i2];_path.replaceWith(this.argumentsId)}var decl=t.variableDeclarator(this.argumentsId);if(this.argumentsId){decl.init=t.identifier("arguments");decl.init._shadowedFunctionLiteral=this.path}topVars.push(decl)}var leftId=this.leftId;if(leftId){topVars.push(t.variableDeclarator(leftId))}if(topVars.length>0){node.body.body.unshift(t.variableDeclaration("var",topVars))}};TailCallTransformer.prototype.subTransform=function subTransform(node){if(!node)return;var handler=this["subTransform"+node.type];if(handler)return handler.call(this,node)};TailCallTransformer.prototype.subTransformConditionalExpression=function subTransformConditionalExpression(node){var callConsequent=this.subTransform(node.consequent);var callAlternate=this.subTransform(node.alternate);if(!callConsequent&&!callAlternate){return}node.type="IfStatement";node.consequent=callConsequent?t.toBlock(callConsequent):returnBlock(node.consequent);if(callAlternate){node.alternate=t.isIfStatement(callAlternate)?callAlternate:t.toBlock(callAlternate)}else{node.alternate=returnBlock(node.alternate)}return[node]};TailCallTransformer.prototype.subTransformLogicalExpression=function subTransformLogicalExpression(node){var callRight=this.subTransform(node.right);if(!callRight)return;var leftId=this.getLeftId();var testExpr=t.assignmentExpression("=",leftId,node.left);if(node.operator==="&&"){testExpr=t.unaryExpression("!",testExpr)}return[t.ifStatement(testExpr,returnBlock(leftId))].concat(callRight)};TailCallTransformer.prototype.subTransformSequenceExpression=function subTransformSequenceExpression(node){var seq=node.expressions;var lastCall=this.subTransform(seq[seq.length-1]);if(!lastCall){return}if(--seq.length===1){node=seq[0]}return[t.expressionStatement(node)].concat(lastCall)};TailCallTransformer.prototype.subTransformCallExpression=function subTransformCallExpression(node){var callee=node.callee;var thisBinding,args;if(t.isMemberExpression(callee,{computed:false})&&t.isIdentifier(callee.property)){switch(callee.property.name){case"call":args=t.arrayExpression(node.arguments.slice(1));break;case"apply":args=node.arguments[1]||t.identifier("undefined");this.needsArguments=true;break;default:return}thisBinding=node.arguments[0];callee=callee.object}if(!t.isIdentifier(callee)||!this.scope.bindingIdentifierEquals(callee.name,this.ownerId)){return}this.hasTailRecursion=true;if(this.hasDeopt())return;var body=[];if(this.needsThis&&!t.isThisExpression(thisBinding)){body.push(t.expressionStatement(t.assignmentExpression("=",this.getThisId(),thisBinding||t.identifier("undefined"))))}if(!args){args=t.arrayExpression(node.arguments)}var argumentsId=this.getArgumentsId();var params=this.getParams();if(this.needsArguments){body.push(t.expressionStatement(t.assignmentExpression("=",argumentsId,args)))}if(t.isArrayExpression(args)){var elems=args.elements;while(elems.length1){var root=buildBinaryExpression(nodes.shift(),nodes.shift());var _arr3=nodes;for(var _i3=0;_i3<_arr3.length;_i3++){var _node=_arr3[_i3];root=buildBinaryExpression(root,_node)}this.replaceWith(root)}else{return nodes[0]}}};exports.visitor=visitor},{"../../../types":196}],132:[function(require,module,exports){"use strict";exports.__esModule=true;var metadata={stage:2};exports.metadata=metadata},{}],133:[function(require,module,exports){"use strict";exports.__esModule=true;var metadata={stage:0,dependencies:["es6.classes"]};exports.metadata=metadata},{}],134:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _helpersBuildComprehension=require("../../helpers/build-comprehension");var _helpersBuildComprehension2=_interopRequireDefault(_helpersBuildComprehension);var _traversal=require("../../../traversal");var _traversal2=_interopRequireDefault(_traversal);var _util=require("../../../util");var util=_interopRequireWildcard(_util);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={stage:0};exports.metadata=metadata;var visitor={ComprehensionExpression:function ComprehensionExpression(node,parent,scope){var callback=array;if(node.generator)callback=generator;return callback(node,parent,scope)}};exports.visitor=visitor;function generator(node){var body=[];var container=t.functionExpression(null,[],t.blockStatement(body),true);container.shadow=true;body.push(_helpersBuildComprehension2["default"](node,function(){return t.expressionStatement(t.yieldExpression(node.body))}));return t.callExpression(container,[])}function array(node,parent,scope){var uid=scope.generateUidIdentifierBasedOnNode(parent);var container=util.template("array-comprehension-container",{KEY:uid});container.callee.shadow=true;var block=container.callee.body;var body=block.body;if(_traversal2["default"].hasType(node,scope,"YieldExpression",t.FUNCTION_TYPES)){container.callee.generator=true;container=t.yieldExpression(container,true)}var returnStatement=body.pop();body.push(_helpersBuildComprehension2["default"](node,function(){return util.template("array-push",{STATEMENT:node.body,KEY:uid},true)}));body.push(returnStatement);return container}},{"../../../traversal":165,"../../../types":196,"../../../util":199,"../../helpers/build-comprehension":71}],135:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _helpersMemoiseDecorators=require("../../helpers/memoise-decorators");var _helpersMemoiseDecorators2=_interopRequireDefault(_helpersMemoiseDecorators);var _helpersDefineMap=require("../../helpers/define-map");var defineMap=_interopRequireWildcard(_helpersDefineMap);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={dependencies:["es6.classes"],optional:true,stage:1};exports.metadata=metadata;var visitor={ObjectExpression:function ObjectExpression(node,parent,scope,file){var hasDecorators=false;for(var i=0;i=1){nodes.push(node)}return nodes}};exports.visitor=visitor},{"../../../types":196}],139:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={optional:true,stage:0};exports.metadata=metadata;function getTempId(scope){var id=scope.path.getData("functionBind");if(id)return id;id=scope.generateDeclaredUidIdentifier("context");return scope.path.setData("functionBind",id)}function getStaticContext(bind,scope){var object=bind.object||bind.callee.object;return scope.isStatic(object)&&object}function inferBindContext(bind,scope){var staticContext=getStaticContext(bind,scope);if(staticContext)return staticContext;var tempId=getTempId(scope);if(bind.object){bind.callee=t.sequenceExpression([t.assignmentExpression("=",tempId,bind.object),bind.callee])}else{bind.callee.object=t.assignmentExpression("=",tempId,bind.callee.object)}return tempId}var visitor={CallExpression:function CallExpression(node,parent,scope){var bind=node.callee;if(!t.isBindExpression(bind))return;var context=inferBindContext(bind,scope);node.callee=t.memberExpression(bind.callee,t.identifier("call"));node.arguments.unshift(context)},BindExpression:function BindExpression(node,parent,scope){var context=inferBindContext(node,scope);return t.callExpression(t.memberExpression(node.callee,t.identifier("bind")),[context])}};exports.visitor=visitor},{"../../../types":196}],140:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={stage:2,dependencies:["es6.destructuring"]};exports.metadata=metadata;var hasSpread=function hasSpread(node){for(var i=0;i=opts.stage)return true}function optional(transformer,opts){if(transformer.metadata.optional&&!_lodashCollectionIncludes2["default"](opts.optional,transformer.key))return false}},{"lodash/collection/includes":439}],143:[function(require,module,exports){"use strict";exports.__esModule=true;exports["default"]={"minification.constantFolding":require("babel-plugin-constant-folding"),strict:require("./other/strict"),eval:require("babel-plugin-eval"),_validation:require("./internal/validation"),_hoistDirectives:require("./internal/hoist-directives"),"minification.removeDebugger":require("babel-plugin-remove-debugger"),"minification.removeConsole":require("babel-plugin-remove-console"),"utility.inlineEnvironmentVariables":require("babel-plugin-inline-environment-variables"),"minification.deadCodeElimination":require("babel-plugin-dead-code-elimination"),_modules:require("./internal/modules"),"react.displayName":require("babel-plugin-react-display-name"),"es6.spec.modules":require("./es6/spec.modules"),"es6.spec.arrowFunctions":require("./es6/spec.arrow-functions"),"es6.spec.templateLiterals":require("./es6/spec.template-literals"),"es6.templateLiterals":require("./es6/template-literals"),"es6.literals":require("./es6/literals"),"validation.undeclaredVariableCheck":require("babel-plugin-undeclared-variables-check"),"spec.functionName":require("./spec/function-name"),"es7.classProperties":require("./es7/class-properties"),"es7.trailingFunctionCommas":require("./es7/trailing-function-commas"),"es7.asyncFunctions":require("./es7/async-functions"),"es7.decorators":require("./es7/decorators"),"validation.react":require("./validation/react"),"es6.arrowFunctions":require("./es6/arrow-functions"),"spec.blockScopedFunctions":require("./spec/block-scoped-functions"),"optimisation.react.constantElements":require("babel-plugin-react-constant-elements"),"optimisation.react.inlineElements":require("./optimisation/react.inline-elements"),"es7.comprehensions":require("./es7/comprehensions"),"es6.classes":require("./es6/classes"),asyncToGenerator:require("./other/async-to-generator"),bluebirdCoroutines:require("./other/bluebird-coroutines"),"es6.objectSuper":require("./es6/object-super"),"es7.objectRestSpread":require("./es7/object-rest-spread"),"es7.exponentiationOperator":require("./es7/exponentiation-operator"),"es5.properties.mutators":require("./es5/properties.mutators"),"es6.properties.shorthand":require("./es6/properties.shorthand"),"es6.properties.computed":require("./es6/properties.computed"),"optimisation.flow.forOf":require("./optimisation/flow.for-of"),"es6.forOf":require("./es6/for-of"),"es6.regex.sticky":require("./es6/regex.sticky"),"es6.regex.unicode":require("./es6/regex.unicode"),"es6.constants":require("./es6/constants"),"es7.exportExtensions":require("./es7/export-extensions"),"spec.protoToAssign":require("babel-plugin-proto-to-assign"),"es7.doExpressions":require("./es7/do-expressions"),"es6.spec.symbols":require("./es6/spec.symbols"),"es7.functionBind":require("./es7/function-bind"),"spec.undefinedToVoid":require("babel-plugin-undefined-to-void"),"es6.spread":require("./es6/spread"),"es6.parameters":require("./es6/parameters"),"es6.destructuring":require("./es6/destructuring"),"es6.blockScoping":require("./es6/block-scoping"),"es6.spec.blockScoping":require("./es6/spec.block-scoping"),reactCompat:require("./other/react-compat"),react:require("./other/react"),regenerator:require("./other/regenerator"),runtime:require("babel-plugin-runtime"),"es6.modules":require("./es6/modules"),_moduleFormatter:require("./internal/module-formatter"), -"es6.tailCall":require("./es6/tail-call"),_shadowFunctions:require("./internal/shadow-functions"),"es3.propertyLiterals":require("./es3/property-literals"),"es3.memberExpressionLiterals":require("./es3/member-expression-literals"),"minification.memberExpressionLiterals":require("babel-plugin-member-expression-literals"),"minification.propertyLiterals":require("babel-plugin-property-literals"),_blockHoist:require("./internal/block-hoist"),jscript:require("babel-plugin-jscript"),flow:require("./other/flow"),"optimisation.modules.system":require("./optimisation/modules.system")};module.exports=exports["default"]},{"./es3/member-expression-literals":103,"./es3/property-literals":104,"./es5/properties.mutators":105,"./es6/arrow-functions":106,"./es6/block-scoping":107,"./es6/classes":108,"./es6/constants":111,"./es6/destructuring":112,"./es6/for-of":113,"./es6/literals":114,"./es6/modules":115,"./es6/object-super":116,"./es6/parameters":118,"./es6/properties.computed":120,"./es6/properties.shorthand":121,"./es6/regex.sticky":122,"./es6/regex.unicode":123,"./es6/spec.arrow-functions":124,"./es6/spec.block-scoping":125,"./es6/spec.modules":126,"./es6/spec.symbols":127,"./es6/spec.template-literals":128,"./es6/spread":129,"./es6/tail-call":130,"./es6/template-literals":131,"./es7/async-functions":132,"./es7/class-properties":133,"./es7/comprehensions":134,"./es7/decorators":135,"./es7/do-expressions":136,"./es7/exponentiation-operator":137,"./es7/export-extensions":138,"./es7/function-bind":139,"./es7/object-rest-spread":140,"./es7/trailing-function-commas":141,"./internal/block-hoist":144,"./internal/hoist-directives":145,"./internal/module-formatter":146,"./internal/modules":147,"./internal/shadow-functions":148,"./internal/validation":149,"./optimisation/flow.for-of":150,"./optimisation/modules.system":151,"./optimisation/react.inline-elements":152,"./other/async-to-generator":153,"./other/bluebird-coroutines":154,"./other/flow":155,"./other/react":157,"./other/react-compat":156,"./other/regenerator":158,"./other/strict":159,"./spec/block-scoped-functions":160,"./spec/function-name":161,"./validation/react":162,"babel-plugin-constant-folding":200,"babel-plugin-dead-code-elimination":201,"babel-plugin-eval":202,"babel-plugin-inline-environment-variables":203,"babel-plugin-jscript":204,"babel-plugin-member-expression-literals":205,"babel-plugin-property-literals":206,"babel-plugin-proto-to-assign":207,"babel-plugin-react-constant-elements":208,"babel-plugin-react-display-name":209,"babel-plugin-remove-console":210,"babel-plugin-remove-debugger":211,"babel-plugin-runtime":213,"babel-plugin-undeclared-variables-check":214,"babel-plugin-undefined-to-void":216}],144:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashCollectionSortBy=require("lodash/collection/sortBy");var _lodashCollectionSortBy2=_interopRequireDefault(_lodashCollectionSortBy);var metadata={group:"builtin-trailing"};exports.metadata=metadata;var visitor={Block:{exit:function exit(node){var hasChange=false;for(var i=0;i=0){comment.value=comment.value.replace(FLOW_DIRECTIVE,"");if(!comment.value.replace(/\*/g,"").trim())comment._displayed=true}}},Flow:function Flow(){this.dangerouslyRemove()},ClassProperty:function ClassProperty(node){node.typeAnnotation=null;if(!node.value)this.dangerouslyRemove()},Class:function Class(node){node["implements"]=null},Function:function Function(node){for(var i=0;i0){nodePath=nodePath.get(keysAlongPath.pop())}return nodePath}},{"../../../types":196,regenerator:561}],159:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var metadata={group:"builtin-pre"};exports.metadata=metadata;var THIS_BREAK_KEYS=["FunctionExpression","FunctionDeclaration","ClassProperty"];function isUseStrict(node){if(!t.isLiteral(node))return false;if(node.raw&&node.rawValue===node.value){return node.rawValue==="use strict"}else{return node.value==="use strict"}}var visitor={Program:{enter:function enter(program){var first=program.body[0];var directive;if(t.isExpressionStatement(first)&&isUseStrict(first.expression)){directive=first}else{directive=t.expressionStatement(t.literal("use strict"));this.unshiftContainer("body",directive);if(first){directive.leadingComments=first.leadingComments;first.leadingComments=[]}}directive._blockHoist=Infinity}},ThisExpression:function ThisExpression(){if(!this.findParent(function(path){return!path.is("shadow")&&THIS_BREAK_KEYS.indexOf(path.type)>=0})){return t.identifier("undefined")}}};exports.visitor=visitor},{"../../../types":196}],160:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);function statementList(key,path){var paths=path.get(key);for(var i=0;i=0)continue;visited.push(path.node);if(path.visit()){stop=true;break}}var _arr3=queue;for(var _i3=0;_i3<_arr3.length;_i3++){var path=_arr3[_i3];path.shiftContext()}this.queue=null;return stop};TraversalContext.prototype.visitSingle=function visitSingle(node,key){if(this.shouldVisit(node[key])){var path=this.create(node,node,key);path.visit();path.shiftContext()}};TraversalContext.prototype.visit=function visit(node,key){var nodes=node[key];if(!nodes)return;if(Array.isArray(nodes)){return this.visitMultiple(nodes,node,key)}else{return this.visitSingle(node,key)}};return TraversalContext}();exports["default"]=TraversalContext;module.exports=exports["default"]},{"../types":196,"./path":172}],164:[function(require,module,exports){"use strict";exports.__esModule=true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Hub=function Hub(file){_classCallCheck(this,Hub);this.file=file};exports["default"]=Hub;module.exports=exports["default"]},{}],165:[function(require,module,exports){"use strict";exports.__esModule=true;exports["default"]=traverse;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _context=require("./context");var _context2=_interopRequireDefault(_context);var _visitors=require("./visitors");var visitors=_interopRequireWildcard(_visitors);var _messages=require("../messages");var messages=_interopRequireWildcard(_messages);var _lodashCollectionIncludes=require("lodash/collection/includes");var _lodashCollectionIncludes2=_interopRequireDefault(_lodashCollectionIncludes);var _types=require("../types");var t=_interopRequireWildcard(_types);function traverse(parent,opts,scope,state,parentPath){if(!parent)return;if(!opts)opts={};if(!opts.noScope&&!scope){if(parent.type!=="Program"&&parent.type!=="File"){throw new Error(messages.get("traverseNeedsParent",parent.type))}}visitors.explode(opts);if(Array.isArray(parent)){for(var i=0;icurrentKeyIndex){earliest=path}}return earliest})}function getDeepestCommonAncestorFrom(paths,filter){var _this=this;if(!paths.length){return this}if(paths.length===1){return paths[0]}var minDepth=Infinity;var lastCommonIndex,lastCommon;var ancestries=paths.map(function(path){var ancestry=[];do{ancestry.unshift(path)}while((path=path.parentPath)&&path!==_this);if(ancestry.length-1}function visit(){if(this.isBlacklisted())return false;if(this.opts.shouldSkip&&this.opts.shouldSkip(this))return false;this.call("enter");if(this.shouldSkip){return this.shouldStop}var node=this.node;var opts=this.opts;if(node){if(Array.isArray(node)){for(var i=0;i":return left>right;case"<=":return left<=right;case">=":return left>=right;case"==":return left==right;case"!=":return left!=right;case"===":return left===right;case"!==":return left!==right}}if(path.isCallExpression()){var callee=path.get("callee");var context;var func;if(callee.isIdentifier()&&!path.scope.getBinding(callee.node.name,true)&&VALID_CALLEES.indexOf(callee.node.name)>=0){func=global[node.callee.name]}if(callee.isMemberExpression()){var object=callee.get("object");var property=callee.get("property");if(object.isIdentifier()&&property.isIdentifier()&&VALID_CALLEES.indexOf(object.node.name)>=0){context=global[object.node.name];func=context[property.node.name]}if(object.isLiteral()&&property.isIdentifier()){var type=typeof object.node.value;if(type==="string"||type==="number"){context=object.node.value;func=context[property.node.name]}}}if(func){var args=path.get("arguments").map(evaluate);if(!confident)return;return func.apply(context,args)}}confident=false}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],171:[function(require,module,exports){"use strict";exports.__esModule=true;exports.getStatementParent=getStatementParent;exports.getOpposite=getOpposite;exports.getCompletionRecords=getCompletionRecords;exports.getSibling=getSibling;exports.get=get;exports._getKey=_getKey;exports._getPattern=_getPattern;exports.getBindingIdentifiers=getBindingIdentifiers;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _index=require("./index");var _index2=_interopRequireDefault(_index);var _types=require("../../types");var t=_interopRequireWildcard(_types);function getStatementParent(){var path=this;do{if(!path.parentPath||Array.isArray(path.container)&&path.isStatement()){break}else{path=path.parentPath}}while(path);if(path&&(path.isProgram()||path.isFile())){throw new Error("File/Program node, we can't possibly find a statement parent to this")}return path}function getOpposite(){if(this.key==="left"){return this.getSibling("right")}else if(this.key==="right"){return this.getSibling("left")}}function getCompletionRecords(){var paths=[];var add=function add(path){if(path)paths=paths.concat(path.getCompletionRecords())};if(this.isIfStatement()){add(this.get("consequent"));add(this.get("alternate"))}else if(this.isDoExpression()||this.isFor()||this.isWhile()){add(this.get("body"))}else if(this.isProgram()||this.isBlockStatement()){add(this.get("body").pop())}else if(this.isFunction()){return this.get("body").getCompletionRecords()}else if(this.isTryStatement()){add(this.get("block"));add(this.get("handler"));add(this.get("finalizer"))}else{paths.push(this)}return paths}function getSibling(key){return _index2["default"].get({parentPath:this.parentPath,parent:this.parent,container:this.container,listKey:this.listKey,key:key})}function get(key,context){if(context===true)context=this.context;var parts=key.split(".");if(parts.length===1){return this._getKey(key,context)}else{return this._getPattern(parts,context)}}function _getKey(key,context){var _this=this;var node=this.node;var container=node[key];if(Array.isArray(container)){return container.map(function(_,i){return _index2["default"].get({listKey:key,parentPath:_this,parent:node,container:container,key:i}).setContext(context)})}else{return _index2["default"].get({parentPath:this,parent:node,container:node,key:key}).setContext(context)}}function _getPattern(parts,context){var path=this;var _arr=parts;for(var _i=0;_i<_arr.length;_i++){var part=_arr[_i];if(part==="."){path=path.parentPath}else{if(Array.isArray(path)){path=path[part]}else{path=path.get(part,context)}}}return path}function getBindingIdentifiers(duplicates){return t.getBindingIdentifiers(this.node,duplicates)}},{"../../types":196,"./index":172}],172:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _libVirtualTypes=require("./lib/virtual-types");var virtualTypes=_interopRequireWildcard(_libVirtualTypes);var _index=require("../index");var _index2=_interopRequireDefault(_index);var _lodashObjectAssign=require("lodash/object/assign");var _lodashObjectAssign2=_interopRequireDefault(_lodashObjectAssign);var _scope=require("../scope");var _scope2=_interopRequireDefault(_scope);var _types=require("../../types");var t=_interopRequireWildcard(_types);var NodePath=function(){function NodePath(hub,parent){_classCallCheck(this,NodePath);this.contexts=[];this.parent=parent;this.data={};this.hub=hub;this.shouldSkip=false;this.shouldStop=false;this.removed=false;this.state=null;this.opts=null;this.skipKeys=null;this.parentPath=null;this.context=null;this.container=null;this.listKey=null;this.inList=false;this.parentKey=null;this.key=null;this.node=null;this.scope=null;this.type=null;this.typeAnnotation=null}NodePath.get=function get(_ref){var hub=_ref.hub;var parentPath=_ref.parentPath;var parent=_ref.parent;var container=_ref.container;var listKey=_ref.listKey;var key=_ref.key;if(!hub&&parentPath){hub=parentPath.hub}var targetNode=container[key];var paths=parent._paths=parent._paths||[];var path;for(var i=0;i=0)continue;visitedScopes.push(violationScope);constantViolations.push(violation);if(violationScope===path.scope){constantViolations=[violation];break}}constantViolations=constantViolations.concat(functionConstantViolations);var _arr2=constantViolations;for(var _i2=0;_i2<_arr2.length;_i2++){var violation=_arr2[_i2];types.push(violation.getTypeAnnotation())}}if(types.length){return t.createUnionTypeAnnotation(types)}}function getConstantViolationsBefore(binding,path,functions){var violations=binding.constantViolations.slice();violations.unshift(binding.path);return violations.filter(function(violation){violation=violation.resolve();var status=violation._guessExecutionStatusRelativeTo(path);if(functions&&status==="function")functions.push(violation);return status==="before"})}function inferAnnotationFromBinaryExpression(name,path){var operator=path.node.operator;var right=path.get("right").resolve();var left=path.get("left").resolve();var target;if(left.isIdentifier({name:name})){target=right}else if(right.isIdentifier({name:name})){target=left}if(target){if(operator==="==="){return target.getTypeAnnotation()}else if(t.BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator)>=0){return t.numberTypeAnnotation()}else{return}}else{if(operator!=="===")return}var typeofPath;var typePath;if(left.isUnaryExpression({operator:"typeof"})){typeofPath=left;typePath=right}else if(right.isUnaryExpression({operator:"typeof"})){typeofPath=right;typePath=left}if(!typePath&&!typeofPath)return;typePath=typePath.resolve();if(!typePath.isLiteral())return;var typeValue=typePath.node.value;if(typeof typeValue!=="string")return;if(!typeofPath.get("argument").isIdentifier({name:name}))return;return t.createTypeAnnotationBasedOnTypeof(typePath.node.value)}function getParentConditionalPath(path){var parentPath;while(parentPath=path.parentPath){if(parentPath.isIfStatement()||parentPath.isConditionalExpression()){if(path.key==="test"){return}else{return parentPath}}else{path=parentPath}}}function getConditionalAnnotation(path,name){var ifStatement=getParentConditionalPath(path);if(!ifStatement)return;var test=ifStatement.get("test");var paths=[test];var types=[];do{var _path=paths.shift().resolve();if(_path.isLogicalExpression()){paths.push(_path.get("left"));paths.push(_path.get("right"))}if(_path.isBinaryExpression()){var type=inferAnnotationFromBinaryExpression(name,_path);if(type)types.push(type)}}while(paths.length);if(types.length){return{typeAnnotation:t.createUnionTypeAnnotation(types),ifStatement:ifStatement}}else{return getConditionalAnnotation(ifStatement,name)}}module.exports=exports["default"]},{"../../../types":196}],175:[function(require,module,exports){"use strict";exports.__esModule=true;exports.VariableDeclarator=VariableDeclarator;exports.TypeCastExpression=TypeCastExpression;exports.NewExpression=NewExpression;exports.TemplateLiteral=TemplateLiteral;exports.UnaryExpression=UnaryExpression;exports.BinaryExpression=BinaryExpression;exports.LogicalExpression=LogicalExpression;exports.ConditionalExpression=ConditionalExpression;exports.SequenceExpression=SequenceExpression;exports.AssignmentExpression=AssignmentExpression;exports.UpdateExpression=UpdateExpression;exports.Literal=Literal;exports.ObjectExpression=ObjectExpression;exports.ArrayExpression=ArrayExpression;exports.RestElement=RestElement;exports.CallExpression=CallExpression;exports.TaggedTemplateExpression=TaggedTemplateExpression;function _interopRequire(obj){return obj&&obj.__esModule?obj["default"]:obj}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var _infererReference=require("./inferer-reference");exports.Identifier=_interopRequire(_infererReference);function VariableDeclarator(){var id=this.get("id");if(id.isIdentifier()){return this.get("init").getTypeAnnotation()}else{return}}function TypeCastExpression(node){return node.typeAnnotation}TypeCastExpression.validParent=true;function NewExpression(node){if(this.get("callee").isIdentifier()){return t.genericTypeAnnotation(node.callee)}}function TemplateLiteral(){return t.stringTypeAnnotation()}function UnaryExpression(node){var operator=node.operator;if(operator==="void"){return t.voidTypeAnnotation()}else if(t.NUMBER_UNARY_OPERATORS.indexOf(operator)>=0){return t.numberTypeAnnotation()}else if(t.STRING_UNARY_OPERATORS.indexOf(operator)>=0){return t.stringTypeAnnotation()}else if(t.BOOLEAN_UNARY_OPERATORS.indexOf(operator)>=0){return t.booleanTypeAnnotation()}}function BinaryExpression(node){var operator=node.operator;if(t.NUMBER_BINARY_OPERATORS.indexOf(operator)>=0){return t.numberTypeAnnotation()}else if(t.BOOLEAN_BINARY_OPERATORS.indexOf(operator)>=0){return t.booleanTypeAnnotation()}else if(operator==="+"){var right=this.get("right");var left=this.get("left");if(left.isBaseType("number")&&right.isBaseType("number")){return t.numberTypeAnnotation()}else if(left.isBaseType("string")||right.isBaseType("string")){return t.stringTypeAnnotation()}return t.unionTypeAnnotation([t.stringTypeAnnotation(),t.numberTypeAnnotation()])}}function LogicalExpression(){return t.createUnionTypeAnnotation([this.get("left").getTypeAnnotation(),this.get("right").getTypeAnnotation()])}function ConditionalExpression(){return t.createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(),this.get("alternate").getTypeAnnotation()])}function SequenceExpression(){return this.get("expressions").pop().getTypeAnnotation()}function AssignmentExpression(){return this.get("right").getTypeAnnotation()}function UpdateExpression(node){var operator=node.operator;if(operator==="++"||operator==="--"){return t.numberTypeAnnotation()}}function Literal(node){var value=node.value;if(typeof value==="string")return t.stringTypeAnnotation();if(typeof value==="number")return t.numberTypeAnnotation();if(typeof value==="boolean")return t.booleanTypeAnnotation();if(value===null)return t.voidTypeAnnotation();if(node.regex)return t.genericTypeAnnotation(t.identifier("RegExp"))}function ObjectExpression(){return t.genericTypeAnnotation(t.identifier("Object"))}function ArrayExpression(){return t.genericTypeAnnotation(t.identifier("Array"))}function RestElement(){return ArrayExpression()}RestElement.validParent=true;function Func(){return t.genericTypeAnnotation(t.identifier("Function"))}exports.Function=Func;exports.Class=Func;function CallExpression(){return resolveCall(this.get("callee"))}function TaggedTemplateExpression(){return resolveCall(this.get("tag"))}function resolveCall(callee){callee=callee.resolve();if(callee.isFunction()){if(callee.is("async")){if(callee.is("generator")){return t.genericTypeAnnotation(t.identifier("AsyncIterator"))}else{return t.genericTypeAnnotation(t.identifier("Promise"))}}else{if(callee.node.returnType){return callee.node.returnType}else{}}}}},{"../../../types":196,"./inferer-reference":174}],176:[function(require,module,exports){"use strict";exports.__esModule=true;exports.matchesPattern=matchesPattern;exports.has=has;exports.isnt=isnt;exports.equals=equals;exports.isNodeType=isNodeType;exports.canHaveVariableDeclarationOrExpression=canHaveVariableDeclarationOrExpression;exports.isCompletionRecord=isCompletionRecord;exports.isStatementOrBlock=isStatementOrBlock;exports.referencesImport=referencesImport;exports.getSource=getSource;exports.willIMaybeExecuteBefore=willIMaybeExecuteBefore;exports._guessExecutionStatusRelativeTo=_guessExecutionStatusRelativeTo;exports.resolve=resolve;exports._resolve=_resolve;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashCollectionIncludes=require("lodash/collection/includes");var _lodashCollectionIncludes2=_interopRequireDefault(_lodashCollectionIncludes);var _types=require("../../types");var t=_interopRequireWildcard(_types); -function matchesPattern(pattern,allowPartial){if(!this.isMemberExpression())return false;var parts=pattern.split(".");var search=[this.node];var i=0;function matches(name){var part=parts[i];return part==="*"||name===part}while(search.length){var node=search.shift();if(allowPartial&&i===parts.length){return true}if(t.isIdentifier(node)){if(!matches(node.name))return false}else if(t.isLiteral(node)){if(!matches(node.value))return false}else if(t.isMemberExpression(node)){if(node.computed&&!t.isLiteral(node.property)){return false}else{search.unshift(node.property);search.unshift(node.object);continue}}else if(t.isThisExpression(node)){if(!matches("this"))return false}else{return false}if(++i>parts.length){return false}}return i===parts.length}function has(key){var val=this.node[key];if(val&&Array.isArray(val)){return!!val.length}else{return!!val}}var is=has;exports.is=is;function isnt(key){return!this.has(key)}function equals(key,value){return this.node[key]===value}function isNodeType(type){return t.isType(this.type,type)}function canHaveVariableDeclarationOrExpression(){return(this.key==="init"||this.key==="left")&&this.parentPath.isFor()}function isCompletionRecord(allowInsideFunction){var path=this;var first=true;do{var container=path.container;if(path.isFunction()&&!first){return!!allowInsideFunction}first=false;if(Array.isArray(container)&&path.key!==container.length-1){return false}}while((path=path.parentPath)&&!path.isProgram());return true}function isStatementOrBlock(){if(this.parentPath.isLabeledStatement()||t.isBlockStatement(this.container)){return false}else{return _lodashCollectionIncludes2["default"](t.STATEMENT_OR_BLOCK_KEYS,this.key)}}function referencesImport(moduleSource,importName){if(!this.isReferencedIdentifier())return false;var binding=this.scope.getBinding(this.node.name);if(!binding||binding.kind!=="module")return false;var path=binding.path;var parent=path.parentPath;if(!parent.isImportDeclaration())return false;if(parent.node.source.value===moduleSource){if(!importName)return true}else{return false}if(path.isImportDefaultSpecifier()&&importName==="default"){return true}if(path.isImportNamespaceSpecifier()&&importName==="*"){return true}if(path.isImportSpecifier()&&path.node.imported.name===importName){return true}return false}function getSource(){var node=this.node;if(node.end){return this.hub.file.code.slice(node.start,node.end)}else{return""}}function willIMaybeExecuteBefore(target){return this._guessExecutionStatusRelativeTo(target)!=="after"}function _guessExecutionStatusRelativeTo(target){var targetFuncParent=target.scope.getFunctionParent();var selfFuncParent=this.scope.getFunctionParent();if(targetFuncParent!==selfFuncParent){return"function"}var targetPaths=target.getAncestry();var selfPaths=this.getAncestry();var commonPath;var targetIndex;var selfIndex;for(selfIndex=0;selfIndex=0){commonPath=selfPath;break}}if(!commonPath){return"before"}var targetRelationship=targetPaths[targetIndex-1];var selfRelationship=selfPaths[selfIndex-1];if(!targetRelationship||!selfRelationship){return"before"}if(targetRelationship.listKey&&targetRelationship.container===selfRelationship.container){return targetRelationship.key>selfRelationship.key?"before":"after"}var targetKeyPosition=t.VISITOR_KEYS[targetRelationship.type].indexOf(targetRelationship.key);var selfKeyPosition=t.VISITOR_KEYS[selfRelationship.type].indexOf(selfRelationship.key);return targetKeyPosition>selfKeyPosition?"before":"after"}function resolve(dangerous,resolved){return this._resolve(dangerous,resolved)||this}function _resolve(dangerous,resolved){if(resolved&&resolved.indexOf(this)>=0)return;resolved=resolved||[];resolved.push(this);if(this.isVariableDeclarator()){if(this.get("id").isIdentifier()){return this.get("init").resolve(dangerous,resolved)}else{}}else if(this.isReferencedIdentifier()){var binding=this.scope.getBinding(this.node.name);if(!binding)return;if(!binding.constant)return;if(binding.kind==="module")return;if(binding.path!==this){return binding.path.resolve(dangerous,resolved)}}else if(this.isTypeCastExpression()){return this.get("expression").resolve(dangerous,resolved)}else if(dangerous&&this.isMemberExpression()){var targetKey=this.toComputedKey();if(!t.isLiteral(targetKey))return;var targetName=targetKey.value;var target=this.get("object").resolve(dangerous,resolved);if(target.isObjectExpression()){var props=target.get("properties");var _arr=props;for(var _i=0;_i<_arr.length;_i++){var prop=_arr[_i];if(!prop.isProperty())continue;var key=prop.get("key");var match=prop.isnt("computed")&&key.isIdentifier({name:targetName});match=match||key.isLiteral({value:targetName});if(match)return prop.get("value").resolve(dangerous,resolved)}}else if(target.isArrayExpression()&&!isNaN(+targetName)){var elems=target.get("elements");var elem=elems[targetName];if(elem)return elem.resolve(dangerous,resolved)}}}},{"../../types":196,"lodash/collection/includes":439}],177:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var _transformationHelpersReact=require("../../../transformation/helpers/react");var react=_interopRequireWildcard(_transformationHelpersReact);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var referenceVisitor={ReferencedIdentifier:function ReferencedIdentifier(node,parent,scope,state){if(this.isJSXIdentifier()&&react.isCompatTag(node.name)){return}var binding=scope.getBinding(node.name);if(!binding)return;if(binding!==state.scope.getBinding(node.name))return;if(binding.constant){state.bindings[node.name]=binding}else{var _arr=binding.constantViolations;for(var _i=0;_i<_arr.length;_i++){var violationPath=_arr[_i];state.breakOnScopePaths=state.breakOnScopePaths.concat(violationPath.getAncestry())}}}};var PathHoister=function(){function PathHoister(path,scope){_classCallCheck(this,PathHoister);this.breakOnScopePaths=[];this.bindings={};this.scopes=[];this.scope=scope;this.path=path}PathHoister.prototype.isCompatibleScope=function isCompatibleScope(scope){for(var key in this.bindings){var binding=this.bindings[key];if(!scope.bindingIdentifierEquals(key,binding.identifier)){return false}}return true};PathHoister.prototype.getCompatibleScopes=function getCompatibleScopes(){var scope=this.path.scope;do{if(this.isCompatibleScope(scope)){this.scopes.push(scope)}else{break}if(this.breakOnScopePaths.indexOf(scope.path)>=0){break}}while(scope=scope.parent)};PathHoister.prototype.getAttachmentPath=function getAttachmentPath(){var scopes=this.scopes;var scope=scopes.pop();if(!scope)return;if(scope.path.isFunction()){if(this.hasOwnParamBindings(scope)){if(this.scope===scope)return;return scope.path.get("body").get("body")[0]}else{return this.getNextScopeStatementParent()}}else if(scope.path.isProgram()){return this.getNextScopeStatementParent()}};PathHoister.prototype.getNextScopeStatementParent=function getNextScopeStatementParent(){var scope=this.scopes.pop();if(scope)return scope.path.getStatementParent()};PathHoister.prototype.hasOwnParamBindings=function hasOwnParamBindings(scope){for(var name in this.bindings){if(!scope.hasOwnBinding(name))continue;var binding=this.bindings[name];if(binding.kind==="param")return true}return false};PathHoister.prototype.run=function run(){var node=this.path.node;if(node._hoisted)return;node._hoisted=true;this.path.traverse(referenceVisitor,this);this.getCompatibleScopes();var attachTo=this.getAttachmentPath();if(!attachTo)return;if(attachTo.getFunctionParent()===this.path.getFunctionParent())return;var uid=attachTo.scope.generateUidIdentifier("ref");attachTo.insertBefore([t.variableDeclaration("var",[t.variableDeclarator(uid,this.path.node)])]);var parent=this.path.parentPath;if(parent.isJSXElement()&&this.path.container===parent.node.children){uid=t.JSXExpressionContainer(uid)}this.path.replaceWith(uid)};return PathHoister}();exports["default"]=PathHoister;module.exports=exports["default"]},{"../../../transformation/helpers/react":79,"../../../types":196}],178:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _types=require("../../../types");var t=_interopRequireWildcard(_types);var pre=[function(self){if(self.key==="body"&&(self.isBlockStatement()||self.isClassBody())){self.node.body=[];return true}},function(self,parent){var replace=false;replace=replace||self.key==="body"&&parent.isArrowFunctionExpression();replace=replace||self.key==="argument"&&parent.isThrowStatement();if(replace){self.replaceWith(t.identifier("undefined"));return true}}];exports.pre=pre;var post=[function(self,parent){var removeParent=false;removeParent=removeParent||self.key==="test"&&(parent.isWhile()||parent.isSwitchCase());removeParent=removeParent||self.key==="declaration"&&parent.isExportDeclaration();removeParent=removeParent||self.key==="body"&&parent.isLabeledStatement();removeParent=removeParent||self.listKey==="declarations"&&parent.isVariableDeclaration()&&parent.node.declarations.length===0;removeParent=removeParent||self.key==="expression"&&parent.isExpressionStatement();removeParent=removeParent||self.key==="test"&&parent.isIfStatement();if(removeParent){parent.dangerouslyRemove();return true}},function(self,parent){if(parent.isSequenceExpression()&&parent.node.expressions.length===1){parent.replaceWith(parent.node.expressions[0]);return true}},function(self,parent){if(parent.isBinary()){if(self.key==="left"){parent.replaceWith(parent.node.right)}else{parent.replaceWith(parent.node.left)}return true}}];exports.post=post},{"../../../types":196}],179:[function(require,module,exports){"use strict";exports.__esModule=true;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _transformationHelpersReact=require("../../../transformation/helpers/react");var react=_interopRequireWildcard(_transformationHelpersReact);var _types=require("../../../types");var t=_interopRequireWildcard(_types);var ReferencedIdentifier={types:["Identifier","JSXIdentifier"],checkPath:function checkPath(_ref,opts){var node=_ref.node;var parent=_ref.parent;if(!t.isIdentifier(node,opts)){if(t.isJSXIdentifier(node,opts)){if(react.isCompatTag(node.name))return false}else{return false}}return t.isReferenced(node,parent)}};exports.ReferencedIdentifier=ReferencedIdentifier;var BindingIdentifier={types:["Identifier"],checkPath:function checkPath(_ref2){var node=_ref2.node;var parent=_ref2.parent;return t.isBinding(node,parent)}};exports.BindingIdentifier=BindingIdentifier;var Statement={types:["Statement"],checkPath:function checkPath(_ref3){var node=_ref3.node;var parent=_ref3.parent;if(t.isStatement(node)){if(t.isVariableDeclaration(node)){if(t.isForXStatement(parent,{left:node}))return false;if(t.isForStatement(parent,{init:node}))return false}return true}else{return false}}};exports.Statement=Statement;var Expression={types:["Expression"],checkPath:function checkPath(path){if(path.isIdentifier()){return path.isReferencedIdentifier()}else{return t.isExpression(path.node)}}};exports.Expression=Expression;var Scope={types:["Scopable"],checkPath:function checkPath(path){return t.isScope(path.node,path.parent)}};exports.Scope=Scope;var Referenced={checkPath:function checkPath(path){return t.isReferenced(path.node,path.parent)}};exports.Referenced=Referenced;var BlockScoped={checkPath:function checkPath(path){return t.isBlockScoped(path.node)}};exports.BlockScoped=BlockScoped;var Var={types:["VariableDeclaration"],checkPath:function checkPath(path){return t.isVar(path.node)}};exports.Var=Var;var DirectiveLiteral={types:["Literal"],checkPath:function checkPath(path){return path.isLiteral()&&path.parentPath.isExpressionStatement()}};exports.DirectiveLiteral=DirectiveLiteral;var Directive={types:["ExpressionStatement"],checkPath:function checkPath(path){return path.get("expression").isLiteral()}};exports.Directive=Directive;var User={checkPath:function checkPath(path){return path.node&&!!path.node.loc}};exports.User=User;var Generated={checkPath:function checkPath(path){return!path.isUser()}};exports.Generated=Generated;var Flow={types:["Flow","ImportDeclaration","ExportDeclaration"],checkPath:function checkPath(_ref4){var node=_ref4.node;if(t.isFlow(node)){return true}else if(t.isImportDeclaration(node)){return node.importKind==="type"||node.importKind==="typeof"}else if(t.isExportDeclaration(node)){return node.exportKind==="type"}else{return false}}};exports.Flow=Flow},{"../../../transformation/helpers/react":79,"../../../types":196}],180:[function(require,module,exports){"use strict";exports.__esModule=true;exports.insertBefore=insertBefore;exports._containerInsert=_containerInsert;exports._containerInsertBefore=_containerInsertBefore;exports._containerInsertAfter=_containerInsertAfter;exports._maybePopFromStatements=_maybePopFromStatements;exports.insertAfter=insertAfter;exports.updateSiblingKeys=updateSiblingKeys;exports._verifyNodeList=_verifyNodeList;exports.unshiftContainer=unshiftContainer;exports.pushContainer=pushContainer;exports.hoist=hoist;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _libHoister=require("./lib/hoister");var _libHoister2=_interopRequireDefault(_libHoister);var _index=require("./index");var _index2=_interopRequireDefault(_index);var _types=require("../../types");var t=_interopRequireWildcard(_types);function insertBefore(nodes){this._assertUnremoved();nodes=this._verifyNodeList(nodes);if(this.parentPath.isExpressionStatement()||this.parentPath.isLabeledStatement()){return this.parentPath.insertBefore(nodes)}else if(this.isNodeType("Expression")||this.parentPath.isForStatement()&&this.key==="init"){if(this.node)nodes.push(this.node);this.replaceExpressionWithStatements(nodes)}else{this._maybePopFromStatements(nodes);if(Array.isArray(this.container)){return this._containerInsertBefore(nodes)}else if(this.isStatementOrBlock()){if(this.node)nodes.push(this.node);this.node=this.container[this.key]=t.blockStatement(nodes)}else{throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?")}}return[this]}function _containerInsert(from,nodes){this.updateSiblingKeys(from,nodes.length);var paths=[];for(var i=0;i=fromIndex){path.key+=incrementBy}}}function _verifyNodeList(nodes){if(nodes.constructor!==Array){nodes=[nodes]}for(var i=0;i1)id+=i;return"_"+id};Scope.prototype.generateUidIdentifierBasedOnNode=function generateUidIdentifierBasedOnNode(parent,defaultName){var node=parent;if(t.isAssignmentExpression(parent)){node=parent.left}else if(t.isVariableDeclarator(parent)){node=parent.id}else if(t.isProperty(node)){node=node.key}var parts=[];var add=function add(node){if(t.isModuleDeclaration(node)){if(node.source){add(node.source)}else if(node.specifiers&&node.specifiers.length){var _arr4=node.specifiers;for(var _i4=0;_i4<_arr4.length;_i4++){var specifier=_arr4[_i4];add(specifier)}}else if(node.declaration){add(node.declaration)}}else if(t.isModuleSpecifier(node)){add(node.local)}else if(t.isMemberExpression(node)){add(node.object);add(node.property)}else if(t.isIdentifier(node)){parts.push(node.name)}else if(t.isLiteral(node)){parts.push(node.value)}else if(t.isCallExpression(node)){add(node.callee)}else if(t.isObjectExpression(node)||t.isObjectPattern(node)){var _arr5=node.properties;for(var _i5=0;_i5<_arr5.length;_i5++){var prop=_arr5[_i5];add(prop.key||prop.argument)}}};add(node);var id=parts.join("$");id=id.replace(/^_/,"")||defaultName||"ref";return this.generateUidIdentifier(id)};Scope.prototype.isStatic=function isStatic(node){if(t.isThisExpression(node)||t.isSuper(node)){return true}if(t.isIdentifier(node)){var binding=this.getBinding(node.name);if(binding){return binding.constant}else{return this.hasBinding(node.name)}}return false};Scope.prototype.maybeGenerateMemoised=function maybeGenerateMemoised(node,dontPush){if(this.isStatic(node)){return null}else{var id=this.generateUidIdentifierBasedOnNode(node);if(!dontPush)this.push({id:id});return id}};Scope.prototype.checkBlockScopedCollisions=function checkBlockScopedCollisions(local,kind,name,id){if(kind==="param")return;if(kind==="hoisted"&&local.kind==="let")return;var duplicate=false;if(!duplicate)duplicate=kind==="let"||local.kind==="let"||local.kind==="const"||local.kind==="module";if(!duplicate)duplicate=local.kind==="param"&&(kind==="let"||kind==="const");if(duplicate){throw this.hub.file.errorWithNode(id,messages.get("scopeDuplicateDeclaration",name),TypeError)}};Scope.prototype.rename=function rename(oldName,newName,block){newName=newName||this.generateUidIdentifier(oldName).name;var info=this.getBinding(oldName);if(!info)return;var state={newName:newName,oldName:oldName,binding:info.identifier,info:info};var scope=info.scope;scope.traverse(block||scope.block,renameVisitor,state);if(!block){scope.removeOwnBinding(oldName);scope.bindings[newName]=info;state.binding.name=newName}var file=this.hub.file;if(file){this._renameFromMap(file.moduleFormatter.localImports,oldName,newName,state.binding)}};Scope.prototype._renameFromMap=function _renameFromMap(map,oldName,newName,value){if(map[oldName]){map[newName]=value;map[oldName]=null}};Scope.prototype.dump=function dump(){var sep=_repeating2["default"]("-",60);console.log(sep);var scope=this;do{console.log("#",scope.block.type);for(var name in scope.bindings){var binding=scope.bindings[name];console.log(" -",name,{constant:binding.constant,references:binding.references,kind:binding.kind})}}while(scope=scope.parent);console.log(sep)};Scope.prototype.toArray=function toArray(node,i){var file=this.hub.file;if(t.isIdentifier(node)){var binding=this.getBinding(node.name);if(binding&&binding.constant&&binding.path.isGenericType("Array"))return node}if(t.isArrayExpression(node)){return node}if(t.isIdentifier(node,{name:"arguments"})){return t.callExpression(t.memberExpression(file.addHelper("slice"),t.identifier("call")),[node])}var helperName="to-array";var args=[node];if(i===true){helperName="to-consumable-array"}else if(i){args.push(t.literal(i));helperName="sliced-to-array";if(this.hub.file.isLoose("es6.forOf"))helperName+="-loose"}return t.callExpression(file.addHelper(helperName),args)};Scope.prototype.registerDeclaration=function registerDeclaration(path){if(path.isLabeledStatement()){this.registerBinding("label",path)}else if(path.isFunctionDeclaration()){this.registerBinding("hoisted",path)}else if(path.isVariableDeclaration()){var declarations=path.get("declarations");var _arr6=declarations;for(var _i6=0;_i6<_arr6.length;_i6++){var declar=_arr6[_i6];this.registerBinding(path.node.kind,declar)}}else if(path.isClassDeclaration()){this.registerBinding("let",path)}else if(path.isImportDeclaration()){var specifiers=path.get("specifiers");var _arr7=specifiers;for(var _i7=0;_i7<_arr7.length;_i7++){var specifier=_arr7[_i7];this.registerBinding("module",specifier)}}else if(path.isExportDeclaration()){var declar=path.get("declaration");if(declar.isClassDeclaration()||declar.isFunctionDeclaration()||declar.isVariableDeclaration()){this.registerDeclaration(declar)}}else{this.registerBinding("unknown",path)}};Scope.prototype.registerConstantViolation=function registerConstantViolation(root,left,right){var ids=left.getBindingIdentifiers();for(var name in ids){var binding=this.getBinding(name);if(binding)binding.reassign(root,left,right)}};Scope.prototype.registerBinding=function registerBinding(kind,path){if(!kind)throw new ReferenceError("no `kind`");if(path.isVariableDeclaration()){var declarators=path.get("declarations");var _arr8=declarators;for(var _i8=0;_i8<_arr8.length;_i8++){var declar=_arr8[_i8];this.registerBinding(kind,declar)}return}var parent=this.getProgramParent();var ids=path.getBindingIdentifiers(true);for(var name in ids){var _arr9=ids[name];for(var _i9=0;_i9<_arr9.length;_i9++){var id=_arr9[_i9];var local=this.getOwnBinding(name);if(local){if(local.identifier===id)continue;this.checkBlockScopedCollisions(local,kind,name,id)}parent.references[name]=true;this.bindings[name]=new _binding2["default"]({identifier:id,existing:local,scope:this,path:path,kind:kind})}}};Scope.prototype.addGlobal=function addGlobal(node){this.globals[node.name]=node};Scope.prototype.hasUid=function hasUid(name){var scope=this;do{if(scope.uids[name])return true}while(scope=scope.parent);return false};Scope.prototype.hasGlobal=function hasGlobal(name){var scope=this;do{if(scope.globals[name])return true}while(scope=scope.parent);return false};Scope.prototype.hasReference=function hasReference(name){var scope=this;do{if(scope.references[name])return true}while(scope=scope.parent);return false};Scope.prototype.isPure=function isPure(node,constantsOnly){if(t.isIdentifier(node)){var binding=this.getBinding(node.name);if(!binding)return false;if(constantsOnly)return binding.constant;return true}else if(t.isClass(node)){return!node.superClass||this.isPure(node.superClass,constantsOnly)}else if(t.isBinary(node)){return this.isPure(node.left,constantsOnly)&&this.isPure(node.right,constantsOnly)}else if(t.isArrayExpression(node)){var _arr10=node.elements;for(var _i10=0;_i10<_arr10.length;_i10++){var elem=_arr10[_i10];if(!this.isPure(elem,constantsOnly))return false}return true}else if(t.isObjectExpression(node)){var _arr11=node.properties;for(var _i11=0;_i11<_arr11.length;_i11++){var prop=_arr11[_i11];if(!this.isPure(prop,constantsOnly))return false}return true}else if(t.isProperty(node)){if(node.computed&&!this.isPure(node.key,constantsOnly))return false;return this.isPure(node.value,constantsOnly)}else{return t.isPure(node)}};Scope.prototype.setData=function setData(key,val){return this.data[key]=val};Scope.prototype.getData=function getData(key){var scope=this;do{var data=scope.data[key];if(data!=null)return data}while(scope=scope.parent)};Scope.prototype.removeData=function removeData(key){var scope=this;do{var data=scope.data[key];if(data!=null)scope.data[key]=null}while(scope=scope.parent)};Scope.prototype.init=function init(){if(!this.references)this.crawl()};Scope.prototype.crawl=function crawl(){var path=this.path;var info=this.block._scopeInfo;if(info)return _lodashObjectExtend2["default"](this,info);info=this.block._scopeInfo={references:_helpersObject2["default"](),bindings:_helpersObject2["default"](),globals:_helpersObject2["default"](),uids:_helpersObject2["default"](),data:_helpersObject2["default"]()};_lodashObjectExtend2["default"](this,info);if(path.isLoop()){var _arr12=t.FOR_INIT_KEYS;for(var _i12=0;_i12<_arr12.length;_i12++){var key=_arr12[_i12];var node=path.get(key);if(node.isBlockScoped())this.registerBinding(node.node.kind,node)}}if(path.isFunctionExpression()&&path.has("id")){if(!t.isProperty(path.parent,{method:true})){this.registerBinding("var",path)}}if(path.isClassExpression()&&path.has("id")){this.registerBinding("var",path)}if(path.isFunction()){var params=path.get("params");var _arr13=params;for(var _i13=0;_i13<_arr13.length;_i13++){var param=_arr13[_i13];this.registerBinding("param",param)}}if(path.isCatchClause()){this.registerBinding("let",path)}if(path.isComprehensionExpression()){this.registerBinding("let",path)}var parent=this.getProgramParent();if(parent.crawling)return;this.crawling=true;path.traverse(collectorVisitor);this.crawling=false};Scope.prototype.push=function push(opts){var path=this.path;if(path.isSwitchStatement()){path=this.getFunctionParent().path}if(path.isLoop()||path.isCatchClause()||path.isFunction()){t.ensureBlock(path.node);path=path.get("body")}if(!path.isBlockStatement()&&!path.isProgram()){path=this.getBlockParent().path}var unique=opts.unique;var kind=opts.kind||"var";var blockHoist=opts._blockHoist==null?2:opts._blockHoist;var dataKey="declaration:"+kind+":"+blockHoist;var declarPath=!unique&&path.getData(dataKey);if(!declarPath){var declar=t.variableDeclaration(kind,[]);declar._generated=true;declar._blockHoist=blockHoist;this.hub.file.attachAuxiliaryComment(declar);var _path$unshiftContainer=path.unshiftContainer("body",[declar]);declarPath=_path$unshiftContainer[0];if(!unique)path.setData(dataKey,declarPath)}var declarator=t.variableDeclarator(opts.id,opts.init);declarPath.node.declarations.push(declarator);this.registerBinding(kind,declarPath.get("declarations").pop())};Scope.prototype.getProgramParent=function getProgramParent(){var scope=this;do{if(scope.path.isProgram()){return scope}}while(scope=scope.parent);throw new Error("We couldn't find a Function or Program...")};Scope.prototype.getFunctionParent=function getFunctionParent(){var scope=this;do{if(scope.path.isFunctionParent()){return scope}}while(scope=scope.parent);throw new Error("We couldn't find a Function or Program...")};Scope.prototype.getBlockParent=function getBlockParent(){var scope=this;do{if(scope.path.isBlockParent()){return scope}}while(scope=scope.parent);throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...")};Scope.prototype.getAllBindings=function getAllBindings(){var ids=_helpersObject2["default"]();var scope=this;do{_lodashObjectDefaults2["default"](ids,scope.bindings);scope=scope.parent}while(scope);return ids};Scope.prototype.getAllBindingsOfKind=function getAllBindingsOfKind(){var ids=_helpersObject2["default"]();var _arr14=arguments;for(var _i14=0;_i14<_arr14.length;_i14++){var kind=_arr14[_i14];var scope=this;do{for(var name in scope.bindings){var binding=scope.bindings[name];if(binding.kind===kind)ids[name]=binding}scope=scope.parent}while(scope)}return ids};Scope.prototype.bindingIdentifierEquals=function bindingIdentifierEquals(name,node){return this.getBindingIdentifier(name)===node};Scope.prototype.getBinding=function getBinding(name){var scope=this;do{var binding=scope.getOwnBinding(name);if(binding)return binding}while(scope=scope.parent)};Scope.prototype.getOwnBinding=function getOwnBinding(name){return this.bindings[name]};Scope.prototype.getBindingIdentifier=function getBindingIdentifier(name){var info=this.getBinding(name);return info&&info.identifier};Scope.prototype.getOwnBindingIdentifier=function getOwnBindingIdentifier(name){var binding=this.bindings[name];return binding&&binding.identifier};Scope.prototype.hasOwnBinding=function hasOwnBinding(name){return!!this.getOwnBinding(name)};Scope.prototype.hasBinding=function hasBinding(name,noGlobals){if(!name)return false;if(this.hasOwnBinding(name))return true;if(this.parentHasBinding(name,noGlobals))return true;if(this.hasUid(name))return true;if(!noGlobals&&_lodashCollectionIncludes2["default"](Scope.globals,name))return true;if(!noGlobals&&_lodashCollectionIncludes2["default"](Scope.contextVariables,name))return true;return false};Scope.prototype.parentHasBinding=function parentHasBinding(name,noGlobals){return this.parent&&this.parent.hasBinding(name,noGlobals)};Scope.prototype.moveBindingTo=function moveBindingTo(name,scope){var info=this.getBinding(name);if(info){info.scope.removeOwnBinding(name);info.scope=scope;scope.bindings[name]=info}};Scope.prototype.removeOwnBinding=function removeOwnBinding(name){delete this.bindings[name]};Scope.prototype.removeBinding=function removeBinding(name){var info=this.getBinding(name);if(info){info.scope.removeOwnBinding(name)}var scope=this;do{if(scope.uids[name]){scope.uids[name]=false}}while(scope=scope.parent)};_createClass(Scope,null,[{key:"globals",value:_lodashArrayFlatten2["default"]([_globals2["default"].builtin,_globals2["default"].browser,_globals2["default"].node].map(Object.keys)),enumerable:true},{key:"contextVariables",value:["arguments","undefined","Infinity","NaN"],enumerable:true}]);return Scope}();exports["default"]=Scope;module.exports=exports["default"]},{"../../helpers/object":58,"../../messages":60,"../../types":196,"../index":165,"./binding":183,globals:415,"lodash/array/flatten":432,"lodash/collection/includes":439,"lodash/object/defaults":536,"lodash/object/extend":537,repeating:611}],185:[function(require,module,exports){"use strict";exports.__esModule=true;exports.explode=explode;exports.verify=verify;exports.merge=merge;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}var _pathLibVirtualTypes=require("./path/lib/virtual-types");var virtualTypes=_interopRequireWildcard(_pathLibVirtualTypes);var _messages=require("../messages");var messages=_interopRequireWildcard(_messages);var _types=require("../types");var t=_interopRequireWildcard(_types);var _lodashLangClone=require("lodash/lang/clone");var _lodashLangClone2=_interopRequireDefault(_lodashLangClone);function explode(visitor){if(visitor._exploded)return visitor;visitor._exploded=true;for(var nodeType in visitor){if(shouldIgnoreKey(nodeType))continue;var parts=nodeType.split("|");if(parts.length===1)continue;var fns=visitor[nodeType];delete visitor[nodeType];var _arr=parts;for(var _i=0;_i<_arr.length;_i++){var part=_arr[_i];visitor[part]=fns}}verify(visitor);delete visitor.__esModule;ensureEntranceObjects(visitor);ensureCallbackArrays(visitor);var _arr2=Object.keys(visitor);for(var _i2=0;_i2<_arr2.length;_i2++){var nodeType=_arr2[_i2];if(shouldIgnoreKey(nodeType))continue;var wrapper=virtualTypes[nodeType];if(!wrapper)continue;var fns=visitor[nodeType];for(var type in fns){fns[type]=wrapCheck(wrapper,fns[type])}delete visitor[nodeType];if(wrapper.types){var _arr4=wrapper.types;for(var _i4=0;_i4<_arr4.length;_i4++){var type=_arr4[_i4];if(visitor[type]){mergePair(visitor[type],fns)}else{visitor[type]=fns}}}else{mergePair(visitor,fns)}}for(var nodeType in visitor){if(shouldIgnoreKey(nodeType))continue;var fns=visitor[nodeType];var aliases=t.FLIPPED_ALIAS_KEYS[nodeType];if(!aliases)continue;delete visitor[nodeType];var _arr3=aliases;for(var _i3=0;_i3<_arr3.length;_i3++){var alias=_arr3[_i3];var existing=visitor[alias];if(existing){mergePair(existing,fns)}else{visitor[alias]=_lodashLangClone2["default"](fns)}}}for(var nodeType in visitor){if(shouldIgnoreKey(nodeType))continue;ensureCallbackArrays(visitor[nodeType])}return visitor}function verify(visitor){if(visitor._verified)return;if(typeof visitor==="function"){throw new Error(messages.get("traverseVerifyRootFunction"))}for(var nodeType in visitor){if(shouldIgnoreKey(nodeType))continue;if(t.TYPES.indexOf(nodeType)<0){throw new Error(messages.get("traverseVerifyNodeType",nodeType))}var visitors=visitor[nodeType];if(typeof visitors==="object"){for(var visitorKey in visitors){if(visitorKey==="enter"||visitorKey==="exit")continue;throw new Error(messages.get("traverseVerifyVisitorProperty",nodeType,visitorKey))}}}visitor._verified=true}function merge(visitors){var rootVisitor={};var _arr5=visitors;for(var _i5=0;_i5<_arr5.length;_i5++){var visitor=_arr5[_i5];explode(visitor);for(var type in visitor){var nodeVisitor=rootVisitor[type]=rootVisitor[type]||{};mergePair(nodeVisitor,visitor[type])}}return rootVisitor}function ensureEntranceObjects(obj){for(var key in obj){if(shouldIgnoreKey(key))continue;var fns=obj[key];if(typeof fns==="function"){obj[key]={enter:fns}}}}function ensureCallbackArrays(obj){if(obj.enter&&!Array.isArray(obj.enter))obj.enter=[obj.enter];if(obj.exit&&!Array.isArray(obj.exit))obj.exit=[obj.exit]}function wrapCheck(wrapper,fn){return function(){if(wrapper.checkPath(this)){return fn.apply(this,arguments)}}}function shouldIgnoreKey(key){if(key[0]==="_")return true;if(key==="enter"||key==="exit"||key==="shouldSkip")return true;if(key==="blacklist"||key==="noScope"||key==="skipKeys")return true;return false}function mergePair(dest,src){for(var key in src){dest[key]=[].concat(dest[key]||[],src[key])}}},{"../messages":60,"../types":196,"./path/lib/virtual-types":179,"lodash/lang/clone":520}],186:[function(require,module,exports){"use strict";exports.__esModule=true;exports.toComputedKey=toComputedKey;exports.toSequenceExpression=toSequenceExpression;exports.toKeyAlias=toKeyAlias;exports.toIdentifier=toIdentifier;exports.toBindingIdentifierName=toBindingIdentifierName;exports.toStatement=toStatement;exports.toExpression=toExpression;exports.toBlock=toBlock;exports.valueToNode=valueToNode;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashLangIsPlainObject=require("lodash/lang/isPlainObject");var _lodashLangIsPlainObject2=_interopRequireDefault(_lodashLangIsPlainObject);var _lodashLangIsNumber=require("lodash/lang/isNumber");var _lodashLangIsNumber2=_interopRequireDefault(_lodashLangIsNumber);var _lodashLangIsRegExp=require("lodash/lang/isRegExp");var _lodashLangIsRegExp2=_interopRequireDefault(_lodashLangIsRegExp);var _lodashLangIsString=require("lodash/lang/isString");var _lodashLangIsString2=_interopRequireDefault(_lodashLangIsString);var _traversal=require("../traversal");var _traversal2=_interopRequireDefault(_traversal);var _index=require("./index");var t=_interopRequireWildcard(_index);function toComputedKey(node){var key=arguments.length<=1||arguments[1]===undefined?node.key||node.property:arguments[1];return function(){if(!node.computed){if(t.isIdentifier(key))key=t.literal(key.name)}return key}()}function toSequenceExpression(nodes,scope){var declars=[];var bailed=false;var result=convert(nodes);if(bailed)return;for(var i=0;i=0){continue}if(t.isAnyTypeAnnotation(node)){return[node]}if(t.isFlowBaseAnnotation(node)){bases[node.type]=node;continue}if(t.isUnionTypeAnnotation(node)){if(typeGroups.indexOf(node.types)<0){nodes=nodes.concat(node.types);typeGroups.push(node.types)}continue}if(t.isGenericTypeAnnotation(node)){var _name=node.id.name;if(generics[_name]){var existing=generics[_name];if(existing.typeParameters){if(node.typeParameters){existing.typeParameters.params=removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params))}}else{existing=node.typeParameters}}else{generics[_name]=node}continue}types.push(node)}for(var type in bases){types.push(bases[type])}for(var _name2 in generics){types.push(generics[_name2])}return types}function createTypeAnnotationBasedOnTypeof(type){if(type==="string"){return t.stringTypeAnnotation()}else if(type==="number"){return t.numberTypeAnnotation()}else if(type==="undefined"){return t.voidTypeAnnotation()}else if(type==="boolean"){return t.booleanTypeAnnotation()}else if(type==="function"){return t.genericTypeAnnotation(t.identifier("Function"))}else if(type==="object"){return t.genericTypeAnnotation(t.identifier("Object"))}else if(type==="symbol"){return t.genericTypeAnnotation(t.identifier("Symbol"))}else{throw new Error("Invalid typeof value")}}},{"./index":196}],196:[function(require,module,exports){"use strict";exports.__esModule=true;exports.is=is;exports.isType=isType;exports.shallowEqual=shallowEqual;exports.appendToMemberExpression=appendToMemberExpression;exports.prependToMemberExpression=prependToMemberExpression;exports.ensureBlock=ensureBlock;exports.clone=clone;exports.cloneDeep=cloneDeep;exports.buildMatchMemberExpression=buildMatchMemberExpression;exports.removeComments=removeComments;exports.inheritsComments=inheritsComments;exports.inheritTrailingComments=inheritTrailingComments;exports.inheritLeadingComments=inheritLeadingComments;exports.inheritInnerComments=inheritInnerComments;exports.inherits=inherits;function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _toFastProperties=require("to-fast-properties");var _toFastProperties2=_interopRequireDefault(_toFastProperties);var _lodashArrayCompact=require("lodash/array/compact");var _lodashArrayCompact2=_interopRequireDefault(_lodashArrayCompact);var _lodashObjectAssign=require("lodash/object/assign");var _lodashObjectAssign2=_interopRequireDefault(_lodashObjectAssign);var _lodashCollectionEach=require("lodash/collection/each");var _lodashCollectionEach2=_interopRequireDefault(_lodashCollectionEach);var _lodashArrayUniq=require("lodash/array/uniq");var _lodashArrayUniq2=_interopRequireDefault(_lodashArrayUniq);require("./definitions/init");var _definitions=require("./definitions");var t=exports;function registerType(type,skipAliasCheck){var is=t["is"+type]=function(node,opts){return t.is(type,node,opts,skipAliasCheck)};t["assert"+type]=function(node,opts){opts=opts||{};if(!is(node,opts)){throw new Error("Expected type "+JSON.stringify(type)+" with option "+JSON.stringify(opts))}}}var STATEMENT_OR_BLOCK_KEYS=["consequent","body","alternate"];exports.STATEMENT_OR_BLOCK_KEYS=STATEMENT_OR_BLOCK_KEYS;var FLATTENABLE_KEYS=["body","expressions"];exports.FLATTENABLE_KEYS=FLATTENABLE_KEYS;var FOR_INIT_KEYS=["left","init"];exports.FOR_INIT_KEYS=FOR_INIT_KEYS;var COMMENT_KEYS=["leadingComments","trailingComments","innerComments"];exports.COMMENT_KEYS=COMMENT_KEYS;var INHERIT_KEYS={optional:["typeAnnotation","typeParameters","returnType"],force:["_scopeInfo","_paths","start","loc","end"]};exports.INHERIT_KEYS=INHERIT_KEYS;var BOOLEAN_NUMBER_BINARY_OPERATORS=[">","<",">=","<="];exports.BOOLEAN_NUMBER_BINARY_OPERATORS=BOOLEAN_NUMBER_BINARY_OPERATORS;var EQUALITY_BINARY_OPERATORS=["==","===","!=","!=="];exports.EQUALITY_BINARY_OPERATORS=EQUALITY_BINARY_OPERATORS;var COMPARISON_BINARY_OPERATORS=EQUALITY_BINARY_OPERATORS.concat(["in","instanceof"]);exports.COMPARISON_BINARY_OPERATORS=COMPARISON_BINARY_OPERATORS;var BOOLEAN_BINARY_OPERATORS=[].concat(COMPARISON_BINARY_OPERATORS,BOOLEAN_NUMBER_BINARY_OPERATORS);exports.BOOLEAN_BINARY_OPERATORS=BOOLEAN_BINARY_OPERATORS;var NUMBER_BINARY_OPERATORS=["-","/","*","**","&","|",">>",">>>","<<","^"];exports.NUMBER_BINARY_OPERATORS=NUMBER_BINARY_OPERATORS;var BOOLEAN_UNARY_OPERATORS=["delete","!"];exports.BOOLEAN_UNARY_OPERATORS=BOOLEAN_UNARY_OPERATORS;var NUMBER_UNARY_OPERATORS=["+","-","++","--","~"];exports.NUMBER_UNARY_OPERATORS=NUMBER_UNARY_OPERATORS;var STRING_UNARY_OPERATORS=["typeof"];exports.STRING_UNARY_OPERATORS=STRING_UNARY_OPERATORS;exports.VISITOR_KEYS=_definitions.VISITOR_KEYS;exports.BUILDER_KEYS=_definitions.BUILDER_KEYS;exports.ALIAS_KEYS=_definitions.ALIAS_KEYS;_lodashCollectionEach2["default"](t.VISITOR_KEYS,function(keys,type){registerType(type,true)});t.FLIPPED_ALIAS_KEYS={};_lodashCollectionEach2["default"](t.ALIAS_KEYS,function(aliases,type){_lodashCollectionEach2["default"](aliases,function(alias){var types=t.FLIPPED_ALIAS_KEYS[alias]=t.FLIPPED_ALIAS_KEYS[alias]||[];types.push(type)})});_lodashCollectionEach2["default"](t.FLIPPED_ALIAS_KEYS,function(types,type){t[type.toUpperCase()+"_TYPES"]=types;registerType(type,false)});var TYPES=Object.keys(t.VISITOR_KEYS).concat(Object.keys(t.FLIPPED_ALIAS_KEYS));exports.TYPES=TYPES;function is(type,node,opts,skipAliasCheck){if(!node)return false;var matches=isType(node.type,type);if(!matches)return false;if(typeof opts==="undefined"){return true}else{return t.shallowEqual(node,opts)}}function isType(nodeType,targetType){if(nodeType===targetType)return true;var aliases=t.FLIPPED_ALIAS_KEYS[targetType];if(aliases){if(aliases[0]===nodeType)return true;var _arr=aliases;for(var _i=0;_i<_arr.length;_i++){var alias=_arr[_i];if(nodeType===alias)return true}}return false}_lodashCollectionEach2["default"](t.VISITOR_KEYS,function(keys,type){if(t.BUILDER_KEYS[type])return;var defs={};_lodashCollectionEach2["default"](keys,function(key){defs[key]=null});t.BUILDER_KEYS[type]=defs});_lodashCollectionEach2["default"](t.BUILDER_KEYS,function(keys,type){var builder=function builder(){var node={};node.type=type;var i=0;for(var key in keys){var arg=arguments[i++];if(arg===undefined)arg=keys[key];node[key]=arg}return node};t[type]=builder;t[type[0].toLowerCase()+type.slice(1)]=builder});function shallowEqual(actual,expected){var keys=Object.keys(expected);var _arr2=keys;for(var _i2=0;_i2<_arr2.length;_i2++){var key=_arr2[_i2];if(actual[key]!==expected[key]){return false}}return true}function appendToMemberExpression(member,append,computed){member.object=t.memberExpression(member.object,member.property,member.computed);member.property=append;member.computed=!!computed;return member}function prependToMemberExpression(member,prepend){member.object=t.memberExpression(prepend,member.object);return member}function ensureBlock(node){var key=arguments.length<=1||arguments[1]===undefined?"body":arguments[1];return node[key]=t.toBlock(node[key],node)}function clone(node){var newNode={};for(var key in node){if(key[0]==="_")continue;newNode[key]=node[key]}return newNode}function cloneDeep(node){var newNode={};for(var key in node){if(key[0]==="_")continue;var val=node[key];if(val){if(val.type){val=t.cloneDeep(val)}else if(Array.isArray(val)){val=val.map(t.cloneDeep)}}newNode[key]=val}return newNode}function buildMatchMemberExpression(match,allowPartial){var parts=match.split(".");return function(member){if(!t.isMemberExpression(member))return false;var search=[member];var i=0;while(search.length){var node=search.shift();if(allowPartial&&i===parts.length){return true}if(t.isIdentifier(node)){if(parts[i]!==node.name)return false}else if(t.isLiteral(node)){if(parts[i]!==node.value)return false}else if(t.isMemberExpression(node)){if(node.computed&&!t.isLiteral(node.property)){return false}else{search.push(node.object);search.push(node.property);continue}}else{return false}if(++i>parts.length){return false}}return true}}function removeComments(node){var _arr3=COMMENT_KEYS;for(var _i3=0;_i3<_arr3.length;_i3++){var key=_arr3[_i3];delete node[key]}return node}function inheritsComments(child,parent){inheritTrailingComments(child,parent);inheritLeadingComments(child,parent);inheritInnerComments(child,parent);return child}function inheritTrailingComments(child,parent){_inheritComments("trailingComments",child,parent)}function inheritLeadingComments(child,parent){_inheritComments("leadingComments",child,parent)}function inheritInnerComments(child,parent){_inheritComments("innerComments",child,parent)}function _inheritComments(key,child,parent){if(child&&parent){child[key]=_lodashArrayUniq2["default"](_lodashArrayCompact2["default"]([].concat(child[key],parent[key])))}}function inherits(child,parent){if(!child||!parent)return child;var _arr4=t.INHERIT_KEYS.optional;for(var _i4=0;_i4<_arr4.length;_i4++){var key=_arr4[_i4];if(child[key]==null){child[key]=parent[key]}}var _arr5=t.INHERIT_KEYS.force;for(var _i5=0;_i5<_arr5.length;_i5++){var key=_arr5[_i5];child[key]=parent[key]}t.inheritsComments(child,parent);return child}_toFastProperties2["default"](t);_toFastProperties2["default"](t.VISITOR_KEYS);_lodashObjectAssign2["default"](t,require("./retrievers"));_lodashObjectAssign2["default"](t,require("./validators"));_lodashObjectAssign2["default"](t,require("./converters"));_lodashObjectAssign2["default"](t,require("./flow"))},{"./converters":186,"./definitions":191,"./definitions/init":192,"./flow":195,"./retrievers":197,"./validators":198,"lodash/array/compact":431,"lodash/array/uniq":435,"lodash/collection/each":437,"lodash/object/assign":535,"to-fast-properties":628}],197:[function(require,module,exports){"use strict";exports.__esModule=true;exports.getBindingIdentifiers=getBindingIdentifiers;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _helpersObject=require("../helpers/object");var _helpersObject2=_interopRequireDefault(_helpersObject);var _index=require("./index");var t=_interopRequireWildcard(_index);function getBindingIdentifiers(node,duplicates){var search=[].concat(node);var ids=_helpersObject2["default"]();while(search.length){var id=search.shift();if(!id)continue;var key=t.getBindingIdentifiers.keys[id.type];if(t.isIdentifier(id)){if(duplicates){var _ids=ids[id.name]=ids[id.name]||[];_ids.push(id)}else{ids[id.name]=id}}else if(t.isExportDeclaration(id)){if(t.isDeclaration(node.declaration)){search.push(node.declaration)}}else if(key&&id[key]){search=search.concat(id[key])}}return ids}getBindingIdentifiers.keys={DeclareClass:"id",DeclareFunction:"id",DeclareModule:"id",DeclareVariable:"id",InterfaceDeclaration:"id",TypeAlias:"id",ComprehensionExpression:"blocks",ComprehensionBlock:"left",CatchClause:"param",LabeledStatement:"label",UnaryExpression:"argument",AssignmentExpression:"left",ImportSpecifier:"local",ImportNamespaceSpecifier:"local",ImportDefaultSpecifier:"local",ImportDeclaration:"specifiers",FunctionDeclaration:"id",FunctionExpression:"id",ClassDeclaration:"id",ClassExpression:"id",RestElement:"argument",UpdateExpression:"argument",SpreadProperty:"argument",Property:"value",AssignmentPattern:"left",ArrayPattern:"elements",ObjectPattern:"properties",VariableDeclaration:"declarations",VariableDeclarator:"id"}},{"../helpers/object":58,"./index":196}],198:[function(require,module,exports){"use strict";exports.__esModule=true;exports.isBinding=isBinding;exports.isReferenced=isReferenced;exports.isValidIdentifier=isValidIdentifier;exports.isLet=isLet;exports.isBlockScoped=isBlockScoped;exports.isVar=isVar;exports.isSpecifierDefault=isSpecifierDefault;exports.isScope=isScope;exports.isImmutable=isImmutable;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _retrievers=require("./retrievers");var _esutils=require("esutils");var _esutils2=_interopRequireDefault(_esutils);var _index=require("./index");var t=_interopRequireWildcard(_index);function isBinding(node,parent){var bindingKey=_retrievers.getBindingIdentifiers.keys[parent.type];if(bindingKey){return parent[bindingKey]===node}else{return false}}function isReferenced(node,parent){switch(parent.type){case"MemberExpression":case"JSXMemberExpression":if(parent.property===node&&parent.computed){return true}else if(parent.object===node){return true}else{return false}case"MetaProperty":return false;case"Property":if(parent.key===node){return parent.computed}case"VariableDeclarator":return parent.id!==node;case"ArrowFunctionExpression":case"FunctionDeclaration":case"FunctionExpression":var _arr=parent.params;for(var _i=0;_i<_arr.length;_i++){var param=_arr[_i];if(param===node)return false}return parent.id!==node;case"ExportSpecifier":if(parent.source){return false}else{return parent.local===node}case"JSXAttribute":return parent.name!==node;case"ClassProperty":return parent.value===node;case"ImportDefaultSpecifier":case"ImportNamespaceSpecifier":case"ImportSpecifier":return false;case"ClassDeclaration":case"ClassExpression":return parent.id!==node;case"MethodDefinition":return parent.key===node&&parent.computed;case"LabeledStatement":return false;case"CatchClause":return parent.param!==node;case"RestElement":return false;case"AssignmentExpression":return parent.right===node;case"AssignmentPattern":return false;case"ObjectPattern":case"ArrayPattern":return false}return true}function isValidIdentifier(name){if(typeof name!=="string"||_esutils2["default"].keyword.isReservedWordES6(name,true)){return false}else{return _esutils2["default"].keyword.isIdentifierNameES6(name)}}function isLet(node){return t.isVariableDeclaration(node)&&(node.kind!=="var"||node._let)}function isBlockScoped(node){return t.isFunctionDeclaration(node)||t.isClassDeclaration(node)||t.isLet(node)}function isVar(node){return t.isVariableDeclaration(node,{kind:"var"})&&!node._let}function isSpecifierDefault(specifier){return t.isImportDefaultSpecifier(specifier)||t.isIdentifier(specifier.imported||specifier.exported,{name:"default"})}function isScope(node,parent){if(t.isBlockStatement(node)&&t.isFunction(parent,{body:node})){return false}return t.isScopable(node)}function isImmutable(node){if(t.isType(node.type,"Immutable"))return true;if(t.isLiteral(node)){if(node.regex){return false}else{return true}}else if(t.isIdentifier(node)){if(node.name==="undefined"){return true}else{return false}}return false}},{"./index":196,"./retrievers":197,esutils:413}],199:[function(require,module,exports){(function(__dirname){"use strict";exports.__esModule=true;exports.canCompile=canCompile;exports.list=list;exports.regexify=regexify;exports.arrayify=arrayify;exports.booleanify=booleanify;exports.shouldIgnore=shouldIgnore;exports.template=template;exports.parseTemplate=parseTemplate;function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj["default"]=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _lodashStringEscapeRegExp=require("lodash/string/escapeRegExp");var _lodashStringEscapeRegExp2=_interopRequireDefault(_lodashStringEscapeRegExp);var _lodashStringStartsWith=require("lodash/string/startsWith");var _lodashStringStartsWith2=_interopRequireDefault(_lodashStringStartsWith);var _lodashLangCloneDeep=require("lodash/lang/cloneDeep");var _lodashLangCloneDeep2=_interopRequireDefault(_lodashLangCloneDeep);var _lodashLangIsBoolean=require("lodash/lang/isBoolean");var _lodashLangIsBoolean2=_interopRequireDefault(_lodashLangIsBoolean);var _messages=require("./messages");var messages=_interopRequireWildcard(_messages);var _minimatch=require("minimatch");var _minimatch2=_interopRequireDefault(_minimatch);var _lodashCollectionContains=require("lodash/collection/contains");var _lodashCollectionContains2=_interopRequireDefault(_lodashCollectionContains);var _traversal=require("./traversal");var _traversal2=_interopRequireDefault(_traversal);var _lodashLangIsString=require("lodash/lang/isString");var _lodashLangIsString2=_interopRequireDefault(_lodashLangIsString);var _lodashLangIsRegExp=require("lodash/lang/isRegExp");var _lodashLangIsRegExp2=_interopRequireDefault(_lodashLangIsRegExp);var _lodashLangIsEmpty=require("lodash/lang/isEmpty");var _lodashLangIsEmpty2=_interopRequireDefault(_lodashLangIsEmpty);var _helpersParse=require("./helpers/parse");var _helpersParse2=_interopRequireDefault(_helpersParse);var _path=require("path");var _path2=_interopRequireDefault(_path);var _lodashObjectHas=require("lodash/object/has");var _lodashObjectHas2=_interopRequireDefault(_lodashObjectHas);var _fs=require("fs");var _fs2=_interopRequireDefault(_fs);var _types=require("./types");var t=_interopRequireWildcard(_types);var _slash=require("slash");var _slash2=_interopRequireDefault(_slash);var _pathExists=require("path-exists");var _pathExists2=_interopRequireDefault(_pathExists);var _util=require("util");exports.inherits=_util.inherits;exports.inspect=_util.inspect;function canCompile(filename,altExts){var exts=altExts||canCompile.EXTENSIONS;var ext=_path2["default"].extname(filename);return _lodashCollectionContains2["default"](exts,ext)}canCompile.EXTENSIONS=[".js",".jsx",".es6",".es"];function list(val){if(!val){return[]}else if(Array.isArray(val)){return val}else if(typeof val==="string"){return val.split(",")}else{return[val]}}function regexify(val){if(!val)return new RegExp(/.^/);if(Array.isArray(val))val=new RegExp(val.map(_lodashStringEscapeRegExp2["default"]).join("|"),"i");if(_lodashLangIsString2["default"](val)){val=_slash2["default"](val);if(_lodashStringStartsWith2["default"](val,"./")||_lodashStringStartsWith2["default"](val,"*/"))val=val.slice(2);if(_lodashStringStartsWith2["default"](val,"**/"))val=val.slice(3);var regex=_minimatch2["default"].makeRe(val,{nocase:true});return new RegExp(regex.source.slice(1,-1),"i")}if(_lodashLangIsRegExp2["default"](val))return val;throw new TypeError("illegal type for regexify")}function arrayify(val,mapFn){if(!val)return[];if(_lodashLangIsBoolean2["default"](val))return arrayify([val],mapFn);if(_lodashLangIsString2["default"](val))return arrayify(list(val),mapFn);if(Array.isArray(val)){if(mapFn)val=val.map(mapFn);return val}return[val]}function booleanify(val){if(val==="true")return true;if(val==="false")return false;return val}function shouldIgnore(filename,ignore,only){filename=_slash2["default"](filename);if(only){var _arr=only;for(var _i=0;_i<_arr.length;_i++){var pattern=_arr[_i];if(_shouldIgnore(pattern,filename))return false}return true}else if(ignore.length){var _arr2=ignore;for(var _i2=0;_i2<_arr2.length;_i2++){var pattern=_arr2[_i2];if(_shouldIgnore(pattern,filename))return true}}return false}function _shouldIgnore(pattern,filename){if(typeof pattern==="function"){return pattern(filename)}else{return pattern.test(filename)}}var templateVisitor={noScope:true,enter:function enter(node,parent,scope,nodes){if(t.isExpressionStatement(node)){node=node.expression}if(t.isIdentifier(node)&&_lodashObjectHas2["default"](nodes,node.name)){this.skip();this.replaceInline(nodes[node.name])}},exit:function exit(node){_traversal2["default"].clearNode(node)}};function template(name,nodes,keepExpression){var ast=exports.templates[name];if(!ast)throw new ReferenceError("unknown template "+name);if(nodes===true){keepExpression=true;nodes=null}ast=_lodashLangCloneDeep2["default"](ast);if(!_lodashLangIsEmpty2["default"](nodes)){_traversal2["default"](ast,templateVisitor,null,nodes)}if(ast.body.length>1)return ast.body;var node=ast.body[0];if(!keepExpression&&t.isExpressionStatement(node)){return node.expression}else{return node}}function parseTemplate(loc,code){var ast=_helpersParse2["default"](code,{filename:loc,looseModules:true}).program;ast=_traversal2["default"].removeProperties(ast);return ast}function loadTemplates(){var templates={};var templatesLoc=_path2["default"].join(__dirname,"transformation/templates");if(!_pathExists2["default"].sync(templatesLoc)){throw new ReferenceError(messages.get("missingTemplatesDirectory"))}var _arr3=_fs2["default"].readdirSync(templatesLoc);for(var _i3=0;_i3<_arr3.length;_i3++){var name=_arr3[_i3];if(name[0]===".")return;var key=_path2["default"].basename(name,_path2["default"].extname(name));var loc=_path2["default"].join(templatesLoc,name);var code=_fs2["default"].readFileSync(loc,"utf8");templates[key]=parseTemplate(loc,code)}return templates}try{exports.templates=require("../templates.json")}catch(err){if(err.code!=="MODULE_NOT_FOUND")throw err;exports.templates=loadTemplates()}}).call(this,"/lib")},{"../templates.json":632,"./helpers/parse":59,"./messages":60,"./traversal":165,"./types":196,fs:1,"lodash/collection/contains":436,"lodash/lang/cloneDeep":521,"lodash/lang/isBoolean":524,"lodash/lang/isEmpty":525,"lodash/lang/isRegExp":531,"lodash/lang/isString":532,"lodash/object/has":538,"lodash/string/escapeRegExp":544,"lodash/string/startsWith":545,minimatch:548,path:11,"path-exists":552,slash:615,util:30}],200:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=function(_ref){var Plugin=_ref.Plugin;var t=_ref.types;return new Plugin("constant-folding",{metadata:{group:"builtin-prepass",experimental:true},visitor:{AssignmentExpression:function AssignmentExpression(){var left=this.get("left");if(!left.isIdentifier())return;var binding=this.scope.getBinding(left.node.name);if(!binding||binding.hasDeoptValue)return;var evaluated=this.get("right").evaluate();if(evaluated.confident){binding.setValue(evaluated.value)}else{binding.deoptValue()}},IfStatement:function IfStatement(){var evaluated=this.get("test").evaluate();if(!evaluated.confident){return this.skip()}if(evaluated.value){this.skipKey("alternate")}else{this.skipKey("consequent")}},Scopable:{enter:function enter(){var funcScope=this.scope.getFunctionParent();for(var name in this.scope.bindings){var binding=this.scope.bindings[name];var deopt=false;var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=binding.constantViolations[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var path=_step.value;var funcViolationScope=path.scope.getFunctionParent();if(funcViolationScope!==funcScope){deopt=true;break}}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}if(deopt)binding.deoptValue()}},exit:function exit(){for(var name in this.scope.bindings){var binding=this.scope.bindings[name];binding.clearValue()}}},Expression:{exit:function exit(){var res=this.evaluate();if(res.confident)return t.valueToNode(res.value)}}}})};module.exports=exports["default"]},{}],201:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=function(_ref){var Plugin=_ref.Plugin;var t=_ref.types;function toStatements(node){ -if(t.isBlockStatement(node)){var hasBlockScoped=false;for(var i=0;i1||!binding.constant)return;if(binding.kind==="param"||binding.kind==="module")return;var replacement=binding.path.node;if(t.isVariableDeclarator(replacement)){replacement=replacement.init}if(!replacement)return;if(!scope.isPure(replacement,true))return;if(t.isClass(replacement)||t.isFunction(replacement)){if(binding.path.scope.parent!==scope)return}if(this.findParent(function(path){return path.node===replacement})){return}t.toExpression(replacement);scope.removeBinding(node.name);binding.path.dangerouslyRemove();return replacement},"ClassDeclaration|FunctionDeclaration":function ClassDeclarationFunctionDeclaration(node,parent,scope){var binding=scope.getBinding(node.id.name);if(binding&&!binding.referenced){this.dangerouslyRemove()}},VariableDeclarator:function VariableDeclarator(node,parent,scope){if(!t.isIdentifier(node.id)||!scope.isPure(node.init,true))return;visitor["ClassDeclaration|FunctionDeclaration"].apply(this,arguments)},ConditionalExpression:function ConditionalExpression(node){var evaluateTest=this.get("test").evaluateTruthy();if(evaluateTest===true){return node.consequent}else if(evaluateTest===false){return node.alternate}},BlockStatement:function BlockStatement(){var paths=this.get("body");var purge=false;for(var i=0;i3)continue;if(distance<=shortest)continue;closest=name;shortest=distance}var msg;if(closest){msg=messages.get("undeclaredVariableSuggestion",node.name,closest)}else{msg=messages.get("undeclaredVariable",node.name)}throw this.errorWithNode(msg,ReferenceError)}}})};module.exports=exports["default"]},{leven:215}],215:[function(require,module,exports){"use strict";var arr=[];var charCodeCache=[];module.exports=function(a,b){if(a===b){return 0}var aLen=a.length;var bLen=b.length;if(aLen===0){return bLen}if(bLen===0){return aLen}var bCharCode;var ret;var tmp;var tmp2;var i=0;var j=0;while(iret?tmp2>ret?ret+1:tmp2:tmp2>tmp?tmp+1:tmp2}}return ret}},{}],216:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=function(_ref){var Plugin=_ref.Plugin;var t=_ref.types;return new Plugin("undefined-to-void",{metadata:{group:"builtin-basic"},visitor:{ReferencedIdentifier:function ReferencedIdentifier(node,parent){if(node.name==="undefined"){return t.unaryExpression("void",t.literal(0),true)}}}})};module.exports=exports["default"]},{}],217:[function(require,module,exports){(function(process){"use strict";var escapeStringRegexp=require("escape-string-regexp");var ansiStyles=require("ansi-styles");var stripAnsi=require("strip-ansi");var hasAnsi=require("has-ansi");var supportsColor=require("supports-color");var defineProps=Object.defineProperties;var isSimpleWindowsTerm=process.platform==="win32"&&!/^xterm/i.test(process.env.TERM);function Chalk(options){this.enabled=!options||options.enabled===undefined?supportsColor:options.enabled}if(isSimpleWindowsTerm){ansiStyles.blue.open=""}var styles=function(){var ret={};Object.keys(ansiStyles).forEach(function(key){ansiStyles[key].closeRe=new RegExp(escapeStringRegexp(ansiStyles[key].close),"g");ret[key]={get:function(){return build.call(this,this._styles.concat(key))}}});return ret}();var proto=defineProps(function chalk(){},styles);function build(_styles){var builder=function(){return applyStyle.apply(builder,arguments)};builder._styles=_styles;builder.enabled=this.enabled;builder.__proto__=proto;return builder}function applyStyle(){var args=arguments;var argsLen=args.length;var str=argsLen!==0&&String(arguments[0]);if(argsLen>1){for(var a=1;a<]/g}},{}],222:[function(require,module,exports){"use strict";var ansiRegex=require("ansi-regex")();module.exports=function(str){return typeof str==="string"?str.replace(ansiRegex,""):str}},{"ansi-regex":223}],223:[function(require,module,exports){arguments[4][221][0].apply(exports,arguments)},{dup:221}],224:[function(require,module,exports){(function(process){"use strict";var argv=process.argv;var terminator=argv.indexOf("--");var hasFlag=function(flag){flag="--"+flag;var pos=argv.indexOf(flag);return pos!==-1&&(terminator!==-1?pos0;i--){line=lines[i];if(~line.indexOf("sourceMappingURL=data:"))return exports.fromComment(line)}}Converter.prototype.toJSON=function(space){return JSON.stringify(this.sourcemap,null,space)};Converter.prototype.toBase64=function(){var json=this.toJSON();return new Buffer(json).toString("base64")};Converter.prototype.toComment=function(options){var base64=this.toBase64();var data="sourceMappingURL=data:application/json;base64,"+base64;return options&&options.multiline?"/*# "+data+" */":"//# "+data};Converter.prototype.toObject=function(){return JSON.parse(this.toJSON())};Converter.prototype.addProperty=function(key,value){if(this.sourcemap.hasOwnProperty(key))throw new Error("property %s already exists on the sourcemap, use set property instead");return this.setProperty(key,value)};Converter.prototype.setProperty=function(key,value){this.sourcemap[key]=value;return this};Converter.prototype.getProperty=function(key){return this.sourcemap[key]};exports.fromObject=function(obj){return new Converter(obj)};exports.fromJSON=function(json){return new Converter(json,{isJSON:true})};exports.fromBase64=function(base64){return new Converter(base64,{isEncoded:true})};exports.fromComment=function(comment){comment=comment.replace(/^\/\*/g,"//").replace(/\*\/$/g,"");return new Converter(comment,{isEncoded:true,hasComment:true})};exports.fromMapFileComment=function(comment,dir){return new Converter(comment,{commentFileDir:dir,isFileComment:true,isJSON:true})};exports.fromSource=function(content,largeSource){if(largeSource)return convertFromLargeSource(content);var m=content.match(commentRx);commentRx.lastIndex=0;return m?exports.fromComment(m.pop()):null};exports.fromMapFileSource=function(content,dir){var m=content.match(mapFileCommentRx);mapFileCommentRx.lastIndex=0;return m?exports.fromMapFileComment(m.pop(),dir):null};exports.removeComments=function(src){commentRx.lastIndex=0;return src.replace(commentRx,"")};exports.removeMapFileComments=function(src){mapFileCommentRx.lastIndex=0;return src.replace(mapFileCommentRx,"")};Object.defineProperty(exports,"commentRegex",{get:function getCommentRegex(){commentRx.lastIndex=0;return commentRx}});Object.defineProperty(exports,"mapFileCommentRegex",{get:function getMapFileCommentRegex(){mapFileCommentRx.lastIndex=0;return mapFileCommentRx}})}).call(this,require("buffer").Buffer)},{buffer:4,fs:1,path:11}],226:[function(require,module,exports){module.exports=function(it){if(typeof it!="function")throw TypeError(it+" is not a function!");return it}},{}],227:[function(require,module,exports){var isObject=require("./$.is-object");module.exports=function(it){if(!isObject(it))throw TypeError(it+" is not an object!");return it}},{"./$.is-object":257}],228:[function(require,module,exports){var toIObject=require("./$.to-iobject"),toLength=require("./$.to-length"),toIndex=require("./$.to-index");module.exports=function(IS_INCLUDES){return function($this,el,fromIndex){var O=toIObject($this),length=toLength(O.length),index=toIndex(fromIndex,length),value;if(IS_INCLUDES&&el!=el)while(length>index){value=O[index++];if(value!=value)return true}else for(;length>index;index++)if(IS_INCLUDES||index in O){if(O[index]===el)return IS_INCLUDES||index}return!IS_INCLUDES&&-1}}},{"./$.to-index":293,"./$.to-iobject":295,"./$.to-length":296}],229:[function(require,module,exports){var ctx=require("./$.ctx"),IObject=require("./$.iobject"),toObject=require("./$.to-object"),toLength=require("./$.to-length");module.exports=function(TYPE){var IS_MAP=TYPE==1,IS_FILTER=TYPE==2,IS_SOME=TYPE==3,IS_EVERY=TYPE==4,IS_FIND_INDEX=TYPE==6,NO_HOLES=TYPE==5||IS_FIND_INDEX;return function($this,callbackfn,that){var O=toObject($this),self=IObject(O),f=ctx(callbackfn,that,3),length=toLength(self.length),index=0,result=IS_MAP?Array(length):IS_FILTER?[]:undefined,val,res;for(;length>index;index++)if(NO_HOLES||index in self){val=self[index];res=f(val,index,O);if(TYPE){if(IS_MAP)result[index]=res;else if(res)switch(TYPE){case 3:return true;case 5:return val;case 6:return index;case 2:result.push(val)}else if(IS_EVERY)return false}}return IS_FIND_INDEX?-1:IS_SOME||IS_EVERY?IS_EVERY:result}}},{"./$.ctx":238,"./$.iobject":254,"./$.to-length":296,"./$.to-object":297}],230:[function(require,module,exports){var toObject=require("./$.to-object"),IObject=require("./$.iobject"),enumKeys=require("./$.enum-keys");module.exports=Object.assign||function assign(target,source){var T=toObject(target),l=arguments.length,i=1;while(l>i){var S=IObject(arguments[i++]),keys=enumKeys(S),length=keys.length,j=0,key;while(length>j)T[key=keys[j++]]=S[key]}return T}},{"./$.enum-keys":242,"./$.iobject":254,"./$.to-object":297}],231:[function(require,module,exports){var cof=require("./$.cof"),TAG=require("./$.wks")("toStringTag"),ARG=cof(function(){return arguments}())=="Arguments";module.exports=function(it){var O,T,B;return it===undefined?"Undefined":it===null?"Null":typeof(T=(O=Object(it))[TAG])=="string"?T:ARG?cof(O):(B=cof(O))=="Object"&&typeof O.callee=="function"?"Arguments":B}},{"./$.cof":232,"./$.wks":300}],232:[function(require,module,exports){var toString={}.toString;module.exports=function(it){return toString.call(it).slice(8,-1)}},{}],233:[function(require,module,exports){"use strict";var $=require("./$"),hide=require("./$.hide"),ctx=require("./$.ctx"),species=require("./$.species"),strictNew=require("./$.strict-new"),defined=require("./$.defined"),forOf=require("./$.for-of"),step=require("./$.iter-step"),ID=require("./$.uid")("id"),$has=require("./$.has"),isObject=require("./$.is-object"),isExtensible=Object.isExtensible||isObject,SUPPORT_DESC=require("./$.support-desc"),SIZE=SUPPORT_DESC?"_s":"size",id=0;var fastKey=function(it,create){if(!isObject(it))return typeof it=="symbol"?it:(typeof it=="string"?"S":"P")+it;if(!$has(it,ID)){if(!isExtensible(it))return"F";if(!create)return"E";hide(it,ID,++id)}return"O"+it[ID]};var getEntry=function(that,key){var index=fastKey(key),entry;if(index!=="F")return that._i[index];for(entry=that._f;entry;entry=entry.n){if(entry.k==key)return entry}};module.exports={getConstructor:function(wrapper,NAME,IS_MAP,ADDER){var C=wrapper(function(that,iterable){strictNew(that,C,NAME);that._i=$.create(null);that._f=undefined;that._l=undefined;that[SIZE]=0;if(iterable!=undefined)forOf(iterable,IS_MAP,that[ADDER],that)});require("./$.mix")(C.prototype,{clear:function clear(){for(var that=this,data=that._i,entry=that._f;entry;entry=entry.n){entry.r=true;if(entry.p)entry.p=entry.p.n=undefined; -delete data[entry.i]}that._f=that._l=undefined;that[SIZE]=0},"delete":function(key){var that=this,entry=getEntry(that,key);if(entry){var next=entry.n,prev=entry.p;delete that._i[entry.i];entry.r=true;if(prev)prev.n=next;if(next)next.p=prev;if(that._f==entry)that._f=next;if(that._l==entry)that._l=prev;that[SIZE]--}return!!entry},forEach:function forEach(callbackfn){var f=ctx(callbackfn,arguments[1],3),entry;while(entry=entry?entry.n:this._f){f(entry.v,entry.k,this);while(entry&&entry.r)entry=entry.p}},has:function has(key){return!!getEntry(this,key)}});if(SUPPORT_DESC)$.setDesc(C.prototype,"size",{get:function(){return defined(this[SIZE])}});return C},def:function(that,key,value){var entry=getEntry(that,key),prev,index;if(entry){entry.v=value}else{that._l=entry={i:index=fastKey(key,true),k:key,v:value,p:prev=that._l,n:undefined,r:false};if(!that._f)that._f=entry;if(prev)prev.n=entry;that[SIZE]++;if(index!=="F")that._i[index]=entry}return that},getEntry:getEntry,setStrong:function(C,NAME,IS_MAP){require("./$.iter-define")(C,NAME,function(iterated,kind){this._t=iterated;this._k=kind;this._l=undefined},function(){var that=this,kind=that._k,entry=that._l;while(entry&&entry.r)entry=entry.p;if(!that._t||!(that._l=entry=entry?entry.n:that._t._f)){that._t=undefined;return step(1)}if(kind=="keys")return step(0,entry.k);if(kind=="values")return step(0,entry.v);return step(0,[entry.k,entry.v])},IS_MAP?"entries":"values",!IS_MAP,true);species(C);species(require("./$.core")[NAME])}}},{"./$":265,"./$.core":237,"./$.ctx":238,"./$.defined":240,"./$.for-of":247,"./$.has":250,"./$.hide":251,"./$.is-object":257,"./$.iter-define":261,"./$.iter-step":263,"./$.mix":270,"./$.species":283,"./$.strict-new":284,"./$.support-desc":290,"./$.uid":298}],234:[function(require,module,exports){var forOf=require("./$.for-of"),classof=require("./$.classof");module.exports=function(NAME){return function toJSON(){if(classof(this)!=NAME)throw TypeError(NAME+"#toJSON isn't generic");var arr=[];forOf(this,false,arr.push,arr);return arr}}},{"./$.classof":231,"./$.for-of":247}],235:[function(require,module,exports){"use strict";var hide=require("./$.hide"),anObject=require("./$.an-object"),strictNew=require("./$.strict-new"),forOf=require("./$.for-of"),method=require("./$.array-methods"),WEAK=require("./$.uid")("weak"),isObject=require("./$.is-object"),$has=require("./$.has"),isExtensible=Object.isExtensible||isObject,find=method(5),findIndex=method(6),id=0;var frozenStore=function(that){return that._l||(that._l=new FrozenStore)};var FrozenStore=function(){this.a=[]};var findFrozen=function(store,key){return find(store.a,function(it){return it[0]===key})};FrozenStore.prototype={get:function(key){var entry=findFrozen(this,key);if(entry)return entry[1]},has:function(key){return!!findFrozen(this,key)},set:function(key,value){var entry=findFrozen(this,key);if(entry)entry[1]=value;else this.a.push([key,value])},"delete":function(key){var index=findIndex(this.a,function(it){return it[0]===key});if(~index)this.a.splice(index,1);return!!~index}};module.exports={getConstructor:function(wrapper,NAME,IS_MAP,ADDER){var C=wrapper(function(that,iterable){strictNew(that,C,NAME);that._i=id++;that._l=undefined;if(iterable!=undefined)forOf(iterable,IS_MAP,that[ADDER],that)});require("./$.mix")(C.prototype,{"delete":function(key){if(!isObject(key))return false;if(!isExtensible(key))return frozenStore(this)["delete"](key);return $has(key,WEAK)&&$has(key[WEAK],this._i)&&delete key[WEAK][this._i]},has:function has(key){if(!isObject(key))return false;if(!isExtensible(key))return frozenStore(this).has(key);return $has(key,WEAK)&&$has(key[WEAK],this._i)}});return C},def:function(that,key,value){if(!isExtensible(anObject(key))){frozenStore(that).set(key,value)}else{$has(key,WEAK)||hide(key,WEAK,{});key[WEAK][that._i]=value}return that},frozenStore:frozenStore,WEAK:WEAK}},{"./$.an-object":227,"./$.array-methods":229,"./$.for-of":247,"./$.has":250,"./$.hide":251,"./$.is-object":257,"./$.mix":270,"./$.strict-new":284,"./$.uid":298}],236:[function(require,module,exports){"use strict";var global=require("./$.global"),$def=require("./$.def"),BUGGY=require("./$.iter-buggy"),forOf=require("./$.for-of"),strictNew=require("./$.strict-new");module.exports=function(NAME,wrapper,methods,common,IS_MAP,IS_WEAK){var Base=global[NAME],C=Base,ADDER=IS_MAP?"set":"add",proto=C&&C.prototype,O={};var fixMethod=function(KEY){var fn=proto[KEY];require("./$.redef")(proto,KEY,KEY=="delete"?function(a){return fn.call(this,a===0?0:a)}:KEY=="has"?function has(a){return fn.call(this,a===0?0:a)}:KEY=="get"?function get(a){return fn.call(this,a===0?0:a)}:KEY=="add"?function add(a){fn.call(this,a===0?0:a);return this}:function set(a,b){fn.call(this,a===0?0:a,b);return this})};if(typeof C!="function"||!(IS_WEAK||!BUGGY&&proto.forEach&&proto.entries)){C=common.getConstructor(wrapper,NAME,IS_MAP,ADDER);require("./$.mix")(C.prototype,methods)}else{var inst=new C,chain=inst[ADDER](IS_WEAK?{}:-0,1),buggyZero;if(!require("./$.iter-detect")(function(iter){new C(iter)})){C=wrapper(function(target,iterable){strictNew(target,C,NAME);var that=new Base;if(iterable!=undefined)forOf(iterable,IS_MAP,that[ADDER],that);return that});C.prototype=proto;proto.constructor=C}IS_WEAK||inst.forEach(function(val,key){buggyZero=1/key===-Infinity});if(buggyZero){fixMethod("delete");fixMethod("has");IS_MAP&&fixMethod("get")}if(buggyZero||chain!==inst)fixMethod(ADDER);if(IS_WEAK&&proto.clear)delete proto.clear}require("./$.tag")(C,NAME);O[NAME]=C;$def($def.G+$def.W+$def.F*(C!=Base),O);if(!IS_WEAK)common.setStrong(C,NAME,IS_MAP);return C}},{"./$.def":239,"./$.for-of":247,"./$.global":249,"./$.iter-buggy":258,"./$.iter-detect":262,"./$.mix":270,"./$.redef":277,"./$.strict-new":284,"./$.tag":291}],237:[function(require,module,exports){var core=module.exports={};if(typeof __e=="number")__e=core},{}],238:[function(require,module,exports){var aFunction=require("./$.a-function");module.exports=function(fn,that,length){aFunction(fn);if(that===undefined)return fn;switch(length){case 1:return function(a){return fn.call(that,a)};case 2:return function(a,b){return fn.call(that,a,b)};case 3:return function(a,b,c){return fn.call(that,a,b,c)}}return function(){return fn.apply(that,arguments)}}},{"./$.a-function":226}],239:[function(require,module,exports){var global=require("./$.global"),core=require("./$.core"),hide=require("./$.hide"),$redef=require("./$.redef"),PROTOTYPE="prototype";var ctx=function(fn,that){return function(){return fn.apply(that,arguments)}};var $def=function(type,name,source){var key,own,out,exp,isGlobal=type&$def.G,isProto=type&$def.P,target=isGlobal?global:type&$def.S?global[name]||(global[name]={}):(global[name]||{})[PROTOTYPE],exports=isGlobal?core:core[name]||(core[name]={});if(isGlobal)source=name;for(key in source){own=!(type&$def.F)&&target&&key in target;out=(own?target:source)[key];if(type&$def.B&&own)exp=ctx(out,global);else exp=isProto&&typeof out=="function"?ctx(Function.call,out):out;if(target&&!own)$redef(target,key,out);if(exports[key]!=out)hide(exports,key,exp);if(isProto)(exports[PROTOTYPE]||(exports[PROTOTYPE]={}))[key]=out}};global.core=core;$def.F=1;$def.G=2;$def.S=4;$def.P=8;$def.B=16;$def.W=32;module.exports=$def},{"./$.core":237,"./$.global":249,"./$.hide":251,"./$.redef":277}],240:[function(require,module,exports){module.exports=function(it){if(it==undefined)throw TypeError("Can't call method on "+it);return it}},{}],241:[function(require,module,exports){var isObject=require("./$.is-object"),document=require("./$.global").document,is=isObject(document)&&isObject(document.createElement);module.exports=function(it){return is?document.createElement(it):{}}},{"./$.global":249,"./$.is-object":257}],242:[function(require,module,exports){var $=require("./$");module.exports=function(it){var keys=$.getKeys(it),getSymbols=$.getSymbols;if(getSymbols){var symbols=getSymbols(it),isEnum=$.isEnum,i=0,key;while(symbols.length>i)if(isEnum.call(it,key=symbols[i++]))keys.push(key)}return keys}},{"./$":265}],243:[function(require,module,exports){module.exports=Math.expm1||function expm1(x){return(x=+x)==0?x:x>-1e-6&&x<1e-6?x+x*x/2:Math.exp(x)-1}},{}],244:[function(require,module,exports){module.exports=function(exec){try{return!!exec()}catch(e){return true}}},{}],245:[function(require,module,exports){"use strict";module.exports=function(KEY,length,exec){var defined=require("./$.defined"),SYMBOL=require("./$.wks")(KEY),original=""[KEY];if(require("./$.fails")(function(){var O={};O[SYMBOL]=function(){return 7};return""[KEY](O)!=7})){require("./$.redef")(String.prototype,KEY,exec(defined,SYMBOL,original));require("./$.hide")(RegExp.prototype,SYMBOL,length==2?function(string,arg){return original.call(string,this,arg)}:function(string){return original.call(string,this)})}}},{"./$.defined":240,"./$.fails":244,"./$.hide":251,"./$.redef":277,"./$.wks":300}],246:[function(require,module,exports){"use strict";var anObject=require("./$.an-object");module.exports=function(){var that=anObject(this),result="";if(that.global)result+="g";if(that.ignoreCase)result+="i";if(that.multiline)result+="m";if(that.unicode)result+="u";if(that.sticky)result+="y";return result}},{"./$.an-object":227}],247:[function(require,module,exports){var ctx=require("./$.ctx"),call=require("./$.iter-call"),isArrayIter=require("./$.is-array-iter"),anObject=require("./$.an-object"),toLength=require("./$.to-length"),getIterFn=require("./core.get-iterator-method");module.exports=function(iterable,entries,fn,that){var iterFn=getIterFn(iterable),f=ctx(fn,that,entries?2:1),index=0,length,step,iterator;if(typeof iterFn!="function")throw TypeError(iterable+" is not iterable!");if(isArrayIter(iterFn))for(length=toLength(iterable.length);length>index;index++){entries?f(anObject(step=iterable[index])[0],step[1]):f(iterable[index])}else for(iterator=iterFn.call(iterable);!(step=iterator.next()).done;){call(iterator,f,step.value,entries)}}},{"./$.an-object":227,"./$.ctx":238,"./$.is-array-iter":255,"./$.iter-call":259,"./$.to-length":296,"./core.get-iterator-method":301}],248:[function(require,module,exports){var toString={}.toString,toIObject=require("./$.to-iobject"),getNames=require("./$").getNames;var windowNames=typeof window=="object"&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];var getWindowNames=function(it){try{return getNames(it)}catch(e){return windowNames.slice()}};module.exports.get=function getOwnPropertyNames(it){if(windowNames&&toString.call(it)=="[object Window]")return getWindowNames(it);return getNames(toIObject(it))}},{"./$":265,"./$.to-iobject":295}],249:[function(require,module,exports){var global=typeof self!="undefined"&&self.Math==Math?self:Function("return this")();module.exports=global;if(typeof __g=="number")__g=global},{}],250:[function(require,module,exports){var hasOwnProperty={}.hasOwnProperty;module.exports=function(it,key){return hasOwnProperty.call(it,key)}},{}],251:[function(require,module,exports){var $=require("./$"),createDesc=require("./$.property-desc");module.exports=require("./$.support-desc")?function(object,key,value){return $.setDesc(object,key,createDesc(1,value))}:function(object,key,value){object[key]=value;return object}},{"./$":265,"./$.property-desc":276,"./$.support-desc":290}],252:[function(require,module,exports){module.exports=require("./$.global").document&&document.documentElement},{"./$.global":249}],253:[function(require,module,exports){module.exports=function(fn,args,that){var un=that===undefined;switch(args.length){case 0:return un?fn():fn.call(that);case 1:return un?fn(args[0]):fn.call(that,args[0]);case 2:return un?fn(args[0],args[1]):fn.call(that,args[0],args[1]);case 3:return un?fn(args[0],args[1],args[2]):fn.call(that,args[0],args[1],args[2]);case 4:return un?fn(args[0],args[1],args[2],args[3]):fn.call(that,args[0],args[1],args[2],args[3])}return fn.apply(that,args)}},{}],254:[function(require,module,exports){var cof=require("./$.cof");module.exports=0 in Object("z")?Object:function(it){return cof(it)=="String"?it.split(""):Object(it)}},{"./$.cof":232}],255:[function(require,module,exports){var Iterators=require("./$.iterators"),ITERATOR=require("./$.wks")("iterator");module.exports=function(it){return(Iterators.Array||Array.prototype[ITERATOR])===it}},{"./$.iterators":264,"./$.wks":300}],256:[function(require,module,exports){var isObject=require("./$.is-object"),floor=Math.floor;module.exports=function isInteger(it){return!isObject(it)&&isFinite(it)&&floor(it)===it}},{"./$.is-object":257}],257:[function(require,module,exports){module.exports=function(it){return it!==null&&(typeof it=="object"||typeof it=="function")}},{}],258:[function(require,module,exports){module.exports="keys"in[]&&!("next"in[].keys())},{}],259:[function(require,module,exports){var anObject=require("./$.an-object");module.exports=function(iterator,fn,value,entries){try{return entries?fn(anObject(value)[0],value[1]):fn(value)}catch(e){var ret=iterator["return"];if(ret!==undefined)anObject(ret.call(iterator));throw e}}},{"./$.an-object":227}],260:[function(require,module,exports){"use strict";var $=require("./$"),IteratorPrototype={};require("./$.hide")(IteratorPrototype,require("./$.wks")("iterator"),function(){return this});module.exports=function(Constructor,NAME,next){Constructor.prototype=$.create(IteratorPrototype,{next:require("./$.property-desc")(1,next)});require("./$.tag")(Constructor,NAME+" Iterator")}},{"./$":265,"./$.hide":251,"./$.property-desc":276,"./$.tag":291,"./$.wks":300}],261:[function(require,module,exports){"use strict";var LIBRARY=require("./$.library"),$def=require("./$.def"),$redef=require("./$.redef"),hide=require("./$.hide"),has=require("./$.has"),SYMBOL_ITERATOR=require("./$.wks")("iterator"),Iterators=require("./$.iterators"),FF_ITERATOR="@@iterator",KEYS="keys",VALUES="values";var returnThis=function(){return this};module.exports=function(Base,NAME,Constructor,next,DEFAULT,IS_SET,FORCE){require("./$.iter-create")(Constructor,NAME,next);var createMethod=function(kind){switch(kind){case KEYS:return function keys(){return new Constructor(this,kind)};case VALUES:return function values(){return new Constructor(this,kind)}}return function entries(){return new Constructor(this,kind)}};var TAG=NAME+" Iterator",proto=Base.prototype,_native=proto[SYMBOL_ITERATOR]||proto[FF_ITERATOR]||DEFAULT&&proto[DEFAULT],_default=_native||createMethod(DEFAULT),methods,key;if(_native){var IteratorPrototype=require("./$").getProto(_default.call(new Base));require("./$.tag")(IteratorPrototype,TAG,true);if(!LIBRARY&&has(proto,FF_ITERATOR))hide(IteratorPrototype,SYMBOL_ITERATOR,returnThis)}if(!LIBRARY||FORCE)hide(proto,SYMBOL_ITERATOR,_default);Iterators[NAME]=_default;Iterators[TAG]=returnThis;if(DEFAULT){methods={keys:IS_SET?_default:createMethod(KEYS),values:DEFAULT==VALUES?_default:createMethod(VALUES),entries:DEFAULT!=VALUES?_default:createMethod("entries")};if(FORCE)for(key in methods){if(!(key in proto))$redef(proto,key,methods[key])}else $def($def.P+$def.F*require("./$.iter-buggy"),NAME,methods)}}},{"./$":265,"./$.def":239,"./$.has":250,"./$.hide":251,"./$.iter-buggy":258,"./$.iter-create":260,"./$.iterators":264,"./$.library":267,"./$.redef":277,"./$.tag":291,"./$.wks":300}],262:[function(require,module,exports){var SYMBOL_ITERATOR=require("./$.wks")("iterator"),SAFE_CLOSING=false;try{var riter=[7][SYMBOL_ITERATOR]();riter["return"]=function(){SAFE_CLOSING=true};Array.from(riter,function(){throw 2})}catch(e){}module.exports=function(exec){if(!SAFE_CLOSING)return false;var safe=false;try{var arr=[7],iter=arr[SYMBOL_ITERATOR]();iter.next=function(){safe=true};arr[SYMBOL_ITERATOR]=function(){return iter};exec(arr)}catch(e){}return safe}},{"./$.wks":300}],263:[function(require,module,exports){module.exports=function(done,value){return{value:value,done:!!done}}},{}],264:[function(require,module,exports){module.exports={}},{}],265:[function(require,module,exports){var $Object=Object;module.exports={create:$Object.create,getProto:$Object.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:$Object.getOwnPropertyDescriptor,setDesc:$Object.defineProperty,setDescs:$Object.defineProperties,getKeys:$Object.keys,getNames:$Object.getOwnPropertyNames,getSymbols:$Object.getOwnPropertySymbols,each:[].forEach}},{}],266:[function(require,module,exports){var $=require("./$"),toIObject=require("./$.to-iobject");module.exports=function(object,el){var O=toIObject(object),keys=$.getKeys(O),length=keys.length,index=0,key;while(length>index)if(O[key=keys[index++]]===el)return key}},{"./$":265,"./$.to-iobject":295}],267:[function(require,module,exports){module.exports=false},{}],268:[function(require,module,exports){module.exports=Math.log1p||function log1p(x){return(x=+x)>-1e-8&&x<1e-8?x-x*x/2:Math.log(1+x)}},{}],269:[function(require,module,exports){var global=require("./$.global"),macrotask=require("./$.task").set,Observer=global.MutationObserver||global.WebKitMutationObserver,process=global.process,head,last,notify;function flush(){while(head){head.fn.call();head=head.next}last=undefined}if(require("./$.cof")(process)=="process"){notify=function(){process.nextTick(flush)}}else if(Observer){var toggle=1,node=document.createTextNode("");new Observer(flush).observe(node,{characterData:true});notify=function(){node.data=toggle=-toggle}}else{notify=function(){macrotask.call(global,flush)}}module.exports=function asap(fn){var task={fn:fn,next:undefined};if(last)last.next=task;if(!head){head=task;notify()}last=task}},{"./$.cof":232,"./$.global":249,"./$.task":292}],270:[function(require,module,exports){var $redef=require("./$.redef");module.exports=function(target,src){for(var key in src)$redef(target,key,src[key]);return target}},{"./$.redef":277}],271:[function(require,module,exports){module.exports=function(KEY,exec){var $def=require("./$.def"),fn=(require("./$.core").Object||{})[KEY]||Object[KEY],exp={};exp[KEY]=exec(fn);$def($def.S+$def.F*require("./$.fails")(function(){fn(1)}),"Object",exp)}},{"./$.core":237,"./$.def":239,"./$.fails":244}],272:[function(require,module,exports){var $=require("./$"),toIObject=require("./$.to-iobject");module.exports=function(isEntries){return function(it){var O=toIObject(it),keys=$.getKeys(O),length=keys.length,i=0,result=Array(length),key;if(isEntries)while(length>i)result[i]=[key=keys[i++],O[key]];else while(length>i)result[i]=O[keys[i++]];return result}}},{"./$":265,"./$.to-iobject":295}],273:[function(require,module,exports){var $=require("./$"),anObject=require("./$.an-object");module.exports=function ownKeys(it){var keys=$.getNames(anObject(it)),getSymbols=$.getSymbols;return getSymbols?keys.concat(getSymbols(it)):keys}},{"./$":265,"./$.an-object":227}],274:[function(require,module,exports){"use strict";var path=require("./$.path"),invoke=require("./$.invoke"),aFunction=require("./$.a-function");module.exports=function(){var fn=aFunction(this),length=arguments.length,pargs=Array(length),i=0,_=path._,holder=false;while(length>i)if((pargs[i]=arguments[i++])===_)holder=true;return function(){var that=this,_length=arguments.length,j=0,k=0,args;if(!holder&&!_length)return invoke(fn,pargs,that);args=pargs.slice();if(holder)for(;length>j;j++)if(args[j]===_)args[j]=arguments[k++];while(_length>k)args.push(arguments[k++]);return invoke(fn,args,that)}}},{"./$.a-function":226,"./$.invoke":253,"./$.path":275}],275:[function(require,module,exports){module.exports=require("./$.global")},{"./$.global":249}],276:[function(require,module,exports){module.exports=function(bitmap,value){return{enumerable:!(bitmap&1),configurable:!(bitmap&2),writable:!(bitmap&4),value:value}}},{}],277:[function(require,module,exports){var global=require("./$.global"),hide=require("./$.hide"),SRC=require("./$.uid")("src"),TO_STRING="toString",$toString=Function[TO_STRING],TPL=(""+$toString).split(TO_STRING);require("./$.core").inspectSource=function(it){return $toString.call(it)};(module.exports=function(O,key,val,safe){if(typeof val=="function"){hide(val,SRC,O[key]?""+O[key]:TPL.join(String(key)));if(!("name"in val))val.name=key}if(O===global){O[key]=val}else{if(!safe)delete O[key];hide(O,key,val)}})(Function.prototype,TO_STRING,function toString(){return typeof this=="function"&&this[SRC]||$toString.call(this)})},{"./$.core":237,"./$.global":249,"./$.hide":251,"./$.uid":298}],278:[function(require,module,exports){module.exports=function(regExp,replace){var replacer=replace===Object(replace)?function(part){return replace[part]}:replace;return function(it){return String(it).replace(regExp,replacer)}}},{}],279:[function(require,module,exports){module.exports=Object.is||function is(x,y){return x===y?x!==0||1/x===1/y:x!=x&&y!=y}},{}],280:[function(require,module,exports){var getDesc=require("./$").getDesc,isObject=require("./$.is-object"),anObject=require("./$.an-object");var check=function(O,proto){anObject(O);if(!isObject(proto)&&proto!==null)throw TypeError(proto+": can't set as prototype!")};module.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(buggy,set){try{set=require("./$.ctx")(Function.call,getDesc(Object.prototype,"__proto__").set,2);set({},[])}catch(e){buggy=true}return function setPrototypeOf(O,proto){check(O,proto);if(buggy)O.__proto__=proto;else set(O,proto);return O}}():undefined),check:check}},{"./$":265,"./$.an-object":227,"./$.ctx":238,"./$.is-object":257}],281:[function(require,module,exports){var global=require("./$.global"),SHARED="__core-js_shared__",store=global[SHARED]||(global[SHARED]={});module.exports=function(key){return store[key]||(store[key]={})}},{"./$.global":249}],282:[function(require,module,exports){module.exports=Math.sign||function sign(x){return(x=+x)==0||x!=x?x:x<0?-1:1}},{}],283:[function(require,module,exports){"use strict";var $=require("./$"),SPECIES=require("./$.wks")("species");module.exports=function(C){if(require("./$.support-desc")&&!(SPECIES in C))$.setDesc(C,SPECIES,{configurable:true,get:function(){return this}})}},{"./$":265,"./$.support-desc":290,"./$.wks":300}],284:[function(require,module,exports){module.exports=function(it,Constructor,name){if(!(it instanceof Constructor))throw TypeError(name+": use the 'new' operator!");return it}},{}],285:[function(require,module,exports){var toInteger=require("./$.to-integer"),defined=require("./$.defined");module.exports=function(TO_STRING){return function(that,pos){var s=String(defined(that)),i=toInteger(pos),l=s.length,a,b;if(i<0||i>=l)return TO_STRING?"":undefined;a=s.charCodeAt(i);return a<55296||a>56319||i+1===l||(b=s.charCodeAt(i+1))<56320||b>57343?TO_STRING?s.charAt(i):a:TO_STRING?s.slice(i,i+2):(a-55296<<10)+(b-56320)+65536}}},{"./$.defined":240,"./$.to-integer":294}],286:[function(require,module,exports){var defined=require("./$.defined"),cof=require("./$.cof");module.exports=function(that,searchString,NAME){if(cof(searchString)=="RegExp")throw TypeError("String#"+NAME+" doesn't accept regex!");return String(defined(that))}},{"./$.cof":232,"./$.defined":240}],287:[function(require,module,exports){var toLength=require("./$.to-length"),repeat=require("./$.string-repeat"),defined=require("./$.defined");module.exports=function(that,maxLength,fillString,left){var S=String(defined(that)),stringLength=S.length,fillStr=fillString===undefined?" ":String(fillString),intMaxLength=toLength(maxLength);if(intMaxLength<=stringLength)return S;if(fillStr=="")fillStr=" ";var fillLen=intMaxLength-stringLength,stringFiller=repeat.call(fillStr,Math.ceil(fillLen/fillStr.length));if(stringFiller.length>fillLen)stringFiller=left?stringFiller.slice(stringFiller.length-fillLen):stringFiller.slice(0,fillLen);return left?stringFiller+S:S+stringFiller}},{"./$.defined":240,"./$.string-repeat":288,"./$.to-length":296}],288:[function(require,module,exports){"use strict";var toInteger=require("./$.to-integer"),defined=require("./$.defined");module.exports=function repeat(count){var str=String(defined(this)),res="",n=toInteger(count);if(n<0||n==Infinity)throw RangeError("Count can't be negative");for(;n>0;(n>>>=1)&&(str+=str))if(n&1)res+=str;return res}},{"./$.defined":240,"./$.to-integer":294}],289:[function(require,module,exports){var trim=function(string,TYPE){string=String(defined(string));if(TYPE&1)string=string.replace(ltrim,"");if(TYPE&2)string=string.replace(rtrim,"");return string};var $def=require("./$.def"),defined=require("./$.defined"),spaces=" \n \f\r   ᠎    "+"          \u2028\u2029\ufeff",space="["+spaces+"]",non="​…",ltrim=RegExp("^"+space+space+"*"),rtrim=RegExp(space+space+"*$");module.exports=function(KEY,exec){var exp={};exp[KEY]=exec(trim);$def($def.P+$def.F*require("./$.fails")(function(){return!!spaces[KEY]()||non[KEY]()!=non}),"String",exp)}},{"./$.def":239,"./$.defined":240,"./$.fails":244}],290:[function(require,module,exports){module.exports=!require("./$.fails")(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},{"./$.fails":244}],291:[function(require,module,exports){var has=require("./$.has"),hide=require("./$.hide"),TAG=require("./$.wks")("toStringTag");module.exports=function(it,tag,stat){if(it&&!has(it=stat?it:it.prototype,TAG))hide(it,TAG,tag)}},{"./$.has":250,"./$.hide":251,"./$.wks":300}],292:[function(require,module,exports){"use strict";var ctx=require("./$.ctx"),invoke=require("./$.invoke"),html=require("./$.html"),cel=require("./$.dom-create"),global=require("./$.global"),process=global.process,setTask=global.setImmediate,clearTask=global.clearImmediate,MessageChannel=global.MessageChannel,counter=0,queue={},ONREADYSTATECHANGE="onreadystatechange",defer,channel,port;var run=function(){var id=+this;if(queue.hasOwnProperty(id)){var fn=queue[id];delete queue[id];fn()}};var listner=function(event){run.call(event.data)};if(!setTask||!clearTask){setTask=function setImmediate(fn){var args=[],i=1;while(arguments.length>i)args.push(arguments[i++]);queue[++counter]=function(){invoke(typeof fn=="function"?fn:Function(fn),args)};defer(counter);return counter};clearTask=function clearImmediate(id){delete queue[id]};if(require("./$.cof")(process)=="process"){defer=function(id){process.nextTick(ctx(run,id,1))}}else if(MessageChannel){channel=new MessageChannel;port=channel.port2;channel.port1.onmessage=listner;defer=ctx(port.postMessage,port,1)}else if(global.addEventListener&&typeof postMessage=="function"&&!global.importScript){defer=function(id){global.postMessage(id+"","*")};global.addEventListener("message",listner,false)}else if(ONREADYSTATECHANGE in cel("script")){defer=function(id){html.appendChild(cel("script"))[ONREADYSTATECHANGE]=function(){html.removeChild(this);run.call(id)}}}else{defer=function(id){setTimeout(ctx(run,id,1),0)}}}module.exports={set:setTask,clear:clearTask}},{"./$.cof":232,"./$.ctx":238,"./$.dom-create":241,"./$.global":249,"./$.html":252,"./$.invoke":253}],293:[function(require,module,exports){var toInteger=require("./$.to-integer"),max=Math.max,min=Math.min;module.exports=function(index,length){index=toInteger(index);return index<0?max(index+length,0):min(index,length)}},{"./$.to-integer":294}],294:[function(require,module,exports){var ceil=Math.ceil,floor=Math.floor;module.exports=function(it){return isNaN(it=+it)?0:(it>0?floor:ceil)(it)}},{}],295:[function(require,module,exports){var IObject=require("./$.iobject"),defined=require("./$.defined");module.exports=function(it){return IObject(defined(it))}},{"./$.defined":240,"./$.iobject":254}],296:[function(require,module,exports){var toInteger=require("./$.to-integer"),min=Math.min;module.exports=function(it){return it>0?min(toInteger(it),9007199254740991):0}},{"./$.to-integer":294}],297:[function(require,module,exports){var defined=require("./$.defined");module.exports=function(it){return Object(defined(it))}},{"./$.defined":240}],298:[function(require,module,exports){var id=0,px=Math.random();module.exports=function(key){return"Symbol(".concat(key===undefined?"":key,")_",(++id+px).toString(36))}},{}],299:[function(require,module,exports){var UNSCOPABLES=require("./$.wks")("unscopables");if(!(UNSCOPABLES in[]))require("./$.hide")(Array.prototype,UNSCOPABLES,{});module.exports=function(key){[][UNSCOPABLES][key]=true}},{"./$.hide":251,"./$.wks":300}],300:[function(require,module,exports){var store=require("./$.shared")("wks"),Symbol=require("./$.global").Symbol;module.exports=function(name){return store[name]||(store[name]=Symbol&&Symbol[name]||(Symbol||require("./$.uid"))("Symbol."+name))}},{"./$.global":249,"./$.shared":281,"./$.uid":298}],301:[function(require,module,exports){var classof=require("./$.classof"),ITERATOR=require("./$.wks")("iterator"),Iterators=require("./$.iterators");module.exports=require("./$.core").getIteratorMethod=function(it){if(it!=undefined)return it[ITERATOR]||it["@@iterator"]||Iterators[classof(it)]}},{"./$.classof":231,"./$.core":237,"./$.iterators":264,"./$.wks":300}],302:[function(require,module,exports){"use strict";var $=require("./$"),SUPPORT_DESC=require("./$.support-desc"),createDesc=require("./$.property-desc"),html=require("./$.html"),cel=require("./$.dom-create"),has=require("./$.has"),cof=require("./$.cof"),$def=require("./$.def"),invoke=require("./$.invoke"),arrayMethod=require("./$.array-methods"),IE_PROTO=require("./$.uid")("__proto__"),isObject=require("./$.is-object"),anObject=require("./$.an-object"),aFunction=require("./$.a-function"),toObject=require("./$.to-object"),toIObject=require("./$.to-iobject"),toInteger=require("./$.to-integer"),toIndex=require("./$.to-index"),toLength=require("./$.to-length"),IObject=require("./$.iobject"),fails=require("./$.fails"),ObjectProto=Object.prototype,A=[],_slice=A.slice,_join=A.join,defineProperty=$.setDesc,getOwnDescriptor=$.getDesc,defineProperties=$.setDescs,$indexOf=require("./$.array-includes")(false),factories={},IE8_DOM_DEFINE;if(!SUPPORT_DESC){IE8_DOM_DEFINE=!fails(function(){return defineProperty(cel("div"),"a",{get:function(){return 7}}).a!=7});$.setDesc=function(O,P,Attributes){if(IE8_DOM_DEFINE)try{return defineProperty(O,P,Attributes)}catch(e){}if("get"in Attributes||"set"in Attributes)throw TypeError("Accessors not supported!");if("value"in Attributes)anObject(O)[P]=Attributes.value;return O};$.getDesc=function(O,P){if(IE8_DOM_DEFINE)try{return getOwnDescriptor(O,P)}catch(e){}if(has(O,P))return createDesc(!ObjectProto.propertyIsEnumerable.call(O,P),O[P])};$.setDescs=defineProperties=function(O,Properties){anObject(O);var keys=$.getKeys(Properties),length=keys.length,i=0,P;while(length>i)$.setDesc(O,P=keys[i++],Properties[P]);return O}}$def($def.S+$def.F*!SUPPORT_DESC,"Object",{getOwnPropertyDescriptor:$.getDesc,defineProperty:$.setDesc,defineProperties:defineProperties});var keys1=("constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,"+"toLocaleString,toString,valueOf").split(","),keys2=keys1.concat("length","prototype"),keysLen1=keys1.length;var createDict=function(){var iframe=cel("iframe"),i=keysLen1,gt=">",iframeDocument;iframe.style.display="none";html.appendChild(iframe);iframe.src="javascript:";iframeDocument=iframe.contentWindow.document;iframeDocument.open();iframeDocument.write(" + + - + diff --git a/public/javascripts/wechat/project_discussion.js b/public/javascripts/wechat/project_discussion.js index 0ba69c153..94cdcea10 100644 --- a/public/javascripts/wechat/project_discussion.js +++ b/public/javascripts/wechat/project_discussion.js @@ -1,3 +1,105 @@ /** * Created by root on 4/1/16. */ +/** + * Created by root on 4/1/16. + */ +$(document).ready(function(){ + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + + var apiUrl = '/api/v1/'; + + var setReplyTemplate = function(data){ + console.log(data); + var html=bt('t:homework-detail-reply',{reply: data}); + $('#all_homework_reply').prepend(html); + }; + + + var setTemplate = function(data){ + console.log(data); + var html=bt('t:project-discussion',{discussion: data}); + $('#p-discussion-container').prepend(html); + $('.post-reply-submit').click(function(){ + replyInsert(); + }); + /*$('post-interactive-praise').click(function(){ + praiseClick(); + });*/ + }; + + var loadDataFromServer = function(id){ + //getOpenId(function(openid){ + $.ajax({ + url: apiUrl + 'messages/' + id, + dataType: 'json', + success: function(data){ + setTemplate(data.data); + }, + error: function(xhr,status,err){ + console.log(err); + } + }); + //}) + + + }; + + var homeworkUrl = window.location.search; + var homeworkID = homeworkUrl.split("=")[1]; + + loadDataFromServer(homeworkID); + + //点击回复按钮,插入回复内容 + var replyInsert = function(){ + var replyContent = $("#postInput").val(); + if (!replyContent){ + alert("请输入回复"); + }else{ + + /*//将用户输入内容插入最后一条回复 + $(".post-reply-wrap:last").after('
回复
'); + $(".post-reply-content:last").append(replyContent); + $(".post-reply-date:last").append(Date());*/ + var postInput = $("#postInput").val(); + $("#postInput").val(""); + //回复数目+1 + var replyNum = $(".post-interactive-reply").text().match(/\d+/g); + replyNum++; + $(".reply-num").text("(" + replyNum + ")"); + + //获取并传送回复用户数据 + var userInfo = { + "type" : "Message", + "content" : postInput + }; + + $.ajax({ + type: "POST", //提交方式 + dataType: "json", //类型 + url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 + data: userInfo, //参数,如果没有,可以为null + success: function (data) { //如果执行成功,那么执行此方法 + setReplyTemplate(data.data); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + }, + error: function (err) { //如果执行不成功,那么执行此方法 + alert("err:" + err); + } + }); + } + + } + + //点赞效果 + /*var praiseClick = function(){ + var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); + praiseNum++; + $(".praise-num").text("(" + praiseNum + ")"); + }*/ + + +}); \ No newline at end of file From 417484f3ad84b0fefbd590f9f211fffe0de532d3 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 5 Apr 2016 15:12:05 +0800 Subject: [PATCH 123/507] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=A0=87=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 38a6c142f..cb77c6b0f 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -2,13 +2,19 @@ var app = angular.module('wechat', ['ngRoute']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; //var openid= "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; var openid = ''; +var debug = true; //调试标志,如果在本地请置为true + +if(debug){ + openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; +} app.factory('auth', function($http,$routeParams){ - var _openid = ''; + var _openid = openid; var getOpenId = function(cb) { if (_openid.length > 0) { cb(_openid); + return; } var code = $routeParams.code; $http({ @@ -39,16 +45,7 @@ app.controller('ActivityController',function($scope, $http, auth){ $scope.activities = []; $scope.page = 1; - auth.getOpenId(function(openid){ - if(!openid){ - alert("获取openid出错"); - } else { - openid = openid; - $scope.loadActData($scope.page); - } - }); - - $scope.loadActData = function(page){ + var loadActData = function(page){ $scope.page = page; $http({ method: 'POST', @@ -60,6 +57,17 @@ app.controller('ActivityController',function($scope, $http, auth){ }); } + auth.getOpenId(function(openid){ + if(!openid){ + alert("获取openid出错"); + } else { + openid = openid; + loadActData($scope.page); + } + }); + + $scope.loadActData = loadActData; + }); app.controller('IssueController', function($scope, $http, $routeParams, auth){ From ae080314408e0e672fd79a1b087aba265ebc1f14 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 5 Apr 2016 15:54:30 +0800 Subject: [PATCH 124/507] =?UTF-8?q?=E5=BC=80=E6=94=BE=E8=B7=A8=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 1 + config/application.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Gemfile b/Gemfile index 9fe511a59..a74d883fa 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ gem 'delayed_job_active_record'#, :group => :production gem 'daemons' gem 'grape', '~> 0.9.0' gem 'grape-entity' +gem 'rack-cors', :require => 'rack/cors' gem 'seems_rateable', '~> 1.0.13' gem 'rails', '~> 3.2' gem "jquery-rails", "~> 2.0.2" diff --git a/config/application.rb b/config/application.rb index 0c55fc75f..a1e14e0d9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -71,6 +71,14 @@ module RedmineApp config.action_view.sanitized_allowed_tags = 'div', 'p', 'span', 'img', 'embed' + config.middleware.use Rack::Cors do + allow do + origins '*' + # location of your API + resource '/api/*', :headers => :any, :methods => [:get, :post, :options, :put] + end + end + config.before_initialize do end From bb5a527f9e73f16fa4d9218667ba0b4fb25f9492 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 5 Apr 2016 15:57:19 +0800 Subject: [PATCH 125/507] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=B0=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 2 +- public/javascripts/wechat/app.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/menu.yml b/config/menu.yml index afb2ef0f7..99c0cf583 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ button: - type: "view" name: "最新动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/activities.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/app.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect" - type: "click" name: "意见返馈" diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index cb77c6b0f..b9e0e1958 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -2,7 +2,7 @@ var app = angular.module('wechat', ['ngRoute']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; //var openid= "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; var openid = ''; -var debug = true; //调试标志,如果在本地请置为true +var debug = false; //调试标志,如果在本地请置为true if(debug){ openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; From 619b07b5c2432c0e4581744e6d0fa1399bf23768 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 5 Apr 2016 16:32:42 +0800 Subject: [PATCH 126/507] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=B8=8A?= =?UTF-8?q?=E8=B0=83=E8=AF=95openid=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 2 +- public/javascripts/wechat/app.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/menu.yml b/config/menu.yml index 99c0cf583..224ad23dd 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ button: - type: "view" name: "最新动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/app.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/app.html#/activities?response_type=code&scope=snsapi_base&state=123#wechat_redirect" - type: "click" name: "意见返馈" diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index b9e0e1958..7e5983652 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -4,7 +4,7 @@ var apiUrl = 'http://wechat.trustie.net/api/v1/'; var openid = ''; var debug = false; //调试标志,如果在本地请置为true -if(debug){ +if(debug===true){ openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; } @@ -22,7 +22,8 @@ app.factory('auth', function($http,$routeParams){ data: {code: code}, method: 'POST' }).then(function successCallback(response) { - _openid = data.openid; + _openid = response.data.openid; + openid = _openid; cb(_openid); }, function errorCallback(response) { cb(null); @@ -57,11 +58,10 @@ app.controller('ActivityController',function($scope, $http, auth){ }); } - auth.getOpenId(function(openid){ - if(!openid){ + auth.getOpenId(function(oid){ + if(!oid){ alert("获取openid出错"); } else { - openid = openid; loadActData($scope.page); } }); @@ -136,4 +136,4 @@ app.config(['$routeProvider',function ($routeProvider) { .otherwise({ redirectTo: '/activities' }); -}]); \ No newline at end of file +}]); From 80d5424ff313a187476f9361aa26aee1d2e18684 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 5 Apr 2016 16:36:18 +0800 Subject: [PATCH 127/507] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E5=87=BA?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 7e5983652..68eb5ed85 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -113,7 +113,6 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth){ }); } - console.log(auth.getOpenId()); }); From afd779f2924e2674fcbf296596200019e2a367d7 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 5 Apr 2016 17:19:00 +0800 Subject: [PATCH 128/507] =?UTF-8?q?=E4=BD=BF=E7=94=A8cookies=E5=AD=98?= =?UTF-8?q?=E5=82=A8openid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/app.html | 1 + public/javascripts/wechat/app.js | 37 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index ef8e06d64..d2eebb0b8 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -19,6 +19,7 @@ + diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 68eb5ed85..4d2d71dd7 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,18 +1,16 @@ -var app = angular.module('wechat', ['ngRoute']); +var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -//var openid= "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; -var openid = ''; var debug = false; //调试标志,如果在本地请置为true -if(debug===true){ - openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; -} +app.factory('auth', function($http,$routeParams, $cookies){ + var _openid = ''; -app.factory('auth', function($http,$routeParams){ - var _openid = openid; + if(debug===true){ + _openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; + } var getOpenId = function(cb) { - if (_openid.length > 0) { + if (typeof _openid !== 'undefined' || _openid.length > 0) { cb(_openid); return; } @@ -23,19 +21,24 @@ app.factory('auth', function($http,$routeParams){ method: 'POST' }).then(function successCallback(response) { _openid = response.data.openid; - openid = _openid; + if(debug !== true){ //如果是生产环境,就存到cookies中 + $cookies.put("openid", _openid); + } cb(_openid); }, function errorCallback(response) { - cb(null); + if(debug!==true){//考虑从cookies中取出 + _openid = $cookies.get('openid'); + } + cb(_openid); }); }; - var setOpenId = function(id){ - _openid = id; + var openid = function(){ + return _openid; } - return {getOpenId: getOpenId, setOpenId: setOpenId}; + return {getOpenId: getOpenId, openid: openid}; }); app.controller('ActivityController',function($scope, $http, auth){ @@ -43,6 +46,8 @@ app.controller('ActivityController',function($scope, $http, auth){ return "http://www.trustie.net/" + url; } + console.log("ActivityController load"); + $scope.activities = []; $scope.page = 1; @@ -51,7 +56,7 @@ app.controller('ActivityController',function($scope, $http, auth){ $http({ method: 'POST', url: apiUrl+ "activities", - data: {openid: openid, page: page}, + data: {openid: auth.openid(), page: page}, }).then(function successCallback(response) { $scope.activities = $scope.activities.concat(response.data.data); }, function errorCallback(response) { @@ -98,7 +103,7 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth){ var userInfo = { type: "Issue", content: data.comment, - openid: openid, + openid: auth.openid(), }; $http({ From 23ec67b2ebe34f60ea26416b7b8c944a1f30edb5 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 5 Apr 2016 17:23:36 +0800 Subject: [PATCH 129/507] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E5=87=BA?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 4d2d71dd7..119e962d1 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies){ } var getOpenId = function(cb) { - if (typeof _openid !== 'undefined' || _openid.length > 0) { + if (typeof _openid !== 'undefined' && _openid.length > 0) { cb(_openid); return; } From 606599047d5a3452290321bc1bb32de3cf65d6dd Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 5 Apr 2016 17:35:27 +0800 Subject: [PATCH 130/507] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E5=87=BA?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 119e962d1..5a18a2e35 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -21,20 +21,22 @@ app.factory('auth', function($http,$routeParams, $cookies){ method: 'POST' }).then(function successCallback(response) { _openid = response.data.openid; - if(debug !== true){ //如果是生产环境,就存到cookies中 - $cookies.put("openid", _openid); + if(typeof _openid !== 'undefined' && _openid.length>0){ + if(debug !== true){ //如果是生产环境,就存到cookies中 + $cookies.put("openid", _openid); + } + } else { + if(debug!==true){//考虑从cookies中取出 + _openid = $cookies.get('openid'); + } } + cb(_openid); }, function errorCallback(response) { - if(debug!==true){//考虑从cookies中取出 - _openid = $cookies.get('openid'); - } - cb(_openid); + cb(null); }); }; - - var openid = function(){ return _openid; } From 035b47d2b7381c2761caed2e6c4aa59ced53f3bd Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 6 Apr 2016 09:38:46 +0800 Subject: [PATCH 131/507] =?UTF-8?q?issue=E9=A1=B5=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 4 ++-- public/assets/wechat/issue_detail.html | 18 ++---------------- public/javascripts/wechat/app.js | 8 ++++---- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 05ce3eb16..81cc040ba 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -12,7 +12,7 @@
-

+
{{act.description|safeHtml}}
迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
@@ -104,7 +104,7 @@
-

+
{{act.description|safeHtml}}
状态:{{act.issue_detail.issue_status}} 优先级:{{act.issue_detail.issue_priority}}
指派给:{{act.issue_detail.issue_assigned_to}} 完成度:{{act.issue_detail.done_ratio}}%
点击展开 diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index b8fdc5928..eb56cf558 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -8,8 +8,8 @@
-
- 状态: 优先级:
指派给: 完成度:
+
{{issue.description}}
+ 状态:{{issue.issue_status}} 优先级:{{issue.issue_priority}}
指派给:{{issue.issue_assigned_to}} 完成度:{{issue.done_ratio}}%
{{issue.created_on}} @@ -44,17 +44,3 @@
- - diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 68eb5ed85..b9f2a50e8 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,11 +1,11 @@ var app = angular.module('wechat', ['ngRoute']); -var apiUrl = 'http://wechat.trustie.net/api/v1/'; +var apiUrl = 'http://localhost:3000/api/v1/'; //var openid= "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; var openid = ''; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ - openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; + openid = "1"; } app.factory('auth', function($http,$routeParams){ @@ -39,7 +39,7 @@ app.factory('auth', function($http,$routeParams){ }); app.controller('ActivityController',function($scope, $http, auth){ - $scope.repaceUrl = function(url){ + $scope.replaceUrl = function(url){ return "http://www.trustie.net/" + url; } From feb0014bf8372e2ec8761a0511de42803eb79a07 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 6 Apr 2016 11:29:50 +0800 Subject: [PATCH 132/507] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 4184 ++++++++++----------- public/assets/wechat/activities.html | 17 +- public/assets/wechat/app.html | 1 + public/assets/wechat/homework_detail.html | 78 +- public/assets/wechat/issue_detail.html | 1 - public/javascripts/wechat/app.js | 97 +- 6 files changed, 2212 insertions(+), 2166 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 38c7e5ad2..75f316f06 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,2092 +1,2092 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20160317090350) do - - create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - t.integer "activity_container_id" - t.string "activity_container_type", :default => "" - t.datetime "created_at" - end - - add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" - add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" - add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - - create_table "activity_notifies", :force => true do |t| - t.integer "activity_container_id" - t.string "activity_container_type" - t.integer "activity_id" - t.string "activity_type" - t.integer "notify_to" - t.datetime "created_on" - t.integer "is_read" - end - - add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" - add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" - add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" - - create_table "api_keys", :force => true do |t| - t.string "access_token" - t.datetime "expires_at" - t.integer "user_id" - t.boolean "active", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" - add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" - - create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - end - - create_table "apply_project_masters", :force => true do |t| - t.integer "user_id" - t.string "apply_type" - t.integer "apply_id" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "at_messages", :force => true do |t| - t.integer "user_id" - t.integer "at_message_id" - t.string "at_message_type" - t.boolean "viewed", :default => false - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sender_id" - end - - add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" - - create_table "attachment_histories", :force => true do |t| - t.integer "container_id" - t.string "container_type" - t.string "filename", :default => "" - t.string "disk_filename", :default => "" - t.integer "filesize", :default => 0 - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "" - t.integer "downloads", :default => 0 - t.integer "author_id" - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.integer "copy_from" - t.integer "quotes" - t.integer "version" - t.integer "attachment_id" - t.integer "is_publish", :default => 1 - t.date "publish_time" - end - - create_table "attachments", :force => true do |t| - t.integer "container_id" - t.string "container_type", :limit => 30 - t.string "filename", :default => "", :null => false - t.string "disk_filename", :default => "", :null => false - t.integer "filesize", :default => 0, :null => false - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "", :null => false - t.integer "downloads", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype", :default => 1 - t.integer "is_public", :default => 1 - t.integer "copy_from" - t.integer "quotes" - t.integer "is_publish", :default => 1 - t.date "publish_time" - end - - add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" - add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" - add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" - - create_table "attachmentstypes", :force => true do |t| - t.integer "typeId", :null => false - t.string "typeName", :limit => 50 - end - - create_table "auth_sources", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 60, :default => "", :null => false - t.string "host", :limit => 60 - t.integer "port" - t.string "account" - t.string "account_password", :default => "" - t.string "base_dn" - t.string "attr_login", :limit => 30 - t.string "attr_firstname", :limit => 30 - t.string "attr_lastname", :limit => 30 - t.string "attr_mail", :limit => 30 - t.boolean "onthefly_register", :default => false, :null => false - t.boolean "tls", :default => false, :null => false - t.string "filter" - t.integer "timeout" - end - - add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" - - create_table "biding_projects", :force => true do |t| - t.integer "project_id" - t.integer "bid_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "bids", :force => true do |t| - t.string "name" - t.string "budget", :null => false - t.integer "author_id" - t.date "deadline" - t.text "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.integer "commit" - t.integer "reward_type" - t.integer "homework_type" - t.integer "parent_id" - t.string "password" - t.integer "is_evaluation" - t.integer "proportion", :default => 60 - t.integer "comment_status", :default => 0 - t.integer "evaluation_num", :default => 3 - t.integer "open_anonymous_evaluation", :default => 1 - end - - create_table "blog_comments", :force => true do |t| - t.integer "blog_id", :null => false - t.integer "parent_id" - t.string "title", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comment_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "blogs", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.integer "position", :default => 1 - t.integer "article_count", :default => 0, :null => false - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comments_id" - t.integer "parent_id" - t.integer "author_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "homepage_id" - end - - create_table "boards", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :default => "", :null => false - t.string "description" - t.integer "position", :default => 1 - t.integer "topics_count", :default => 0, :null => false - t.integer "messages_count", :default => 0, :null => false - t.integer "last_message_id" - t.integer "parent_id" - t.integer "course_id" - t.integer "org_subfield_id" - end - - add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" - add_index "boards", ["project_id"], :name => "boards_project_id" - - create_table "bug_to_osps", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "changes", :force => true do |t| - t.integer "changeset_id", :null => false - t.string "action", :limit => 1, :default => "", :null => false - t.text "path", :null => false - t.text "from_path" - t.string "from_revision" - t.string "revision" - t.string "branch" - end - - add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" - - create_table "changeset_parents", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "parent_id", :null => false - end - - add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" - add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" - - create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false - t.string "committer" - t.datetime "committed_on", :null => false - t.text "comments" - t.date "commit_date" - t.string "scmid" - t.integer "user_id" - end - - add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" - add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true - add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" - add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" - add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" - - create_table "changesets_issues", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "issue_id", :null => false - end - - add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - - create_table "comments", :force => true do |t| - t.string "commented_type", :limit => 30, :default => "", :null => false - t.integer "commented_id", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.text "comments" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "comments", ["author_id"], :name => "index_comments_on_author_id" - add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" - - create_table "contest_notifications", :force => true do |t| - t.text "title" - t.text "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" - t.integer "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contestnotifications", :force => true do |t| - t.integer "contest_id" - t.string "title" - t.string "summary" - t.text "description" - t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contests", :force => true do |t| - t.string "name" - t.string "budget", :default => "" - t.integer "author_id" - t.date "deadline" - t.string "description" - t.integer "commit" - t.string "password" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - create_table "course_activities", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_act_id" - t.string "course_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_attachments", :force => true do |t| - t.string "filename" - t.string "disk_filename" - t.integer "filesize" - t.string "content_type" - t.string "digest" - t.integer "downloads" - t.string "author_id" - t.string "integer" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "container_id", :default => 0 - end - - create_table "course_contributor_scores", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.integer "message_num" - t.integer "message_reply_num" - t.integer "news_reply_num" - t.integer "resource_num" - t.integer "journal_num" - t.integer "journal_reply_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "total_score" - t.integer "homework_journal_num", :default => 0 - t.integer "news_num", :default => 0 - end - - create_table "course_groups", :force => true do |t| - t.string "name" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_infos", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_messages", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_message_id" - t.string "course_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "content" - t.integer "status" - end - - create_table "course_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "course_id" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "courses", :force => true do |t| - t.integer "tea_id" - t.string "name" - t.integer "state" - t.string "code" - t.integer "time" - t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "location" - t.string "term" - t.string "string" - t.string "password" - t.string "setup_time" - t.string "endup_time" - t.string "class_period" - t.integer "school_id" - t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 - t.integer "lft" - t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "is_delete", :default => 0 - t.integer "end_time" - t.string "end_term" - t.integer "is_excellent", :default => 0 - t.integer "excellent_option", :default => 0 - t.integer "is_copy", :default => 0 - t.integer "visits", :default => 0 - end - - create_table "custom_fields", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.string "field_format", :limit => 30, :default => "", :null => false - t.text "possible_values" - t.string "regexp", :default => "" - t.integer "min_length", :default => 0, :null => false - t.integer "max_length", :default => 0, :null => false - t.boolean "is_required", :default => false, :null => false - t.boolean "is_for_all", :default => false, :null => false - t.boolean "is_filter", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "searchable", :default => false - t.text "default_value" - t.boolean "editable", :default => true - t.boolean "visible", :default => true, :null => false - t.boolean "multiple", :default => false - end - - add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" - - create_table "custom_fields_projects", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "project_id", :default => 0, :null => false - end - - add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true - - create_table "custom_fields_trackers", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true - - create_table "custom_values", :force => true do |t| - t.string "customized_type", :limit => 30, :default => "", :null => false - t.integer "customized_id", :default => 0, :null => false - t.integer "custom_field_id", :default => 0, :null => false - t.text "value" - end - - add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" - add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" - - create_table "delayed_jobs", :force => true do |t| - t.integer "priority", :default => 0, :null => false - t.integer "attempts", :default => 0, :null => false - t.text "handler", :null => false - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "documents", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "category_id", :default => 0, :null => false - t.string "title", :limit => 60, :default => "", :null => false - t.text "description" - t.datetime "created_on" - t.integer "user_id", :default => 0 - t.integer "is_public", :default => 1 - end - - add_index "documents", ["category_id"], :name => "index_documents_on_category_id" - add_index "documents", ["created_on"], :name => "index_documents_on_created_on" - add_index "documents", ["project_id"], :name => "documents_project_id" - - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 - t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false - end - - create_table "editor_of_documents", :force => true do |t| - t.integer "editor_id" - t.integer "org_document_comment_id" - t.datetime "created_at" - end - - create_table "enabled_modules", :force => true do |t| - t.integer "project_id" - t.string "name", :null => false - t.integer "course_id" - end - - add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" - - create_table "enumerations", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "is_default", :default => false, :null => false - t.string "type" - t.boolean "active", :default => true, :null => false - t.integer "project_id" - t.integer "parent_id" - t.string "position_name", :limit => 30 - end - - add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" - add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" - - create_table "exercise_answers", :force => true do |t| - t.integer "user_id" - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_choices", :force => true do |t| - t.integer "exercise_question_id" - t.text "choice_text" - t.integer "choice_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_questions", :force => true do |t| - t.text "question_title" - t.integer "question_type" - t.integer "question_number" - t.integer "exercise_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_score" - end - - create_table "exercise_standard_answers", :force => true do |t| - t.integer "exercise_question_id" - t.integer "exercise_choice_id" - t.text "answer_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "exercise_users", :force => true do |t| - t.integer "user_id" - t.integer "exercise_id" - t.integer "score" - t.datetime "start_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "end_at" - t.integer "status" - end - - create_table "exercises", :force => true do |t| - t.text "exercise_name" - t.text "exercise_description" - t.integer "course_id" - t.integer "exercise_status" - t.integer "user_id" - t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.datetime "publish_time" - t.datetime "end_time" - t.integer "show_result" - end - - create_table "first_pages", :force => true do |t| - t.string "web_title" - t.string "title" - t.text "description" - t.string "page_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sort_type" - t.integer "image_width", :default => 107 - t.integer "image_height", :default => 63 - t.integer "show_course", :default => 1 - t.integer "show_contest", :default => 1 - end - - create_table "forge_activities", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_act_id" - t.string "forge_act_type" - t.integer "org_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" - - create_table "forge_messages", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_message_id" - t.string "forge_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "secret_key" - t.integer "status" - end - - create_table "forums", :force => true do |t| - t.string "name", :null => false - t.text "description" - t.integer "topic_count", :default => 0 - t.integer "memo_count", :default => 0 - t.integer "last_memo_id", :default => 0 - t.integer "creator_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sticky" - t.integer "locked" - end - - create_table "forwards", :force => true do |t| - t.integer "from_id" - t.string "from_type" - t.integer "to_id" - t.string "to_type" - t.datetime "created_at" - end - - create_table "groups_users", :id => false, :force => true do |t| - t.integer "group_id", :null => false - t.integer "user_id", :null => false - end - - add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true - - create_table "homework_attaches", :force => true do |t| - t.integer "bid_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - t.string "name" - t.text "description" - t.integer "state" - t.integer "project_id", :default => 0 - t.float "score", :default => 0.0 - t.integer "is_teacher_score", :default => 0 - end - - add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" - - create_table "homework_commons", :force => true do |t| - t.string "name" - t.integer "user_id" - t.text "description" - t.date "publish_time" - t.date "end_time" - t.integer "homework_type", :default => 1 - t.string "late_penalty" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "teacher_priority", :default => 1 - t.integer "anonymous_comment", :default => 0 - t.integer "quotes", :default => 0 - t.integer "is_open", :default => 0 - end - - add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" - - create_table "homework_detail_groups", :force => true do |t| - t.integer "homework_common_id" - t.integer "min_num" - t.integer "max_num" - t.integer "base_on_project" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" - - create_table "homework_detail_manuals", :force => true do |t| - t.float "ta_proportion" - t.integer "comment_status" - t.date "evaluation_start" - t.date "evaluation_end" - t.integer "evaluation_num" - t.integer "absence_penalty", :default => 1 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_detail_programings", :force => true do |t| - t.string "language" - t.text "standard_code", :limit => 2147483647 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "ta_proportion", :default => 0.1 - t.integer "question_id" - end - - create_table "homework_evaluations", :force => true do |t| - t.string "user_id" - t.string "homework_attach_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_for_courses", :force => true do |t| - t.integer "course_id" - t.integer "bid_id" - end - - add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" - add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" - - create_table "homework_tests", :force => true do |t| - t.text "input" - t.text "output" - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "result" - t.text "error_msg" - end - - create_table "homework_users", :force => true do |t| - t.string "homework_attach_id" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "invite_lists", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "mail" - end - - create_table "issue_categories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.integer "assigned_to_id" - end - - add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" - add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" - - create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :default => "", :null => false - t.integer "delay" - end - - add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true - add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" - add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" - - create_table "issue_statuses", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_closed", :default => false, :null => false - t.boolean "is_default", :default => false, :null => false - t.integer "position", :default => 1 - t.integer "default_done_ratio" - end - - add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" - add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" - add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" - - create_table "issues", :force => true do |t| - t.integer "tracker_id", :null => false - t.integer "project_id", :null => false - t.string "subject", :default => "", :null => false - t.text "description" - t.date "due_date" - t.integer "category_id" - t.integer "status_id", :null => false - t.integer "assigned_to_id" - t.integer "priority_id", :null => false - t.integer "fixed_version_id" - t.integer "author_id", :null => false - t.integer "lock_version", :default => 0, :null => false - t.datetime "created_on" - t.datetime "updated_on" - t.date "start_date" - t.integer "done_ratio", :default => 0, :null => false - t.float "estimated_hours" - t.integer "parent_id" - t.integer "root_id" - t.integer "lft" - t.integer "rgt" - t.boolean "is_private", :default => false, :null => false - t.datetime "closed_on" - t.integer "project_issues_index" - end - - add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" - add_index "issues", ["category_id"], :name => "index_issues_on_category_id" - add_index "issues", ["created_on"], :name => "index_issues_on_created_on" - add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" - add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" - add_index "issues", ["project_id"], :name => "issues_project_id" - add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" - add_index "issues", ["status_id"], :name => "index_issues_on_status_id" - add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" - - create_table "join_in_competitions", :force => true do |t| - t.integer "user_id" - t.integer "competition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "join_in_contests", :force => true do |t| - t.integer "user_id" - t.integer "bid_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "journal_details", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - - create_table "journal_replies", :id => false, :force => true do |t| - t.integer "journal_id" - t.integer "user_id" - t.integer "reply_id" - end - - add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" - add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" - add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" - - create_table "journals", :force => true do |t| - t.integer "journalized_id", :default => 0, :null => false - t.string "journalized_type", :limit => 30, :default => "", :null => false - t.integer "user_id", :default => 0, :null => false - t.text "notes" - t.datetime "created_on", :null => false - t.boolean "private_notes", :default => false, :null => false - end - - add_index "journals", ["created_on"], :name => "index_journals_on_created_on" - add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" - add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" - add_index "journals", ["user_id"], :name => "index_journals_on_user_id" - - create_table "journals_for_messages", :force => true do |t| - t.integer "jour_id" - t.string "jour_type" - t.integer "user_id" - t.text "notes" - t.integer "status" - t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.string "m_parent_id" - t.boolean "is_readed" - t.integer "m_reply_count" - t.integer "m_reply_id" - t.integer "is_comprehensive_evaluation" - t.integer "private", :default => 0 - end - - create_table "kindeditor_assets", :force => true do |t| - t.string "asset" - t.integer "file_size" - t.string "file_type" - t.integer "owner_id" - t.string "asset_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "owner_type", :default => 0 - end - - create_table "member_roles", :force => true do |t| - t.integer "member_id", :null => false - t.integer "role_id", :null => false - t.integer "inherited_from" - end - - add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" - add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" - - create_table "members", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "project_id", :default => 0 - t.datetime "created_on" - t.boolean "mail_notification", :default => false, :null => false - t.integer "course_id", :default => -1 - t.integer "course_group_id", :default => 0 - end - - add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true - add_index "members", ["user_id"], :name => "index_members_on_user_id" - - create_table "memo_messages", :force => true do |t| - t.integer "user_id" - t.integer "forum_id" - t.integer "memo_id" - t.string "memo_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "memos", :force => true do |t| - t.integer "forum_id", :null => false - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false - t.integer "author_id", :null => false - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count", :default => 0 - end - - create_table "message_alls", :force => true do |t| - t.integer "user_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "messages", :force => true do |t| - t.integer "board_id", :null => false - t.integer "parent_id" - t.string "subject", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "replies_count", :default => 0, :null => false - t.integer "last_reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.integer "quotes" - t.integer "status", :default => 0 - end - - add_index "messages", ["author_id"], :name => "index_messages_on_author_id" - add_index "messages", ["board_id"], :name => "messages_board_id" - add_index "messages", ["created_on"], :name => "index_messages_on_created_on" - add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" - add_index "messages", ["parent_id"], :name => "messages_parent_id" - - create_table "news", :force => true do |t| - t.integer "project_id" - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" - t.text "description" - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false - t.integer "course_id" - t.integer "sticky", :default => 0 - t.integer "org_subfield_id" - end - - add_index "news", ["author_id"], :name => "index_news_on_author_id" - add_index "news", ["created_on"], :name => "index_news_on_created_on" - add_index "news", ["project_id"], :name => "news_project_id" - - create_table "no_uses", :force => true do |t| - t.integer "user_id", :null => false - t.string "no_use_type" - t.integer "no_use_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "notificationcomments", :force => true do |t| - t.string "notificationcommented_type" - t.integer "notificationcommented_id" - t.integer "author_id" - t.text "notificationcomments" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "onclick_times", :force => true do |t| - t.integer "user_id" - t.datetime "onclick_time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "open_id_authentication_associations", :force => true do |t| - t.integer "issued" - t.integer "lifetime" - t.string "handle" - t.string "assoc_type" - t.binary "server_url" - t.binary "secret" - end - - create_table "open_id_authentication_nonces", :force => true do |t| - t.integer "timestamp", :null => false - t.string "server_url" - t.string "salt", :null => false - end - - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.text "description" - t.integer "commit_count", :default => 0 - t.integer "code_line", :default => 0 - t.integer "users_count", :default => 0 - t.date "last_commit_time" - t.string "url" - t.date "date_collected" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "option_numbers", :force => true do |t| - t.integer "user_id" - t.integer "memo" - t.integer "messages_for_issues" - t.integer "issues_status" - t.integer "replay_for_message" - t.integer "replay_for_memo" - t.integer "follow" - t.integer "tread" - t.integer "praise_by_one" - t.integer "praise_by_two" - t.integer "praise_by_three" - t.integer "tread_by_one" - t.integer "tread_by_two" - t.integer "tread_by_three" - t.integer "changeset" - t.integer "document" - t.integer "attachment" - t.integer "issue_done_ratio" - t.integer "post_issue" - t.integer "score_type" - t.integer "total_score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - end - - create_table "org_activities", :force => true do |t| - t.integer "user_id" - t.integer "org_act_id" - t.string "org_act_type" - t.integer "container_id" - t.string "container_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_courses", :force => true do |t| - t.integer "organization_id" - t.integer "course_id" - t.datetime "created_at" - end - - create_table "org_document_comments", :force => true do |t| - t.text "title" - t.text "content" - t.integer "organization_id" - t.integer "creator_id" - t.integer "parent_id" - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "org_subfield_id" - end - - create_table "org_member_roles", :force => true do |t| - t.integer "org_member_id" - t.integer "role_id" - end - - create_table "org_members", :force => true do |t| - t.integer "user_id" - t.integer "organization_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_messages", :force => true do |t| - t.integer "user_id" - t.integer "sender_id" - t.integer "organization_id" - t.string "message_type" - t.integer "message_id" - t.integer "viewed" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "status", :default => 0 - end - - create_table "org_projects", :force => true do |t| - t.integer "organization_id" - t.integer "project_id" - t.datetime "created_at" - end - - create_table "org_subfield_messages", :force => true do |t| - t.integer "org_subfield_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "org_subfields", :force => true do |t| - t.integer "organization_id" - t.integer "priority" - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "field_type" - t.integer "hide", :default => 0 - end - - create_table "organizations", :force => true do |t| - t.string "name" - t.text "description" - t.integer "creator_id" - t.integer "home_id" - t.boolean "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "allow_guest_download", :default => true - t.integer "visits", :default => 0 - end - - create_table "phone_app_versions", :force => true do |t| - t.string "version" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_answers", :force => true do |t| - t.integer "poll_question_id" - t.text "answer_text" - t.integer "answer_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_questions", :force => true do |t| - t.string "question_title" - t.integer "question_type" - t.integer "is_necessary" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_number" - end - - create_table "poll_users", :force => true do |t| - t.integer "user_id" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_votes", :force => true do |t| - t.integer "user_id" - t.integer "poll_question_id" - t.integer "poll_answer_id" - t.text "vote_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "polls", :force => true do |t| - t.string "polls_name" - t.string "polls_type" - t.integer "polls_group_id" - t.integer "polls_status" - t.integer "user_id" - t.datetime "published_at" - t.datetime "closed_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "polls_description" - t.integer "show_result", :default => 1 - end - - create_table "praise_tread_caches", :force => true do |t| - t.integer "object_id", :null => false - t.string "object_type" - t.integer "praise_num" - t.integer "tread_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "praise_treads", :force => true do |t| - t.integer "user_id", :null => false - t.integer "praise_tread_object_id" - t.string "praise_tread_object_type" - t.integer "praise_or_tread" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "principal_activities", :force => true do |t| - t.integer "user_id" - t.integer "principal_id" - t.integer "principal_act_id" - t.string "principal_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_infos", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_scores", :force => true do |t| - t.string "project_id" - t.integer "score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "issue_num", :default => 0 - t.integer "issue_journal_num", :default => 0 - t.integer "news_num", :default => 0 - t.integer "documents_num", :default => 0 - t.integer "changeset_num", :default => 0 - t.integer "board_message_num", :default => 0 - t.integer "board_num", :default => 0 - t.integer "attach_num", :default => 0 - t.datetime "commit_time" - end - - create_table "project_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "project_id" - t.integer "project_type" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - end - - add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - - create_table "projecting_softapplictions", :force => true do |t| - t.integer "user_id" - t.integer "softapplication_id" - t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false - t.integer "parent_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "identifier" - t.integer "status", :default => 1, :null => false - t.integer "lft" - t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false - t.integer "project_type" - t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 - t.integer "user_id" - t.integer "dts_test", :default => 0 - t.string "enterprise_name" - t.integer "organization_id" - t.integer "project_new_type" - t.integer "gpid" - t.integer "forked_from_project_id" - t.integer "forked_count" - t.integer "commits_count", :default => 0 - t.integer "publish_resource", :default => 0 - t.integer "issues_count", :default => 0 - t.integer "attachments_count", :default => 0 - t.integer "boards_count", :default => 0 - t.integer "news_count", :default => 0 - t.integer "acts_count", :default => 0 - t.integer "journals_count", :default => 0 - t.integer "boards_reply_count", :default => 0 - t.integer "visits", :default => 0 - end - - add_index "projects", ["lft"], :name => "index_projects_on_lft" - add_index "projects", ["rgt"], :name => "index_projects_on_rgt" - - create_table "projects_trackers", :id => false, :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true - add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" - - create_table "queries", :force => true do |t| - t.integer "project_id" - t.string "name", :default => "", :null => false - t.text "filters" - t.integer "user_id", :default => 0, :null => false - t.boolean "is_public", :default => false, :null => false - t.text "column_names" - t.text "sort_criteria" - t.string "group_by" - t.string "type" - end - - add_index "queries", ["project_id"], :name => "index_queries_on_project_id" - add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - - create_table "relative_memo_to_open_source_projects", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "relative_memos", :force => true do |t| - t.integer "osp_id" - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 16777215, :null => false - t.integer "author_id" - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 - t.string "url" - t.string "username" - t.string "userhomeurl" - t.date "date_collected" - t.string "topic_resource" - end - - create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" - t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 - t.text "extra_info" - t.string "identifier" - t.boolean "is_default", :default => false - t.boolean "hidden", :default => false - end - - add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - - create_table "roles", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "assignable", :default => true - t.integer "builtin", :default => 0, :null => false - t.text "permissions" - t.string "issues_visibility", :limit => 30, :default => "default", :null => false - end - - create_table "schools", :force => true do |t| - t.string "name" - t.string "province" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "logo_link" - t.string "pinyin" - end - - create_table "secdomains", :force => true do |t| - t.integer "sub_type" - t.string "subname" - t.integer "pid", :default => 0 - t.string "desc" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_cached_ratings", :force => true do |t| - t.integer "cacheable_id", :limit => 8 - t.string "cacheable_type" - t.float "avg", :null => false - t.integer "cnt", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_rates", :force => true do |t| - t.integer "rater_id", :limit => 8 - t.integer "rateable_id" - t.string "rateable_type" - t.float "stars", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "is_teacher_score", :default => 0 - end - - create_table "settings", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "value" - t.datetime "updated_on" - end - - add_index "settings", ["name"], :name => "index_settings_on_name" - - create_table "shares", :force => true do |t| - t.date "created_on" - t.string "url" - t.string "title" - t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - t.integer "user_id" - t.string "description" - end - - create_table "shield_activities", :force => true do |t| - t.string "container_type" - t.integer "container_id" - t.string "shield_type" - t.integer "shield_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "softapplications", :force => true do |t| - t.string "name" - t.text "description" - t.integer "app_type_id" - t.string "app_type_name" - t.string "android_min_version_available" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "contest_id" - t.integer "softapplication_id" - t.integer "is_public" - t.string "application_developers" - t.string "deposit_project_url" - t.string "deposit_project" - t.integer "project_id" - end - - create_table "student_work_projects", :force => true do |t| - t.integer "homework_common_id" - t.integer "student_work_id" - t.integer "project_id" - t.integer "user_id" - t.integer "is_leader" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "student_work_projects", ["homework_common_id"], :name => "index_student_work_projects_on_homework_common_id" - add_index "student_work_projects", ["project_id"], :name => "index_student_work_projects_on_project_id" - add_index "student_work_projects", ["student_work_id"], :name => "index_student_work_projects_on_student_work_id" - add_index "student_work_projects", ["user_id"], :name => "index_student_work_projects_on_user_id" - - create_table "student_work_tests", :force => true do |t| - t.integer "student_work_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "status", :default => 9 - t.text "results" - t.text "src" - end - - create_table "student_works", :force => true do |t| - t.string "name" - t.text "description", :limit => 2147483647 - t.integer "homework_common_id" - t.integer "user_id" - t.float "final_score" - t.float "teacher_score" - t.float "student_score" - t.float "teaching_asistant_score" - t.integer "project_id", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "late_penalty", :default => 0 - t.integer "absence_penalty", :default => 0 - t.float "system_score", :default => 0.0 - t.boolean "is_test", :default => false - end - - add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" - - create_table "student_works_evaluation_distributions", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "student_works_scores", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.integer "score" - t.text "comment" - t.integer "reviewer_role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "students_for_courses", :force => true do |t| - t.integer "student_id" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" - add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" - - create_table "subfield_subdomain_dirs", :force => true do |t| - t.integer "org_subfield_id" - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "system_messages", :force => true do |t| - t.integer "user_id" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "description" - t.string "subject" - end - - create_table "taggings", :force => true do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", :limit => 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" - - create_table "tags", :force => true do |t| - t.string "name" - end - - create_table "teachers", :force => true do |t| - t.string "tea_name" - t.string "location" - t.integer "couurse_time" - t.integer "course_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "extra" - end - - create_table "time_entries", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "issue_id" - t.float "hours", :null => false - t.string "comments" - t.integer "activity_id", :null => false - t.date "spent_on", :null => false - t.integer "tyear", :null => false - t.integer "tmonth", :null => false - t.integer "tweek", :null => false - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" - add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" - add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" - add_index "time_entries", ["project_id"], :name => "time_entries_project_id" - add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - - create_table "tokens", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40, :default => "", :null => false - t.datetime "created_on", :null => false - end - - add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" - add_index "tokens", ["value"], :name => "tokens_value", :unique => true - - create_table "trackers", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_in_chlog", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "is_in_roadmap", :default => true, :null => false - t.integer "fields_bits", :default => 0 - end - - create_table "user_actions", :force => true do |t| - t.integer "user_id" - t.string "action_type" - t.integer "action_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_activities", :force => true do |t| - t.string "act_type" - t.integer "act_id" - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "user_id" - end - - create_table "user_extensions", :force => true do |t| - t.integer "user_id", :null => false - t.date "birthday" - t.string "brief_introduction" - t.integer "gender" - t.string "location" - t.string "occupation" - t.integer "work_experience" - t.integer "zip_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "technical_title" - t.integer "identity" - t.string "student_id" - t.string "teacher_realname" - t.string "student_realname" - t.string "location_city" - t.integer "school_id" - t.string "description", :default => "" - end - - create_table "user_feedback_messages", :force => true do |t| - t.integer "user_id" - t.integer "journals_for_message_id" - t.string "journals_for_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_grades", :force => true do |t| - t.integer "user_id", :null => false - t.integer "project_id", :null => false - t.float "grade", :default => 0.0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" - add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" - add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" - - create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - end - - create_table "user_preferences", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.text "others" - t.boolean "hide_mail", :default => false - t.string "time_zone" - end - - add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" - - create_table "user_score_details", :force => true do |t| - t.integer "current_user_id" - t.integer "target_user_id" - t.string "score_type" - t.string "score_action" - t.integer "user_id" - t.integer "old_score" - t.integer "new_score" - t.integer "current_user_level" - t.integer "target_user_level" - t.integer "score_changeable_obj_id" - t.string "score_changeable_obj_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "grade", :default => 0.0 - end - - add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" - add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" - add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" - - create_table "user_wechats", :force => true do |t| - t.integer "subscribe" - t.string "openid" - t.string "nickname" - t.integer "sex" - t.string "language" - t.string "city" - t.string "province" - t.string "country" - t.string "headimgurl" - t.string "subscribe_time" - t.string "unionid" - t.string "remark" - t.integer "groupid" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "users", :force => true do |t| - t.string "login", :default => "", :null => false - t.string "hashed_password", :limit => 40, :default => "", :null => false - t.string "firstname", :limit => 30, :default => "", :null => false - t.string "lastname", :default => "", :null => false - t.string "mail", :limit => 60, :default => "", :null => false - t.boolean "admin", :default => false, :null => false - t.integer "status", :default => 1, :null => false - t.datetime "last_login_on" - t.string "language", :limit => 5, :default => "" - t.integer "auth_source_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "type" - t.string "identity_url" - t.string "mail_notification", :default => "", :null => false - t.string "salt", :limit => 64 - t.integer "gid" - t.integer "visits", :default => 0 - end - - add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" - add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" - add_index "users", ["type"], :name => "index_users_on_type" - - create_table "versions", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :default => "", :null => false - t.string "description", :default => "" - t.date "effective_date" - t.datetime "created_on" - t.datetime "updated_on" - t.string "wiki_page_title" - t.string "status", :default => "open" - t.string "sharing", :default => "none", :null => false - end - - add_index "versions", ["project_id"], :name => "versions_project_id" - add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - - create_table "visitors", :force => true do |t| - t.integer "user_id" - t.integer "master_id" - t.datetime "updated_on" - t.datetime "created_on" - end - - add_index "visitors", ["master_id"], :name => "index_visitors_master_id" - add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" - add_index "visitors", ["user_id"], :name => "index_visitors_user_id" - - create_table "watchers", :force => true do |t| - t.string "watchable_type", :default => "", :null => false - t.integer "watchable_id", :default => 0, :null => false - t.integer "user_id" - end - - add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" - add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" - add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" - - create_table "web_footer_companies", :force => true do |t| - t.string "name" - t.string "logo_size" - t.string "url" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "web_footer_oranizers", :force => true do |t| - t.string "name" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "wechat_logs", :force => true do |t| - t.string "openid", :null => false - t.text "request_raw" - t.text "response_raw" - t.text "session_raw" - t.datetime "created_at", :null => false - end - - create_table "wiki_content_versions", :force => true do |t| - t.integer "wiki_content_id", :null => false - t.integer "page_id", :null => false - t.integer "author_id" - t.binary "data", :limit => 2147483647 - t.string "compression", :limit => 6, :default => "" - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" - add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" - - create_table "wiki_contents", :force => true do |t| - t.integer "page_id", :null => false - t.integer "author_id" - t.text "text", :limit => 2147483647 - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" - add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" - - create_table "wiki_pages", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title", :null => false - t.datetime "created_on", :null => false - t.boolean "protected", :default => false, :null => false - t.integer "parent_id" - end - - add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" - add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" - add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" - - create_table "wiki_redirects", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title" - t.string "redirects_to" - t.datetime "created_on", :null => false - end - - add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" - add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" - - create_table "wikis", :force => true do |t| - t.integer "project_id", :null => false - t.string "start_page", :null => false - t.integer "status", :default => 1, :null => false - end - - add_index "wikis", ["project_id"], :name => "wikis_project_id" - - create_table "workflows", :force => true do |t| - t.integer "tracker_id", :default => 0, :null => false - t.integer "old_status_id", :default => 0, :null => false - t.integer "new_status_id", :default => 0, :null => false - t.integer "role_id", :default => 0, :null => false - t.boolean "assignee", :default => false, :null => false - t.boolean "author", :default => false, :null => false - t.string "type", :limit => 30 - t.string "field_name", :limit => 30 - t.string "rule", :limit => 30 - end - - add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" - add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" - add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" - add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - - create_table "works_categories", :force => true do |t| - t.string "category" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "zip_packs", :force => true do |t| - t.integer "user_id" - t.integer "homework_id" - t.string "file_digest" - t.string "file_path" - t.integer "pack_times", :default => 1 - t.integer "pack_size", :default => 0 - t.text "file_digests" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -end +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20160317090350) do + + create_table "activities", :force => true do |t| + t.integer "act_id", :null => false + t.string "act_type", :null => false + t.integer "user_id", :null => false + t.integer "activity_container_id" + t.string "activity_container_type", :default => "" + t.datetime "created_at" + end + + add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" + add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" + add_index "activities", ["user_id"], :name => "index_activities_on_user_id" + + create_table "activity_notifies", :force => true do |t| + t.integer "activity_container_id" + t.string "activity_container_type" + t.integer "activity_id" + t.string "activity_type" + t.integer "notify_to" + t.datetime "created_on" + t.integer "is_read" + end + + add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" + add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" + add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" + + create_table "api_keys", :force => true do |t| + t.string "access_token" + t.datetime "expires_at" + t.integer "user_id" + t.boolean "active", :default => true + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" + add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" + + create_table "applied_projects", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + end + + create_table "apply_project_masters", :force => true do |t| + t.integer "user_id" + t.string "apply_type" + t.integer "apply_id" + t.integer "status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "at_messages", :force => true do |t| + t.integer "user_id" + t.integer "at_message_id" + t.string "at_message_type" + t.boolean "viewed", :default => false + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sender_id" + end + + add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" + + create_table "attachment_histories", :force => true do |t| + t.integer "container_id" + t.string "container_type" + t.string "filename", :default => "" + t.string "disk_filename", :default => "" + t.integer "filesize", :default => 0 + t.string "content_type", :default => "" + t.string "digest", :limit => 40, :default => "" + t.integer "downloads", :default => 0 + t.integer "author_id" + t.datetime "created_on" + t.string "description" + t.string "disk_directory" + t.integer "attachtype" + t.integer "is_public" + t.integer "copy_from" + t.integer "quotes" + t.integer "version" + t.integer "attachment_id" + t.integer "is_publish", :default => 1 + t.date "publish_time" + end + + create_table "attachments", :force => true do |t| + t.integer "container_id" + t.string "container_type", :limit => 30 + t.string "filename", :default => "", :null => false + t.string "disk_filename", :default => "", :null => false + t.integer "filesize", :default => 0, :null => false + t.string "content_type", :default => "" + t.string "digest", :limit => 40, :default => "", :null => false + t.integer "downloads", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.string "description" + t.string "disk_directory" + t.integer "attachtype", :default => 1 + t.integer "is_public", :default => 1 + t.integer "copy_from" + t.integer "quotes" + t.integer "is_publish", :default => 1 + t.date "publish_time" + end + + add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" + add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" + add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" + + create_table "attachmentstypes", :force => true do |t| + t.integer "typeId", :null => false + t.string "typeName", :limit => 50 + end + + create_table "auth_sources", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 60, :default => "", :null => false + t.string "host", :limit => 60 + t.integer "port" + t.string "account" + t.string "account_password", :default => "" + t.string "base_dn" + t.string "attr_login", :limit => 30 + t.string "attr_firstname", :limit => 30 + t.string "attr_lastname", :limit => 30 + t.string "attr_mail", :limit => 30 + t.boolean "onthefly_register", :default => false, :null => false + t.boolean "tls", :default => false, :null => false + t.string "filter" + t.integer "timeout" + end + + add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" + + create_table "biding_projects", :force => true do |t| + t.integer "project_id" + t.integer "bid_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "bids", :force => true do |t| + t.string "name" + t.string "budget", :null => false + t.integer "author_id" + t.date "deadline" + t.text "description" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.integer "commit" + t.integer "reward_type" + t.integer "homework_type" + t.integer "parent_id" + t.string "password" + t.integer "is_evaluation" + t.integer "proportion", :default => 60 + t.integer "comment_status", :default => 0 + t.integer "evaluation_num", :default => 3 + t.integer "open_anonymous_evaluation", :default => 1 + end + + create_table "blog_comments", :force => true do |t| + t.integer "blog_id", :null => false + t.integer "parent_id" + t.string "title", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comment_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "blogs", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.integer "position", :default => 1 + t.integer "article_count", :default => 0, :null => false + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comments_id" + t.integer "parent_id" + t.integer "author_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "homepage_id" + end + + create_table "boards", :force => true do |t| + t.integer "project_id", :null => false + t.string "name", :default => "", :null => false + t.string "description" + t.integer "position", :default => 1 + t.integer "topics_count", :default => 0, :null => false + t.integer "messages_count", :default => 0, :null => false + t.integer "last_message_id" + t.integer "parent_id" + t.integer "course_id" + t.integer "org_subfield_id" + end + + add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" + add_index "boards", ["project_id"], :name => "boards_project_id" + + create_table "bug_to_osps", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "changes", :force => true do |t| + t.integer "changeset_id", :null => false + t.string "action", :limit => 1, :default => "", :null => false + t.text "path", :null => false + t.text "from_path" + t.string "from_revision" + t.string "revision" + t.string "branch" + end + + add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" + + create_table "changeset_parents", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "parent_id", :null => false + end + + add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" + add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" + + create_table "changesets", :force => true do |t| + t.integer "repository_id", :null => false + t.string "revision", :null => false + t.string "committer" + t.datetime "committed_on", :null => false + t.text "comments" + t.date "commit_date" + t.string "scmid" + t.integer "user_id" + end + + add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" + add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true + add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" + add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" + add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" + + create_table "changesets_issues", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "issue_id", :null => false + end + + add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true + + create_table "code_review_assignments", :force => true do |t| + t.integer "issue_id" + t.integer "change_id" + t.integer "attachment_id" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.string "action_type" + t.integer "changeset_id" + end + + create_table "code_review_project_settings", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "updated_by" + t.boolean "hide_code_review_tab", :default => false + t.integer "auto_relation", :default => 1 + t.integer "assignment_tracker_id" + t.text "auto_assign" + t.integer "lock_version", :default => 0, :null => false + t.boolean "tracker_in_review_dialog", :default => false + end + + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "code_reviews", :force => true do |t| + t.integer "project_id" + t.integer "change_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line" + t.integer "updated_by_id" + t.integer "lock_version", :default => 0, :null => false + t.integer "status_changed_from" + t.integer "status_changed_to" + t.integer "issue_id" + t.string "action_type" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.integer "attachment_id" + t.integer "file_count", :default => 0, :null => false + t.boolean "diff_all" + end + + create_table "comments", :force => true do |t| + t.string "commented_type", :limit => 30, :default => "", :null => false + t.integer "commented_id", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.text "comments" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + add_index "comments", ["author_id"], :name => "index_comments_on_author_id" + add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + + create_table "contest_notifications", :force => true do |t| + t.text "title" + t.text "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contesting_projects", :force => true do |t| + t.integer "project_id" + t.string "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contesting_softapplications", :force => true do |t| + t.integer "softapplication_id" + t.integer "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.text "description" + t.integer "author_id" + t.integer "notificationcomments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contests", :force => true do |t| + t.string "name" + t.string "budget", :default => "" + t.integer "author_id" + t.date "deadline" + t.string "description" + t.integer "commit" + t.string "password" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + create_table "course_activities", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_act_id" + t.string "course_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_attachments", :force => true do |t| + t.string "filename" + t.string "disk_filename" + t.integer "filesize" + t.string "content_type" + t.string "digest" + t.integer "downloads" + t.string "author_id" + t.string "integer" + t.string "description" + t.string "disk_directory" + t.integer "attachtype" + t.integer "is_public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "container_id", :default => 0 + end + + create_table "course_contributor_scores", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.integer "message_num" + t.integer "message_reply_num" + t.integer "news_reply_num" + t.integer "resource_num" + t.integer "journal_num" + t.integer "journal_reply_num" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "total_score" + t.integer "homework_journal_num", :default => 0 + t.integer "news_num", :default => 0 + end + + create_table "course_groups", :force => true do |t| + t.string "name" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_infos", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_messages", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_message_id" + t.string "course_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "content" + t.integer "status" + end + + create_table "course_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "course_id" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "courses", :force => true do |t| + t.integer "tea_id" + t.string "name" + t.integer "state" + t.string "code" + t.integer "time" + t.string "extra" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "location" + t.string "term" + t.string "string" + t.string "password" + t.string "setup_time" + t.string "endup_time" + t.string "class_period" + t.integer "school_id" + t.text "description" + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 + t.integer "lft" + t.integer "rgt" + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 + t.integer "open_student", :default => 0 + t.integer "outline", :default => 0 + t.integer "publish_resource", :default => 0 + t.integer "is_delete", :default => 0 + t.integer "end_time" + t.string "end_term" + t.integer "is_excellent", :default => 0 + t.integer "excellent_option", :default => 0 + t.integer "is_copy", :default => 0 + t.integer "visits", :default => 0 + end + + create_table "custom_fields", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.string "field_format", :limit => 30, :default => "", :null => false + t.text "possible_values" + t.string "regexp", :default => "" + t.integer "min_length", :default => 0, :null => false + t.integer "max_length", :default => 0, :null => false + t.boolean "is_required", :default => false, :null => false + t.boolean "is_for_all", :default => false, :null => false + t.boolean "is_filter", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "searchable", :default => false + t.text "default_value" + t.boolean "editable", :default => true + t.boolean "visible", :default => true, :null => false + t.boolean "multiple", :default => false + end + + add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" + + create_table "custom_fields_projects", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "project_id", :default => 0, :null => false + end + + add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true + + create_table "custom_fields_trackers", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true + + create_table "custom_values", :force => true do |t| + t.string "customized_type", :limit => 30, :default => "", :null => false + t.integer "customized_id", :default => 0, :null => false + t.integer "custom_field_id", :default => 0, :null => false + t.text "value" + end + + add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" + add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" + + create_table "delayed_jobs", :force => true do |t| + t.integer "priority", :default => 0, :null => false + t.integer "attempts", :default => 0, :null => false + t.text "handler", :null => false + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "documents", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "category_id", :default => 0, :null => false + t.string "title", :limit => 60, :default => "", :null => false + t.text "description" + t.datetime "created_on" + t.integer "user_id", :default => 0 + t.integer "is_public", :default => 1 + end + + add_index "documents", ["category_id"], :name => "index_documents_on_category_id" + add_index "documents", ["created_on"], :name => "index_documents_on_created_on" + add_index "documents", ["project_id"], :name => "documents_project_id" + + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 + t.string "File" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false + end + + create_table "editor_of_documents", :force => true do |t| + t.integer "editor_id" + t.integer "org_document_comment_id" + t.datetime "created_at" + end + + create_table "enabled_modules", :force => true do |t| + t.integer "project_id" + t.string "name", :null => false + t.integer "course_id" + end + + add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" + + create_table "enumerations", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "is_default", :default => false, :null => false + t.string "type" + t.boolean "active", :default => true, :null => false + t.integer "project_id" + t.integer "parent_id" + t.string "position_name", :limit => 30 + end + + add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" + add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" + + create_table "exercise_answers", :force => true do |t| + t.integer "user_id" + t.integer "exercise_question_id" + t.integer "exercise_choice_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_choices", :force => true do |t| + t.integer "exercise_question_id" + t.text "choice_text" + t.integer "choice_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_questions", :force => true do |t| + t.text "question_title" + t.integer "question_type" + t.integer "question_number" + t.integer "exercise_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_score" + end + + create_table "exercise_standard_answers", :force => true do |t| + t.integer "exercise_question_id" + t.integer "exercise_choice_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_users", :force => true do |t| + t.integer "user_id" + t.integer "exercise_id" + t.integer "score" + t.datetime "start_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.datetime "end_at" + t.integer "status" + end + + create_table "exercises", :force => true do |t| + t.text "exercise_name" + t.text "exercise_description" + t.integer "course_id" + t.integer "exercise_status" + t.integer "user_id" + t.integer "time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.datetime "publish_time" + t.datetime "end_time" + t.integer "show_result" + end + + create_table "first_pages", :force => true do |t| + t.string "web_title" + t.string "title" + t.text "description" + t.string "page_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sort_type" + t.integer "image_width", :default => 107 + t.integer "image_height", :default => 63 + t.integer "show_course", :default => 1 + t.integer "show_contest", :default => 1 + end + + create_table "forge_activities", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_act_id" + t.string "forge_act_type" + t.integer "org_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" + + create_table "forge_messages", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_message_id" + t.string "forge_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "secret_key" + t.integer "status" + end + + create_table "forums", :force => true do |t| + t.string "name", :null => false + t.text "description" + t.integer "topic_count", :default => 0 + t.integer "memo_count", :default => 0 + t.integer "last_memo_id", :default => 0 + t.integer "creator_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sticky" + t.integer "locked" + end + + create_table "forwards", :force => true do |t| + t.integer "from_id" + t.string "from_type" + t.integer "to_id" + t.string "to_type" + t.datetime "created_at" + end + + create_table "groups_users", :id => false, :force => true do |t| + t.integer "group_id", :null => false + t.integer "user_id", :null => false + end + + add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true + + create_table "homework_attaches", :force => true do |t| + t.integer "bid_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + t.string "name" + t.text "description" + t.integer "state" + t.integer "project_id", :default => 0 + t.float "score", :default => 0.0 + t.integer "is_teacher_score", :default => 0 + end + + add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" + + create_table "homework_commons", :force => true do |t| + t.string "name" + t.integer "user_id" + t.text "description" + t.date "publish_time" + t.date "end_time" + t.integer "homework_type", :default => 1 + t.string "late_penalty" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "teacher_priority", :default => 1 + t.integer "anonymous_comment", :default => 0 + t.integer "quotes", :default => 0 + t.integer "is_open", :default => 0 + end + + add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" + + create_table "homework_detail_groups", :force => true do |t| + t.integer "homework_common_id" + t.integer "min_num" + t.integer "max_num" + t.integer "base_on_project" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" + + create_table "homework_detail_manuals", :force => true do |t| + t.float "ta_proportion" + t.integer "comment_status" + t.date "evaluation_start" + t.date "evaluation_end" + t.integer "evaluation_num" + t.integer "absence_penalty", :default => 1 + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_detail_programings", :force => true do |t| + t.string "language" + t.text "standard_code", :limit => 2147483647 + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "ta_proportion", :default => 0.1 + t.integer "question_id" + end + + create_table "homework_evaluations", :force => true do |t| + t.string "user_id" + t.string "homework_attach_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_for_courses", :force => true do |t| + t.integer "course_id" + t.integer "bid_id" + end + + add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" + add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" + + create_table "homework_tests", :force => true do |t| + t.text "input" + t.text "output" + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "result" + t.text "error_msg" + end + + create_table "homework_users", :force => true do |t| + t.string "homework_attach_id" + t.string "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "invite_lists", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "mail" + end + + create_table "issue_categories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.integer "assigned_to_id" + end + + add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" + add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" + + create_table "issue_relations", :force => true do |t| + t.integer "issue_from_id", :null => false + t.integer "issue_to_id", :null => false + t.string "relation_type", :default => "", :null => false + t.integer "delay" + end + + add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true + add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" + add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" + + create_table "issue_statuses", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_closed", :default => false, :null => false + t.boolean "is_default", :default => false, :null => false + t.integer "position", :default => 1 + t.integer "default_done_ratio" + end + + add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" + add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" + add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" + + create_table "issues", :force => true do |t| + t.integer "tracker_id", :null => false + t.integer "project_id", :null => false + t.string "subject", :default => "", :null => false + t.text "description" + t.date "due_date" + t.integer "category_id" + t.integer "status_id", :null => false + t.integer "assigned_to_id" + t.integer "priority_id", :null => false + t.integer "fixed_version_id" + t.integer "author_id", :null => false + t.integer "lock_version", :default => 0, :null => false + t.datetime "created_on" + t.datetime "updated_on" + t.date "start_date" + t.integer "done_ratio", :default => 0, :null => false + t.float "estimated_hours" + t.integer "parent_id" + t.integer "root_id" + t.integer "lft" + t.integer "rgt" + t.boolean "is_private", :default => false, :null => false + t.datetime "closed_on" + t.integer "project_issues_index" + end + + add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" + add_index "issues", ["author_id"], :name => "index_issues_on_author_id" + add_index "issues", ["category_id"], :name => "index_issues_on_category_id" + add_index "issues", ["created_on"], :name => "index_issues_on_created_on" + add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" + add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" + add_index "issues", ["project_id"], :name => "issues_project_id" + add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" + add_index "issues", ["status_id"], :name => "index_issues_on_status_id" + add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" + + create_table "join_in_competitions", :force => true do |t| + t.integer "user_id" + t.integer "competition_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "join_in_contests", :force => true do |t| + t.integer "user_id" + t.integer "bid_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "journal_details", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + + create_table "journal_replies", :id => false, :force => true do |t| + t.integer "journal_id" + t.integer "user_id" + t.integer "reply_id" + end + + add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" + add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" + add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" + + create_table "journals", :force => true do |t| + t.integer "journalized_id", :default => 0, :null => false + t.string "journalized_type", :limit => 30, :default => "", :null => false + t.integer "user_id", :default => 0, :null => false + t.text "notes" + t.datetime "created_on", :null => false + t.boolean "private_notes", :default => false, :null => false + end + + add_index "journals", ["created_on"], :name => "index_journals_on_created_on" + add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" + add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" + add_index "journals", ["user_id"], :name => "index_journals_on_user_id" + + create_table "journals_for_messages", :force => true do |t| + t.integer "jour_id" + t.string "jour_type" + t.integer "user_id" + t.text "notes" + t.integer "status" + t.integer "reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.string "m_parent_id" + t.boolean "is_readed" + t.integer "m_reply_count" + t.integer "m_reply_id" + t.integer "is_comprehensive_evaluation" + t.integer "private", :default => 0 + end + + create_table "kindeditor_assets", :force => true do |t| + t.string "asset" + t.integer "file_size" + t.string "file_type" + t.integer "owner_id" + t.string "asset_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "owner_type", :default => 0 + end + + create_table "member_roles", :force => true do |t| + t.integer "member_id", :null => false + t.integer "role_id", :null => false + t.integer "inherited_from" + end + + add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" + add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" + + create_table "members", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "project_id", :default => 0 + t.datetime "created_on" + t.boolean "mail_notification", :default => false, :null => false + t.integer "course_id", :default => -1 + t.integer "course_group_id", :default => 0 + end + + add_index "members", ["project_id"], :name => "index_members_on_project_id" + add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true + add_index "members", ["user_id"], :name => "index_members_on_user_id" + + create_table "memo_messages", :force => true do |t| + t.integer "user_id" + t.integer "forum_id" + t.integer "memo_id" + t.string "memo_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "memos", :force => true do |t| + t.integer "forum_id", :null => false + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :null => false + t.integer "author_id", :null => false + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count", :default => 0 + end + + create_table "message_alls", :force => true do |t| + t.integer "user_id" + t.integer "message_id" + t.string "message_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "messages", :force => true do |t| + t.integer "board_id", :null => false + t.integer "parent_id" + t.string "subject", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "replies_count", :default => 0, :null => false + t.integer "last_reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + t.integer "quotes" + t.integer "status", :default => 0 + end + + add_index "messages", ["author_id"], :name => "index_messages_on_author_id" + add_index "messages", ["board_id"], :name => "messages_board_id" + add_index "messages", ["created_on"], :name => "index_messages_on_created_on" + add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" + add_index "messages", ["parent_id"], :name => "messages_parent_id" + + create_table "news", :force => true do |t| + t.integer "project_id" + t.string "title", :limit => 60, :default => "", :null => false + t.string "summary", :default => "" + t.text "description" + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.integer "comments_count", :default => 0, :null => false + t.integer "course_id" + t.integer "sticky", :default => 0 + t.integer "org_subfield_id" + end + + add_index "news", ["author_id"], :name => "index_news_on_author_id" + add_index "news", ["created_on"], :name => "index_news_on_created_on" + add_index "news", ["project_id"], :name => "news_project_id" + + create_table "no_uses", :force => true do |t| + t.integer "user_id", :null => false + t.string "no_use_type" + t.integer "no_use_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "notificationcomments", :force => true do |t| + t.string "notificationcommented_type" + t.integer "notificationcommented_id" + t.integer "author_id" + t.text "notificationcomments" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "onclick_times", :force => true do |t| + t.integer "user_id" + t.datetime "onclick_time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "open_id_authentication_associations", :force => true do |t| + t.integer "issued" + t.integer "lifetime" + t.string "handle" + t.string "assoc_type" + t.binary "server_url" + t.binary "secret" + end + + create_table "open_id_authentication_nonces", :force => true do |t| + t.integer "timestamp", :null => false + t.string "server_url" + t.string "salt", :null => false + end + + create_table "open_source_projects", :force => true do |t| + t.string "name" + t.text "description" + t.integer "commit_count", :default => 0 + t.integer "code_line", :default => 0 + t.integer "users_count", :default => 0 + t.date "last_commit_time" + t.string "url" + t.date "date_collected" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "option_numbers", :force => true do |t| + t.integer "user_id" + t.integer "memo" + t.integer "messages_for_issues" + t.integer "issues_status" + t.integer "replay_for_message" + t.integer "replay_for_memo" + t.integer "follow" + t.integer "tread" + t.integer "praise_by_one" + t.integer "praise_by_two" + t.integer "praise_by_three" + t.integer "tread_by_one" + t.integer "tread_by_two" + t.integer "tread_by_three" + t.integer "changeset" + t.integer "document" + t.integer "attachment" + t.integer "issue_done_ratio" + t.integer "post_issue" + t.integer "score_type" + t.integer "total_score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + end + + create_table "org_activities", :force => true do |t| + t.integer "user_id" + t.integer "org_act_id" + t.string "org_act_type" + t.integer "container_id" + t.string "container_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_courses", :force => true do |t| + t.integer "organization_id" + t.integer "course_id" + t.datetime "created_at" + end + + create_table "org_document_comments", :force => true do |t| + t.text "title" + t.text "content" + t.integer "organization_id" + t.integer "creator_id" + t.integer "parent_id" + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "org_subfield_id" + end + + create_table "org_member_roles", :force => true do |t| + t.integer "org_member_id" + t.integer "role_id" + end + + create_table "org_members", :force => true do |t| + t.integer "user_id" + t.integer "organization_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_messages", :force => true do |t| + t.integer "user_id" + t.integer "sender_id" + t.integer "organization_id" + t.string "message_type" + t.integer "message_id" + t.integer "viewed" + t.string "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "status", :default => 0 + end + + create_table "org_projects", :force => true do |t| + t.integer "organization_id" + t.integer "project_id" + t.datetime "created_at" + end + + create_table "org_subfield_messages", :force => true do |t| + t.integer "org_subfield_id" + t.integer "message_id" + t.string "message_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "org_subfields", :force => true do |t| + t.integer "organization_id" + t.integer "priority" + t.string "name" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "field_type" + t.integer "hide", :default => 0 + end + + create_table "organizations", :force => true do |t| + t.string "name" + t.text "description" + t.integer "creator_id" + t.integer "home_id" + t.boolean "is_public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "allow_guest_download", :default => true + t.integer "visits", :default => 0 + end + + create_table "phone_app_versions", :force => true do |t| + t.string "version" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_answers", :force => true do |t| + t.integer "poll_question_id" + t.text "answer_text" + t.integer "answer_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_questions", :force => true do |t| + t.string "question_title" + t.integer "question_type" + t.integer "is_necessary" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_number" + end + + create_table "poll_users", :force => true do |t| + t.integer "user_id" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_votes", :force => true do |t| + t.integer "user_id" + t.integer "poll_question_id" + t.integer "poll_answer_id" + t.text "vote_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "polls", :force => true do |t| + t.string "polls_name" + t.string "polls_type" + t.integer "polls_group_id" + t.integer "polls_status" + t.integer "user_id" + t.datetime "published_at" + t.datetime "closed_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "polls_description" + t.integer "show_result", :default => 1 + end + + create_table "praise_tread_caches", :force => true do |t| + t.integer "object_id", :null => false + t.string "object_type" + t.integer "praise_num" + t.integer "tread_num" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "praise_treads", :force => true do |t| + t.integer "user_id", :null => false + t.integer "praise_tread_object_id" + t.string "praise_tread_object_type" + t.integer "praise_or_tread" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "principal_activities", :force => true do |t| + t.integer "user_id" + t.integer "principal_id" + t.integer "principal_act_id" + t.string "principal_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_infos", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_scores", :force => true do |t| + t.string "project_id" + t.integer "score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "issue_num", :default => 0 + t.integer "issue_journal_num", :default => 0 + t.integer "news_num", :default => 0 + t.integer "documents_num", :default => 0 + t.integer "changeset_num", :default => 0 + t.integer "board_message_num", :default => 0 + t.integer "board_num", :default => 0 + t.integer "attach_num", :default => 0 + t.datetime "commit_time" + end + + create_table "project_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "project_id" + t.integer "project_type" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + end + + add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" + + create_table "projecting_softapplictions", :force => true do |t| + t.integer "user_id" + t.integer "softapplication_id" + t.integer "project_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "projects", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.string "homepage", :default => "" + t.boolean "is_public", :default => true, :null => false + t.integer "parent_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "identifier" + t.integer "status", :default => 1, :null => false + t.integer "lft" + t.integer "rgt" + t.boolean "inherit_members", :default => false, :null => false + t.integer "project_type" + t.boolean "hidden_repo", :default => false, :null => false + t.integer "attachmenttype", :default => 1 + t.integer "user_id" + t.integer "dts_test", :default => 0 + t.string "enterprise_name" + t.integer "organization_id" + t.integer "project_new_type" + t.integer "gpid" + t.integer "forked_from_project_id" + t.integer "forked_count" + t.integer "commits_count", :default => 0 + t.integer "publish_resource", :default => 0 + t.integer "issues_count", :default => 0 + t.integer "attachments_count", :default => 0 + t.integer "boards_count", :default => 0 + t.integer "news_count", :default => 0 + t.integer "acts_count", :default => 0 + t.integer "journals_count", :default => 0 + t.integer "boards_reply_count", :default => 0 + t.integer "visits", :default => 0 + end + + add_index "projects", ["lft"], :name => "index_projects_on_lft" + add_index "projects", ["rgt"], :name => "index_projects_on_rgt" + + create_table "projects_trackers", :id => false, :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true + add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" + + create_table "queries", :force => true do |t| + t.integer "project_id" + t.string "name", :default => "", :null => false + t.text "filters" + t.integer "user_id", :default => 0, :null => false + t.boolean "is_public", :default => false, :null => false + t.text "column_names" + t.text "sort_criteria" + t.string "group_by" + t.string "type" + end + + add_index "queries", ["project_id"], :name => "index_queries_on_project_id" + add_index "queries", ["user_id"], :name => "index_queries_on_user_id" + + create_table "relative_memo_to_open_source_projects", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "relative_memos", :force => true do |t| + t.integer "osp_id" + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :limit => 16777215, :null => false + t.integer "author_id" + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 + t.string "url" + t.string "username" + t.string "userhomeurl" + t.date "date_collected" + t.string "topic_resource" + end + + create_table "repositories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "url", :default => "", :null => false + t.string "login", :limit => 60, :default => "" + t.string "password", :default => "" + t.string "root_url", :default => "" + t.string "type" + t.string "path_encoding", :limit => 64 + t.string "log_encoding", :limit => 64 + t.text "extra_info" + t.string "identifier" + t.boolean "is_default", :default => false + t.boolean "hidden", :default => false + end + + add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" + + create_table "rich_rich_files", :force => true do |t| + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "rich_file_file_name" + t.string "rich_file_content_type" + t.integer "rich_file_file_size" + t.datetime "rich_file_updated_at" + t.string "owner_type" + t.integer "owner_id" + t.text "uri_cache" + t.string "simplified_type", :default => "file" + end + + create_table "roles", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "assignable", :default => true + t.integer "builtin", :default => 0, :null => false + t.text "permissions" + t.string "issues_visibility", :limit => 30, :default => "default", :null => false + end + + create_table "schools", :force => true do |t| + t.string "name" + t.string "province" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "logo_link" + t.string "pinyin" + end + + create_table "secdomains", :force => true do |t| + t.integer "sub_type" + t.string "subname" + t.integer "pid", :default => 0 + t.string "desc" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "seems_rateable_cached_ratings", :force => true do |t| + t.integer "cacheable_id", :limit => 8 + t.string "cacheable_type" + t.float "avg", :null => false + t.integer "cnt", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "seems_rateable_rates", :force => true do |t| + t.integer "rater_id", :limit => 8 + t.integer "rateable_id" + t.string "rateable_type" + t.float "stars", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "is_teacher_score", :default => 0 + end + + create_table "settings", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "value" + t.datetime "updated_on" + end + + add_index "settings", ["name"], :name => "index_settings_on_name" + + create_table "shares", :force => true do |t| + t.date "created_on" + t.string "url" + t.string "title" + t.integer "share_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + t.integer "user_id" + t.string "description" + end + + create_table "shield_activities", :force => true do |t| + t.string "container_type" + t.integer "container_id" + t.string "shield_type" + t.integer "shield_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "softapplications", :force => true do |t| + t.string "name" + t.text "description" + t.integer "app_type_id" + t.string "app_type_name" + t.string "android_min_version_available" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "contest_id" + t.integer "softapplication_id" + t.integer "is_public" + t.string "application_developers" + t.string "deposit_project_url" + t.string "deposit_project" + t.integer "project_id" + end + + create_table "student_work_projects", :force => true do |t| + t.integer "homework_common_id" + t.integer "student_work_id" + t.integer "project_id" + t.integer "user_id" + t.integer "is_leader" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "student_work_projects", ["homework_common_id"], :name => "index_student_work_projects_on_homework_common_id" + add_index "student_work_projects", ["project_id"], :name => "index_student_work_projects_on_project_id" + add_index "student_work_projects", ["student_work_id"], :name => "index_student_work_projects_on_student_work_id" + add_index "student_work_projects", ["user_id"], :name => "index_student_work_projects_on_user_id" + + create_table "student_work_tests", :force => true do |t| + t.integer "student_work_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "status", :default => 9 + t.text "results" + t.text "src" + end + + create_table "student_works", :force => true do |t| + t.string "name" + t.text "description", :limit => 2147483647 + t.integer "homework_common_id" + t.integer "user_id" + t.float "final_score" + t.float "teacher_score" + t.float "student_score" + t.float "teaching_asistant_score" + t.integer "project_id", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "late_penalty", :default => 0 + t.integer "absence_penalty", :default => 0 + t.float "system_score", :default => 0.0 + t.boolean "is_test", :default => false + end + + add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" + + create_table "student_works_evaluation_distributions", :force => true do |t| + t.integer "student_work_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "student_works_scores", :force => true do |t| + t.integer "student_work_id" + t.integer "user_id" + t.integer "score" + t.text "comment" + t.integer "reviewer_role" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "students_for_courses", :force => true do |t| + t.integer "student_id" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" + add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" + + create_table "subfield_subdomain_dirs", :force => true do |t| + t.integer "org_subfield_id" + t.string "name" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "system_messages", :force => true do |t| + t.integer "user_id" + t.string "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "description" + t.string "subject" + end + + create_table "taggings", :force => true do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context", :limit => 128 + t.datetime "created_at" + end + + add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" + add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" + + create_table "tags", :force => true do |t| + t.string "name" + end + + create_table "teachers", :force => true do |t| + t.string "tea_name" + t.string "location" + t.integer "couurse_time" + t.integer "course_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "extra" + end + + create_table "time_entries", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.integer "issue_id" + t.float "hours", :null => false + t.string "comments" + t.integer "activity_id", :null => false + t.date "spent_on", :null => false + t.integer "tyear", :null => false + t.integer "tmonth", :null => false + t.integer "tweek", :null => false + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" + add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" + add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" + add_index "time_entries", ["project_id"], :name => "time_entries_project_id" + add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" + + create_table "tokens", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.string "action", :limit => 30, :default => "", :null => false + t.string "value", :limit => 40, :default => "", :null => false + t.datetime "created_on", :null => false + end + + add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" + add_index "tokens", ["value"], :name => "tokens_value", :unique => true + + create_table "trackers", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_in_chlog", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "is_in_roadmap", :default => true, :null => false + t.integer "fields_bits", :default => 0 + end + + create_table "user_actions", :force => true do |t| + t.integer "user_id" + t.string "action_type" + t.integer "action_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_activities", :force => true do |t| + t.string "act_type" + t.integer "act_id" + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "user_id" + end + + create_table "user_extensions", :force => true do |t| + t.integer "user_id", :null => false + t.date "birthday" + t.string "brief_introduction" + t.integer "gender" + t.string "location" + t.string "occupation" + t.integer "work_experience" + t.integer "zip_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "technical_title" + t.integer "identity" + t.string "student_id" + t.string "teacher_realname" + t.string "student_realname" + t.string "location_city" + t.integer "school_id" + t.string "description", :default => "" + end + + create_table "user_feedback_messages", :force => true do |t| + t.integer "user_id" + t.integer "journals_for_message_id" + t.string "journals_for_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_grades", :force => true do |t| + t.integer "user_id", :null => false + t.integer "project_id", :null => false + t.float "grade", :default => 0.0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" + add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" + add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" + + create_table "user_levels", :force => true do |t| + t.integer "user_id" + t.integer "level" + end + + create_table "user_preferences", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.text "others" + t.boolean "hide_mail", :default => false + t.string "time_zone" + end + + add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" + + create_table "user_score_details", :force => true do |t| + t.integer "current_user_id" + t.integer "target_user_id" + t.string "score_type" + t.string "score_action" + t.integer "user_id" + t.integer "old_score" + t.integer "new_score" + t.integer "current_user_level" + t.integer "target_user_level" + t.integer "score_changeable_obj_id" + t.string "score_changeable_obj_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_scores", :force => true do |t| + t.integer "user_id", :null => false + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "active" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "grade", :default => 0.0 + end + + add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" + add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" + add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" + + create_table "user_wechats", :force => true do |t| + t.integer "subscribe" + t.string "openid" + t.string "nickname" + t.integer "sex" + t.string "language" + t.string "city" + t.string "province" + t.string "country" + t.string "headimgurl" + t.string "subscribe_time" + t.string "unionid" + t.string "remark" + t.integer "groupid" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "users", :force => true do |t| + t.string "login", :default => "", :null => false + t.string "hashed_password", :limit => 40, :default => "", :null => false + t.string "firstname", :limit => 30, :default => "", :null => false + t.string "lastname", :default => "", :null => false + t.string "mail", :limit => 60, :default => "", :null => false + t.boolean "admin", :default => false, :null => false + t.integer "status", :default => 1, :null => false + t.datetime "last_login_on" + t.string "language", :limit => 5, :default => "" + t.integer "auth_source_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "type" + t.string "identity_url" + t.string "mail_notification", :default => "", :null => false + t.string "salt", :limit => 64 + t.integer "gid" + t.integer "visits", :default => 0 + end + + add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" + add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" + add_index "users", ["type"], :name => "index_users_on_type" + + create_table "versions", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :default => "", :null => false + t.string "description", :default => "" + t.date "effective_date" + t.datetime "created_on" + t.datetime "updated_on" + t.string "wiki_page_title" + t.string "status", :default => "open" + t.string "sharing", :default => "none", :null => false + end + + add_index "versions", ["project_id"], :name => "versions_project_id" + add_index "versions", ["sharing"], :name => "index_versions_on_sharing" + + create_table "visitors", :force => true do |t| + t.integer "user_id" + t.integer "master_id" + t.datetime "updated_on" + t.datetime "created_on" + end + + add_index "visitors", ["master_id"], :name => "index_visitors_master_id" + add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" + add_index "visitors", ["user_id"], :name => "index_visitors_user_id" + + create_table "watchers", :force => true do |t| + t.string "watchable_type", :default => "", :null => false + t.integer "watchable_id", :default => 0, :null => false + t.integer "user_id" + end + + add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" + add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" + add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" + + create_table "web_footer_companies", :force => true do |t| + t.string "name" + t.string "logo_size" + t.string "url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "web_footer_oranizers", :force => true do |t| + t.string "name" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "wechat_logs", :force => true do |t| + t.string "openid", :null => false + t.text "request_raw" + t.text "response_raw" + t.text "session_raw" + t.datetime "created_at", :null => false + end + + create_table "wiki_content_versions", :force => true do |t| + t.integer "wiki_content_id", :null => false + t.integer "page_id", :null => false + t.integer "author_id" + t.binary "data", :limit => 2147483647 + t.string "compression", :limit => 6, :default => "" + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" + add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" + + create_table "wiki_contents", :force => true do |t| + t.integer "page_id", :null => false + t.integer "author_id" + t.text "text", :limit => 2147483647 + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" + add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" + + create_table "wiki_pages", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title", :null => false + t.datetime "created_on", :null => false + t.boolean "protected", :default => false, :null => false + t.integer "parent_id" + end + + add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" + add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" + add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" + + create_table "wiki_redirects", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title" + t.string "redirects_to" + t.datetime "created_on", :null => false + end + + add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" + add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" + + create_table "wikis", :force => true do |t| + t.integer "project_id", :null => false + t.string "start_page", :null => false + t.integer "status", :default => 1, :null => false + end + + add_index "wikis", ["project_id"], :name => "wikis_project_id" + + create_table "workflows", :force => true do |t| + t.integer "tracker_id", :default => 0, :null => false + t.integer "old_status_id", :default => 0, :null => false + t.integer "new_status_id", :default => 0, :null => false + t.integer "role_id", :default => 0, :null => false + t.boolean "assignee", :default => false, :null => false + t.boolean "author", :default => false, :null => false + t.string "type", :limit => 30 + t.string "field_name", :limit => 30 + t.string "rule", :limit => 30 + end + + add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" + add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" + add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" + add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" + + create_table "works_categories", :force => true do |t| + t.string "category" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "zip_packs", :force => true do |t| + t.integer "user_id" + t.integer "homework_id" + t.string "file_digest" + t.string "file_path" + t.integer "pack_times", :default => 1 + t.integer "pack_size", :default => 0 + t.text "file_digests" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + +end diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 05871eb41..88db4eeb5 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -12,9 +12,9 @@
-
{{act.description|safeHtml}}
- 迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
- 缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
+
+ 迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
+ 缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
点击展开
@@ -22,7 +22,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
@@ -63,9 +63,9 @@
-

+
- 点击展开 + 点击展开 {{act.latest_update}}
@@ -104,8 +104,9 @@
-
{{act.description|safeHtml}}
- 状态:{{act.issue_detail.issue_status}} 优先级:{{act.issue_detail.issue_priority}}
指派给:{{act.issue_detail.issue_assigned_to}} 完成度:{{act.issue_detail.done_ratio}}%
+
+ 状态:{{act.issue_detail.issue_status}} 优先级:{{act.issue_detail.issue_priority}}
+ 指派给:{{act.issue_detail.issue_assigned_to}} 完成度:{{act.issue_detail.done_ratio}}%
点击展开
diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index d2eebb0b8..eb97a8360 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -20,6 +20,7 @@ + diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 6f7449754..dcac4d64d 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -1,90 +1,46 @@ - - - - 作业详情 - - - - - - - - - - -
- - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index eb56cf558..791db4e49 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -20,7 +20,6 @@
({{issue.issue_praise_count}})
-
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 759224d14..1ab4301e3 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,12 +1,12 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); -var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var apiUrl = 'http://localhost:3000/api/v1/'; +var debug = true; //调试标志,如果在本地请置为true app.factory('auth', function($http,$routeParams, $cookies){ var _openid = ''; if(debug===true){ - _openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; + _openid = "2"; } var getOpenId = function(cb) { @@ -74,7 +74,6 @@ app.controller('ActivityController',function($scope, $http, auth){ }); $scope.loadActData = loadActData; - }); app.controller('IssueController', function($scope, $http, $routeParams, auth){ @@ -119,8 +118,94 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth){ }, function errorCallback(response) { }); } +}); + +app.controller('IssueController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "issues/"+id, + }).then(function successCallback(response) { + console.log(response.data); + $scope.issue = response.data.data; + + }, function errorCallback(response) { + }); + } + + loadData($routeParams.id); + $scope.addIssueReply = function(data){ + console.log(data.comment); + + if(!data.comment || data.comment.length<=0){ + return; + } + + var userInfo = { + type: "Issue", + content: data.comment, + openid: auth.openid(), + }; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+$routeParams.id, + data: userInfo, + }).then(function successCallback(response) { + alert("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } +}); + +app.controller('HomeworkController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "whomeworks/"+id, + }).then(function successCallback(response) { + console.log(response.data); + $scope.homework = response.data.data; + + }, function errorCallback(response) { + }); + } + + loadData($routeParams.id); + + + $scope.addIssueReply = function(data){ + console.log(data.comment); + + if(!data.comment || data.comment.length<=0){ + return; + } + + var userInfo = { + type: "HomeworkCommon", + content: data.comment, + openid: auth.openid(), + }; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+$routeParams.id, + data: userInfo, + }).then(function successCallback(response) { + alert("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } }); app.filter('safeHtml', function ($sce) { @@ -139,6 +224,10 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'issue_detail.html', controller: 'IssueController' }) + .when('/homework/:id', { + templateUrl: 'homework_detail.html', + controller: 'HomeworkController' + }) .otherwise({ redirectTo: '/activities' }); From 6c527a9a54a70807bbcbd5b7048e906408fb5204 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 6 Apr 2016 11:40:05 +0800 Subject: [PATCH 133/507] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E7=9A=84api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/new_comment.rb | 26 +------ app/api/mobile/apis/praise.rb | 40 +++++++++++ app/api/mobile/entities/jours.rb | 3 + app/helpers/api_helper.rb | 35 +++++++++ public/assets/wechat/jour_message_detail.html | 42 +++++++++++ public/assets/wechat/message_detail.html | 71 ------------------- 6 files changed, 122 insertions(+), 95 deletions(-) create mode 100644 app/api/mobile/apis/praise.rb create mode 100644 public/assets/wechat/jour_message_detail.html delete mode 100644 public/assets/wechat/message_detail.html diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 8b27803ad..f7d723090 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -24,11 +24,7 @@ module Mobile feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id]) if (feedback.errors.empty?) homework_common.update_attributes(:updated_at => Time.now) - data = homework_common.journals_for_messages.last - present :data, data, with: Mobile::Entities::Jours result = 2 - else - result = 3 end when "News" news = News.find(params[:id]) @@ -36,11 +32,7 @@ module Mobile comment.comments = params[:content] comment.author = current_user if news.comments << comment - data = comment - present :data, data, with: Mobile::Entities::Comment result = 2 - else - result = 3 end when "Message" message = Message.find(params[:id]) @@ -53,11 +45,7 @@ module Mobile reply.parent_id = params[:id] reply.subject = "RE: #{topic.subject}" if topic.children << reply - data = reply - present :data, data, with: Mobile::Entities::Message result = 2 - else - result = 3 end when "JournalsForMessage" jour = JournalsForMessage.find params[:id] @@ -77,8 +65,6 @@ module Mobile if jfm.errors.empty? (JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now) result = 2 - else - result = 3 end when 'Issue' issue = Issue.find params[:id] @@ -86,13 +72,8 @@ module Mobile is_jour.user_id = current_user.id is_jour.notes = params[:content] is_jour.journalized = issue - #is_jour.journalized_type = "Issue" if is_jour.save - data = is_jour - present :data, data, with: Mobile::Entities::Journal result = 2 - else - result = 3 end when 'BlogComment' blog = BlogComment.find(params[:id]).root @@ -101,11 +82,8 @@ module Mobile blogComment.blog = blog.blog blogComment.content = params[:content] blogComment.title = "RE: #{blog.title}" - blog.children << blogComment - if blog.save + if blog.children << blogComment result = 2 - else - result = 3 end end if result == 2 @@ -116,7 +94,7 @@ module Mobile update_principal_activity_api(type,params[:id]) end else - result = 4 + result = 3 end present :result, result present :status, 0 diff --git a/app/api/mobile/apis/praise.rb b/app/api/mobile/apis/praise.rb new file mode 100644 index 000000000..3ba6e5eb7 --- /dev/null +++ b/app/api/mobile/apis/praise.rb @@ -0,0 +1,40 @@ +#coding=utf-8 + +module Mobile + module Apis + class Praise< Grape::API + include ApiHelper + resources :praise do + desc "praise an activity" + + params do + requires :type, type: String + requires :openid, type: String + end + post ':id' do + obj_id = params[:id] + obj_type = params[:type] + user = UserWechat.find_by_openid(params[:openid]).user + obj = find_object_by_type_and_id(obj_id,obj_type) + pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id) + if pts.empty? + praise_or_cancel(obj_type,obj_id,user,1) + num = get_activity_praise_num(obj) + else + pts.delete if !pts.nil? + #再更新praise_tread_cache表 使相应的记录减1 当为0时删除 + ptc = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first + ptc.praise_minus(1) if !ptc.nil? + if ptc.praise_num == 0 + ptc.delete + end + num = get_activity_praise_num(obj) + end + + present :data, num + present :status, 0 + end + end + end + end +end \ No newline at end of file diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index e3ce04cf6..9d4d85f7a 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -19,6 +19,8 @@ module Mobile time_from_now f.created_on when :reply_count f.children.count + when :message_praise_count + get_activity_praise_num(f) end end end @@ -35,6 +37,7 @@ module Mobile jours_expose :m_reply_id jours_expose :m_parent_id jours_expose :reply_count + jours_expose :message_praise_count expose :course,using:Mobile::Entities::Course do |f,opt| if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course" f.course diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index 1955b78c0..28a8f74e4 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -450,4 +450,39 @@ module ApiHelper principal_activity.save end end + + #赞/取消赞 + def praise_or_cancel(type,id,user,flag) + unless id.nil? and type.nil? + #首先创建或更新praise_tread 表 + pt = PraiseTread.new + pt.user_id = user.id + pt.praise_tread_object_id = id.to_i + pt.praise_tread_object_type = type + pt.praise_or_tread = flag + pt.save + # end + + #再创建或更新praise_tread_cache表 + #@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type) + ptc = PraiseTreadCache.where("object_id = ? and object_type = ?",id.to_i,type).first + ptc = ptc.nil? ? PraiseTreadCache.new : ptc + ptc.object_id = id.to_i + ptc.object_type = type + ptc.save + ptc.praise_plus(flag,1) + end + end + + def praise_plus(flag,num) + case flag + when 1 + self.update_attribute(:praise_num, self.praise_num.to_i + num) + end + end + + def praise_minus(num) + self.update_attribute(:praise_num, self.praise_num.to_i - num) + end + end \ No newline at end of file diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html new file mode 100644 index 000000000..e0ef85ecd --- /dev/null +++ b/public/assets/wechat/jour_message_detail.html @@ -0,0 +1,42 @@ + +
+
+
+
+ + +
+
+
{{message.notes}}
+
+
+
+
+
回复 ({{message.reply_count}})
+
({{message.message_praise_count}})
+
+
+ +
+
+
+
+ +
+
{{journal.lasted_comment}}
+
回复
+
+
+
+
+
+
+
+ + + +
+
+
+
+
\ No newline at end of file diff --git a/public/assets/wechat/message_detail.html b/public/assets/wechat/message_detail.html deleted file mode 100644 index 3709f65cf..000000000 --- a/public/assets/wechat/message_detail.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - 留言 - - - - - - - - - - -
- - - - - - - - - - - - - - \ No newline at end of file From c9687a8764b4490c73b97043e26b87bb1e6a7dbc Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 6 Apr 2016 14:44:35 +0800 Subject: [PATCH 134/507] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 2 +- public/assets/wechat/course_discussion.html | 44 +--------- public/assets/wechat/course_notice.html | 77 ++++------------- public/javascripts/wechat/app.js | 92 +++++++++++---------- 4 files changed, 65 insertions(+), 150 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 88db4eeb5..63c9c0833 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -47,7 +47,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index d5572b9f8..33bcf9471 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -1,24 +1,5 @@ - - - - 课程问答区 - - - - - - - - - - -
- - - - - - - - - - - - - - \ No newline at end of file +
\ No newline at end of file diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 33ea6fe4b..2e8caf15a 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -1,91 +1,44 @@ - - - - 课程通知 - - - - - - - - - - -
- - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 1ab4301e3..b465dfcf6 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -120,50 +120,6 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth){ } }); -app.controller('IssueController', function($scope, $http, $routeParams, auth){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - $http({ - method: 'GET', - url: apiUrl+ "issues/"+id, - }).then(function successCallback(response) { - console.log(response.data); - $scope.issue = response.data.data; - - }, function errorCallback(response) { - }); - } - - loadData($routeParams.id); - - - $scope.addIssueReply = function(data){ - console.log(data.comment); - - if(!data.comment || data.comment.length<=0){ - return; - } - - var userInfo = { - type: "Issue", - content: data.comment, - openid: auth.openid(), - }; - - $http({ - method: 'POST', - url: apiUrl+ "new_comment/"+$routeParams.id, - data: userInfo, - }).then(function successCallback(response) { - alert("提交成功"); - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }, function errorCallback(response) { - }); - } -}); - app.controller('HomeworkController', function($scope, $http, $routeParams, auth){ $scope.formData = {comment: ''}; @@ -208,6 +164,50 @@ app.controller('HomeworkController', function($scope, $http, $routeParams, auth) } }); +app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "newss/"+id, + }).then(function successCallback(response) { + console.log(response.data); + $scope.news = response.data.data; + + }, function errorCallback(response) { + }); + } + + loadData($routeParams.id); + + + $scope.addIssueReply = function(data){ + console.log(data.comment); + + if(!data.comment || data.comment.length<=0){ + return; + } + + var userInfo = { + type: "News", + content: data.comment, + openid: auth.openid(), + }; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+$routeParams.id, + data: userInfo, + }).then(function successCallback(response) { + alert("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } +}); + app.filter('safeHtml', function ($sce) { return function (input) { return $sce.trustAsHtml(input); @@ -228,6 +228,10 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'homework_detail.html', controller: 'HomeworkController' }) + .when('/course_notice/:id', { + templateUrl: 'course_notice.html', + controller: 'CourseNoticeController' + }) .otherwise({ redirectTo: '/activities' }); From 8f7c6f49b7547181d484522429ec566359b3167a Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 6 Apr 2016 14:56:09 +0800 Subject: [PATCH 135/507] =?UTF-8?q?api=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/api_helper.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index 28a8f74e4..bd7ba8751 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -412,7 +412,7 @@ module ApiHelper #课程动态的更新 def update_course_activity_api type, id - course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", type.to_s, id).first + course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", type.to_s, id.to_i).first if course_activity course_activity.updated_at = Time.now course_activity.save @@ -420,7 +420,7 @@ module ApiHelper end #首页动态更新 def update_user_activity_api type, id - user_activity = UserActivity.where("act_type=? and act_id =?", type.to_s, id).first + user_activity = UserActivity.where("act_type=? and act_id =?", type.to_s, id.to_i).first if user_activity user_activity.updated_at = Time.now user_activity.save @@ -428,7 +428,7 @@ module ApiHelper end #项目动态更新 def update_forge_activity_api type, id - forge_activity = ForgeActivity.where("forge_act_type=? and forge_act_id=?", type.to_s, id).first + forge_activity = ForgeActivity.where("forge_act_type=? and forge_act_id=?", type.to_s, id.to_i).first if forge_activity forge_activity.updated_at = Time.now forge_activity.save @@ -436,7 +436,7 @@ module ApiHelper end #组织动态更新 def update_org_activity_api type , id - org_activity = OrgActivity.where("org_act_type=? and org_act_id =?", type.to_s, id).first + org_activity = OrgActivity.where("org_act_type=? and org_act_id =?", type.to_s, id.to_i).first if org_activity org_activity.updated_at = Time.now org_activity.save @@ -444,7 +444,7 @@ module ApiHelper end #个人动态更新 def update_principal_activity_api type, id - principal_activity = PrincipalActivity.where("principal_act_type=? and principal_act_id =?", type.to_s, id).first + principal_activity = PrincipalActivity.where("principal_act_type=? and principal_act_id =?", type.to_s, id.to_i).first if principal_activity principal_activity.updated_at = Time.now principal_activity.save From 70c2c9cc9f9137b10f9d61646993f74e86384885 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 6 Apr 2016 15:19:18 +0800 Subject: [PATCH 136/507] =?UTF-8?q?=E6=8A=8Aactivities=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=AD=98=E8=B5=B7=E6=9D=A5,=E9=98=B2=E6=AD=A2=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=97=B6=E9=A1=B5=E9=9D=A2=E5=8F=98=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 84 +++++++++++++++++++------------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 5a18a2e35..09440b4bf 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,41 +1,41 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true -app.factory('auth', function($http,$routeParams, $cookies){ +app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ _openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; } - var getOpenId = function(cb) { + var getOpenId = function() { + var deferred = $q.defer(); if (typeof _openid !== 'undefined' && _openid.length > 0) { - cb(_openid); - return; + deferred.resolve(_openid); + } else { + var code = $routeParams.code; + $http({ + url: '/wechat/get_open_id', + data: {code: code}, + method: 'POST' + }).then(function successCallback(response) { + _openid = response.data.openid; + if(typeof _openid !== 'undefined' && _openid.length>0){ + if(debug !== true){ //如果是生产环境,就存到cookies中 + $cookies.put("openid", _openid); + } + } else { + if(debug!==true){//考虑从cookies中取出 + _openid = $cookies.get('openid'); + } + } + deferred.resolve(_openid); + }, function errorCallback(response) { + deferred.reject(response); + }); } - var code = $routeParams.code; - $http({ - url: '/wechat/get_open_id', - data: {code: code}, - method: 'POST' - }).then(function successCallback(response) { - _openid = response.data.openid; - if(typeof _openid !== 'undefined' && _openid.length>0){ - if(debug !== true){ //如果是生产环境,就存到cookies中 - $cookies.put("openid", _openid); - } - } else { - if(debug!==true){//考虑从cookies中取出 - _openid = $cookies.get('openid'); - } - } - - cb(_openid); - }, function errorCallback(response) { - cb(null); - }); - + return deferred.promise; }; var openid = function(){ return _openid; @@ -43,14 +43,27 @@ app.factory('auth', function($http,$routeParams, $cookies){ return {getOpenId: getOpenId, openid: openid}; }); -app.controller('ActivityController',function($scope, $http, auth){ +app.factory('rms', function(){ + var _saveStorage = {}; + var save = function(key, value){ + _saveStorage[key] = value; + }; + + var get = function(key){ + return _saveStorage[key]; + } + + return {save: save, get: get}; +}); + +app.controller('ActivityController',function($scope, $http, auth, rms){ $scope.repaceUrl = function(url){ return "http://www.trustie.net/" + url; } console.log("ActivityController load"); - $scope.activities = []; + $scope.activities = rms.get("activities") || []; $scope.page = 1; var loadActData = function(page){ @@ -61,17 +74,18 @@ app.controller('ActivityController',function($scope, $http, auth){ data: {openid: auth.openid(), page: page}, }).then(function successCallback(response) { $scope.activities = $scope.activities.concat(response.data.data); + rms.save('activities', $scope.activities); }, function errorCallback(response) { }); } - - auth.getOpenId(function(oid){ - if(!oid){ - alert("获取openid出错"); - } else { + auth.getOpenId().then( + function successCallback(response){ loadActData($scope.page); + }, function errorCallback(response) { + alert("获取openid出错:"+response); } - }); + ); + $scope.loadActData = loadActData; From 42bd2dcfc5f1c0aaa2a4d75cb82dc3dc7f91e71a Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 6 Apr 2016 15:23:48 +0800 Subject: [PATCH 137/507] Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange # Conflicts: # public/javascripts/wechat/app.js --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index f3c86e966..c0104b358 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = true; //调试标志,如果在本地请置为true +var debug = false; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; From a1a9dbd8a30a951eb39a7a12a11da1566cc490e0 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 6 Apr 2016 15:34:54 +0800 Subject: [PATCH 138/507] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 4 +- public/assets/wechat/course_discussion.html | 32 ++++--- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/project_discussion.html | 87 +++++--------------- public/javascripts/wechat/app.js | 56 ++++++++++++- 5 files changed, 93 insertions(+), 88 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 63c9c0833..895b77999 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -70,7 +70,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
@@ -148,7 +148,7 @@
-
回复 ()
+
回复 ()
赞 ()
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 33bcf9471..9f98299ee 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -3,42 +3,40 @@
-
- - +
+ +
-
+
- + {{discussion.created_on}}
-
回复 ()
-
(())
+
回复 ({{discussion.replies_count}})
+
({{discussion.message_praise_count}})
- = 0; --j){ !> -
+
-
+
- -
-
+ +
+
{{journal.lasted_comment}}
回复
-
- - - + + +
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 2e8caf15a..b8e468701 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -24,7 +24,7 @@
-
{{comments.comments}}
+
{{comments.created_on}}
回复
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 45c84c822..be9ee8328 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -1,89 +1,44 @@ - - - - 项目讨论区 - - - - - - - - - - -
- - - - - - - - - - - - - - - \ No newline at end of file +
\ No newline at end of file diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index b465dfcf6..05fc16c0a 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -6,7 +6,7 @@ app.factory('auth', function($http,$routeParams, $cookies){ var _openid = ''; if(debug===true){ - _openid = "2"; + _openid = "1"; } var getOpenId = function(cb) { @@ -177,7 +177,7 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -208,6 +208,50 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a } }); +app.controller('CourseDiscussionController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "messages/"+id, + }).then(function successCallback(response) { + console.log(response.data); + $scope.discussion = response.data.data; + + }, function errorCallback(response) { + }); + }; + + loadData($routeParams.id); + + + $scope.addIssueReply = function(data){ + console.log(data.comment); + + if(!data.comment || data.comment.length<=0){ + return; + } + + var userInfo = { + type: "Message", + content: data.comment, + openid: auth.openid(), + }; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+$routeParams.id, + data: userInfo, + }).then(function successCallback(response) { + alert("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } +}); + app.filter('safeHtml', function ($sce) { return function (input) { return $sce.trustAsHtml(input); @@ -232,6 +276,14 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'course_notice.html', controller: 'CourseNoticeController' }) + .when('/course_discussion/:id', { + templateUrl: 'course_discussion.html', + controller: 'CourseDiscussionController' + }) + .when('/project_discussion/:id', { + templateUrl: 'project_discussion.html', + controller: 'CourseDiscussionController' + }) .otherwise({ redirectTo: '/activities' }); From 2ede6e2b9d1663ceafe163e322789b129373fe7e Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 6 Apr 2016 15:43:37 +0800 Subject: [PATCH 139/507] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/blog_detail.html | 91 +++++++++------------------ 1 file changed, 31 insertions(+), 60 deletions(-) diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index dd40df5ab..d9c4f5835 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -1,73 +1,44 @@ - - - - 博客 - - - - - - - - - - -
- - - - - - - - - - - - \ No newline at end of file +
\ No newline at end of file From 20bb8c1e09d4b1c50d3713e25c8b919f4e316662 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 6 Apr 2016 16:23:21 +0800 Subject: [PATCH 140/507] =?UTF-8?q?=E7=95=99=E8=A8=80=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 4 +- public/assets/wechat/jour_message_detail.html | 2 +- public/javascripts/wechat/app.js | 96 ++++++++++++++++++- 3 files changed, 98 insertions(+), 4 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 895b77999..1ffc10941 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -184,7 +184,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
@@ -208,7 +208,7 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index e0ef85ecd..867616441 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -22,7 +22,7 @@
-
+
{{journal.lasted_comment}}
回复
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index c69b119c1..04c0cb7af 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; @@ -271,6 +271,92 @@ app.controller('CourseDiscussionController', function($scope, $http, $routeParam } }); +app.controller('JournalsController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "journal_for_messages/"+id, + }).then(function successCallback(response) { + console.log(response.data); + $scope.message = response.data.data; + }, function errorCallback(response) { + }); + }; + + loadData($routeParams.id); + + + $scope.addJournalReply = function(data){ + console.log(data.comment); + + if(!data.comment || data.comment.length<=0){ + return; + } + + var userInfo = { + type: "JournalsForMessage", + content: data.comment, + openid: auth.openid(), + }; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+$routeParams.id, + data: userInfo, + }).then(function successCallback(response) { + alert("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } +}); + +app.controller('BlogController', function($scope, $http, $routeParams, auth){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + $http({ + method: 'GET', + url: apiUrl+ "blog_comments/"+id, + }).then(function successCallback(response) { + console.log(response.data); + $scope.blog = response.data.data; + }, function errorCallback(response) { + }); + }; + + loadData($routeParams.id); + + + $scope.addBlogReply = function(data){ + console.log(data.comment); + + if(!data.comment || data.comment.length<=0){ + return; + } + + var userInfo = { + type: "BlogComment", + content: data.comment, + openid: auth.openid(), + }; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+$routeParams.id, + data: userInfo, + }).then(function successCallback(response) { + alert("提交成功"); + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }, function errorCallback(response) { + }); + } +}); + app.filter('safeHtml', function ($sce) { return function (input) { return $sce.trustAsHtml(input); @@ -303,6 +389,14 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'project_discussion.html', controller: 'CourseDiscussionController' }) + .when('/journal_for_message/:id', { + templateUrl: 'jour_message_detail.html', + controller: 'JournalsController' + }) + .when('/blog_comment/:id', { + templateUrl: 'blog_detail.html', + controller: 'BlogController' + }) .otherwise({ redirectTo: '/activities' }); From 422621759e16789a135c72c2157699f9341ecca9 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 6 Apr 2016 16:24:35 +0800 Subject: [PATCH 141/507] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E8=AF=A6=E6=83=85=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/project_discussion.html | 2 +- public/javascripts/wechat/app.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index be9ee8328..91aa983d2 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -5,7 +5,7 @@
- +
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index c69b119c1..f7c076852 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "1"; + _openid = "2"; } var getOpenId = function() { From ec47fb1949c22ff41f18b36aae81becb7ca325e8 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 6 Apr 2016 19:29:00 +0800 Subject: [PATCH 142/507] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 14 ++------ public/assets/wechat/course_discussion.html | 2 +- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/homework_detail.html | 2 +- public/assets/wechat/issue_detail.html | 5 +-- public/assets/wechat/project_discussion.html | 2 +- public/javascripts/wechat/app.js | 34 +++++++++++++++----- 7 files changed, 36 insertions(+), 25 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 1ffc10941..b22131604 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -58,7 +58,7 @@
-
+
@@ -139,17 +139,9 @@
-
回复 ({{act.reply_count}})
+
回复 ({{act.reply_count}})
赞 ({{act.activity_praise_count}})
- 点击展开 -
- -
-
-
-
回复 ()
-
赞 ()
@@ -173,7 +165,7 @@
-
+
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 9f98299ee..980474dd7 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -36,7 +36,7 @@
- +
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index b8e468701..4ad38b3da 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -36,7 +36,7 @@
- +
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index dcac4d64d..7ae41b418 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -38,7 +38,7 @@
- +
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 791db4e49..5b6590aa9 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -8,8 +8,9 @@
-
{{issue.description}}
- 状态:{{issue.issue_status}} 优先级:{{issue.issue_priority}}
指派给:{{issue.issue_assigned_to}} 完成度:{{issue.done_ratio}}%
+
+ 状态:{{issue.issue_status}} 优先级:{{issue.issue_priority}}
+ 指派给:{{issue.issue_assigned_to}} 完成度:{{issue.done_ratio}}%
{{issue.created_on}} diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 91aa983d2..e8cfba46a 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -36,7 +36,7 @@
- +
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 7fb1fc6df..23b4c9943 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -62,7 +62,7 @@ app.factory('rms', function(){ }); app.controller('ActivityController',function($scope, $http, auth, rms){ - $scope.repaceUrl = function(url){ + $scope.replaceUrl = function(url){ return "http://www.trustie.net/" + url; } @@ -93,6 +93,24 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ $scope.loadActData = loadActData; + + var descToggle = function(){ + $(".post-all-content").each(function(){ + var postHeight = $(this).height(); + if (postHeight > 90){ + $(this).parent().next().css("display","block"); + $(this).parent().next().toggle(function(){ + $(this).text("点击隐藏"); + $(this).prev().css("height",postHeight); + },function(){ + $(this).text("点击展开"); + $(this).prev().css("height",90); + }); + } + }); + } + + $scope.descToggle = descToggle; }); app.controller('IssueController', function($scope, $http, $routeParams, auth){ @@ -157,7 +175,7 @@ app.controller('HomeworkController', function($scope, $http, $routeParams, auth) loadData($routeParams.id); - $scope.addIssueReply = function(data){ + $scope.addHomeworkReply = function(data){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -201,7 +219,7 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a loadData($routeParams.id); - $scope.addIssueReply = function(data){ + $scope.addNoticeReply = function(data){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -245,7 +263,7 @@ app.controller('CourseDiscussionController', function($scope, $http, $routeParam loadData($routeParams.id); - $scope.addIssueReply = function(data){ + $scope.addDiscussionReply = function(data){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -373,6 +391,10 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'issue_detail.html', controller: 'IssueController' }) + .when('/project_discussion/:id', { + templateUrl: 'project_discussion.html', + controller: 'CourseDiscussionController' + }) .when('/homework/:id', { templateUrl: 'homework_detail.html', controller: 'HomeworkController' @@ -385,10 +407,6 @@ app.config(['$routeProvider',function ($routeProvider) { templateUrl: 'course_discussion.html', controller: 'CourseDiscussionController' }) - .when('/project_discussion/:id', { - templateUrl: 'project_discussion.html', - controller: 'CourseDiscussionController' - }) .when('/journal_for_message/:id', { templateUrl: 'jour_message_detail.html', controller: 'JournalsController' From 8e1473a484b3ebc4126fcdded70d148298b1d7ae Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 7 Apr 2016 09:26:24 +0800 Subject: [PATCH 143/507] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 2 +- app/api/mobile/entities/activity.rb | 4 + public/assets/wechat/activities.html | 27 +++-- public/assets/wechat/blog_detail.html | 2 +- public/assets/wechat/course_discussion.html | 2 +- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/homework_detail.html | 2 +- public/assets/wechat/issue_detail.html | 2 +- public/assets/wechat/jour_message_detail.html | 2 +- public/assets/wechat/project_discussion.html | 2 +- public/javascripts/wechat/app.js | 104 ++++++++++-------- 11 files changed, 87 insertions(+), 64 deletions(-) diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index c7f8509ae..8e4d69738 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -30,7 +30,7 @@ module Mobile all_count = activities.count activities = activities.limit(10).offset(page * 10) count = activities.count - present :data, activities, with: Mobile::Entities::Activity + present :data, activities, with: Mobile::Entities::Activity,user: user present :all_count, all_count present :count, count present :page, page diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 8c6b07281..945601bd6 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -130,6 +130,10 @@ module Mobile act_expose :latest_update #最新更新时间 act_expose :course_project_name #课程/项目名字 act_expose :activity_type_name #课程问答区/项目缺陷等 + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + false + end end end end \ No newline at end of file diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index b22131604..ae8fe8136 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -9,13 +9,14 @@
- +
迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
+ 点击展开 点击展开
{{act.latest_update}} @@ -36,7 +37,7 @@
- +
@@ -48,7 +49,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
+
一赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
@@ -60,12 +62,12 @@
- +
- 点击展开 + 点击展开 {{act.latest_update}}
@@ -83,7 +85,7 @@
- +
@@ -101,7 +103,7 @@
- +
@@ -115,7 +117,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
+
一赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
@@ -128,7 +131,7 @@
- +
@@ -153,7 +156,7 @@
- +
@@ -166,7 +169,7 @@
- +
@@ -189,7 +192,7 @@
- +
diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index d9c4f5835..5c1d6bf22 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -5,7 +5,7 @@
- +
{{blog.content}}
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 980474dd7..13ae823c3 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -5,7 +5,7 @@
- +
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 4ad38b3da..3881d96f1 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -5,7 +5,7 @@
- +
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 7ae41b418..072678ba1 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -5,7 +5,7 @@
- +
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 5b6590aa9..ea3fd06be 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -5,7 +5,7 @@
- +
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 867616441..857498f0a 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -3,7 +3,7 @@
- +
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index e8cfba46a..d868e0d03 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -5,7 +5,7 @@
- +
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 23b4c9943..c8edfaf84 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "2"; + _openid = "1"; } var getOpenId = function() { @@ -67,7 +67,6 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ } console.log("ActivityController load"); - $scope.activities = rms.get("activities") || []; $scope.page = 1; @@ -91,47 +90,20 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ } ); + $scope.addPraise = function(act){ + act.activity_praise_count += 1; + act.has_praise = true; + + //$http + + } $scope.loadActData = loadActData; - var descToggle = function(){ - $(".post-all-content").each(function(){ - var postHeight = $(this).height(); - if (postHeight > 90){ - $(this).parent().next().css("display","block"); - $(this).parent().next().toggle(function(){ - $(this).text("点击隐藏"); - $(this).prev().css("height",postHeight); - },function(){ - $(this).text("点击展开"); - $(this).prev().css("height",90); - }); - } - }); - } - - $scope.descToggle = descToggle; }); -app.controller('IssueController', function($scope, $http, $routeParams, auth){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - $http({ - method: 'GET', - url: apiUrl+ "issues/"+id, - }).then(function successCallback(response) { - console.log(response.data); - $scope.issue = response.data.data; - - }, function errorCallback(response) { - }); - } - - loadData($routeParams.id); - - - $scope.addIssueReply = function(data){ +app.factory('common', function($http, auth){ + var addCommonReply = function(id, type, data, cb){ console.log(data.comment); if(!data.comment || data.comment.length<=0){ @@ -139,22 +111,66 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth){ } var userInfo = { - type: "Issue", + type: type, content: data.comment, - openid: auth.openid(), + openid: auth.openid() }; $http({ method: 'POST', - url: apiUrl+ "new_comment/"+$routeParams.id, - data: userInfo, + url: apiUrl+ "new_comment/"+id, + data: userInfo }).then(function successCallback(response) { alert("提交成功"); - $scope.formData = {comment: ''}; - loadData($routeParams.id); + if(typeof cb === 'function'){ + cb(); + } + }, function errorCallback(response) { + }); + }; + + + + + var loadCommonData = function(id, type){ + return $http({ + method: 'GET', + url: apiUrl+ type + "/"+id + }) + }; + + return {addCommonReply: addCommonReply, loadCommonData: loadCommonData}; + + +}); + + + +app.controller('IssueController', function($scope, $http, $routeParams, auth, common){ + $scope.formData = {comment: ''}; + + var loadData = function(id){ + common.loadCommonData(id, 'issues').then(function successCallback(response) { + console.log(response.data); + $scope.issue = response.data.data; }, function errorCallback(response) { }); } + + loadData($routeParams.id); + + $scope.addIssueReply = function(data){ + console.log("add issue reply"); + common.addCommonReply($routeParams.id, 'Issue', data, function(){ + $scope.formData = {comment: ''}; + loadData($routeParams.id); + }); + + }; + + + + }); app.controller('HomeworkController', function($scope, $http, $routeParams, auth){ From edb18bd1b8941576e4ee1150a524f7d4cb499989 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 11:16:38 +0800 Subject: [PATCH 144/507] =?UTF-8?q?api=E6=8F=90=E4=BE=9Bhas=5Fpraise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/blog_comments.rb | 3 ++- app/api/mobile/apis/issues.rb | 3 ++- app/api/mobile/apis/journal_for_messages.rb | 3 ++- app/api/mobile/apis/messages.rb | 3 ++- app/api/mobile/apis/newss.rb | 3 ++- app/api/mobile/apis/whomeworks.rb | 3 ++- app/api/mobile/entities/activity.rb | 5 ++++- app/api/mobile/entities/blog_comment.rb | 7 +++++++ app/api/mobile/entities/issue.rb | 7 +++++++ app/api/mobile/entities/jours.rb | 7 +++++++ app/api/mobile/entities/message.rb | 7 +++++++ app/api/mobile/entities/news.rb | 9 +++++++-- app/api/mobile/entities/whomework.rb | 7 +++++++ public/assets/wechat/activities.html | 2 +- public/assets/wechat/blog_detail.html | 3 ++- public/assets/wechat/course_discussion.html | 3 ++- public/assets/wechat/course_notice.html | 3 ++- public/assets/wechat/homework_detail.html | 3 ++- public/assets/wechat/issue_detail.html | 3 ++- public/assets/wechat/jour_message_detail.html | 3 ++- public/assets/wechat/project_discussion.html | 3 ++- 21 files changed, 73 insertions(+), 17 deletions(-) diff --git a/app/api/mobile/apis/blog_comments.rb b/app/api/mobile/apis/blog_comments.rb index 01fd05c0f..5a064245a 100644 --- a/app/api/mobile/apis/blog_comments.rb +++ b/app/api/mobile/apis/blog_comments.rb @@ -7,8 +7,9 @@ module Mobile desc "get special topic" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user blog = BlogComment.find params[:id] - present :data, blog, with: Mobile::Entities::BlogComment + present :data, blog, with: Mobile::Entities::BlogComment,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb index 1815c85f3..b767bd768 100644 --- a/app/api/mobile/apis/issues.rb +++ b/app/api/mobile/apis/issues.rb @@ -8,8 +8,9 @@ module Mobile desc "get special issuse" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user issue = Issue.find params[:id] - present :data, issue, with: Mobile::Entities::Issue + present :data, issue, with: Mobile::Entities::Issue,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb index 648924912..15a571a82 100644 --- a/app/api/mobile/apis/journal_for_messages.rb +++ b/app/api/mobile/apis/journal_for_messages.rb @@ -7,8 +7,9 @@ module Mobile desc "get special journal" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user jour = JournalsForMessage.find params[:id] - present :data, jour, with: Mobile::Entities::Jours + present :data, jour, with: Mobile::Entities::Jours,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb index 5e2fb05b7..ae2f9a39c 100644 --- a/app/api/mobile/apis/messages.rb +++ b/app/api/mobile/apis/messages.rb @@ -7,8 +7,9 @@ module Mobile desc "get special topic" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user message = Message.find params[:id] - present :data, message, with: Mobile::Entities::Message + present :data, message, with: Mobile::Entities::Message,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb index 6f15ae2ee..8bdd460cc 100644 --- a/app/api/mobile/apis/newss.rb +++ b/app/api/mobile/apis/newss.rb @@ -7,8 +7,9 @@ module Mobile desc "get special news" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user news = News.find params[:id] - present :data, news, with: Mobile::Entities::News + present :data, news, with: Mobile::Entities::News,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb index 39a6faa68..a88d509a3 100644 --- a/app/api/mobile/apis/whomeworks.rb +++ b/app/api/mobile/apis/whomeworks.rb @@ -7,8 +7,9 @@ module Mobile desc "get one homework" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user homework = HomeworkCommon.find params[:id] - present :data, homework, with: Mobile::Entities::Whomework + present :data, homework, with: Mobile::Entities::Whomework,user: user present :status, 0 end end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 945601bd6..59127dedd 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -131,8 +131,11 @@ module Mobile act_expose :course_project_name #课程/项目名字 act_expose :activity_type_name #课程问答区/项目缺陷等 expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false current_user = options[:user] - false + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.act_id,instance.act_type.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise end end end diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index ac3fc3d9e..6961823d0 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -45,6 +45,13 @@ module Mobile c.children end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index d0bb0fa0d..e64248353 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -49,6 +49,13 @@ module Mobile f.journals.where("notes is not null and notes != ''") end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 9d4d85f7a..87bbd0184 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -51,6 +51,13 @@ module Mobile f.children end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index d182e5965..7a00b5725 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -52,6 +52,13 @@ module Mobile c.children end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index d1ec9c5c3..85504a280 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -73,8 +73,13 @@ module Mobile f.send(:comments) end end - - + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index b24c50aa2..76b88ec6f 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -67,6 +67,13 @@ module Mobile f.journals_for_messages end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index ae8fe8136..e63bcf642 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -117,7 +117,7 @@
回复 ({{act.reply_count}})
-
一赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
赞 ({{act.activity_praise_count}})
diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 5c1d6bf22..f678c8159 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -16,7 +16,8 @@
回复 ({{blog.comments_count}})
-
({{blog.blog_praise_count}})
+
已赞 ({{blog.blog_praise_count}})
+
赞 ({{blog.blog_praise_count}})
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 13ae823c3..1e7b53f84 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -16,7 +16,8 @@
回复 ({{discussion.replies_count}})
-
({{discussion.message_praise_count}})
+
已赞 ({{discussion.message_praise_count}})
+
赞 ({{discussion.message_praise_count}})
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 3881d96f1..9ac5a402d 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -16,7 +16,8 @@
回复 ({{news.comments_count}})
-
({{news.news_praise_count}})
+
已赞 ({{news.news_praise_count}})
+
赞 ({{news.news_praise_count}})
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 072678ba1..25d75d583 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -18,7 +18,8 @@
回复 ({{homework.whomework_journal_count}})
-
({{homework.whomework_praise_count}})
+
已赞 ({{homework.whomework_praise_count}})
+
赞 ({{homework.whomework_praise_count}})
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index ea3fd06be..79afbb547 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -18,7 +18,8 @@
回复 ({{issue.journals_count}})
-
({{issue.issue_praise_count}})
+
已赞 ({{issue.issue_praise_count}})
+
赞 ({{issue.issue_praise_count}})
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 857498f0a..d866e887e 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -13,7 +13,8 @@
回复 ({{message.reply_count}})
-
({{message.message_praise_count}})
+
已赞 ({{message.message_praise_count}})
+
赞 ({{message.message_praise_count}})
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index d868e0d03..2b31df8bf 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -16,7 +16,8 @@
回复 ({{discussion.replies_count}})
-
({{discussion.message_praise_count}})
+
已赞 ({{discussion.message_praise_count}})
+
赞 ({{discussion.message_praise_count}})
From a0e95976ac5db6b0caad37d70c1718abe72d58b8 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 11:21:59 +0800 Subject: [PATCH 145/507] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E7=82=B9=E8=B5=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/blog_detail.html | 4 ++-- public/assets/wechat/course_discussion.html | 4 ++-- public/assets/wechat/course_notice.html | 4 ++-- public/assets/wechat/homework_detail.html | 4 ++-- public/assets/wechat/issue_detail.html | 4 ++-- public/assets/wechat/jour_message_detail.html | 4 ++-- public/assets/wechat/project_discussion.html | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index f678c8159..1fc92eabb 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -16,8 +16,8 @@
回复 ({{blog.comments_count}})
-
已赞 ({{blog.blog_praise_count}})
-
赞 ({{blog.blog_praise_count}})
+
已赞 ({{blog.blog_praise_count}})
+
赞 ({{blog.blog_praise_count}})
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 1e7b53f84..2c2c210a9 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -16,8 +16,8 @@
回复 ({{discussion.replies_count}})
-
已赞 ({{discussion.message_praise_count}})
-
赞 ({{discussion.message_praise_count}})
+
已赞 ({{discussion.message_praise_count}})
+
赞 ({{discussion.message_praise_count}})
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 9ac5a402d..eccd91848 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -16,8 +16,8 @@
回复 ({{news.comments_count}})
-
已赞 ({{news.news_praise_count}})
-
赞 ({{news.news_praise_count}})
+
已赞 ({{news.news_praise_count}})
+
赞 ({{news.news_praise_count}})
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 25d75d583..98992da59 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -18,8 +18,8 @@
回复 ({{homework.whomework_journal_count}})
-
已赞 ({{homework.whomework_praise_count}})
-
赞 ({{homework.whomework_praise_count}})
+
已赞 ({{homework.whomework_praise_count}})
+
赞 ({{homework.whomework_praise_count}})
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 79afbb547..0fb443e67 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -18,8 +18,8 @@
回复 ({{issue.journals_count}})
-
已赞 ({{issue.issue_praise_count}})
-
赞 ({{issue.issue_praise_count}})
+
已赞 ({{issue.issue_praise_count}})
+
赞 ({{issue.issue_praise_count}})
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index d866e887e..893d693c8 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -13,8 +13,8 @@
回复 ({{message.reply_count}})
-
已赞 ({{message.message_praise_count}})
-
赞 ({{message.message_praise_count}})
+
已赞 ({{message.message_praise_count}})
+
赞 ({{message.message_praise_count}})
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 2b31df8bf..62d6dc728 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -16,8 +16,8 @@
回复 ({{discussion.replies_count}})
-
已赞 ({{discussion.message_praise_count}})
-
赞 ({{discussion.message_praise_count}})
+
已赞 ({{discussion.message_praise_count}})
+
赞 ({{discussion.message_praise_count}})
From 79dcd48d8cbf1fb4020eeda7ec082104e22b09d8 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 7 Apr 2016 11:22:22 +0800 Subject: [PATCH 146/507] =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index c0104b358..4368adbdf 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -15,7 +15,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var getOpenId = function() { var deferred = $q.defer(); - if (typeof _openid !== 'undefined' && _openid.length > 0) { + if (typeof _openid !== 'undefined' && _openid.length > 0){ deferred.resolve(_openid); } else { var code = $routeParams.code; From 6d8ffabb39f450ac35b1e0e846f07932d64a7b56 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 7 Apr 2016 11:40:20 +0800 Subject: [PATCH 147/507] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 2 +- public/javascripts/wechat/app.js | 166 +++++---------------------- 2 files changed, 28 insertions(+), 140 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index ae8fe8136..e63bcf642 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -117,7 +117,7 @@
回复 ({{act.reply_count}})
-
一赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
赞 ({{act.activity_praise_count}})
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index c8edfaf84..9204d169b 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "1"; + _openid = "2"; } var getOpenId = function() { @@ -135,7 +135,7 @@ app.factory('common', function($http, auth){ var loadCommonData = function(id, type){ return $http({ method: 'GET', - url: apiUrl+ type + "/"+id + url: apiUrl+ type + "/" + id }) }; @@ -155,238 +155,126 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth, co $scope.issue = response.data.data; }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); $scope.addIssueReply = function(data){ - console.log("add issue reply"); + console.log(data.comment); common.addCommonReply($routeParams.id, 'Issue', data, function(){ $scope.formData = {comment: ''}; loadData($routeParams.id); }); }; - - - - }); -app.controller('HomeworkController', function($scope, $http, $routeParams, auth){ +app.controller('HomeworkController', function($scope, $http, $routeParams, auth, common){ $scope.formData = {comment: ''}; var loadData = function(id){ - $http({ - method: 'GET', - url: apiUrl+ "whomeworks/"+id, - }).then(function successCallback(response) { + common.loadCommonData(id, 'whomeworks').then(function successCallback(response) { console.log(response.data); $scope.homework = response.data.data; - }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); - $scope.addHomeworkReply = function(data){ console.log(data.comment); - - if(!data.comment || data.comment.length<=0){ - return; - } - - var userInfo = { - type: "HomeworkCommon", - content: data.comment, - openid: auth.openid(), - }; - - $http({ - method: 'POST', - url: apiUrl+ "new_comment/"+$routeParams.id, - data: userInfo, - }).then(function successCallback(response) { - alert("提交成功"); + common.addCommonReply($routeParams.id, 'HomeworkCommon', data, function(){ $scope.formData = {comment: ''}; loadData($routeParams.id); - }, function errorCallback(response) { }); - } + }; }); -app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth){ +app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth, common){ $scope.formData = {comment: ''}; var loadData = function(id){ - $http({ - method: 'GET', - url: apiUrl+ "newss/"+id, - }).then(function successCallback(response) { + common.loadCommonData(id, 'newss').then(function successCallback(response) { console.log(response.data); $scope.news = response.data.data; - }, function errorCallback(response) { }); - }; + } loadData($routeParams.id); - $scope.addNoticeReply = function(data){ console.log(data.comment); - - if(!data.comment || data.comment.length<=0){ - return; - } - - var userInfo = { - type: "News", - content: data.comment, - openid: auth.openid(), - }; - - $http({ - method: 'POST', - url: apiUrl+ "new_comment/"+$routeParams.id, - data: userInfo, - }).then(function successCallback(response) { - alert("提交成功"); + common.addCommonReply($routeParams.id, 'News', data, function(){ $scope.formData = {comment: ''}; loadData($routeParams.id); - }, function errorCallback(response) { }); } }); -app.controller('CourseDiscussionController', function($scope, $http, $routeParams, auth){ +app.controller('DiscussionController', function($scope, $http, $routeParams, auth, common){ $scope.formData = {comment: ''}; var loadData = function(id){ - $http({ - method: 'GET', - url: apiUrl+ "messages/"+id, - }).then(function successCallback(response) { + common.loadCommonData(id, 'messages').then(function successCallback(response) { console.log(response.data); $scope.discussion = response.data.data; - }, function errorCallback(response) { }); - }; + } loadData($routeParams.id); - $scope.addDiscussionReply = function(data){ console.log(data.comment); - - if(!data.comment || data.comment.length<=0){ - return; - } - - var userInfo = { - type: "Message", - content: data.comment, - openid: auth.openid(), - }; - - $http({ - method: 'POST', - url: apiUrl+ "new_comment/"+$routeParams.id, - data: userInfo, - }).then(function successCallback(response) { - alert("提交成功"); + common.addCommonReply($routeParams.id, 'Message', data, function(){ $scope.formData = {comment: ''}; loadData($routeParams.id); - }, function errorCallback(response) { }); } }); -app.controller('JournalsController', function($scope, $http, $routeParams, auth){ +app.controller('JournalsController', function($scope, $http, $routeParams, auth, common){ $scope.formData = {comment: ''}; var loadData = function(id){ - $http({ - method: 'GET', - url: apiUrl+ "journal_for_messages/"+id, - }).then(function successCallback(response) { + common.loadCommonData(id, 'journal_for_messages').then(function successCallback(response) { console.log(response.data); $scope.message = response.data.data; }, function errorCallback(response) { }); - }; + } loadData($routeParams.id); - $scope.addJournalReply = function(data){ console.log(data.comment); - - if(!data.comment || data.comment.length<=0){ - return; - } - - var userInfo = { - type: "JournalsForMessage", - content: data.comment, - openid: auth.openid(), - }; - - $http({ - method: 'POST', - url: apiUrl+ "new_comment/"+$routeParams.id, - data: userInfo, - }).then(function successCallback(response) { - alert("提交成功"); + common.addCommonReply($routeParams.id, 'JournalsForMessage', data, function(){ $scope.formData = {comment: ''}; loadData($routeParams.id); - }, function errorCallback(response) { }); } }); -app.controller('BlogController', function($scope, $http, $routeParams, auth){ +app.controller('BlogController', function($scope, $http, $routeParams, auth, common){ $scope.formData = {comment: ''}; var loadData = function(id){ - $http({ - method: 'GET', - url: apiUrl+ "blog_comments/"+id, - }).then(function successCallback(response) { + common.loadCommonData(id, 'blog_comments').then(function successCallback(response) { console.log(response.data); $scope.blog = response.data.data; }, function errorCallback(response) { }); - }; + } loadData($routeParams.id); - $scope.addBlogReply = function(data){ console.log(data.comment); - - if(!data.comment || data.comment.length<=0){ - return; - } - - var userInfo = { - type: "BlogComment", - content: data.comment, - openid: auth.openid(), - }; - - $http({ - method: 'POST', - url: apiUrl+ "new_comment/"+$routeParams.id, - data: userInfo, - }).then(function successCallback(response) { - alert("提交成功"); + common.addCommonReply($routeParams.id, 'BlogComment', data, function(){ $scope.formData = {comment: ''}; loadData($routeParams.id); - }, function errorCallback(response) { }); } }); @@ -409,7 +297,7 @@ app.config(['$routeProvider',function ($routeProvider) { }) .when('/project_discussion/:id', { templateUrl: 'project_discussion.html', - controller: 'CourseDiscussionController' + controller: 'DiscussionController' }) .when('/homework/:id', { templateUrl: 'homework_detail.html', @@ -421,7 +309,7 @@ app.config(['$routeProvider',function ($routeProvider) { }) .when('/course_discussion/:id', { templateUrl: 'course_discussion.html', - controller: 'CourseDiscussionController' + controller: 'DiscussionController' }) .when('/journal_for_message/:id', { templateUrl: 'jour_message_detail.html', From 99f39696d0ada73f3c13997dcd471441b67f46b6 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 7 Apr 2016 13:57:38 +0800 Subject: [PATCH 148/507] =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 5 ++-- public/javascripts/wechat/app.js | 36 ++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index ae8fe8136..2db18be26 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -16,8 +16,7 @@ 迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
- 点击展开 - 点击展开 + 点击展开
{{act.latest_update}}
@@ -110,7 +109,7 @@ 状态:{{act.issue_detail.issue_status}} 优先级:{{act.issue_detail.issue_priority}}
指派给:{{act.issue_detail.issue_assigned_to}} 完成度:{{act.issue_detail.done_ratio}}%
- 点击展开 + 点击展开
{{act.latest_update}}
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index f288a4b65..dc926574d 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -3,14 +3,14 @@ var apiUrl = 'http://wechat.trustie.net/api/v1/'; var debug = true; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'http://localhost:3000/api/v1/'; + //apiUrl = 'http://localhost:3000/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "1"; + _openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; } var getOpenId = function() { @@ -397,6 +397,38 @@ app.filter('safeHtml', function ($sce) { } }); +app.directive('textAutoHeight', function($timeout){ + return { + restrict: 'A', + scope: {}, + link: function(scope, element, attr){ + scope.text = '点击展开'; + $timeout(function(){ + var e = element.parent().children().eq(4); + var height = e[0].scrollHeight; + var offsetHeight = e[0].offsetHeight; + console.log(height); + console.log(offsetHeight); + console.log(attr); + if(height>90){ + element.css('display', 'block'); + element.on('click', function(){ + if(element.text() == "点击展开"){ + e.css("height", height+'px'); + element.text("点击隐藏"); + } else { + e.css("height", '90px'); + element.text("点击展开"); + } + + }); + } + }, false); + + } + } +}); + app.config(['$routeProvider',function ($routeProvider) { $routeProvider .when('/activities', { From 0b1b08bd3d6279f749ca8e4f82afd9507d9bc5b7 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 7 Apr 2016 14:15:19 +0800 Subject: [PATCH 149/507] =?UTF-8?q?=E7=82=B9=E8=B5=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 24 +++++++++++-------- public/assets/wechat/blog_detail.html | 2 +- public/assets/wechat/course_discussion.html | 2 +- public/assets/wechat/course_notice.html | 2 +- public/assets/wechat/homework_detail.html | 2 +- public/assets/wechat/issue_detail.html | 2 +- public/assets/wechat/jour_message_detail.html | 2 +- public/assets/wechat/project_discussion.html | 2 +- public/javascripts/wechat/app.js | 4 ++++ 9 files changed, 25 insertions(+), 17 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index e63bcf642..130898051 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -16,7 +16,6 @@ 迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
- 点击展开 点击展开
{{act.latest_update}} @@ -24,7 +23,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
@@ -49,8 +49,8 @@
回复 ({{act.reply_count}})
-
一赞 ({{act.activity_praise_count}})
-
赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
@@ -73,7 +73,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
@@ -117,8 +118,8 @@
回复 ({{act.reply_count}})
-
已赞 ({{act.activity_praise_count}})
-
赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
@@ -143,7 +144,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
@@ -180,7 +182,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
@@ -204,7 +207,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 1fc92eabb..a2cb70650 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -17,7 +17,7 @@
回复 ({{blog.comments_count}})
已赞 ({{blog.blog_praise_count}})
-
赞 ({{blog.blog_praise_count}})
+
赞 ({{blog.blog_praise_count}})
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 2c2c210a9..416cfaa22 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -17,7 +17,7 @@
回复 ({{discussion.replies_count}})
已赞 ({{discussion.message_praise_count}})
-
赞 ({{discussion.message_praise_count}})
+
赞 ({{discussion.message_praise_count}})
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index eccd91848..737728d95 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -17,7 +17,7 @@
回复 ({{news.comments_count}})
已赞 ({{news.news_praise_count}})
-
赞 ({{news.news_praise_count}})
+
赞 ({{news.news_praise_count}})
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 98992da59..5926727e1 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -19,7 +19,7 @@
回复 ({{homework.whomework_journal_count}})
已赞 ({{homework.whomework_praise_count}})
-
赞 ({{homework.whomework_praise_count}})
+
赞 ({{homework.whomework_praise_count}})
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 0fb443e67..3be9d0d21 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -19,7 +19,7 @@
回复 ({{issue.journals_count}})
已赞 ({{issue.issue_praise_count}})
-
赞 ({{issue.issue_praise_count}})
+
赞 ({{issue.issue_praise_count}})
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 893d693c8..990055b56 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -14,7 +14,7 @@
回复 ({{message.reply_count}})
已赞 ({{message.message_praise_count}})
-
赞 ({{message.message_praise_count}})
+
赞 ({{message.message_praise_count}})
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 62d6dc728..6c06b95e9 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -17,7 +17,7 @@
回复 ({{discussion.replies_count}})
已赞 ({{discussion.message_praise_count}})
-
赞 ({{discussion.message_praise_count}})
+
赞 ({{discussion.message_praise_count}})
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 9204d169b..6c8d79c48 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -97,6 +97,10 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ //$http } + $scope.decreasePraise = function(act){ + act.activity_praise_count -= 1; + act.has_praise = false; + } $scope.loadActData = loadActData; From f1783c06a211b5cd0c58ad9a8ca46b52f90a1c61 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 14:24:15 +0800 Subject: [PATCH 150/507] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BC=A0=E5=8F=82openid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 39 +++++++++++++------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 5e6234501..6061b665e 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -3,14 +3,14 @@ var apiUrl = 'http://wechat.trustie.net/api/v1/'; var debug = true; //调试标志,如果在本地请置为true if(debug===true){ - //apiUrl = 'http://localhost:3000/api/v1/'; + apiUrl = 'http://localhost:3000/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; + _openid = "1"; } var getOpenId = function() { @@ -43,7 +43,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ }; var openid = function(){ return _openid; - } + }; return {getOpenId: getOpenId, openid: openid}; }); @@ -56,7 +56,7 @@ app.factory('rms', function(){ var get = function(key){ return _saveStorage[key]; - } + }; return {save: save, get: get}; }); @@ -64,7 +64,7 @@ app.factory('rms', function(){ app.controller('ActivityController',function($scope, $http, auth, rms){ $scope.replaceUrl = function(url){ return "http://www.trustie.net/" + url; - } + }; console.log("ActivityController load"); $scope.activities = rms.get("activities") || []; @@ -75,13 +75,13 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ $http({ method: 'POST', url: apiUrl+ "activities", - data: {openid: auth.openid(), page: page}, + data: {openid: auth.openid(), page: page} }).then(function successCallback(response) { $scope.activities = $scope.activities.concat(response.data.data); rms.save('activities', $scope.activities); }, function errorCallback(response) { }); - } + }; auth.getOpenId().then( function successCallback(response){ loadActData($scope.page); @@ -96,11 +96,11 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ //$http - } + }; $scope.decreasePraise = function(act){ act.activity_praise_count -= 1; act.has_praise = false; - } + }; $scope.loadActData = loadActData; @@ -133,23 +133,16 @@ app.factory('common', function($http, auth){ }); }; - - - var loadCommonData = function(id, type){ return $http({ method: 'GET', - url: apiUrl+ type + "/" + id + url: apiUrl+ type + "/" + id+"?openid="+auth.openid() }) }; return {addCommonReply: addCommonReply, loadCommonData: loadCommonData}; - - }); - - app.controller('IssueController', function($scope, $http, $routeParams, auth, common){ $scope.formData = {comment: ''}; @@ -204,7 +197,7 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a $scope.news = response.data.data; }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -226,7 +219,7 @@ app.controller('DiscussionController', function($scope, $http, $routeParams, aut $scope.discussion = response.data.data; }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -248,7 +241,7 @@ app.controller('JournalsController', function($scope, $http, $routeParams, auth, $scope.message = response.data.data; }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -258,7 +251,7 @@ app.controller('JournalsController', function($scope, $http, $routeParams, auth, $scope.formData = {comment: ''}; loadData($routeParams.id); }); - } + }; }); app.controller('BlogController', function($scope, $http, $routeParams, auth, common){ @@ -270,7 +263,7 @@ app.controller('BlogController', function($scope, $http, $routeParams, auth, com $scope.blog = response.data.data; }, function errorCallback(response) { }); - } + }; loadData($routeParams.id); @@ -280,7 +273,7 @@ app.controller('BlogController', function($scope, $http, $routeParams, auth, com $scope.formData = {comment: ''}; loadData($routeParams.id); }); - } + }; }); app.filter('safeHtml', function ($sce) { From eb996280a6048388bcda33219506894bd4edc1a8 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 7 Apr 2016 15:07:37 +0800 Subject: [PATCH 151/507] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 58 +++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 6061b665e..0a7e80d16 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "1"; + _openid = "2"; } var getOpenId = function() { @@ -61,7 +61,7 @@ app.factory('rms', function(){ return {save: save, get: get}; }); -app.controller('ActivityController',function($scope, $http, auth, rms){ +app.controller('ActivityController',function($scope, $http, auth, rms, common){ $scope.replaceUrl = function(url){ return "http://www.trustie.net/" + url; }; @@ -90,23 +90,22 @@ app.controller('ActivityController',function($scope, $http, auth, rms){ } ); - $scope.addPraise = function(act){ - act.activity_praise_count += 1; - act.has_praise = true; - - //$http - - }; - $scope.decreasePraise = function(act){ - act.activity_praise_count -= 1; - act.has_praise = false; - }; $scope.loadActData = loadActData; + $scope.addPraise = function(act){ + console.log(act); + common.addCommonPraise(act,'activities'); + } + + $scope.decreasePraise = function(act){ + console.log(act); + common.decreaseCommonPraise(act,'activities'); + } + }); -app.factory('common', function($http, auth){ +app.factory('common', function($http, auth, $routeParams){ var addCommonReply = function(id, type, data, cb){ console.log(data.comment); @@ -140,7 +139,36 @@ app.factory('common', function($http, auth){ }) }; - return {addCommonReply: addCommonReply, loadCommonData: loadCommonData}; + var addCommonPraise = function(act, type){ + act.activity_praise_count += 1; + act.has_praise = true; + + $http({ + method: 'POST', + url: apiUrl, + data:{openid:auth.openid(),type:type,id:$routeParams.id} + }).then(function successCallback(response) { + console.log("点赞成功"); + }, function errorCallback(response) { + }); + + }; + + var decreaseCommonPraise = function(act, type){ + act.activity_praise_count -= 1; + act.has_praise = false; + + $http({ + method: 'POST', + url: apiUrl , + data:{openid:auth.openid(),type:type,id:$routeParams.id} + }).then(function successCallback(response) { + console.log("取消赞成功"); + }, function errorCallback(response) { + }); + }; + + return {addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise}; }); app.controller('IssueController', function($scope, $http, $routeParams, auth, common){ From c8e769e05b9f95634a79f2a43f222169412c3f2e Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 15:09:17 +0800 Subject: [PATCH 152/507] =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E5=80=92=E5=BA=8F?= =?UTF-8?q?=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/blog_comment.rb | 2 +- app/api/mobile/entities/issue.rb | 2 +- app/api/mobile/entities/jours.rb | 2 +- app/api/mobile/entities/message.rb | 2 +- app/api/mobile/entities/news.rb | 2 +- app/api/mobile/entities/whomework.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index 6961823d0..dad3f7a93 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -42,7 +42,7 @@ module Mobile blog_comment_expose :blog_praise_count expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| if c.is_a? (::BlogComment) - c.children + c.children.reverse end end expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index e64248353..41b9003d6 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -46,7 +46,7 @@ module Mobile issue_expose :issue_praise_count expose :issue_journals, using: Mobile::Entities::Journal do |f, opt| if f.is_a?(::Issue) - f.journals.where("notes is not null and notes != ''") + f.journals.where("notes is not null and notes != ''").reverse end end expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 87bbd0184..3d3e76e7c 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -48,7 +48,7 @@ module Mobile end expose :child_reply,using: Mobile::Entities::Jours do |f, opt| if f.is_a?(::JournalsForMessage) - f.children + f.children.reverse end end expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index 7a00b5725..fe55bc090 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -49,7 +49,7 @@ module Mobile message_expose :lasted_comment expose :message_children,using:Mobile::Entities::Message do |c,opt| if c.is_a? (::Message) - c.children + c.children.reverse end end expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index 85504a280..aab9a93b0 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -70,7 +70,7 @@ module Mobile if f.is_a?(Hash) && f.key?(:comments) f[:comments] elsif f.is_a?(::News) && f.respond_to?(:comments) - f.send(:comments) + f.comments.reverse end end expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index 76b88ec6f..4c4dd2403 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -64,7 +64,7 @@ module Mobile expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt| #f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages) if f.is_a?(::HomeworkCommon) - f.journals_for_messages + f.journals_for_messages.reverse end end expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| From 2fe32fda61556b0434f05fd11a1b96413298e7e0 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 15:17:42 +0800 Subject: [PATCH 153/507] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E7=9A=84js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/praise.rb | 2 +- public/assets/wechat/activities.html | 4 ++-- public/javascripts/wechat/app.js | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/api/mobile/apis/praise.rb b/app/api/mobile/apis/praise.rb index 3ba6e5eb7..e5577eeb3 100644 --- a/app/api/mobile/apis/praise.rb +++ b/app/api/mobile/apis/praise.rb @@ -21,7 +21,7 @@ module Mobile praise_or_cancel(obj_type,obj_id,user,1) num = get_activity_praise_num(obj) else - pts.delete if !pts.nil? + pts.delete if !pts.empty? #再更新praise_tread_cache表 使相应的记录减1 当为0时删除 ptc = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first ptc.praise_minus(1) if !ptc.nil? diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index c99c9ee09..716385537 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -118,8 +118,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 0a7e80d16..1e0e0f737 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -93,9 +93,9 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){ $scope.loadActData = loadActData; - $scope.addPraise = function(act){ - console.log(act); - common.addCommonPraise(act,'activities'); + $scope.addPraise = function(id, type){ + console.log(type); + common.addCommonPraise(id, type); } $scope.decreasePraise = function(act){ @@ -139,14 +139,14 @@ app.factory('common', function($http, auth, $routeParams){ }) }; - var addCommonPraise = function(act, type){ + var addCommonPraise = function(id, type){ act.activity_praise_count += 1; act.has_praise = true; $http({ method: 'POST', - url: apiUrl, - data:{openid:auth.openid(),type:type,id:$routeParams.id} + url: apiUrl + "praise/" +id, + data:{openid:auth.openid(),type:type} }).then(function successCallback(response) { console.log("点赞成功"); }, function errorCallback(response) { @@ -154,14 +154,14 @@ app.factory('common', function($http, auth, $routeParams){ }; - var decreaseCommonPraise = function(act, type){ + var decreaseCommonPraise = function(id, type){ act.activity_praise_count -= 1; act.has_praise = false; $http({ method: 'POST', - url: apiUrl , - data:{openid:auth.openid(),type:type,id:$routeParams.id} + url: apiUrl + "praise/" +id, + data:{openid:auth.openid(),type:type} }).then(function successCallback(response) { console.log("取消赞成功"); }, function errorCallback(response) { From 938bf48d08be3b425786409617448d9311f58abd Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 7 Apr 2016 15:26:23 +0800 Subject: [PATCH 154/507] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 4 ++-- public/javascripts/wechat/app.js | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 716385537..c99c9ee09 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -118,8 +118,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.activity_praise_count}})
+
已赞 ({{act.activity_praise_count}})
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 1e0e0f737..cfbda146e 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "2"; + _openid = "1"; } var getOpenId = function() { @@ -93,14 +93,14 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){ $scope.loadActData = loadActData; - $scope.addPraise = function(id, type){ - console.log(type); - common.addCommonPraise(id, type); + $scope.addPraise = function(act){ + console.log(act); + common.addCommonPraise(act); } $scope.decreasePraise = function(act){ console.log(act); - common.decreaseCommonPraise(act,'activities'); + common.decreaseCommonPraise(act); } }); @@ -139,14 +139,14 @@ app.factory('common', function($http, auth, $routeParams){ }) }; - var addCommonPraise = function(id, type){ + var addCommonPraise = function(act){ act.activity_praise_count += 1; act.has_praise = true; $http({ method: 'POST', - url: apiUrl + "praise/" +id, - data:{openid:auth.openid(),type:type} + url: apiUrl + "praise/" + act.act_id, + data:{openid:auth.openid(),type:act.act_type} }).then(function successCallback(response) { console.log("点赞成功"); }, function errorCallback(response) { @@ -154,14 +154,14 @@ app.factory('common', function($http, auth, $routeParams){ }; - var decreaseCommonPraise = function(id, type){ + var decreaseCommonPraise = function(act){ act.activity_praise_count -= 1; act.has_praise = false; $http({ method: 'POST', - url: apiUrl + "praise/" +id, - data:{openid:auth.openid(),type:type} + url: apiUrl + "praise/" + act.act_id, + data:{openid:auth.openid(),type:act.act_type} }).then(function successCallback(response) { console.log("取消赞成功"); }, function errorCallback(response) { From 60c8320f824f51e11f0ece75256d1e27e82fcc14 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 15:42:08 +0800 Subject: [PATCH 155/507] =?UTF-8?q?praise=20api=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 2 ++ app/api/mobile/apis/praise.rb | 2 +- public/javascripts/wechat/app.js | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 7235a447b..23014b0c1 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -15,6 +15,7 @@ module Mobile require_relative 'apis/messages' require_relative 'apis/blog_comments' require_relative 'apis/new_comment' + require_relative 'apis/praise' class API < Grape::API version 'v1', using: :path @@ -56,6 +57,7 @@ module Mobile mount Apis::Messages mount Apis::BlogComments mount Apis::NewComment + mount Apis::Praise #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? diff --git a/app/api/mobile/apis/praise.rb b/app/api/mobile/apis/praise.rb index e5577eeb3..b3bc8f466 100644 --- a/app/api/mobile/apis/praise.rb +++ b/app/api/mobile/apis/praise.rb @@ -15,7 +15,7 @@ module Mobile obj_id = params[:id] obj_type = params[:type] user = UserWechat.find_by_openid(params[:openid]).user - obj = find_object_by_type_and_id(obj_id,obj_type) + obj = PraiseTreadCache.find_object_by_type_and_id(obj_id,obj_type) pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id) if pts.empty? praise_or_cancel(obj_type,obj_id,user,1) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index cfbda146e..0d79caaed 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -148,7 +148,7 @@ app.factory('common', function($http, auth, $routeParams){ url: apiUrl + "praise/" + act.act_id, data:{openid:auth.openid(),type:act.act_type} }).then(function successCallback(response) { - console.log("点赞成功"); + console.log(response.data); }, function errorCallback(response) { }); From 139a7931ee5b374f0cd25ec2d34b20d5deb49d56 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 7 Apr 2016 16:39:04 +0800 Subject: [PATCH 156/507] =?UTF-8?q?=E7=82=B9=E8=B5=9E=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/praise.rb | 15 ++-- public/assets/wechat/activities.html | 28 +++---- public/assets/wechat/blog_detail.html | 4 +- public/assets/wechat/course_discussion.html | 4 +- public/assets/wechat/course_notice.html | 4 +- public/assets/wechat/homework_detail.html | 4 +- public/assets/wechat/issue_detail.html | 4 +- public/assets/wechat/jour_message_detail.html | 4 +- public/assets/wechat/project_discussion.html | 4 +- public/javascripts/wechat/app.js | 74 +++++++++++++++++-- 10 files changed, 103 insertions(+), 42 deletions(-) diff --git a/app/api/mobile/apis/praise.rb b/app/api/mobile/apis/praise.rb index b3bc8f466..57dbd0729 100644 --- a/app/api/mobile/apis/praise.rb +++ b/app/api/mobile/apis/praise.rb @@ -15,20 +15,21 @@ module Mobile obj_id = params[:id] obj_type = params[:type] user = UserWechat.find_by_openid(params[:openid]).user - obj = PraiseTreadCache.find_object_by_type_and_id(obj_id,obj_type) - pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id) - if pts.empty? + pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id).first + if pts.blank? praise_or_cancel(obj_type,obj_id,user,1) - num = get_activity_praise_num(obj) + obj = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first + num = get_activity_praise_num(obj) if !obj.blank? else - pts.delete if !pts.empty? + pts.destroy if !pts.blank? #再更新praise_tread_cache表 使相应的记录减1 当为0时删除 ptc = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first - ptc.praise_minus(1) if !ptc.nil? + ptc.praise_minus(1) if !ptc.blank? if ptc.praise_num == 0 ptc.delete end - num = get_activity_praise_num(obj) + obj = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first + num = !obj.blank? ? get_activity_praise_num(obj) : 0 end present :data, num diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index c99c9ee09..b3c8f1b99 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -23,8 +23,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -49,8 +49,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -73,8 +73,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -118,8 +118,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -144,8 +144,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -182,8 +182,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -207,8 +207,8 @@
回复 ({{act.reply_count}})
-
赞 ({{act.activity_praise_count}})
-
已赞 ({{act.activity_praise_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index a2cb70650..3c5c30945 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -16,8 +16,8 @@
回复 ({{blog.comments_count}})
-
已赞 ({{blog.blog_praise_count}})
-
赞 ({{blog.blog_praise_count}})
+
已赞 ({{blog.praise_count}})
+
赞 ({{blog.praise_count}})
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 416cfaa22..680e92f5d 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -16,8 +16,8 @@
回复 ({{discussion.replies_count}})
-
已赞 ({{discussion.message_praise_count}})
-
赞 ({{discussion.message_praise_count}})
+
已赞 ({{discussion.praise_count}})
+
赞 ({{discussion.praise_count}})
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 737728d95..6bc5a790c 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -16,8 +16,8 @@
回复 ({{news.comments_count}})
-
已赞 ({{news.news_praise_count}})
-
赞 ({{news.news_praise_count}})
+
已赞 ({{news.praise_count}})
+
赞 ({{news.praise_count}})
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 5926727e1..abc92f133 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -18,8 +18,8 @@
回复 ({{homework.whomework_journal_count}})
-
已赞 ({{homework.whomework_praise_count}})
-
赞 ({{homework.whomework_praise_count}})
+
已赞 ({{homework.praise_count}})
+
赞 ({{homework.praise_count}})
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 3be9d0d21..fc9591692 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -18,8 +18,8 @@
回复 ({{issue.journals_count}})
-
已赞 ({{issue.issue_praise_count}})
-
赞 ({{issue.issue_praise_count}})
+
已赞 ({{issue.praise_count}})
+
赞 ({{issue.praise_count}})
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 990055b56..cdc817941 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -13,8 +13,8 @@
回复 ({{message.reply_count}})
-
已赞 ({{message.message_praise_count}})
-
赞 ({{message.message_praise_count}})
+
已赞 ({{message.praise_count}})
+
赞 ({{message.praise_count}})
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 6c06b95e9..3fa7b0949 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -16,8 +16,8 @@
回复 ({{discussion.replies_count}})
-
已赞 ({{discussion.message_praise_count}})
-
赞 ({{discussion.message_praise_count}})
+
已赞 ({{discussion.praise_count}})
+
赞 ({{discussion.praise_count}})
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 0d79caaed..57003f9e1 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -96,12 +96,12 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){ $scope.addPraise = function(act){ console.log(act); common.addCommonPraise(act); - } + }; $scope.decreasePraise = function(act){ console.log(act); common.decreaseCommonPraise(act); - } + }; }); @@ -140,7 +140,7 @@ app.factory('common', function($http, auth, $routeParams){ }; var addCommonPraise = function(act){ - act.activity_praise_count += 1; + act.praise_count += 1; act.has_praise = true; $http({ @@ -155,7 +155,7 @@ app.factory('common', function($http, auth, $routeParams){ }; var decreaseCommonPraise = function(act){ - act.activity_praise_count -= 1; + act.praise_count -= 1; act.has_praise = false; $http({ @@ -163,7 +163,7 @@ app.factory('common', function($http, auth, $routeParams){ url: apiUrl + "praise/" + act.act_id, data:{openid:auth.openid(),type:act.act_type} }).then(function successCallback(response) { - console.log("取消赞成功"); + console.log(response.data); }, function errorCallback(response) { }); }; @@ -192,6 +192,16 @@ app.controller('IssueController', function($scope, $http, $routeParams, auth, co }); }; + + $scope.addPraise = function(act){ + console.log(act); + common.addCommonPraise(act); + }; + + $scope.decreasePraise = function(act){ + console.log(act); + common.decreaseCommonPraise(act); + }; }); app.controller('HomeworkController', function($scope, $http, $routeParams, auth, common){ @@ -214,6 +224,16 @@ app.controller('HomeworkController', function($scope, $http, $routeParams, auth, loadData($routeParams.id); }); }; + + $scope.addPraise = function(act){ + console.log(act); + common.addCommonPraise(act); + }; + + $scope.decreasePraise = function(act){ + console.log(act); + common.decreaseCommonPraise(act); + }; }); app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth, common){ @@ -235,7 +255,17 @@ app.controller('CourseNoticeController', function($scope, $http, $routeParams, a $scope.formData = {comment: ''}; loadData($routeParams.id); }); - } + }; + + $scope.addPraise = function(act){ + console.log(act); + common.addCommonPraise(act); + }; + + $scope.decreasePraise = function(act){ + console.log(act); + common.decreaseCommonPraise(act); + }; }); app.controller('DiscussionController', function($scope, $http, $routeParams, auth, common){ @@ -257,7 +287,17 @@ app.controller('DiscussionController', function($scope, $http, $routeParams, aut $scope.formData = {comment: ''}; loadData($routeParams.id); }); - } + }; + + $scope.addPraise = function(act){ + console.log(act); + common.addCommonPraise(act); + }; + + $scope.decreasePraise = function(act){ + console.log(act); + common.decreaseCommonPraise(act); + }; }); app.controller('JournalsController', function($scope, $http, $routeParams, auth, common){ @@ -280,6 +320,16 @@ app.controller('JournalsController', function($scope, $http, $routeParams, auth, loadData($routeParams.id); }); }; + + $scope.addPraise = function(act){ + console.log(act); + common.addCommonPraise(act); + }; + + $scope.decreasePraise = function(act){ + console.log(act); + common.decreaseCommonPraise(act); + }; }); app.controller('BlogController', function($scope, $http, $routeParams, auth, common){ @@ -302,6 +352,16 @@ app.controller('BlogController', function($scope, $http, $routeParams, auth, com loadData($routeParams.id); }); }; + + $scope.addPraise = function(act){ + console.log(act); + common.addCommonPraise(act); + }; + + $scope.decreasePraise = function(act){ + console.log(act); + common.decreaseCommonPraise(act); + }; }); app.filter('safeHtml', function ($sce) { From dc0bf4df30990eba6440988cc6e4b96f27e1ef84 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 16:40:21 +0800 Subject: [PATCH 157/507] =?UTF-8?q?=E4=BC=A0act=5Fid=E3=80=81act=5Ftype?= =?UTF-8?q?=E5=88=B0=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/activity.rb | 4 ++-- app/api/mobile/entities/blog_comment.rb | 12 +++++++++--- app/api/mobile/entities/issue.rb | 10 ++++++++-- app/api/mobile/entities/jours.rb | 11 +++++++++-- app/api/mobile/entities/message.rb | 10 ++++++++-- app/api/mobile/entities/news.rb | 10 ++++++++-- app/api/mobile/entities/whomework.rb | 10 ++++++++-- 7 files changed, 52 insertions(+), 15 deletions(-) diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 59127dedd..91e7d220b 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -49,7 +49,7 @@ module Mobile end when :latest_update time_from_now ac.updated_at unless ac.nil? - when :activity_praise_count + when :praise_count if ac.act_type == "HomeworkCommon" || ac.act_type == "News" || ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" || ac.act_type == "Issue" ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act) end @@ -123,7 +123,7 @@ module Mobile end end act_expose :reply_count #回复数 - act_expose :activity_praise_count #点赞数 + act_expose :praise_count #点赞数 #act_expose :user_act #某个动态 act_expose :subject #标题 act_expose :description #描述 diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index dad3f7a93..655050fdd 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -16,10 +16,14 @@ module Mobile end else case f - when :blog_praise_count + when :praise_count get_activity_praise_num(u) when :lasted_comment time_from_now(u.created_at) + when :act_type + 'BlogComment' + when :act_id + u.id end end end @@ -32,6 +36,8 @@ module Mobile c.author end end + blog_comment_expose :act_type + blog_comment_expose :act_id blog_comment_expose :blog_id blog_comment_expose :title blog_comment_expose :content @@ -39,13 +45,13 @@ module Mobile blog_comment_expose :created_at blog_comment_expose :lasted_comment blog_comment_expose :id - blog_comment_expose :blog_praise_count + blog_comment_expose :praise_count expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| if c.is_a? (::BlogComment) c.children.reverse end end - expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + expose :has_praise, if: lambda { |instance, options| options[:user] } do |instance, options| has_praise = false current_user = options[:user] obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index 41b9003d6..ef3d09450 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -26,8 +26,12 @@ module Mobile issue.journals.where("notes is not null and notes != ''").count when :project_name issue.project.name - when :issue_praise_count + when :praise_count get_activity_praise_num(issue) + when :act_type + 'Issue' + when :act_id + issue.id end end end @@ -37,13 +41,15 @@ module Mobile expose :description expose :author, using: Mobile::Entities::User expose :done_ratio + issue_expose :act_type + issue_expose :act_id issue_expose :created_on issue_expose :issue_priority issue_expose :issue_assigned_to issue_expose :issue_status issue_expose :journals_count issue_expose :project_name - issue_expose :issue_praise_count + issue_expose :praise_count expose :issue_journals, using: Mobile::Entities::Journal do |f, opt| if f.is_a?(::Issue) f.journals.where("notes is not null and notes != ''").reverse diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 3d3e76e7c..15e22174c 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -19,12 +19,19 @@ module Mobile time_from_now f.created_on when :reply_count f.children.count - when :message_praise_count + when :praise_count get_activity_praise_num(f) + when :act_type + 'JournalsForMessage' + when :act_id + f.id end end end end + + jours_expose :act_type + jours_expose :act_id jours_expose :id jours_expose :jour_type jours_expose :jour_id @@ -37,7 +44,7 @@ module Mobile jours_expose :m_reply_id jours_expose :m_parent_id jours_expose :reply_count - jours_expose :message_praise_count + jours_expose :praise_count expose :course,using:Mobile::Entities::Course do |f,opt| if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course" f.course diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index fe55bc090..912b07e62 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -24,8 +24,12 @@ module Mobile end when :lasted_comment time_from_now u.created_on - when :message_praise_count + when :praise_count get_activity_praise_num(u) + when :act_type + 'Message' + when :act_id + u.id end end end @@ -38,12 +42,14 @@ module Mobile c.author end end + message_expose :act_type + message_expose :act_id message_expose :course_project_name message_expose :board_id message_expose :subject message_expose :content message_expose :replies_count - message_expose :message_praise_count + message_expose :praise_count message_expose :created_on message_expose :id message_expose :lasted_comment diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index aab9a93b0..4f973d82e 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -18,8 +18,12 @@ module Mobile case field when :course_name get_course(f.course_id).name unless f.course_id == nil - when :news_praise_count + when :praise_count get_activity_praise_num(f) + when :act_type + 'News' + when :act_id + f.id end end elsif f.is_a?(Hash) && !f.key?(field) @@ -50,6 +54,8 @@ module Mobile end obj end + news_expose :act_type + news_expose :act_id #作者id news_expose :author_id #作者名 @@ -62,7 +68,7 @@ module Mobile news_expose :created_on #评论数量 news_expose :comments_count - news_expose :news_praise_count + news_expose :praise_count #课程名字 news_expose :course_name #评论 diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index 4c4dd2403..5101d68eb 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -24,12 +24,16 @@ module Mobile wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0) when :evaluation_end wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1) - when :whomework_praise_count + when :praise_count get_activity_praise_num(wh) when :whomework_journal_count wh.journals_for_messages.count when :course_name wh.course.name + when :act_type + 'Homework' + when :act_id + wh.id end end end @@ -54,12 +58,14 @@ module Mobile expose :anonymous_comment expose :quotes expose :is_open + whomework_expose :act_type + whomework_expose :act_id whomework_expose :course_name whomework_expose :created_at whomework_expose :absence_penalty whomework_expose :evaluation_start whomework_expose :evaluation_end - whomework_expose :whomework_praise_count + whomework_expose :praise_count whomework_expose :whomework_journal_count expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt| #f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages) From 523a623f1ba176a086fccecf3809334bd35e7482 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 16:53:37 +0800 Subject: [PATCH 158/507] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E7=82=B9=E8=B5=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/whomework.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index 5101d68eb..8985f3d60 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -31,7 +31,7 @@ module Mobile when :course_name wh.course.name when :act_type - 'Homework' + 'HomeworkCommon' when :act_id wh.id end From ae981cfb072b47681a628de994deced01c45211a Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 16:57:40 +0800 Subject: [PATCH 159/507] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=97=AE=E7=AD=94?= =?UTF-8?q?=E5=8C=BA=E6=94=B9=E6=88=90=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/activity.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 91e7d220b..ad4af39fd 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -86,7 +86,7 @@ module Mobile when "Issue" "项目缺陷" when "Message" - "项目问答区" + "项目讨论区" when "ProjectCreateInfo" "项目" end From 411a8be8b864b68639340a048a2c7c3c5d286d2e Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 7 Apr 2016 16:58:06 +0800 Subject: [PATCH 160/507] =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=B1=95=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 12 ++++++------ public/javascripts/wechat/app.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index b3c8f1b99..279cf5fbf 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -16,7 +16,7 @@ 迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
- 点击展开 + 点击展开
{{act.latest_update}}
@@ -42,7 +42,7 @@
- 点击展开 + 点击展开
{{act.latest_update}}
@@ -67,7 +67,7 @@
- 点击展开 + 点击展开 {{act.latest_update}}
@@ -137,7 +137,7 @@
- 点击展开 + 点击展开
{{act.latest_update}}
@@ -177,7 +177,7 @@

- 点击展开 + 点击展开
@@ -200,7 +200,7 @@
- 点击展开 + 点击展开
{{act.latest_update}}
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 57003f9e1..baa5a2731 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "1"; + _openid = "2"; } var getOpenId = function() { From bb71d1c3222855cf47bf4a274015d461ec00196e Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 7 Apr 2016 16:59:46 +0800 Subject: [PATCH 161/507] =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index baa5a2731..afb33eca2 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = true; //调试标志,如果在本地请置为true +var debug = false; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; From 320ed07b319c9d6963c0f2f877805dc8ef31e0d2 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 8 Apr 2016 09:55:02 +0800 Subject: [PATCH 162/507] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_org_newstyle.html.erb | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/views/layouts/base_org_newstyle.html.erb b/app/views/layouts/base_org_newstyle.html.erb index fcbbd8bfe..64da94ebf 100644 --- a/app/views/layouts/base_org_newstyle.html.erb +++ b/app/views/layouts/base_org_newstyle.html.erb @@ -62,9 +62,9 @@ From f82ad97a68d4ad9a31ec4ba794c588fa8b87b44f Mon Sep 17 00:00:00 2001 From: txz Date: Mon, 11 Apr 2016 15:11:01 +0800 Subject: [PATCH 208/507] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E6=A1=86=E5=AE=BD=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/blog_detail.html | 4 +++- public/assets/wechat/course_discussion.html | 4 +++- public/assets/wechat/course_notice.html | 4 +++- public/assets/wechat/homework_detail.html | 4 +++- public/assets/wechat/issue_detail.html | 4 +++- public/assets/wechat/jour_message_detail.html | 4 +++- public/assets/wechat/project_discussion.html | 4 +++- public/stylesheets/weui/weixin.css | 3 ++- 8 files changed, 23 insertions(+), 8 deletions(-) diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 92e03ef0c..6af2f3c3e 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -36,7 +36,9 @@
- +
+ +
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 680e92f5d..d1b708718 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -36,7 +36,9 @@
- +
+ +
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 6bc5a790c..3048d219c 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -36,7 +36,9 @@
- +
+ +
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index abc92f133..f61b963a9 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -38,7 +38,9 @@
- +
+ +
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index fc9591692..9391539f1 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -38,7 +38,9 @@
- +
+ +
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index ac0705ac3..515e2216f 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -34,7 +34,9 @@
- +
+ +
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 3fa7b0949..0619ad5bf 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -36,7 +36,9 @@
- +
+ +
diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 33e4e51ae..f587a3e50 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -59,5 +59,6 @@ a.underline {text-decoration:underline;} .post-reply-content {font-size:13px; text-align:left; word-break:break-all; word-wrap:break-word; overflow:hidden;} .post-reply-date {font-size:13px;} .post-reply-trigger {font-size:13px;} -.post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; border-radius:3px;} +.post-input-container {padding-right:2px;} +.post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; padding:0; margin:0; border-radius:3px;} .post-reply-submit {font-size:13px; padding:3px 8px; color:#fff; background-color:#269ac9; outline:none; border:none; display:inline-block;} \ No newline at end of file From 275895f80530d9be6b8f2adc92dec521111e036a Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Apr 2016 11:00:47 +0800 Subject: [PATCH 209/507] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/comment.rb | 4 +++ app/models/homework_common.rb | 40 ++--------------------- app/models/journal.rb | 40 +---------------------- app/models/journals_for_message.rb | 51 ++---------------------------- app/models/message.rb | 7 ++++ config/locales/zh.yml | 27 +++++++++++++++- config/menu.yml | 2 +- 7 files changed, 44 insertions(+), 127 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index b87203a50..59835cfc9 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -16,6 +16,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Comment < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes include ApplicationHelper has_many_kindeditor_assets :assets, :dependent => :destroy @@ -42,10 +44,12 @@ class Comment < ActiveRecord::Base if self.commented.course if self.author_id != self.commented.author_id self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false) + Wechat.api.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe end else # 项目相关 if self.author_id != self.commented.author_id self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false) + Wechat.api.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe end end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index ab687c869..c34c63f2d 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -59,6 +59,7 @@ class HomeworkCommon < ActiveRecord::Base self.course.members.each do |m| # if m.user_id != self.user_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + Wechat.api.homework_template(m.user_id, "#{l(:label_new_homework_template)}", self.course.name, self.name, self.end_time.to_s + " 23:59:59") # end end end @@ -104,44 +105,7 @@ class HomeworkCommon < ActiveRecord::Base #修改作业后发送微信模板消息 def wechat_message self.course.members.each do |member| - uw = UserWechat.where("user_id=?", member.user_id).first - unless uw.nil? - data = { - touser:uw.openid, - template_id:"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", - url:"http://www.trustie.net/", - topcolor:"#FF0000", - data:{ - first: { - value:"您的作业已被修改", - color:"#173177" - }, - keyword1:{ - value:self.course.name, - color:"#173177" - }, - keyword2:{ - value:self.name, - color:"#173177" - }, - keyword3:{ - value:self.end_time.to_s + "23:59:59", - color:"#173177" - }, - remark:{ - value:"具体内容请点击详情查看网站", - color:"#173177" - } - } - } - logger.info "start send template message: #{data}" - begin - req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) - rescue Exception => e - logger.error "[homework_common] ===> #{e}" - end - logger.info "send over. #{req}" - end + Wechat.api.homework_template(member.user_id, "#{l(:label_update_homework_template)}", self.course.name, self.name, self.end_time.to_s + " 23:59:59") end end diff --git a/app/models/journal.rb b/app/models/journal.rb index e56c8b043..95aab7f96 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -239,44 +239,6 @@ class Journal < ActiveRecord::Base #缺陷回复微信模板消息 def issue_wechat_message - uw = UserWechat.where(user_id: self.issue.author_id).first - #unless uw.nil? && self.issue.author_id != User.current.id - unless uw.nil? - data = { - touser:uw.openid, - template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", - url:"http://www.trustie.net/", - topcolor:"#FF0000", - data:{ - first: { - value:"您的缺陷有新回复了", - color:"#173177" - }, - keyword1:{ - value:self.user.try(:realname), - color:"#173177" - }, - keyword2:{ - value:format_time(self.created_on), - color:"#173177" - }, - keyword3:{ - value:self.notes.html_safe, - color:"#173177" - }, - remark:{ - value:"具体内容请点击详情查看网站", - color:"#173177" - } - } - } - logger.info "start send template message: #{data}" - begin - req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) - rescue Exception => e - logger.error "[journal] ===> #{e}" - end - logger.info "send over. #{req}" - end + Wechat.api.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index f207db8a8..c975bcaa6 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -256,7 +256,7 @@ class JournalsForMessage < ActiveRecord::Base end end if self.jour_type == 'HomeworkCommon' - journal_wechat_message '您的作业有新回复了',self.jour.user_id + Wechat.api.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe end end @@ -269,7 +269,7 @@ class JournalsForMessage < ActiveRecord::Base if self.reply_id == 0 if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour - journal_wechat_message "您有新留言了",self.jour_id + Wechat.api.comment_template self.jour_id, "#{l(:label_new_journals_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe end else # 留言回复 reply_to = User.find(self.reply_id) @@ -279,12 +279,11 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 receivers << self.parent.jour end - journal_wechat_message "您的留言有新回复了",self.reply_id + Wechat.api.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) end - end end @@ -305,48 +304,4 @@ class JournalsForMessage < ActiveRecord::Base down_course_score_num(self.jour.course_id, self.user_id, "HomeworkCommon") end end - - #微信模板消息 - def journal_wechat_message type, user_id - uw = UserWechat.where(user_id: user_id).first - #unless uw.nil? && self.reply_id != User.current.id - unless uw.nil? - data = { - touser:uw.openid, - template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", - url:"http://www.trustie.net/", - topcolor:"#FF0000", - data:{ - first: { - value:type, - color:"#173177" - }, - keyword1:{ - value:self.user.try(:realname), - color:"#173177" - }, - keyword2:{ - value:format_time(self.created_on), - color:"#173177" - }, - keyword3:{ - value:self.notes.html_safe, - color:"#173177" - }, - remark:{ - value:"具体内容请点击详情查看网站", - color:"#173177" - } - } - } - logger.info "start send template message: #{data}" - begin - req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) - rescue Exception => e - logger.error "[journal_for_message] ===> #{e}" - end - logger.info "send over. #{req}" - end - end - end diff --git a/app/models/message.rb b/app/models/message.rb index d697db236..2ff900858 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -16,6 +17,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Message < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes include UserScoreHelper include ApplicationHelper @@ -262,12 +265,14 @@ class Message < ActiveRecord::Base self.course.members.each do |m| if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + Wechat.api.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 self.course.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + Wechat.api.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe end end end @@ -276,12 +281,14 @@ class Message < ActiveRecord::Base self.project.members.each do |m| if m.user_id != self.author_id self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) + Wechat.api.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 self.project.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) + Wechat.api.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe end end end diff --git a/config/locales/zh.yml b/config/locales/zh.yml index e67ca806d..8990f2490 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2123,4 +2123,29 @@ zh: label_resource_download_times: 下载次数 label_resource_upload_author: 上传者 label_resource_belongs_course: 所属课程 - label_resource_belongs_project: 所属项目 \ No newline at end of file + label_resource_belongs_project: 所属项目 + + #微信模板消息 + label_new_homework_template: 您的课程有新作业了 + label_update_homework_template: 您的作业已被修改 + label_course_topic_template: 课程问答区有新帖子发布了 + label_topic_comment_template: 您的帖子有新回复了 + label_project_topic_template: 项目讨论区有新帖子发布了 + label_issue_comment_template: 您的缺陷有新回复了 + label_notice_comment_template: 您的课程通知有新回复了 + label_news_comment_template: 您的项目新闻有新回复了 + label_homework_comment_template: 您的作业有新回复了 + label_new_journals_template: 您有新留言了 + label_journals_comment_template: 您的留言有新回复了 + label_resource_name: 您的课程有新作业了 + label_resource_name: 您的课程有新作业了 + label_resource_name: 您的课程有新作业了 + label_resource_name: 您的课程有新作业了 + label_resource_name: 您的课程有新作业了 + label_resource_name: 您的课程有新作业了 + label_resource_name: 您的课程有新作业了 + label_resource_name: 您的课程有新作业了 + label_resource_name: 您的课程有新作业了 + label_resource_name: 您的课程有新作业了 + + diff --git a/config/menu.yml b/config/menu.yml index 34e124845..e289a8cac 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -13,7 +13,7 @@ button: - type: "view" name: "进入网站" - url: "http://www.trustie.net/" + url: "https://www.trustie.net/" - type: "view" name: "使用手册" From 3665597153895b73373e6cbd8c998c8b9015397c Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 12 Apr 2016 14:56:17 +0800 Subject: [PATCH 210/507] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=8E=92=E7=89=88=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1234567 | 1 + public/assets/wechat/activities.html | 6 ++++- public/assets/wechat/blog_detail.html | 7 +++--- public/assets/wechat/course_discussion.html | 15 ++++++++---- public/assets/wechat/course_notice.html | 15 ++++++++---- public/assets/wechat/homework_detail.html | 23 ++++++++++++------- public/assets/wechat/issue_detail.html | 21 +++++++++++------ public/assets/wechat/jour_message_detail.html | 5 ++-- public/assets/wechat/project_discussion.html | 15 ++++++++---- public/javascripts/wechat/app.js | 4 ++-- public/stylesheets/weui/weixin.css | 3 +++ 11 files changed, 75 insertions(+), 40 deletions(-) create mode 100644 1234567 diff --git a/1234567 b/1234567 new file mode 100644 index 000000000..f492d2490 --- /dev/null +++ b/1234567 @@ -0,0 +1 @@ +{"access_token":"ONE7uqb5MhyuYiOtMkzUMPJs8krCiQeBjWek_Q9glYtfCH-kkQKzv84dgxUv5VLBnb5zdKajWDyHqocvu71UwlVuVFhsXs9MwbVdCu1i4l2L5vKCkhNE5GuyO6WisXfvKOUfAEAYCI","expires_in":7200,"got_token_at":1460441290} \ No newline at end of file diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 376fdcf6a..f5eded3ee 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -9,7 +9,11 @@
- +
diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 6af2f3c3e..b3b97f047 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -3,12 +3,11 @@
-
- - +
{{blog.title}}
+
{{blog.user.realname}}发表博客
-
+
{{blog.created_at}} diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index d1b708718..9c70dfcfc 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -3,11 +3,16 @@
-
- - -
-
+
{{discussion.subject}}
+ + + + + + + +
发布者:{{discussion.user.realname}}
来   源:{{discussion.course_project_name}}  |  课程问答区
+
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 3048d219c..750543e03 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -3,11 +3,16 @@
-
- - -
-
+
{{news.title}}
+ + + + + + + +
发布者:{{news.author.realname}}
来   源:{{news.course_name}}  |  课程通知
+
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index f61b963a9..708d8b420 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -3,14 +3,21 @@
-
- - -
-
-
- 迟交扣分:{{homework.late_penalty}}分 匿评开启时间:{{homework.evaluation_start}}
- 缺评扣分:{{homework.absence_penalty}}分/作品 匿评关闭时间:{{homework.evaluation_end}} +
{{homework.name}}
+ + + + + + + +
发布者:{{homework.author.realname}}
来   源:{{homework.course_name}}  |  课程作业
+
+
+ 迟交扣分:{{homework.late_penalty}}分
+ 缺评扣分:{{homework.absence_penalty}}分/作品
+ 匿评开启时间:{{homework.evaluation_start}}
+ 匿评关闭时间:{{homework.evaluation_end}}
{{homework.publish_time}} diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 9391539f1..38f732e6f 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -3,14 +3,21 @@
-
- - -
+
{{issue.subject}}
+ + + + + + + +
发布者:{{issue.author.realname}}
来   源:{{issue.project_name}}  |  项目缺陷
-
- 状态:{{issue.issue_status}} 优先级:{{issue.issue_priority}}
- 指派给:{{issue.issue_assigned_to}} 完成度:{{issue.done_ratio}}% +
+ 状   态:{{issue.issue_status}}
+ 优先级:{{issue.issue_priority}}
+ 指派给:{{issue.issue_assigned_to}}
+ 完成度:{{issue.done_ratio}}%
{{issue.created_on}} diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 515e2216f..7ce14e4a8 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -2,9 +2,8 @@
-
- - +
{{message.user.realname}}给您留言了
+
{{message.created_on}}
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 0619ad5bf..185d06784 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -3,11 +3,16 @@
-
- - -
-
+
{{discussion.subject}}
+ + + + + + + +
发布者:{{discussion.user.realname}}
来   源:{{discussion.course_project_name}}  |  项目讨论区
+
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 4dce14c3a..ddfede164 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "oCnvgvz8R7QheXE-R9Kkr39j8Ndg"; + _openid = "1"; } var getOpenId = function() { diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index f587a3e50..3872bb649 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -33,6 +33,8 @@ a.underline {text-decoration:underline;} .hidden {overflow:hidden; white-space:nowrap; text-overflow:ellipsis;} .inline-block {display:inline-block;} .undis {display:none;} +.text-nowrap {white-space:nowrap;} +.v-top {vertical-align:top;} /*动态样式*/ .post-container {width:100%;} @@ -40,6 +42,7 @@ a.underline {text-decoration:underline;} .post-main {padding:10px; color:#9a9a9a;} .post-avatar {width:45px; height:45px; margin-right:10px;} .post-title {font-size:13px; text-align:left;} +.post-detail-info {font-size:13px; text-align:left; color:#9a9a9a;} .fl {float:left;} .fr {float:right;} .cl {clear:both; overflow:hidden;} From 2898805aa78c55ea4280b88475637f15bf04c537 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Apr 2016 15:12:40 +0800 Subject: [PATCH 211/507] =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E7=9A=84=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1234567 | 1 + app/models/blog_comment.rb | 42 +++---------------- app/models/homework_common.rb | 4 +- app/models/issue.rb | 4 ++ app/models/journals_for_message.rb | 2 +- app/models/mailer.rb | 67 +----------------------------- app/models/news.rb | 4 ++ config/locales/zh.yml | 8 ++-- 8 files changed, 22 insertions(+), 110 deletions(-) create mode 100644 1234567 diff --git a/1234567 b/1234567 new file mode 100644 index 000000000..2954ee65a --- /dev/null +++ b/1234567 @@ -0,0 +1 @@ +{"access_token":"8_uw_0k7gzuGR_jM5OHas7VXxNKScuDVYDAFT0MCXckv53f9QBUtlUxs4baMASygfA-Y45NVaeEFefOcfB8xcyBRdyZjVrEj_A7fr9qxYxWT7RCB8J4whon2_uE5np28JQVcABAFMR","expires_in":7200,"got_token_at":1460444599} \ No newline at end of file diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index cfe6fe3f3..8f618476a 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -78,44 +78,12 @@ class BlogComment < ActiveRecord::Base #博客回复微信模板消息 def blog_wechat_message - uw = UserWechat.where(user_id: self.parent.author_id).first - #unless uw.nil? && self.parent.author_id != User.current.id - unless uw.nil? - data = { - touser:uw.openid, - template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", - url:"http://www.trustie.net/", - topcolor:"#FF0000", - data:{ - first: { - value:"您的博客有新回复了", - color:"#173177" - }, - keyword1:{ - value:self.author.try(:realname), - color:"#173177" - }, - keyword2:{ - value:format_time(self.created_at), - color:"#173177" - }, - keyword3:{ - value:self.content.html_safe, - color:"#173177" - }, - remark:{ - value:"具体内容请点击详情查看网站", - color:"#173177" - } - } - } - logger.info "start send template message: #{data}" - begin - req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) - rescue Exception => e - logger.error "[blog_comment] ===> #{e}" + if self.parent_id.nil? + self.author.watcher_users.each do |watcher| + Wechat.api.message_update_template watcher.id, "#{l(:label_new_blog_template)}", self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, format_time(self.created_at) end - logger.info "send over. #{req}" + else + Wechat.api.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), self.content.html_safe end end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index c34c63f2d..2774295a1 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -59,7 +59,7 @@ class HomeworkCommon < ActiveRecord::Base self.course.members.each do |m| # if m.user_id != self.user_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) - Wechat.api.homework_template(m.user_id, "#{l(:label_new_homework_template)}", self.course.name, self.name, self.end_time.to_s + " 23:59:59") + Wechat.api.homework_template(m.user_id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") # end end end @@ -105,7 +105,7 @@ class HomeworkCommon < ActiveRecord::Base #修改作业后发送微信模板消息 def wechat_message self.course.members.each do |member| - Wechat.api.homework_template(member.user_id, "#{l(:label_update_homework_template)}", self.course.name, self.name, self.end_time.to_s + " 23:59:59") + Wechat.api.homework_template(member.user_id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 0d72407ba..45347b5ad 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -16,6 +17,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Issue < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes include Redmine::Utils::DateCalculation include UserScoreHelper @@ -156,6 +159,7 @@ class Issue < ActiveRecord::Base # 指派给自己的缺陷不提示消息 unless self.author_id == self.assigned_to_id self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) + Wechat.api.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, format_time(self.created_on) end if self.tracker_id == 5 self.project.members.each do |m| diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index c975bcaa6..ce18e1bdb 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -269,7 +269,7 @@ class JournalsForMessage < ActiveRecord::Base if self.reply_id == 0 if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour - Wechat.api.comment_template self.jour_id, "#{l(:label_new_journals_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + Wechat.api.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", self.notes.html_safe, format_time(self.created_on) end else # 留言回复 reply_to = User.find(self.reply_id) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 4b7180857..664e5cfac 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -17,8 +17,6 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Mailer < ActionMailer::Base - require 'net/http' - require 'json' layout 'mailer' helper :application helper :issues @@ -642,9 +640,6 @@ class Mailer < ActionMailer::Base mail :to => recipients, :subject => "[ #{l(:label_user_homework)} : #{homework_common.name} #{l(:label_memo_create_succ)}]", :filter => true - @homework_common.course.members.each do |member| - mail_wechat_message member.user_id, "3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", "您的课程有新作业了", @homework_common.course.name, @homework_common.name, @homework_common.end_time.to_s + " 23:59:59" - end end # Builds a Mail::Message object used to email recipients of a news' project when a news item is added. @@ -710,8 +705,6 @@ class Mailer < ActionMailer::Base mail :to => recipients, :subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}", :filter => true - - mail_wechat_message news.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的课程通知有新回复了", @author.try(:realname), format_time(comment.created_on), comment.comments.html_safe end end @@ -736,14 +729,7 @@ class Mailer < ActionMailer::Base :cc => cc, :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", :filter => true - if message.parent_id == nil - message.project.members.each do |member| - mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "项目讨论区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on) - end - else - mail_wechat_message message.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe - end - elsif message.course + elsif message.course redmine_headers 'Course' => message.course.id, 'Topic-Id' => (message.parent_id || message.id) @author = message.author @@ -758,14 +744,7 @@ class Mailer < ActionMailer::Base :cc => cc, :subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", :filter => true - if message.parent_id == nil - message.course.members.each do |member| - mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "课程问答区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on) - end - else - mail_wechat_message message.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe end - end end # Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was added. @@ -1119,48 +1098,4 @@ class Mailer < ActionMailer::Base 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } return newpass end - - #微信模板消息 - def mail_wechat_message user_id, template_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站" - uw = UserWechat.where(user_id: user_id).first - logger.info "mail_wechat_message #{user_id} #{uw}" - unless uw.nil? - data = { - touser:uw.openid, - template_id:template_id, - url:"http://www.trustie.net/", - topcolor:"#FF0000", - data:{ - first: { - value:first, - color:"#173177" - }, - keyword1:{ - value:key1, - color:"#173177" - }, - keyword2:{ - value:key2, - color:"#173177" - }, - keyword3:{ - value:key3, - color:"#173177" - }, - remark:{ - value:remark, - color:"#173177" - } - } - } - - logger.info "start send template message: #{data}" - begin - req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) - rescue Exception => e - logger.error "[mailer] ===> #{e}" - end - logger.info "send over. #{req}" - end - end end diff --git a/app/models/news.rb b/app/models/news.rb index 6746d90cd..967516e65 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -16,6 +17,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class News < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes belongs_to :project,:touch => true include ApplicationHelper @@ -167,6 +170,7 @@ class News < ActiveRecord::Base self.course.members.each do |m| if m.user_id != self.author_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + Wechat.api.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, format_time(self.created_on) end end else diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 8990f2490..4f0c6b701 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2137,10 +2137,10 @@ zh: label_homework_comment_template: 您的作业有新回复了 label_new_journals_template: 您有新留言了 label_journals_comment_template: 您的留言有新回复了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 + label_blog_comment_template: 您的博客有新回复了 + label_new_blog_template: 您的课程有新作业了 + label_new_issue_template: 您有新缺陷了 + label_new_notice_template: 您的课程有新通知了 label_resource_name: 您的课程有新作业了 label_resource_name: 您的课程有新作业了 label_resource_name: 您的课程有新作业了 From 1882cd8f4f8ab28e91efd9603fdfc856008f8b2a Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Apr 2016 15:42:59 +0800 Subject: [PATCH 212/507] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A7=93=E5=90=8D?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/user.rb | 4 +++- app/helpers/api_helper.rb | 4 ++++ public/javascripts/wechat/app.js | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/api/mobile/entities/user.rb b/app/api/mobile/entities/user.rb index 16048c61a..e33c6a845 100644 --- a/app/api/mobile/entities/user.rb +++ b/app/api/mobile/entities/user.rb @@ -24,6 +24,8 @@ module Mobile u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.brief_introduction when :student_num u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.student_id + when :realname + u.nil? ? "" : get_user_realname(u) end end end @@ -37,7 +39,7 @@ module Mobile #昵称 expose :nickname #真名 - expose :realname + user_expose :realname #性别 user_expose :gender #我的二维码 diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index bd7ba8751..274bfc552 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -27,6 +27,10 @@ module ApiHelper location end + def get_user_realname user + name = user.lastname + user.firstname + name.empty? || name.nil? ? user.login : name + end def get_assigned_homeworks(homeworks, n, index) homeworks += homeworks diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index ddfede164..713c98863 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = true; //调试标志,如果在本地请置为true +var debug = false; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "1"; + _openid = "2"; } var getOpenId = function() { From 70afbb3323db186ed1f8c5ac4c0a5eded3a2c016 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Apr 2016 15:46:56 +0800 Subject: [PATCH 213/507] =?UTF-8?q?=E5=A7=93=E5=90=8D=E7=9A=84=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E3=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/api_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index 274bfc552..49640d889 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -29,7 +29,7 @@ module ApiHelper def get_user_realname user name = user.lastname + user.firstname - name.empty? || name.nil? ? user.login : name + name.empty? || name.nil? || name == " " ? user.login : name end def get_assigned_homeworks(homeworks, n, index) From 38c182d76a28ab40a05f5d78802c6587fe398234 Mon Sep 17 00:00:00 2001 From: txz Date: Tue, 12 Apr 2016 15:51:18 +0800 Subject: [PATCH 214/507] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E8=80=85=E7=9C=9F=E5=90=8D=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=98=B5=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/homework_detail.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 708d8b420..776ecb4ce 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -6,7 +6,9 @@
{{homework.name}}
- + From 5a3b68816ae277bbdb6080e97e7f1f1d4acdad37 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Apr 2016 15:57:18 +0800 Subject: [PATCH 215/507] =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/blog_comment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index ba31cc320..359522f9a 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -81,7 +81,7 @@ class BlogComment < ActiveRecord::Base if self.parent_id.nil? self.author.watcher_users.each do |watcher| Wechat.api.message_update_template watcher.id, "#{l(:label_new_blog_template)}", self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, format_time(self.created_at) - + end else Wechat.api.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), self.content.html_safe end From a6f4b7f5055d35a694c547bab28d3025ae0df69d Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Apr 2016 16:23:52 +0800 Subject: [PATCH 216/507] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 136557634..5c60681a0 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -3,7 +3,7 @@ var apiUrl = '/api/v1/'; var debug = false; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'http://www.trustie.net/api/v1/'; + apiUrl = 'https://test.course.trustie.net/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ From 59f49f586be04c25e1b3e9897f49e192da708396 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 12 Apr 2016 16:32:53 +0800 Subject: [PATCH 217/507] =?UTF-8?q?=E4=B8=8A=E7=BA=BF=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/menu.yml b/config/menu.yml index e289a8cac..fe2159e8c 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ button: - type: "view" name: "最新动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://www.trustie.net/assets/wechat/app.html#/activities?response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.course.trustie.net/assets/wechat/app.html#/activities?response_type=code&scope=snsapi_base&state=123#wechat_redirect" - type: "click" name: "意见返馈" From f5122d7ef0cc898b6c00bd26c8afbe76a3ef3854 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 13 Apr 2016 14:52:18 +0800 Subject: [PATCH 218/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1url=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=88=B0=E6=AD=A3=E5=BC=8F=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/menu.yml | 2 +- public/javascripts/wechat/app.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/menu.yml b/config/menu.yml index fe2159e8c..d129f7aff 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ button: - type: "view" name: "最新动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.course.trustie.net/assets/wechat/app.html#/activities?response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/activities?response_type=code&scope=snsapi_base&state=123#wechat_redirect" - type: "click" name: "意见返馈" diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 5c60681a0..3970ce790 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -3,7 +3,7 @@ var apiUrl = '/api/v1/'; var debug = false; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'https://test.course.trustie.net/api/v1/'; + apiUrl = 'https://www.trustie.net/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ From f97699037b766a7cb7164c1c2f87633a351ab332 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 13 Apr 2016 16:58:44 +0800 Subject: [PATCH 219/507] =?UTF-8?q?=E5=86=B2=E7=AA=81=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/new_base_user.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index c6231de11..14c739009 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -232,10 +232,10 @@ <% if @user.projects.visible.count > 0 project_order_ids = "(" + - ForgeActivity.find_by_sql("SELECT p.project_id, p.created_at FROM - (SELECT fa.project_id, MAX(fa.created_at) AS created_at FROM forge_activities fa WHERE fa.project_id IN (" + @user.projects.visible.select('projects.id').map{|p| p.id}.join(',') + ") + ForgeActivity.find_by_sql("SELECT p.project_id, p.updated_at FROM + (SELECT fa.project_id, MAX(fa.updated_at) AS updated_at FROM forge_activities fa WHERE fa.project_id IN (" + @user.projects.visible.select('projects.id').map{|p| p.id}.join(',') + ") GROUP BY fa.project_id) AS p - ORDER BY p.created_at DESC limit 5").map {|p| p.project_id}.join(",") + ")" + ORDER BY p.updated_at DESC limit 5").map {|p| p.project_id}.join(",") + ")" projects = Project.where("projects.id in #{project_order_ids}") else projects = [] From 13576ca477ce30bbd8d5e88d5f93959fcdd8333b Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 14 Apr 2016 09:43:43 +0800 Subject: [PATCH 220/507] app.js --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 3970ce790..bedd79ed4 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "2"; + _openid = "1"; } var getOpenId = function() { From 76cfa836668f5a785d4ae0a953364d022e453da5 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 14 Apr 2016 10:47:53 +0800 Subject: [PATCH 221/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1234567 | 2 +- app/models/blog_comment.rb | 7 +- app/models/comment.rb | 5 +- app/models/homework_common.rb | 6 +- app/models/issue.rb | 3 +- app/models/journal.rb | 3 +- app/models/journals_for_message.rb | 8 +- app/models/message.rb | 9 ++- app/models/news.rb | 3 +- app/services/wechat_service.rb | 113 +++++++++++++++++++++++++++++ 10 files changed, 141 insertions(+), 18 deletions(-) create mode 100644 app/services/wechat_service.rb diff --git a/1234567 b/1234567 index 62c5e6df2..459204fe5 100644 --- a/1234567 +++ b/1234567 @@ -1 +1 @@ -{"access_token":"ONE7uqb5MhyuYiOtMkzUMPJs8krCiQeBjWek_Q9glYtfCH-kkQKzv84dgxUv5VLBnb5zdKajWDyHqocvu71UwlVuVFhsXs9MwbVdCu1i4l2L5vKCkhNE5GuyO6WisXfvKOUfAEAYCI","expires_in":7200,"got_token_at":1460441290} +{"access_token":"q51KZUeA6_-CCCH-Buy1mxFmRjcrCViHgk2mHHHqEDbjuA_pgCM1IyW1DASYvpzyB06xHiarujo3rz1Ucq3GRoXdgQ7hAoFCzkL_q3Z5vczLjwAjowAVwmulYE-cAij8ATUfADAWPQ","expires_in":7200,"got_token_at":1460601163} \ No newline at end of file diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 359522f9a..62451591f 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -77,13 +77,14 @@ class BlogComment < ActiveRecord::Base end #博客回复微信模板消息 - def blog_wechat_message + def blog_wechat_message + ws = WechatService.new if self.parent_id.nil? self.author.watcher_users.each do |watcher| - Wechat.api.message_update_template watcher.id, "#{l(:label_new_blog_template)}", self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, format_time(self.created_at) + ws.message_update_template watcher.id, "#{l(:label_new_blog_template)}", self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, format_time(self.created_at) end else - Wechat.api.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), self.content.html_safe + ws.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), self.content.html_safe end end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 59835cfc9..9a752129b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -41,15 +41,16 @@ class Comment < ActiveRecord::Base after_destroy :down_course_score def act_as_system_message + ws = WechatService.new if self.commented.course if self.author_id != self.commented.author_id self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false) - Wechat.api.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe + ws.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe end else # 项目相关 if self.author_id != self.commented.author_id self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false) - Wechat.api.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe + ws.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe end end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 2774295a1..663bd6065 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -59,7 +59,8 @@ class HomeworkCommon < ActiveRecord::Base self.course.members.each do |m| # if m.user_id != self.user_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) - Wechat.api.homework_template(m.user_id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + ws = WechatService.new + ws.homework_template(m.user_id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") # end end end @@ -105,7 +106,8 @@ class HomeworkCommon < ActiveRecord::Base #修改作业后发送微信模板消息 def wechat_message self.course.members.each do |member| - Wechat.api.homework_template(member.user_id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + ws = WechatService.new + ws.homework_template(member.user_id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 45347b5ad..5124dd54b 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -159,7 +159,8 @@ class Issue < ActiveRecord::Base # 指派给自己的缺陷不提示消息 unless self.author_id == self.assigned_to_id self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) - Wechat.api.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, format_time(self.created_on) + ws = WechatService.new + ws.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, format_time(self.created_on) end if self.tracker_id == 5 self.project.members.each do |m| diff --git a/app/models/journal.rb b/app/models/journal.rb index 95aab7f96..80d585b06 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -239,6 +239,7 @@ class Journal < ActiveRecord::Base #缺陷回复微信模板消息 def issue_wechat_message - Wechat.api.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + ws = WechatService.new + ws.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index ce18e1bdb..799af8f74 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -256,7 +256,8 @@ class JournalsForMessage < ActiveRecord::Base end end if self.jour_type == 'HomeworkCommon' - Wechat.api.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + ws = WechatService.new + ws.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe end end @@ -264,12 +265,13 @@ class JournalsForMessage < ActiveRecord::Base # 用户留言消息通知 def act_as_user_feedback_message # 主留言 + ws = WechatService.new if self.jour_type == 'Principal' receivers = [] if self.reply_id == 0 if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour - Wechat.api.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", self.notes.html_safe, format_time(self.created_on) + ws.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", self.notes.html_safe, format_time(self.created_on) end else # 留言回复 reply_to = User.find(self.reply_id) @@ -279,7 +281,7 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 receivers << self.parent.jour end - Wechat.api.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + ws.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) diff --git a/app/models/message.rb b/app/models/message.rb index 2ff900858..2f4637042 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -260,19 +260,20 @@ class Message < ActiveRecord::Base # 主贴项目成员都能收到 # 回帖:帖子的发布人收到 def act_as_system_message + ws = WechatService.new if self.course if self.parent_id.nil? # 主贴 self.course.members.each do |m| if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) - Wechat.api.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) + ws.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 self.course.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) - Wechat.api.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe + ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe end end end @@ -281,14 +282,14 @@ class Message < ActiveRecord::Base self.project.members.each do |m| if m.user_id != self.author_id self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) - Wechat.api.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) + ws.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 self.project.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) - Wechat.api.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe + ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe end end end diff --git a/app/models/news.rb b/app/models/news.rb index 967516e65..25a70095f 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -170,7 +170,8 @@ class News < ActiveRecord::Base self.course.members.each do |m| if m.user_id != self.author_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) - Wechat.api.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, format_time(self.created_on) + ws = WechatService.new + ws.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, format_time(self.created_on) end end else diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb new file mode 100644 index 000000000..e0a5feca8 --- /dev/null +++ b/app/services/wechat_service.rb @@ -0,0 +1,113 @@ +class WechatService + + def template_data(openid, template_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + data = { + touser:openid, + template_id:template_id, + url:"https://www.trustie.net/", + topcolor:"#FF0000", + data:{ + first: { + value:first, + color:"#173177" + }, + keyword1:{ + value:key1, + color:"#173177" + }, + keyword2:{ + value:key2, + color:"#173177" + }, + keyword3:{ + value:key3, + color:"#173177" + }, + remark:{ + value:remark, + color:"#173177" + } + } + } + data + end + + def homework_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = template_data uw.openid,"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI",first, key1, key2, key3, remark + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[homework] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + end + + def topic_publish_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = template_data uw.openid,"oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ",first, key1, key2, key3, remark + Rails.logger.info "start send template message: #{data}" + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[topic_publish] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + end + + def comment_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = template_data uw.openid,"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",first, key1, key2, key3, remark + Rails.logger.info "start send template message: #{data}" + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[comment] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + end + + def message_update_template(user_id, first, key1, key2, remark="具体内容请点击详情查看网站") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = { + touser:uw.openid, + template_id:"YTyNPZnQD8uZFBFq-Q6cCOWaq5LA9vL6RFlF2JuD5Cg", + url:"https://www.trustie.net/", + topcolor:"#FF0000", + data:{ + first: { + value:first, + color:"#173177" + }, + keyword1:{ + value:key1, + color:"#173177" + }, + keyword2:{ + value:key2, + color:"#173177" + }, + remark:{ + value:remark, + color:"#173177" + } + } + } + + Rails.logger.info "start send template message: #{data}" + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[message_update] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + end +end \ No newline at end of file From d33f839b955a4750d269821b2391510fa741127e Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 14 Apr 2016 10:57:37 +0800 Subject: [PATCH 222/507] =?UTF-8?q?=E4=B8=AD=E6=96=87=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/wechat_service.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb index e0a5feca8..ae097ad4a 100644 --- a/app/services/wechat_service.rb +++ b/app/services/wechat_service.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 class WechatService def template_data(openid, template_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") From a8dce5e520bf0d7a404e0cf9d89bbc3778cd29cc Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 14 Apr 2016 11:29:22 +0800 Subject: [PATCH 223/507] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9F=A5=E9=87=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=8A=A0,=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=95=8C=E9=9D=A2=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=88=97=E8=A1=A8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 10 + app/controllers/courses_controller.rb | 61 ++ app/controllers/student_work_controller.rb | 121 ++- app/models/homework_common.rb | 2 +- app/models/student_work.rb | 2 +- app/views/admin/code_work_tests.html.erb | 96 +++ .../courses/_compare_code_tips_1.html.erb | 101 +++ .../courses/_compare_code_tips_2.html.erb | 22 + app/views/courses/_show_compare_code.html.erb | 16 + app/views/courses/code_repeat.html.erb | 79 ++ app/views/courses/show_comparecode.js.erb | 101 +++ .../student_work/_evaluation_work.html.erb | 6 +- .../_programing_work_show.html.erb | 13 +- .../student_work/_student_work_list.html.erb | 146 ++++ .../student_work/show_allwork_test.html.erb | 2 + .../users/new_user_commit_homework.html.erb | 23 +- app/views/users/user_commit_homework.html.erb | 22 +- config/locales/zh.yml | 5 +- config/routes.rb | 6 +- ...20160330094039_add_simi_id_to_homeworks.rb | 6 + ...95711_add_simi_time_to_homework_commons.rb | 5 + db/schema.rb | 5 +- lib/redmine.rb | 1 + public/assets/codemirror/merge.css | 113 +++ public/assets/codemirror/merge.js | 774 ++++++++++++++++++ public/javascripts/course.js | 5 +- public/javascripts/homework.js | 3 +- public/stylesheets/application.css | 23 + public/stylesheets/courses.css | 11 + 29 files changed, 1737 insertions(+), 43 deletions(-) create mode 100644 app/views/admin/code_work_tests.html.erb create mode 100644 app/views/courses/_compare_code_tips_1.html.erb create mode 100644 app/views/courses/_compare_code_tips_2.html.erb create mode 100644 app/views/courses/_show_compare_code.html.erb create mode 100644 app/views/courses/code_repeat.html.erb create mode 100644 app/views/courses/show_comparecode.js.erb create mode 100644 app/views/student_work/show_allwork_test.html.erb create mode 100644 db/migrate/20160330094039_add_simi_id_to_homeworks.rb create mode 100644 db/migrate/20160330095711_add_simi_time_to_homework_commons.rb create mode 100644 public/assets/codemirror/merge.css create mode 100644 public/assets/codemirror/merge.js diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index c7aa42b9e..8009feac1 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -556,4 +556,14 @@ class AdminController < ApplicationController end end + #代码测试列表 + def code_work_tests + @code_work_tests = StudentWorkTest.find_by_sql("select a.* ,b.id as homeworkid,d.language from student_work_tests as a , homework_commons as b ,student_works as c, homework_detail_programings as d where a.student_work_id = c.id and b.id = c.homework_common_id and c.homework_common_id = d.homework_common_id order by a.created_at desc") + #@code_work_tests = StudentWorkTest.order('created_at desc') + @code_work_tests = paginateHelper @code_work_tests,30 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end + end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 515b94392..942b3b2d2 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -885,6 +885,7 @@ class CoursesController < ApplicationController @course_activities = course_activities.order('updated_at desc').limit(10).offset(@page * 10) end @type = params[:type] + respond_to do |format| format.js format.html{render :layout => 'base_courses'} @@ -925,6 +926,66 @@ class CoursesController < ApplicationController end end + def search_homework_member homeworks,name + if name == "" + select_homework = homeworks + else + name = name.downcase + select_homework = homeworks.select{ |homework| + homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name) + } + end + select_homework + end + + # 作业查重 + def code_repeat + #代码查重新加的 + @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group] + + @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? + @homework = HomeworkCommon.find params[:homework] + #order("#{@order} #{@b_sort}" + @student_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("simi_value desc"),@name + + @works_hash = {} + + @student_works.each do |tmpwork| + @works_hash[tmpwork.id] = tmpwork + end + + #respond_to do |format| + #format.html {render :layout => 'base_courses'} + #end + end + + def show_comparecode + + src_id = params[:src_id] + dst_id = params[:dst_id] + + src_work = StudentWork.where("id =?", src_id).first + + @homework = HomeworkCommon.find params[:homework_id] + + @src_code = src_work.description + src_user = User.where("id =?", src_work.user_id).first + + @src_username = src_user.try(:realname) != " " ? src_user.lastname + src_user.firstname : src_user.try(:login) + + #descriotion user name + + dst_work = StudentWork.where("id =?", dst_id).first + @dst_code = dst_work.description + dst_user = User.where("id =?", dst_work.user_id).first + + @dst_username = dst_user.try(:realname) != " " ? dst_user.lastname + dst_user.firstname : dst_user.try(:login) + + respond_to do |format| + format.js + end + end + #根据已有课程复制课程 #param id:已有课程ID def copy_course diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 32867090c..ae78bf920 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -5,7 +5,7 @@ class StudentWorkController < ApplicationController include ApplicationHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:code_repeattest,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] @@ -81,6 +81,8 @@ class StudentWorkController < ApplicationController #根据传入的tIndex确定是第几次测试 #之后如果觉得很卡 可以改成将结果传回JS再以参数形式传回来 def program_test_ex + tStarttime = Time.now + is_test = params[:is_test] == 'true' resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T'),tseq:1,tcount:1,testid:1} #保存每测试一次返回的结果 @@ -134,6 +136,16 @@ class StudentWorkController < ApplicationController end #每次从数据库取出上次的结果加上本次的结果再存入数据库 + tEndtime = Time.now + tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 + + if result["status"].to_i != -2 + result["results"].first['user_wait'] = tUsedtime + end + + if result["results"][0]["status"].to_i == 2 + result["status"] = 2 + end status = result["status"] if index == 1 student_work_test = student_work.student_work_tests.build(status: status, @@ -162,6 +174,11 @@ class StudentWorkController < ApplicationController resultObj[:index] = student_work.student_work_tests.count end + tEndtime = Time.now + tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 + + logger.debug "program_test_ex user wait time = #{tUsedtime} 毫秒" + #渲染返回结果 render :json => resultObj end @@ -169,6 +186,106 @@ class StudentWorkController < ApplicationController end end + #找出该作业的所有提交作业 + def find_all_student_work_by_homeid() + all_studentwork = StudentWork.where("homework_common_id =?", @homework.id) + + all_studentwork + end + + def request_code_repeattest(src) + url = "#{Redmine::Configuration['jplag_server']}api/realtime_test.json" + + factor = [] + src.each do |test| + factor << {work_id: test.id, des: test.description,created_at:test.created_at.to_i} + end + + solutions = { + homeid:@homework.id, + language:@homework.homework_detail_programing.language, + factor: factor + } + uri = URI(url) + body = solutions.to_json + + logger.debug "send body" + logger.debug body + + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + + JSON.parse(res.body) + end + + #代码查重 status: 0完成 -2不需要查重 -1查重失败不支持该语言 + def code_repeattest + tStarttime = Time.now + logger.debug "code_repeattest start is #{tStarttime}}" + resultObj = {status: -2} + + @homework = HomeworkCommon.find params[:homework] + + all_studentwork = find_all_student_work_by_homeid() + + if all_studentwork == nil + resultObj[:status] = -2 + elsif all_studentwork.count <= 1 + resultObj[:status] = -2 + else + + #@homework.homework_detail_programing.language、id、description + logger.debug "time1 is #{Time.now.usec} " + result = request_code_repeattest(all_studentwork) + logger.debug "time2 is #{Time.now.usec} " + + resultObj[:status] = result['status'].to_i + # resultObj[:results] = result['results'] + + #Time.now, simi_id = simiworkid , simi_value = simivalue + if resultObj[:status] == 0 + @homework.simi_time = Time.now + resultObj[:comparetime] = @homework.simi_time + @homework.update_column('simi_time', @homework.simi_time) + + logger.debug "time3 is #{Time.now.usec} " + result['results'].each do |key,value| + if value['simiworkid'].to_i > 0 + @student_work = StudentWork.where("id =?", key.to_i).first + @student_work.update_column('simi_id', value['simiworkid'].to_i) + @student_work.update_column('simi_value', value['simivalue'].to_i) + end + # sqlstr = "update student_works set simi_id=#{value['simiworkid']},simi_value=#{value['simivalue']} where id=#{key.to_i} " + # dbh.execute(sqlstr) + + end + logger.debug "time4 is #{Time.now.usec} " + end + end + tEndtime = Time.now + logger.debug "code_repeattest end is #{tEndtime}}" + tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000000+(tEndtime.usec - tStarttime.usec) + logger.debug "code_repeattest userd utime is #{tUsedtime}" + render :json => resultObj + end + + def last_codecomparetime + resultObj = {status: 0} + @homework = HomeworkCommon.find params[:homework] + + #转换一下 + if @homework.simi_time != nil + resultObj[:comparetime] = Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M") + else + resultObj[:comparetime] = @homework.simi_time + end + + render :json => resultObj + end def index # 作业消息状态更新 @@ -351,6 +468,7 @@ class StudentWorkController < ApplicationController render_403 return end + @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name).count end @@ -1152,6 +1270,7 @@ class StudentWorkController < ApplicationController request["Content-Type"] = "application/json" client.request(request) end + JSON.parse(res.body) end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index f8e222b0f..283fea058 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -1,7 +1,7 @@ #老师布置的作业表 #homework_type: 0:普通作业;1:匿评作业;2:编程作业 class HomeworkCommon < ActiveRecord::Base - # attr_accessible :name, :user_id, :description, :publish_time, :end_time, :homework_type, :late_penalty, :course_id + # attr_accessible :name, :user_id, :description, :publish_time, :end_time, :homework_type, :late_penalty, :course_id,:simi_time include Redmine::SafeAttributes include ApplicationHelper diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 144f3859f..82b1ad4a1 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -1,6 +1,6 @@ #学生提交作品表 class StudentWork < ActiveRecord::Base - attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test + attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test, :simi_id, :simi_value belongs_to :homework_common belongs_to :user diff --git a/app/views/admin/code_work_tests.html.erb b/app/views/admin/code_work_tests.html.erb new file mode 100644 index 000000000..df7de6bf0 --- /dev/null +++ b/app/views/admin/code_work_tests.html.erb @@ -0,0 +1,96 @@ +

+ <%=l(:label_code_work_tests)%> +

+ +  + + +
+
发布者:{{homework.author.realname}} + {{homework.author.realname}} + {{homework.author.nickname}}
来   源:
+ + + + + + + + + + + + + + <% @code_work_tests.each do |test| %> + "> + + + + + + + + + + <% end %> + +
+ 作业id + + 平均等待时间 + + 语言 + + 提交测试时间 + + 答题状态 + + 测试集数 + + 最小耗时 + + 最大耗时 +
+ <%=link_to(test.homeworkid, student_work_index_path(:homework => test.homeworkid))%> + + <% if test.status != -2 && test.results.first['user_wait'] %> + <% wait_time = 0 %> + <% test.results.each do |result| wait_time = wait_time + result['user_wait'] end %> + <%=(wait_time/test.results.count).to_s+"毫秒" %> + <% else %> + <%="未记录"%> + <% end %> + + <%=%W(C C++ Python Java).at(test.language.to_i - 1)%> + + <%=Time.parse(test.created_at.to_s).strftime("%Y-%m-%d %H:%M:%S")%> + + <% if test.status == 0 %> + <%= "答题正确" %> + <% elsif test.status == -2 %> + <%= "编译错误" %> + <% elsif test.status == 2 || test.results.last['status'] == 2 %> + <%= "超时" %> + <% else %> + <%= "答题错误" %> + <% end %> + + <% if test.status != -2 %> + <%=test.results.count%> + <% end %> + + <% if test.status != -2 %> + <%test.results = test.results.sort_by {|result| result['time_used'] }%> + <%=test.results.first['time_used'] == 0 ? "1毫秒":test.results.first['time_used'].to_s+"毫秒"%> + <% end %> + + <% if test.status != -2 %> + <%=test.results.last['time_used'] == 0 ? "1毫秒":test.results.last['time_used'].to_s+"毫秒"%> + <% end %> +
+
+ + + +<% html_title(l(:label_code_work_tests)) -%> \ No newline at end of file diff --git a/app/views/courses/_compare_code_tips_1.html.erb b/app/views/courses/_compare_code_tips_1.html.erb new file mode 100644 index 000000000..696c40a48 --- /dev/null +++ b/app/views/courses/_compare_code_tips_1.html.erb @@ -0,0 +1,101 @@ +
+
+ <%if @homework.simi_time != nil %> +

<%="您上次查重的时间为"+Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M")%>

+ <%end%> + +
+
+
+
+ + \ No newline at end of file diff --git a/app/views/courses/_compare_code_tips_2.html.erb b/app/views/courses/_compare_code_tips_2.html.erb new file mode 100644 index 000000000..f926a1a84 --- /dev/null +++ b/app/views/courses/_compare_code_tips_2.html.erb @@ -0,0 +1,22 @@ +
+
+

<%=des%>

+
+ 确定 +
+
+
+
+
+ + \ No newline at end of file diff --git a/app/views/courses/_show_compare_code.html.erb b/app/views/courses/_show_compare_code.html.erb new file mode 100644 index 000000000..39f8e0565 --- /dev/null +++ b/app/views/courses/_show_compare_code.html.erb @@ -0,0 +1,16 @@ + +<% content_for :header_tags do %> + <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> + <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> + <%= stylesheet_link_tag "/assets/codemirror/merge" %> + <%= javascript_include_tag "https://cdnjs.cloudflare.com/ajax/libs/diff_match_patch/20121119/diff_match_patch.js"%> + <%= javascript_include_tag "/assets/codemirror/merge" %> +<% end %> + +
+

<%=src_name%>

+

<%=dst_name%>

+ + +
+
diff --git a/app/views/courses/code_repeat.html.erb b/app/views/courses/code_repeat.html.erb new file mode 100644 index 000000000..9e026c293 --- /dev/null +++ b/app/views/courses/code_repeat.html.erb @@ -0,0 +1,79 @@ +
+

查重结果

+
+
    +
  • 全部作品
  • +
  • 对比作品
  • +
    +
+
    +
  • 作品名称
  • +
  • 姓名
  • +
  • 学号
  • +
  • 时间
  • +
  • 作品名称
  • +
  • 姓名
  • +
  • 学号
  • +
  • 时间
  • +
  • 相似度
  • +
  • 对比
  • +
+ + <%if @homework.homework_type == 2 %> + <% @student_works.each do |student_work|%> +
    + <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%> + +
  • <%=student_work_name%>
  • +
  • <%=student_work.user.show_name%>
  • +
  • <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
  • +
  • <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>
  • + <% if student_work.simi_id > 0 && @works_hash[student_work.simi_id] %> + <% simi_student_work = @works_hash[student_work.simi_id] %> + <% simi_student_work_name = simi_student_work.name.nil? || simi_student_work.name.empty? ? simi_student_work.user.show_name + '的作品' : simi_student_work.name%> +
  • <%=simi_student_work_name%>
  • +
  • <%=simi_student_work.user.show_name%>
  • +
  • <%= simi_student_work.user.user_extensions.nil? ? "--" : simi_student_work.user.user_extensions.student_id%>
  • +
  • <%= Time.parse(format_time(simi_student_work.created_at)).strftime("%m-%d %H:%M")%>
  • + <% if student_work.simi_value >= 90 %> +
  • <%=student_work.simi_value%>%
  • + <% else %> +
  • <%=student_work.simi_value%>%
  • + <% end %> + + + +
  • + <%= link_to("查看", show_comparecode_course_path(:homework_id => @homework.id,:src_id => student_work.id,:dst_id => student_work.simi_id),:class => "cha-btn",:remote => true ) %> +
  • + <%else%> +
  • +
  • --
  • +
  • --
  • +
  • --
  • +
  • --
  • + <% end %> +
+ <%end%> + <%end%> +
+
+
+ + \ No newline at end of file diff --git a/app/views/courses/show_comparecode.js.erb b/app/views/courses/show_comparecode.js.erb new file mode 100644 index 000000000..5cfae9428 --- /dev/null +++ b/app/views/courses/show_comparecode.js.erb @@ -0,0 +1,101 @@ +$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/show_compare_code' ,:locals => {:src_code=> @src_code,:src_name=> @src_username,:dst_name=> @dst_username, :dst_code=> @dst_code,})%>'); +showModal('ajax-modal', '1250px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","20%").css("left","20%").css("position","absolute"); +//$('#ajax-modal').parent().addClass("resourceUploadPopup"); +$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px").css("padding-top","10px"); + +function closeModal(){ + hideModal($(".program-compare-code")); +} + +var program_name = "text/x-csrc"; +var language = <%= @homework.language.to_i %>; +if (language == 1) { + program_name = 'text/x-csrc'; +} else if(language==2){ + program_name = 'text/x-c++src'; +}else if(language==3){ + program_name = 'text/x-cython'; +} else if(language==4){ + program_name = 'text/x-java'; +} +// +//var editor_1 = CodeMirror(document.getElementById("program-code_1"), { +// mode: {name: program_name, +// version: 2, +// singleLineStringErrors: false}, +// lineNumbers: true, +// indentUnit: 2, +// matchBrackets: true, +// readOnly: true, +// value: $("#program-src_1").text() +// } +//); +// +//var editor_2 = CodeMirror(document.getElementById("program-code_2"), { +// mode: {name: program_name, +// version: 2, +// singleLineStringErrors: false}, +// lineNumbers: true, +// indentUnit: 2, +// matchBrackets: true, +// readOnly: true, +// value: $("#program-src_2").text() +// } +//); + +var value, orig1, orig2, dv, panes = 2, highlight = true, connect = null, collapse = false; +function initUI() { + if (value == null) return; + var target = document.getElementById("program-compare-code"); + target.innerHTML = ""; + dv = CodeMirror.MergeView(target, { + value: value, + origLeft: panes == 3 ? orig1 : null, + orig: orig2, + lineNumbers: true, + mode: program_name, + highlightDifferences: highlight, + connect: connect, + collapseIdentical: collapse + }); +} + +function toggleDifferences() { + dv.setShowDifferences(highlight = !highlight); +} + + +value = $("#program-src_1").text(); +orig1 = $("#program-src_1").text(); +orig2 = $("#program-src_2").text(); +initUI(); + + +function mergeViewHeight(mergeView) { + function editorHeight(editor) { + if (!editor) return 0; + return editor.getScrollInfo().height; + } + return Math.max(editorHeight(mergeView.leftOriginal()), + editorHeight(mergeView.editor()), + editorHeight(mergeView.rightOriginal())); +} + +function resize(mergeView) { + var height = mergeViewHeight(mergeView); + for(;;) { + if (mergeView.leftOriginal()) + mergeView.leftOriginal().setSize(null, height); + mergeView.editor().setSize(null, height); + if (mergeView.rightOriginal()) + mergeView.rightOriginal().setSize(null, height); + + var newHeight = mergeViewHeight(mergeView); + if (newHeight >= height) break; + else height = newHeight; + } + mergeView.wrap.style.height = height + "px"; +} \ No newline at end of file diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index f97a8dd2d..1e96a2771 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -1,10 +1,10 @@
    <% if @homework.homework_type != 3 %> - <% is_my_work = student_work.user == User.current%> + <% is_my_work = student_work.user == User.current%> <% else %> - <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> - <% is_my_work = pro && pro.student_work_id == student_work.id%> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% is_my_work = pro && pro.student_work_id == student_work.id%> <% end %>
    • diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index 6009dfbb5..bc516f994 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -1,3 +1,4 @@ +
        @@ -69,16 +70,14 @@ 正确输出:
        <%=x["output"]%>
        - <% if x["status"].to_i == 2 %> - 耗时: -
        <%=x["time_used"]%>毫秒
        - <% end %> + 耗时: +
        <%=x["time_used"]==0?1:x["time_used"]%>毫秒
        <% else %> - 测试正确! - - +   + 耗时: +
        <%=x["time_used"]==0?1:x["time_used"]%>毫秒
        <% end %> diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index 8b2f57723..db15e94fb 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -18,6 +18,9 @@
      + <%if @homework.homework_type == 2 %> + 代码查重 + <% end %> <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> <% end%> @@ -45,6 +48,7 @@
      <% end%> \ No newline at end of file diff --git a/app/views/student_work/show_allwork_test.html.erb b/app/views/student_work/show_allwork_test.html.erb new file mode 100644 index 000000000..139597f9c --- /dev/null +++ b/app/views/student_work/show_allwork_test.html.erb @@ -0,0 +1,2 @@ + + diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb index f8635194d..e84b7a95e 100644 --- a/app/views/users/new_user_commit_homework.html.erb +++ b/app/views/users/new_user_commit_homework.html.erb @@ -2,7 +2,6 @@ <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> <%= javascript_include_tag 'homework','baiduTemplate' %> <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> - <% end %> \ No newline at end of file + +
      当前分支:develop
      \ No newline at end of file diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index f711c25e2..085fc64be 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -1200,3 +1200,4 @@ a.chooseActive {background-color:#269ac9; color:#ffffff;} .popupClose {background:url(../images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:10px; top:5px;} .subjectType {width:70px; text-align:center;} .subjectCount {width:65px; text-align:center;} +.button-rep { color: #888;display: inline-block;background: #eee;padding: 2px 5px;} From a21200ab14a89989e3695184765b268edd76552b Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 15 Apr 2016 15:53:29 +0800 Subject: [PATCH 233/507] =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 8 +++++++- app/views/projects/_rep_static.html.erb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 7553acdbc..e9151c473 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -329,7 +329,13 @@ class ProjectsController < ApplicationController @a_commits_add = rep_statics_code.map {|s| s.add.to_i } @a_commits_del = rep_statics_code.map {|s| s.del.to_i } @a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i } - # @static_total_per_user = g.rep_stats(@project.gpid) + g = Gitlab.client + begin + g_branch = g.project(@project.gpid).default_branch.to_s + rescue + logger.error("get gitlab project failed!") + end + @rev = g_branch.nil? ? "master" : g_branch end # 根据对应的请求,返回对应的数据 respond_to do |format| diff --git a/app/views/projects/_rep_static.html.erb b/app/views/projects/_rep_static.html.erb index 86d557f3a..9ebf68d0c 100644 --- a/app/views/projects/_rep_static.html.erb +++ b/app/views/projects/_rep_static.html.erb @@ -178,4 +178,4 @@ }); }); -
      当前分支:develop
      \ No newline at end of file +
      当前分支:<%= @rev %>
      \ No newline at end of file From 4c4afb7a94eca657e8d705932ebb807fb790434d Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 15 Apr 2016 15:57:49 +0800 Subject: [PATCH 234/507] =?UTF-8?q?=E5=9C=A8=E6=96=B0=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E4=B8=AD=E6=89=93=E5=BC=80=E4=BD=9C=E4=B8=9A=E6=89=B9=E6=AC=A1?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=AD=E7=9A=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_common/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index e4b63a536..e34cf0736 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -47,7 +47,7 @@
        <% @homework_commons.each_with_index do |homework_common,index |%>
      • - <%= link_to "作业#{@homework_commons.count - index}:#{homework_common.name}",student_work_index_path(:homework => homework_common.id)%> + <%= link_to "作业#{@homework_commons.count - index}:#{homework_common.name}",student_work_index_path(:homework => homework_common.id),:target=>"_blank"%>
      • <% end%>
      From a18daeecd1812d1bcdee0549e015120581c8b318 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 15 Apr 2016 16:01:25 +0800 Subject: [PATCH 235/507] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E4=B8=8E=E5=8A=A8=E6=80=81=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/stats.html.erb | 106 +++++++++++++++++++++----- 1 file changed, 89 insertions(+), 17 deletions(-) diff --git a/app/views/repositories/stats.html.erb b/app/views/repositories/stats.html.erb index 4a8bd9217..4b35e64f6 100644 --- a/app/views/repositories/stats.html.erb +++ b/app/views/repositories/stats.html.erb @@ -14,6 +14,7 @@
+ diff --git a/config/routes.rb b/config/routes.rb index 3e2a7485b..fd7546749 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -268,6 +268,7 @@ RedmineApp::Application.routes.draw do get 'retry_work' get 'praise_student_work' get 'forbidden_anonymous_comment' + get 'work_canrepeat' end collection do post 'add_score_reply' @@ -286,6 +287,7 @@ RedmineApp::Application.routes.draw do post 'code_repeattest' post 'last_codecomparetime' post 'set_score_rule' + get 'work_canrepeat' end end diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 21d6f9e92..d58d951d0 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1296,7 +1296,7 @@ a.contributor_course{float: right; color: #888; font-size: 12px; font-weight: no /*20160310分班样式*/ .select-class-option {width:125px;} -/* 弹框 */ +/* 代码查重弹框 */ a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} a:hover.Blue-btn{ background:#3598db; color:#fff;} .fl{ float:left;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 4558437a2..6bd386f9f 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1487,3 +1487,13 @@ a.choose-active {background-color:#269ac9; color:#ffffff;} a.st_up{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 0 no-repeat; margin-top:5px; margin-left:3px;} a.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;} a.st_img { display:block;width:32px; height:32px; border:1px solid #CCC; padding:1px;} + +/* 代码查重弹框 */ +a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +a:hover.Blue-btn{ background:#3598db; color:#fff;} +.fl{ float:left;} +.fr{ float:right;} +.blue-border-box{ width:500px; padding:20px; margin:0 auto; background:#fff;} +.box-con h4{ font-size:14px; font-weight: bold; width:450px; text-align:center;} +.box-con{ width:450px; margin:0 auto; text-align:center;} +.box-con-a{ width:170px; margin:0 auto; margin-top:10px;} From 19a95dfc9c61cb7eb204e142f8481ec5030c9922 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 15 Apr 2016 17:36:23 +0800 Subject: [PATCH 238/507] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E4=BB=A3=E7=A0=81=E6=9F=A5=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_homework_detail.html.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 780b1c6eb..e483f3daf 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -74,6 +74,9 @@
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>
+
+ <%= link_to "代码查重", work_canrepeat_student_work_index_path(homework: homework_common.id, course_id: homework_common.course_id), class: 'c_blue test-program-btn',:remote => true %> +
<% end %> <% if homework_common.homework_type == 2%>
From 5aba3fb11bfd0cedfb530892bc85e6e60697fb54 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 15 Apr 2016 18:48:39 +0800 Subject: [PATCH 239/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E9=87=8D?= =?UTF-8?q?=E6=9C=89=E6=97=B6=E5=80=99=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/views/student_work/work_canrepeat.js.erb | 132 +++++++++---------- config/routes.rb | 1 - 3 files changed, 66 insertions(+), 68 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 89f4dd3b0..e40e11ddb 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -956,6 +956,7 @@ class CoursesController < ApplicationController @student_works.each do |tmpwork| @works_hash[tmpwork.id] = tmpwork + puts tmpwork.id end #respond_to do |format| diff --git a/app/views/student_work/work_canrepeat.js.erb b/app/views/student_work/work_canrepeat.js.erb index d4efd470e..090f63fd2 100644 --- a/app/views/student_work/work_canrepeat.js.erb +++ b/app/views/student_work/work_canrepeat.js.erb @@ -1,5 +1,4 @@ //代码查重 -var homework_id = <%=@homework.id%>; <% if @work_count <= 1 %> //弹框 $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); @@ -14,7 +13,71 @@ var homework_id = <%=@homework.id%>; hideModal($(".blue-border-box")); } <% else %> - <% if !@homework.simi_time %> + <% if !@homework.simi_time %> + //请求查重 + var test_repeat = function () { + $.post( + '/student_work/code_repeattest', + {homework: <%=@homework.id%>}, + function (data, status) { + if (data.status == 0) { + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成是否立即查看结果?",:status=>1, :homework=> @homework,:courseid=> @course_id})%>'); + showModal('ajax-modal', '580px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); + + function closeModal() { + hideModal($(".blue-border-box")); + } + } + else if (data.status == -1) { + // confirm("对不起只支持java/c/c++的代码查重!"); + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起目前只支持java/c/c++的代码查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); + showModal('ajax-modal', '580px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); + + function closeModal() { + hideModal($(".blue-border-box")); + } + + } + else if (data.status == -2) { + // confirm("对不起该作业的作品过少不能查重!"); + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); + showModal('ajax-modal', '580px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); + + function closeModal() { + hideModal($(".blue-border-box")); + } + } + } + ).fail(function (xhr, status) { + // confirm("对不起,服务器繁忙请稍后再试!"); + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起,服务器繁忙请稍后再试!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); + showModal('ajax-modal', '580px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); + + function closeModal() { + hideModal($(".blue-border-box")); + } + }); + }; test_repeat(); <% else%> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_1',:locals => {:homework=> @homework,:courseid=>@course_id })%>'); @@ -30,71 +93,6 @@ var homework_id = <%=@homework.id%>; hideModal($(".blue-border-box")); } <% end %> - - //请求查重 - var test_repeat = function () { - $.post( - '/student_work/code_repeattest', - {homework: homework_id}, - function (data, status) { - if (data.status == 0) { - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成是否立即查看结果?",:status=>1, :homework=> @homework,:courseid=> @course_id})%>'); - showModal('ajax-modal', '580px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); - - function closeModal() { - hideModal($(".blue-border-box")); - } - } - else if (data.status == -1) { - // confirm("对不起只支持java/c/c++的代码查重!"); - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起目前只支持java/c/c++的代码查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); - showModal('ajax-modal', '580px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); - - function closeModal() { - hideModal($(".blue-border-box")); - } - - } - else if (data.status == -2) { - // confirm("对不起该作业的作品过少不能查重!"); - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); - showModal('ajax-modal', '580px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); - - function closeModal() { - hideModal($(".blue-border-box")); - } - } - } - ).fail(function (xhr, status) { - // confirm("对不起,服务器繁忙请稍后再试!"); - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起,服务器繁忙请稍后再试!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); - showModal('ajax-modal', '580px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); - - function closeModal() { - hideModal($(".blue-border-box")); - } - }); - }; <% end %> diff --git a/config/routes.rb b/config/routes.rb index b2645f02a..6cb7a1c7b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -268,7 +268,6 @@ RedmineApp::Application.routes.draw do get 'retry_work' get 'praise_student_work' get 'forbidden_anonymous_comment' - get 'work_canrepeat' end collection do post 'add_score_reply' From 3136191de86ecb13235ec428326564531a618229 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 15 Apr 2016 18:51:31 +0800 Subject: [PATCH 240/507] =?UTF-8?q?=E6=9F=A5=E9=87=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/work_canrepeat.js.erb | 130 +++++++++---------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/app/views/student_work/work_canrepeat.js.erb b/app/views/student_work/work_canrepeat.js.erb index d4efd470e..353a150cf 100644 --- a/app/views/student_work/work_canrepeat.js.erb +++ b/app/views/student_work/work_canrepeat.js.erb @@ -1,5 +1,4 @@ //代码查重 -var homework_id = <%=@homework.id%>; <% if @work_count <= 1 %> //弹框 $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); @@ -15,6 +14,70 @@ var homework_id = <%=@homework.id%>; } <% else %> <% if !@homework.simi_time %> + //请求查重 + var test_repeat = function () { + $.post( + '/student_work/code_repeattest', + {homework: <%=@homework.id%>}, + function (data, status) { + if (data.status == 0) { + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成是否立即查看结果?",:status=>1, :homework=> @homework,:courseid=> @course_id})%>'); + showModal('ajax-modal', '580px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); + + function closeModal() { + hideModal($(".blue-border-box")); + } + } + else if (data.status == -1) { + // confirm("对不起只支持java/c/c++的代码查重!"); + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起目前只支持java/c/c++的代码查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); + showModal('ajax-modal', '580px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); + + function closeModal() { + hideModal($(".blue-border-box")); + } + + } + else if (data.status == -2) { + // confirm("对不起该作业的作品过少不能查重!"); + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); + showModal('ajax-modal', '580px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); + + function closeModal() { + hideModal($(".blue-border-box")); + } + } + } + ).fail(function (xhr, status) { + // confirm("对不起,服务器繁忙请稍后再试!"); + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起,服务器繁忙请稍后再试!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); + showModal('ajax-modal', '580px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); + + function closeModal() { + hideModal($(".blue-border-box")); + } + }); + }; test_repeat(); <% else%> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_1',:locals => {:homework=> @homework,:courseid=>@course_id })%>'); @@ -30,71 +93,6 @@ var homework_id = <%=@homework.id%>; hideModal($(".blue-border-box")); } <% end %> - - //请求查重 - var test_repeat = function () { - $.post( - '/student_work/code_repeattest', - {homework: homework_id}, - function (data, status) { - if (data.status == 0) { - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成是否立即查看结果?",:status=>1, :homework=> @homework,:courseid=> @course_id})%>'); - showModal('ajax-modal', '580px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); - - function closeModal() { - hideModal($(".blue-border-box")); - } - } - else if (data.status == -1) { - // confirm("对不起只支持java/c/c++的代码查重!"); - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起目前只支持java/c/c++的代码查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); - showModal('ajax-modal', '580px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); - - function closeModal() { - hideModal($(".blue-border-box")); - } - - } - else if (data.status == -2) { - // confirm("对不起该作业的作品过少不能查重!"); - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); - showModal('ajax-modal', '580px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); - - function closeModal() { - hideModal($(".blue-border-box")); - } - } - } - ).fail(function (xhr, status) { - // confirm("对不起,服务器繁忙请稍后再试!"); - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起,服务器繁忙请稍后再试!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>'); - showModal('ajax-modal', '580px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px"); - - function closeModal() { - hideModal($(".blue-border-box")); - } - }); - }; <% end %> From c1c20fda3b26b9fd6e22da02da1b4bc7ee8c78a6 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 15 Apr 2016 18:59:47 +0800 Subject: [PATCH 241/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E4=B9=9F=E8=83=BD=E7=9C=8B=E5=88=B0=E4=BB=A3=E7=A0=81=E6=9F=A5?= =?UTF-8?q?=E9=87=8D=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/_student_work_list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index 213bf267a..ac06d900e 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -18,7 +18,7 @@
- <%if @homework.homework_type == 2 %> + <%if @homework.homework_type == 2 && @is_teacher %> <%= link_to "代码查重", work_canrepeat_student_work_index_path(homework:@homework.id, course_id:@course.id), class: 'BlueCirBtn fr',:remote => true %> <% end %> <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> From fcfd17c8c919fee15f4bfc5d0e4761bd5a86fbb9 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 15 Apr 2016 19:20:24 +0800 Subject: [PATCH 242/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=AF=84=E6=B5=8B=E7=9A=84=E4=B8=80=E4=B8=AABUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 2849bdf90..89ee77053 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -141,11 +141,12 @@ class StudentWorkController < ApplicationController if result["status"].to_i != -2 result["results"].first['user_wait'] = tUsedtime + + if result["results"][0]["status"].to_i == 2 + result["status"] = 2 + end end - if result["results"][0]["status"].to_i == 2 - result["status"] = 2 - end status = result["status"] if index == 1 student_work_test = student_work.student_work_tests.build(status: status, From 73b89cdde5eba28d4aa3f210a20b7293aa2b4deb Mon Sep 17 00:00:00 2001 From: txz Date: Mon, 18 Apr 2016 11:19:13 +0800 Subject: [PATCH 243/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E8=BE=B9=E6=A1=86?= =?UTF-8?q?=EF=BC=8C=E5=9B=9E=E5=A4=8D=E7=82=B9=E8=B5=9E=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 5 ++- public/assets/wechat/activities.html | 42 +++++++++---------- public/assets/wechat/blog_detail.html | 6 +-- public/assets/wechat/course_discussion.html | 6 +-- public/assets/wechat/course_notice.html | 6 +-- public/assets/wechat/homework_detail.html | 6 +-- public/assets/wechat/issue_detail.html | 6 +-- public/assets/wechat/jour_message_detail.html | 6 +-- public/assets/wechat/project_discussion.html | 6 +-- public/javascripts/wechat/app.js | 2 +- public/stylesheets/weui/weixin.css | 13 +++--- 11 files changed, 53 insertions(+), 51 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 2fd7fd91d..f9eafe2d8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160408074854) do +ActiveRecord::Schema.define(:version => 20160414055511) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -809,6 +809,7 @@ ActiveRecord::Schema.define(:version => 20160408074854) do t.integer "anonymous_comment", :default => 0 t.integer "quotes", :default => 0 t.integer "is_open", :default => 0 + t.datetime "simi_time" end add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" @@ -1685,6 +1686,8 @@ ActiveRecord::Schema.define(:version => 20160408074854) do t.integer "absence_penalty", :default => 0 t.float "system_score", :default => 0.0 t.boolean "is_test", :default => false + t.integer "simi_id" + t.integer "simi_value" end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index f5eded3ee..7494b7033 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -26,9 +26,9 @@
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
+
回复 ({{act.reply_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -51,9 +51,9 @@
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
+
回复 ({{act.reply_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -76,9 +76,9 @@
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
+
回复 ({{act.reply_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -119,9 +119,9 @@
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
+
回复 ({{act.reply_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -145,9 +145,9 @@
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
+
回复 ({{act.reply_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -183,9 +183,9 @@
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
+
回复 ({{act.reply_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
@@ -209,9 +209,9 @@
-
回复 ({{act.reply_count}})
-
赞 ({{act.praise_count}})
-
已赞 ({{act.praise_count}})
+
回复 ({{act.reply_count}})
+
赞 ({{act.praise_count}})
+
已赞 ({{act.praise_count}})
diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index b3b97f047..c1133f955 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -14,9 +14,9 @@
-
回复 ({{blog.comment_count}})
-
已赞 ({{blog.praise_count}})
-
赞 ({{blog.praise_count}})
+
回复 ({{blog.comment_count}})
+
已赞 ({{blog.praise_count}})
+
赞 ({{blog.praise_count}})
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 9c70dfcfc..3f095ab62 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -20,9 +20,9 @@
-
回复 ({{discussion.replies_count}})
-
已赞 ({{discussion.praise_count}})
-
赞 ({{discussion.praise_count}})
+
回复 ({{discussion.replies_count}})
+
已赞 ({{discussion.praise_count}})
+
赞 ({{discussion.praise_count}})
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 750543e03..3b7965733 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -20,9 +20,9 @@
-
回复 ({{news.comments_count}})
-
已赞 ({{news.praise_count}})
-
赞 ({{news.praise_count}})
+
回复 ({{news.comments_count}})
+
已赞 ({{news.praise_count}})
+
赞 ({{news.praise_count}})
diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 776ecb4ce..fec0c4cff 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -26,9 +26,9 @@
-
回复 ({{homework.whomework_journal_count}})
-
已赞 ({{homework.praise_count}})
-
赞 ({{homework.praise_count}})
+
回复 ({{homework.whomework_journal_count}})
+
已赞 ({{homework.praise_count}})
+
赞 ({{homework.praise_count}})
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 38f732e6f..f61d803dd 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -24,9 +24,9 @@
-
回复 ({{issue.journals_count}})
-
已赞 ({{issue.praise_count}})
-
赞 ({{issue.praise_count}})
+
回复 ({{issue.journals_count}})
+
已赞 ({{issue.praise_count}})
+
赞 ({{issue.praise_count}})
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 7ce14e4a8..0bc87214b 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -11,9 +11,9 @@
-
回复 ({{message.reply_count}})
-
已赞 ({{message.praise_count}})
-
赞 ({{message.praise_count}})
+
回复 ({{message.reply_count}})
+
已赞 ({{message.praise_count}})
+
赞 ({{message.praise_count}})
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 185d06784..890b47a73 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -20,9 +20,9 @@
-
回复 ({{discussion.replies_count}})
-
已赞 ({{discussion.praise_count}})
-
赞 ({{discussion.praise_count}})
+
回复 ({{discussion.replies_count}})
+
已赞 ({{discussion.praise_count}})
+
赞 ({{discussion.praise_count}})
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index bedd79ed4..35d2a1b3d 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -3,7 +3,7 @@ var apiUrl = '/api/v1/'; var debug = false; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'https://www.trustie.net/api/v1/'; + apiUrl = 'http://localhost:3000/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 3872bb649..f164b80e3 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -23,6 +23,7 @@ h1,h2,h3,h4,h5,p {padding:0px; margin:0px;} .c-grey3 {color:#555555;} a {color:#707070;} a.c-grey {color:#707070;} +a.c-grey2 {color:#9a9a9a;} a:link,a:visited{text-decoration:none;} a:hover,a:active{cursor:pointer;} a.link-blue {color:#269ac9;} @@ -38,7 +39,7 @@ a.underline {text-decoration:underline;} /*动态样式*/ .post-container {width:100%;} -.post-wrapper {width:98%; border:1px solid #e6e6e6; border-radius:3px; background-color:#ffffff; margin:15px auto;} +.post-wrapper {width:98%; border-radius:3px; box-shadow:0px 0px 8px rgba(146, 153, 169, 0.5); background-color:#ffffff; margin:15px auto;} .post-main {padding:10px; color:#9a9a9a;} .post-avatar {width:45px; height:45px; margin-right:10px;} .post-title {font-size:13px; text-align:left;} @@ -48,20 +49,18 @@ a.underline {text-decoration:underline;} .cl {clear:both; overflow:hidden;} .post-content {width:100%; font-size:13px; line-height:18px; height:90px; overflow:hidden; word-break:break-all; word-wrap:break-word;} .post-interactive {width:100%; height:35px; line-height:35px; vertical-align:middle; border-top:1px solid #e6e6e6; background-color:#f8f9fb;} -.post-interactive-column {width:50%; text-align:center; float:left; font-size:13px;} -.post-interactive-reply {width:50%; text-align:center; float:left; font-size:13px;} +.post-interactive-column, +.post-interactive-reply, .post-interactive-praise {width:50%; text-align:center; float:left; font-size:13px;} .more-wrap {width:100%;} .more-events {width:98%; font-size:13px; text-align:center; margin:0 auto; padding: 5px 0; border:1px solid #e6e6e6; border-radius:3px; background-color:#f8f9fb; } .border-bottom {border-bottom:1px solid #e6e6e6;} -.post-reply-wrap {width:100%; line-height:18px; background-color:#f8f9fb;} -.post-input-wrap {width:100%; line-height:18px; background-color:#f8f9fb;} +.post-reply-wrap, .post-input-wrap {width:100%; line-height:18px; background-color:#f8f9fb;} .post-reply-row {padding:10px; color:#9a9a9a;} .post-reply-avatar {width:45px; height:30px; text-align:center; margin-right:10px;} .post-reply-user {font-size:13px; text-align:left; margin-bottom:10px;} .post-reply-content {font-size:13px; text-align:left; word-break:break-all; word-wrap:break-word; overflow:hidden;} -.post-reply-date {font-size:13px;} -.post-reply-trigger {font-size:13px;} +.post-reply-date, .post-reply-trigger {font-size:13px;} .post-input-container {padding-right:2px;} .post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; padding:0; margin:0; border-radius:3px;} .post-reply-submit {font-size:13px; padding:3px 8px; color:#fff; background-color:#269ac9; outline:none; border:none; display:inline-block;} \ No newline at end of file From 36d82e1315f77b308fd0d8994f5ad3e0276eecd0 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 18 Apr 2016 11:24:18 +0800 Subject: [PATCH 244/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=87=BA=E7=8E=B0=E4=BA=86=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/wechats/login.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wechats/login.html.erb b/app/views/wechats/login.html.erb index 27898b690..0e6fd8695 100644 --- a/app/views/wechats/login.html.erb +++ b/app/views/wechats/login.html.erb @@ -17,7 +17,7 @@
-
+
From 41aa81f9660ad5bc8c0e50ac1d5fa287166e9801 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 18 Apr 2016 14:44:29 +0800 Subject: [PATCH 245/507] =?UTF-8?q?rake=20=E4=BB=BB=E5=8A=A1=EF=BC=9A?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=96=87=E4=BB=B6=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_files.rake | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/tasks/sync_files.rake diff --git a/lib/tasks/sync_files.rake b/lib/tasks/sync_files.rake new file mode 100644 index 000000000..5c9326356 --- /dev/null +++ b/lib/tasks/sync_files.rake @@ -0,0 +1,38 @@ +require 'trustie/gitlab/sync' + +namespace :trustie do + namespace :files do + desc "sync course'file" + task :course => :environment do + # Course.all.each do |course| + # unless course.attachments.count.to_i == 0 + # attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and container_type ='Course'").count + # project_score = ProjectScore.where("project_id=?", project.id).first + # if project_score.nil? + # ProjectScore.create(:project_id => project.id, :attach_num => 0) + # else + # project_score.attach_num = attachment_count + # project_score.save + # end + # end + # end + end + + desc "sync project'file" + task :project => :environment do + Project.all.each do |project| + unless project.attachments.count.to_i == 0 + attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{project.id} and container_type ='Project'").count + project_score = ProjectScore.where("project_id=?", project.id).first + if project_score.nil? + ProjectScore.create(:project_id => project.id, :attach_num => 0) + else + project_score.attach_num = attachment_count + project_score.save + end + end + end + end + + end +end From 8064fe6c46fff52bc7db9b214eb30127344e475d Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 18 Apr 2016 15:37:32 +0800 Subject: [PATCH 246/507] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E5=B8=96=E5=AD=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 49 +++++++++++++------------------ app/models/message.rb | 14 ++++----- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 366cea06b..9572034aa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -120,59 +120,52 @@ module ApplicationHelper case type when "HomeworkCommon" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :homework_journal_num => 1) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :homework_journal_num => 1) else - score = course_contributor_score.homework_journal_num + 1 + score = course_contributor_score.homework_journal_num.to_i + 1 course_contributor_score.update_attributes(:homework_journal_num => score) end # 课程留言 when "Course" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 0, :resource_num => 0, :journal_num => 1, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :journal_num => 1) else - score = course_contributor_score.journal_num + 1 + score = course_contributor_score.journal_num.to_i + 1 course_contributor_score.update_attributes(:journal_num => score) end when "Message" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1, :message_reply_num => 0, - :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1) else - score = course_contributor_score.message_num + 1 + score = course_contributor_score.message_num.to_i + 1 course_contributor_score.update_attributes(:message_num => score) end when "MessageReply" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 1, - :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_reply_num => 1) else - score = course_contributor_score.message_reply_num + 1 + score = course_contributor_score.message_reply_num.to_i + 1 course_contributor_score.update_attributes(:message_reply_num => score) end when "NewReply" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_reply_num => 1) else - score = course_contributor_score.news_reply_num + 1 + score = course_contributor_score.news_reply_num.to_i + 1 course_contributor_score.update_attributes(:news_reply_num => score) end when "News" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 0, :news_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :news_num => 1) else - score = course_contributor_score.news_num + 1 + score = course_contributor_score.news_num.to_i + 1 course_contributor_score.update_attributes(:news_num => score) end when "Attachment" if course_contributor_score.nil? - CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0, - :news_reply_num => 0, :news_num => 0, :resource_num => 1, :journal_num => 0, :journal_reply_num => 0) + CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :resource_num => 1) else - score = course_contributor_score.resource_num + 1 + score = course_contributor_score.resource_num.to_i + 1 course_contributor_score.update_attributes(:resource_num => score) end end @@ -184,38 +177,38 @@ module ApplicationHelper case type when "HomeworkCommon" unless course_contributor_score.nil? - score = course_contributor_score.homework_journal_num - 1 + score = course_contributor_score.homework_journal_num.to_i - 1 course_contributor_score.update_attribute(:homework_journal_num, score < 0 ? 0 : score) end # 课程留言 when "Course" unless course_contributor_score.nil? - score = course_contributor_score.journal_num - 1 + score = course_contributor_score.journal_num.to_i - 1 course_contributor_score.update_attribute(:journal_num, score < 0 ? 0 : score) end when "Message" unless course_contributor_score.nil? - score = course_contributor_score.message_num - 1 + score = course_contributor_score.message_num.to_i - 1 course_contributor_score.update_attribute(:message_num, score < 0 ? 0 : score) end when "MessageReply" unless course_contributor_score.nil? - score = course_contributor_score.message_reply_num - 1 + score = course_contributor_score.message_reply_num.to_i - 1 course_contributor_score.update_attribute(:message_reply_num, score < 0 ? 0 : score) end when "NewReply" unless course_contributor_score.nil? - score = course_contributor_score.news_reply_num - 1 + score = course_contributor_score.news_reply_num.to_i - 1 course_contributor_score.update_attribute(:news_reply_num, score < 0 ? 0 : score) end when "News" unless course_contributor_score.nil? - score = course_contributor_score.news_num - 1 + score = course_contributor_score.news_num.to_i - 1 course_contributor_score.update_attribute(:news_num, score < 0 ? 0 : score) end when "Attachment" unless course_contributor_score.nil? - score = course_contributor_score.resource_num - 1 + score = course_contributor_score.resource_num.to_i - 1 course_contributor_score.update_attribute(:resource_num, score < 0 ? 0 : score) end end diff --git a/app/models/message.rb b/app/models/message.rb index d697db236..f5df220a0 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -77,12 +77,10 @@ class Message < ActiveRecord::Base validates_length_of :subject, :maximum => 255 validate :cannot_reply_to_locked_topic, :on => :create - after_create :add_author_as_watcher, :reset_counters!, :add_boards_count + # after_create :add_author_as_watcher, :reset_counters!, :add_boards_count after_update :update_messages_board, :update_activity after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score - - after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, - :act_as_system_message, :send_mail, :act_as_student_score, act_as_at_message(:content, :author_id) + after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count #before_save :be_user_score scope :visible, lambda {|*args| @@ -134,11 +132,11 @@ class Message < ActiveRecord::Base if self.project && !project.project_score.nil? # 讨论区 if self.parent_id.nil? - count = self.project.project_score.board_num + 1 - self.project.project_score.update_attribute(:board_num, count) + count = self.project.project_score.board_num.to_i + 1 + self.project.project_score.update_column(:board_num, count) else # 回复 - count = self.project.project_score.board_message_num + 1 - self.project.project_score.update_attribute(:board_message_num, count) + count = self.project.project_score.board_message_num.to_i + 1 + self.project.project_score.update_column(:board_message_num, count) end end end From 200307ec9f4720f6c7d35b48af94fdf29cc7ba1f Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 19 Apr 2016 09:18:58 +0800 Subject: [PATCH 247/507] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E7=BB=9F=E8=AE=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 5 ---- app/views/layouts/base_org.html.erb | 3 +++ app/views/layouts/base_org_newstyle.html.erb | 25 ++++++++++++++------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 4fa7659c9..0d99cd8a5 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -84,9 +84,6 @@ class OrganizationsController < ApplicationController @subfield_content = @organization.org_subfields.order("priority") @organization = Organization.find(params[:id]) - # 统计访问量 - @organization.update_column(:visits, @organization.visits.to_i + 1) - # @org_subfield = OrgSubfield.find(params[:org_subfield_id]) # @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 # @org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) @@ -123,8 +120,6 @@ class OrganizationsController < ApplicationController else if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) - # 统计访问量 - @organization.update_column(:visits, @organization.visits.to_i + 1) if params[:org_subfield_id] @org_subfield = OrgSubfield.find(params[:org_subfield_id]) @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index faf141600..b2cfa9877 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -113,6 +113,9 @@ + <%# 更新访问数,刷新的时候更新访问次数 %> + <% update_visiti_count @organization %> + <%# over %>
diff --git a/app/views/layouts/base_org_newstyle.html.erb b/app/views/layouts/base_org_newstyle.html.erb index fcbbd8bfe..1fcf60d20 100644 --- a/app/views/layouts/base_org_newstyle.html.erb +++ b/app/views/layouts/base_org_newstyle.html.erb @@ -62,9 +62,9 @@ \ No newline at end of file diff --git a/app/views/student_work/work_canrepeat.js.erb b/app/views/student_work/work_canrepeat.js.erb index 353a150cf..29fd61c97 100644 --- a/app/views/student_work/work_canrepeat.js.erb +++ b/app/views/student_work/work_canrepeat.js.erb @@ -81,7 +81,7 @@ test_repeat(); <% else%> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_1',:locals => {:homework=> @homework,:courseid=>@course_id })%>'); - $('#compare-tips-1').html('您上次查重的时间为<%= Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H-%M-%S")%>'); + $('#compare-tips-1').html('您上次查重的时间为<%= Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M:%S")%>'); showModal('ajax-modal', '580px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); diff --git a/db/migrate/20160419061745_create_code_tests.rb b/db/migrate/20160419061745_create_code_tests.rb new file mode 100644 index 000000000..565378ccd --- /dev/null +++ b/db/migrate/20160419061745_create_code_tests.rb @@ -0,0 +1,13 @@ +class CreateCodeTests < ActiveRecord::Migration + def change + create_table :code_tests do |t| + t.integer :homework_id + t.integer :wait_time, default: 0 + t.integer :language + t.integer :status + t.integer :time_used, default: 0 + + t.timestamps + end + end +end diff --git a/db/migrate/20160419074016_add_student_work_id_to_code_tests.rb b/db/migrate/20160419074016_add_student_work_id_to_code_tests.rb new file mode 100644 index 000000000..d2fc6b1f4 --- /dev/null +++ b/db/migrate/20160419074016_add_student_work_id_to_code_tests.rb @@ -0,0 +1,5 @@ +class AddStudentWorkIdToCodeTests < ActiveRecord::Migration + def change + add_column :code_tests, :student_work_id, :integer,:default=>0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 7c1efce6d..2fecd9f48 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160330103916) do +ActiveRecord::Schema.define(:version => 20160419074016) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -334,6 +334,17 @@ ActiveRecord::Schema.define(:version => 20160330103916) do t.boolean "diff_all" end + create_table "code_tests", :force => true do |t| + t.integer "homework_id" + t.integer "wait_time", :default => 0 + t.integer "language" + t.integer "status" + t.integer "time_used", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "student_work_id", :default => 0 + end + create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -1290,6 +1301,7 @@ ActiveRecord::Schema.define(:version => 20160330103916) do t.datetime "updated_at", :null => false t.string "field_type" t.integer "hide", :default => 0 + t.integer "status", :default => 1 end create_table "organizations", :force => true do |t| @@ -1302,6 +1314,7 @@ ActiveRecord::Schema.define(:version => 20160330103916) do t.datetime "updated_at", :null => false t.boolean "allow_guest_download", :default => true t.integer "visits", :default => 0 + t.integer "show_mode", :default => 0 end create_table "phone_app_versions", :force => true do |t| @@ -1666,6 +1679,7 @@ ActiveRecord::Schema.define(:version => 20160330103916) do t.integer "status", :default => 9 t.text "results" t.text "src" + t.integer "uwait_time", :default => 0 end create_table "student_works", :force => true do |t| diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 5162bcb16..3764ceb04 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2847,29 +2847,4 @@ img.school_avatar { } .admin_message_warn{font-size: 12px;color: red;} -a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;} - -/*20160401袁可------------------ 查重结果样式*/ -.conbox{ width:1000px; margin:0 auto; border:3px solid #f0f0f0; background:#fff;} -.conbox-h2{ font-size:16px; padding:10px 0; padding-left:25px;} -.chabox{ width:1000px;} -.chabox ul li{ float:left; width:82px; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} -.chabox ul li.chabox-w-401{ width:151px; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} -.chabox ul li.chabox-r-line{ border-right:1px solid #D1D1D1;} -.chabox-top{ width:1000px; } -.chabox-top li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000;} -.chabox-con li{font-size:12px; line-height:35px; height:35px; color:#888; border-bottom:1px solid #DFDFDF;} -a.cha-btn{ display:block; width:50px; height:20px; line-height:20px; margin:0 auto; border:1px solid #269ac9; color:#269ac9;-webkit-border-radius: 3px;border-radius:3px; margin-top:8px;} -a:hover.cha-btn{ background:#269ac9; color:#fff;} -.chabox-header li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; border-top:1px solid #E4E4E4; border-right:1px solid #E4E4E4; color:#000;} -.chabox ul li.chabox-w-500{ width:499px;} -.chabox ul li.chabox-w-40{ width:39px; border-right:1px solid #D1D1D1;} -.chabox ul li.chabox-txt-left{ text-align:left;text-indent:1em; } - -.contrast-box{ width:1200px;box-shadow: 0 0 5px #6B6B6B; background:#fff; margin:0 auto; } -.contrast-con{ width:599px; border-right:1px solid #D1D1D1; float:left;} -.contrast-con h3{font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} -.contrast-txt{ padding:10px;} -.showCodeC{ width:580px; float:left;} - -.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;} \ No newline at end of file +a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;} \ No newline at end of file diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index dc380f6ef..e9fd46adf 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -1452,3 +1452,28 @@ ul.contest-notification-list li span{ color: #136b3b !important; font-weight:normal !important; } + +/*20160401袁可------------------ 查重结果样式*/ +.conbox{ width:1000px; margin:0 auto; border:3px solid #f0f0f0; background:#fff;} +.conbox-h2{ font-size:16px; padding:10px 0; padding-left:25px;} +.chabox{ width:1000px;} +.chabox ul li{ float:left; width:82px; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.chabox ul li.chabox-w-401{ width:151px; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.chabox ul li.chabox-r-line{ border-right:1px solid #D1D1D1;} +.chabox-top{ width:1000px; } +.chabox-top li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000;} +.chabox-con li{font-size:12px; line-height:35px; height:35px; color:#888; border-bottom:1px solid #DFDFDF;} +a.cha-btn{ display:block; width:50px; height:20px; line-height:20px; margin:0 auto; border:1px solid #269ac9; color:#269ac9;-webkit-border-radius: 3px;border-radius:3px; margin-top:8px;} +a:hover.cha-btn{ background:#269ac9; color:#fff;} +.chabox-header li{ font-size:14px; font-weight:bold; line-height:40px; height:40px; border-top:1px solid #E4E4E4; border-right:1px solid #E4E4E4; color:#000;} +.chabox ul li.chabox-w-500{ width:499px;} +.chabox ul li.chabox-w-40{ width:39px; border-right:1px solid #D1D1D1;} +.chabox ul li.chabox-txt-left{ text-align:left;text-indent:1em; } + +.contrast-box{ width:1200px;box-shadow: 0 0 5px #6B6B6B; background:#fff; margin:0 auto; } +.contrast-con{ width:599px; border-right:1px solid #D1D1D1; float:left;} +.contrast-con h3{font-size:14px; font-weight:bold; line-height:40px; height:40px; background:#E4E4E4; color:#000; text-align:center; display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.contrast-txt{ padding:10px;} +.showCodeC{ width:580px; float:left;} + +.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;} diff --git a/spec/factories/code_tests.rb b/spec/factories/code_tests.rb new file mode 100644 index 000000000..b8eed45fb --- /dev/null +++ b/spec/factories/code_tests.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :code_test, :class => 'CodeTests' do + homework_id 1 +wait_time 1 +language 1 +status 1 +time_used "MyString" + end + +end diff --git a/spec/models/code_tests_spec.rb b/spec/models/code_tests_spec.rb new file mode 100644 index 000000000..4e0d71cf3 --- /dev/null +++ b/spec/models/code_tests_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CodeTests, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 6957c24da555c4d160b3590c11c73234aa9ff1d5 Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 20 Apr 2016 10:08:03 +0800 Subject: [PATCH 259/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E9=A1=B5=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 2 +- public/javascripts/wechat/app.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index dfd60e68a..3cea45bcd 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -143,7 +143,7 @@
- +
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index e9f45f3a9..9f0987552 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; From c6174406fb0294c2371dc095cc34490a131210cb Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Apr 2016 10:39:07 +0800 Subject: [PATCH 260/507] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=E4=BD=BF=E7=94=A8rails=E5=B7=B2=E6=9C=89=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 5 +++-- app/views/admin/code_work_tests.html.erb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7d1ff6426..e581216fe 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -596,7 +596,7 @@ class AdminController < ApplicationController #代码测试列表 def code_work_tests #求出所有条数 - tCount = StudentWorkTest.find_by_sql("select count(*) from code_tests").first['count(*)'] + tCount = CodeTests.count() #设置个空的数组 以便paginateHelper来分页 @code_work_tests = [] @@ -615,7 +615,8 @@ class AdminController < ApplicationController if is_test[test['student_work_id']] != nil test['is_test'] = is_test[test['student_work_id']] else - test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] + test['is_test'] = StudentWork.find(test['student_work_id']).is_test + #test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] is_test[test['student_work_id']] = test['is_test'] end end diff --git a/app/views/admin/code_work_tests.html.erb b/app/views/admin/code_work_tests.html.erb index 385f97169..cb113f1e6 100644 --- a/app/views/admin/code_work_tests.html.erb +++ b/app/views/admin/code_work_tests.html.erb @@ -40,7 +40,7 @@ <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> '> - <% if test['is_test'] == 0 %> + <% if !test['is_test'] %> <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%> <% else %> <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%> From ef987d6bf7aaaca4854ddb5364536e51c904a4c9 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 20 Apr 2016 10:44:54 +0800 Subject: [PATCH 261/507] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=B8=AD=E6=9C=89html=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1234567 | 2 +- app/helpers/application_helper.rb | 15 +++++++++++++++ app/models/blog_comment.rb | 6 ++++-- app/models/comment.rb | 6 ++++-- app/models/issue.rb | 3 ++- app/models/journal.rb | 3 ++- app/models/journals_for_message.rb | 10 +++++++--- app/models/message.rb | 12 ++++++++---- app/models/news.rb | 3 ++- 9 files changed, 45 insertions(+), 15 deletions(-) diff --git a/1234567 b/1234567 index 459204fe5..b584c6f69 100644 --- a/1234567 +++ b/1234567 @@ -1 +1 @@ -{"access_token":"q51KZUeA6_-CCCH-Buy1mxFmRjcrCViHgk2mHHHqEDbjuA_pgCM1IyW1DASYvpzyB06xHiarujo3rz1Ucq3GRoXdgQ7hAoFCzkL_q3Z5vczLjwAjowAVwmulYE-cAij8ATUfADAWPQ","expires_in":7200,"got_token_at":1460601163} \ No newline at end of file +{"access_token":"GbIQJdIaX2c0IyQSOJcNNT2TxUH5aSQCNL7N92BV9oggGePRoj886HDohtqRokwPS6OVcIYF8WZTnSn717CP-czrWupY_gIHehK4UqjqXYqGkVqODXaXEB_LV0grMIwEXQDhAAAFYL","expires_in":7200,"got_token_at":1461117548} \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 366cea06b..f0f959830 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3068,3 +3068,18 @@ def host_with_protocol return Setting.protocol + "://" + Setting.host_name end +def strip_html(text,len=0,endss="...") + ss = "" + if text.length>0 + ss=text.gsub(/<\/?.*?>/, '').strip + + if len > 0 && ss.length > len + ss = ss[0, len] + endss + elsif len > 0 && ss.length <= len + ss = ss + #ss = truncate(ss, :length => len) + end + end + return ss +end + diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 62451591f..a328791bf 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -81,10 +81,12 @@ class BlogComment < ActiveRecord::Base ws = WechatService.new if self.parent_id.nil? self.author.watcher_users.each do |watcher| - ws.message_update_template watcher.id, "#{l(:label_new_blog_template)}", self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, format_time(self.created_at) + content = strip_html self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, 200 + ws.message_update_template watcher.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at) end else - ws.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), self.content.html_safe + content = strip_html self.content.html_safe, 200 + ws.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content end end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 9a752129b..f613a6d46 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -45,12 +45,14 @@ class Comment < ActiveRecord::Base if self.commented.course if self.author_id != self.commented.author_id self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false) - ws.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe + content = strip_html self.comments.html_safe, 200 + ws.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end else # 项目相关 if self.author_id != self.commented.author_id self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false) - ws.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.comments.html_safe + content = strip_html self.comments.html_safe, 200 + ws.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 5124dd54b..7681ce45d 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -160,7 +160,8 @@ class Issue < ActiveRecord::Base unless self.author_id == self.assigned_to_id self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) ws = WechatService.new - ws.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, format_time(self.created_on) + content = strip_html self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, 200 + ws.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) end if self.tracker_id == 5 self.project.members.each do |m| diff --git a/app/models/journal.rb b/app/models/journal.rb index 80d585b06..60bb16b11 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -240,6 +240,7 @@ class Journal < ActiveRecord::Base #缺陷回复微信模板消息 def issue_wechat_message ws = WechatService.new - ws.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + content = strip_html self.notes.html_safe, 200 + ws.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 799af8f74..58aa8620b 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -257,7 +257,9 @@ class JournalsForMessage < ActiveRecord::Base end if self.jour_type == 'HomeworkCommon' ws = WechatService.new - ws.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + #content = truncate(strip_tags(self.notes.to_s), length: 200) + content = strip_html self.notes.html_safe, 200 + ws.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end end @@ -271,7 +273,8 @@ class JournalsForMessage < ActiveRecord::Base if self.reply_id == 0 if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour - ws.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", self.notes.html_safe, format_time(self.created_on) + content = strip_html self.notes, 200 + ws.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on) end else # 留言回复 reply_to = User.find(self.reply_id) @@ -281,7 +284,8 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 receivers << self.parent.jour end - ws.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), self.notes.html_safe + content = strip_html self.notes, 200 + ws.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) diff --git a/app/models/message.rb b/app/models/message.rb index 2f4637042..d606962e1 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -266,14 +266,16 @@ class Message < ActiveRecord::Base self.course.members.each do |m| if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) - ws.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) + content = strip_html self.subject, 200 + ws.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 self.course.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) - ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe + content = strip_html self.content.html_safe, 200 + ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end @@ -282,14 +284,16 @@ class Message < ActiveRecord::Base self.project.members.each do |m| if m.user_id != self.author_id self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) - ws.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", self.subject, self.author.try(:realname), format_time(self.created_on) + content = strip_html self.subject, 200 + ws.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 self.project.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) - ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), self.content.html_safe + content = strip_html self.content.html_safe, 200 + ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/news.rb b/app/models/news.rb index 25a70095f..b7a8baaf5 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -171,7 +171,8 @@ class News < ActiveRecord::Base if m.user_id != self.author_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) ws = WechatService.new - ws.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, format_time(self.created_on) + content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200 + ws.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on) end end else From 4182bb5fe712221457aa8372330e1d73acb92e32 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Apr 2016 14:39:38 +0800 Subject: [PATCH 262/507] 111 --- app/controllers/admin_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index e581216fe..906194951 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -603,7 +603,7 @@ class AdminController < ApplicationController @code_work_tests[tCount-1] = {} @code_work_tests = paginateHelper @code_work_tests,30 - @page = (params['page'] || 1).to_i - 1 + @page = (params['page'] || 1).to_i - 1 #1111111111 #取出需要的那一页数据 tStart = @page*30 From aed38182738ac586a31eb34611dc6dbc2eb54d9a Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 20 Apr 2016 14:44:10 +0800 Subject: [PATCH 263/507] =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=B7=B3=E5=88=B0=E5=BE=AE=E4=BF=A1=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1234567 | 2 +- app/models/blog_comment.rb | 4 ++-- app/models/comment.rb | 6 +++--- app/models/homework_common.rb | 4 ++-- app/models/issue.rb | 2 +- app/models/journal.rb | 2 +- app/models/journals_for_message.rb | 6 +++--- app/models/message.rb | 8 ++++---- app/models/news.rb | 2 +- app/services/wechat_service.rb | 25 ++++++++++++++----------- config/locales/zh.yml | 8 +------- 11 files changed, 33 insertions(+), 36 deletions(-) diff --git a/1234567 b/1234567 index b584c6f69..327c92785 100644 --- a/1234567 +++ b/1234567 @@ -1 +1 @@ -{"access_token":"GbIQJdIaX2c0IyQSOJcNNT2TxUH5aSQCNL7N92BV9oggGePRoj886HDohtqRokwPS6OVcIYF8WZTnSn717CP-czrWupY_gIHehK4UqjqXYqGkVqODXaXEB_LV0grMIwEXQDhAAAFYL","expires_in":7200,"got_token_at":1461117548} \ No newline at end of file +{"access_token":"x7GUTe-MLoVPMzId82-3VSdCsO6sq5cOJZCmIN-yUjDcohfI00t2lzPkNKdRhETLUBptZRQ--v-IBQTG-o5iRZZv-EelOBX7K96DcPMFt9rdzwNu7XerNnZw_ncGYncSLHXeACAQMC","expires_in":7200,"got_token_at":1461133885} \ No newline at end of file diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index a328791bf..af21b4f69 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -82,11 +82,11 @@ class BlogComment < ActiveRecord::Base if self.parent_id.nil? self.author.watcher_users.each do |watcher| content = strip_html self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, 200 - ws.message_update_template watcher.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at) + ws.message_update_template watcher.id, "blog_comment", self.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at) end else content = strip_html self.content.html_safe, 200 - ws.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content + ws.comment_template self.parent.author_id, "blog_comment", self.parent_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content end end end diff --git a/app/models/comment.rb b/app/models/comment.rb index f613a6d46..6b1732eab 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -46,13 +46,13 @@ class Comment < ActiveRecord::Base if self.author_id != self.commented.author_id self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false) content = strip_html self.comments.html_safe, 200 - ws.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end else # 项目相关 if self.author_id != self.commented.author_id self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false) - content = strip_html self.comments.html_safe, 200 - ws.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + #content = strip_html self.comments.html_safe, 200 + #ws.comment_template self.commented.author_id, "blog_comment", self.id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 54f13e57e..a2216bdf9 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -60,7 +60,7 @@ class HomeworkCommon < ActiveRecord::Base # if m.user_id != self.user_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) ws = WechatService.new - ws.homework_template(m.user_id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") # end end end @@ -107,7 +107,7 @@ class HomeworkCommon < ActiveRecord::Base def wechat_message self.course.members.each do |member| ws = WechatService.new - ws.homework_template(member.user_id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + ws.homework_template(member.user_id, "homework", self.id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 7681ce45d..fd378bc05 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -161,7 +161,7 @@ class Issue < ActiveRecord::Base self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) ws = WechatService.new content = strip_html self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, 200 - ws.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) + ws.message_update_template self.assigned_to_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) end if self.tracker_id == 5 self.project.members.each do |m| diff --git a/app/models/journal.rb b/app/models/journal.rb index 60bb16b11..02086fa62 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -241,6 +241,6 @@ class Journal < ActiveRecord::Base def issue_wechat_message ws = WechatService.new content = strip_html self.notes.html_safe, 200 - ws.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 58aa8620b..1f8b0253f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -259,7 +259,7 @@ class JournalsForMessage < ActiveRecord::Base ws = WechatService.new #content = truncate(strip_tags(self.notes.to_s), length: 200) content = strip_html self.notes.html_safe, 200 - ws.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end end @@ -274,7 +274,7 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.jour_id # 过滤自己给自己的留言消息 receivers << self.jour content = strip_html self.notes, 200 - ws.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on) + ws.message_update_template self.jour_id, "journal_for_message", self.id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on) end else # 留言回复 reply_to = User.find(self.reply_id) @@ -285,7 +285,7 @@ class JournalsForMessage < ActiveRecord::Base receivers << self.parent.jour end content = strip_html self.notes, 200 - ws.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + ws.comment_template self.reply_id, "journal_for_message", self.parent.id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) diff --git a/app/models/message.rb b/app/models/message.rb index d606962e1..5dc5dcc2e 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -267,7 +267,7 @@ class Message < ActiveRecord::Base if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) content = strip_html self.subject, 200 - ws.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) + ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 @@ -275,7 +275,7 @@ class Message < ActiveRecord::Base if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) content = strip_html self.content.html_safe, 200 - ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + ws.comment_template m.user_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end @@ -285,7 +285,7 @@ class Message < ActiveRecord::Base if m.user_id != self.author_id self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) content = strip_html self.subject, 200 - ws.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) + ws.topic_publish_template m.user_id, "project_discussion", self.id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) end end else # 回帖 @@ -293,7 +293,7 @@ class Message < ActiveRecord::Base if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) content = strip_html self.content.html_safe, 200 - ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + ws.comment_template m.user_id, "project_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/news.rb b/app/models/news.rb index b7a8baaf5..45e5bc424 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -172,7 +172,7 @@ class News < ActiveRecord::Base self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) ws = WechatService.new content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200 - ws.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on) + ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on) end end else diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb index ae097ad4a..2fb222d4f 100644 --- a/app/services/wechat_service.rb +++ b/app/services/wechat_service.rb @@ -1,11 +1,11 @@ #encoding: utf-8 class WechatService - def template_data(openid, template_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + def template_data(openid, template_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") data = { touser:openid, template_id:template_id, - url:"https://www.trustie.net/", + url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect", topcolor:"#FF0000", data:{ first: { @@ -33,10 +33,10 @@ class WechatService data end - def homework_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + def homework_template(user_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") uw = UserWechat.where(user_id: user_id).first unless uw.nil? - data = template_data uw.openid,"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI",first, key1, key2, key3, remark + data = template_data uw.openid,"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", type, id, first, key1, key2, key3, remark begin req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) rescue Exception => e @@ -44,12 +44,13 @@ class WechatService end Rails.logger.info "send over. #{req}" end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" end - def topic_publish_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + def topic_publish_template(user_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") uw = UserWechat.where(user_id: user_id).first unless uw.nil? - data = template_data uw.openid,"oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ",first, key1, key2, key3, remark + data = template_data uw.openid,"oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", type, id,first, key1, key2, key3, remark Rails.logger.info "start send template message: #{data}" begin req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) @@ -58,12 +59,13 @@ class WechatService end Rails.logger.info "send over. #{req}" end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" end - def comment_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") + def comment_template(user_id,type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站") uw = UserWechat.where(user_id: user_id).first unless uw.nil? - data = template_data uw.openid,"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",first, key1, key2, key3, remark + data = template_data uw.openid,"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",type, id,first, key1, key2, key3, remark Rails.logger.info "start send template message: #{data}" begin req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) @@ -72,15 +74,16 @@ class WechatService end Rails.logger.info "send over. #{req}" end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" end - def message_update_template(user_id, first, key1, key2, remark="具体内容请点击详情查看网站") + def message_update_template(user_id, type, id, first, key1, key2, remark="具体内容请点击详情查看网站") uw = UserWechat.where(user_id: user_id).first unless uw.nil? data = { touser:uw.openid, template_id:"YTyNPZnQD8uZFBFq-Q6cCOWaq5LA9vL6RFlF2JuD5Cg", - url:"https://www.trustie.net/", + url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect", topcolor:"#FF0000", data:{ first: { @@ -101,7 +104,6 @@ class WechatService } } } - Rails.logger.info "start send template message: #{data}" begin req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) @@ -110,5 +112,6 @@ class WechatService end Rails.logger.info "send over. #{req}" end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" end end \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 65d405733..7160e9d27 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2138,15 +2138,9 @@ zh: label_new_journals_template: 您有新留言了 label_journals_comment_template: 您的留言有新回复了 label_blog_comment_template: 您的博客有新回复了 - label_new_blog_template: 您的课程有新作业了 + label_new_blog_template: 有新博客了 label_new_issue_template: 您有新缺陷了 label_new_notice_template: 您的课程有新通知了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 - label_resource_name: 您的课程有新作业了 #edit yk label_code_work_tests: 代码测试列表 From 0b82bf50c2014fcd2cd26d6bd945425c5be3826f Mon Sep 17 00:00:00 2001 From: txz Date: Wed, 20 Apr 2016 15:45:33 +0800 Subject: [PATCH 264/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E4=B8=AD=E5=9B=BE=E7=89=87=E6=AD=A3=E5=B8=B8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/activities.html | 2 +- public/javascripts/wechat/app.js | 3 +-- public/stylesheets/weui/weixin.css | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 3cea45bcd..f87af796f 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -215,7 +215,7 @@
-
+
点击展开 diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 9f0987552..834ccf9d6 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = true; //调试标志,如果在本地请置为true +var debug = false; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; @@ -394,7 +394,6 @@ app.directive('textAutoHeight', function($timeout){ }); } }, false); - } } }); diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index ead53557b..19206d916 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -50,6 +50,7 @@ a.underline {text-decoration:underline;} .fr {float:right;} .cl {clear:both; overflow:hidden;} .post-content {width:100%; font-size:13px; line-height:18px; height:90px; overflow:hidden; word-break:break-all; word-wrap:break-word;} +.post-content img {max-width:100%;} .post-interactive {width:100%; height:35px; line-height:35px; vertical-align:middle; border-top:1px solid #e6e6e6; background-color:#f8f9fb;} .post-interactive-column, .post-interactive-reply, @@ -62,6 +63,7 @@ a.underline {text-decoration:underline;} .post-reply-avatar {width:45px; height:30px; text-align:center; margin-right:10px;} .post-reply-user {font-size:13px; text-align:left; margin-bottom:10px;} .post-reply-content {font-size:13px; text-align:left; word-break:break-all; word-wrap:break-word; overflow:hidden;} +.post-reply-content img {max-width:100%;} .post-reply-date, .post-reply-trigger {font-size:13px;} .post-input-container {padding-right:2px;} .post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; padding:0; margin:0; border-radius:3px;} From 29115bca3ae1fd2d81303e523b56584ab8cd9c23 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Apr 2016 16:12:20 +0800 Subject: [PATCH 265/507] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 7 +- app/controllers/blogs_controller.rb | 7 + app/views/blogs/_article.html.erb | 258 ++++------------------- app/views/blogs/_article_list.html.erb | 37 +--- app/views/blogs/index.html.erb | 2 +- app/views/layouts/new_base_user.html.erb | 2 +- public/images/liststyle.png | Bin 0 -> 19559 bytes public/stylesheets/new_user.css | 35 +++ 8 files changed, 88 insertions(+), 260 deletions(-) create mode 100644 public/images/liststyle.png diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 906194951..e6e0ec087 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -600,10 +600,11 @@ class AdminController < ApplicationController #设置个空的数组 以便paginateHelper来分页 @code_work_tests = [] - @code_work_tests[tCount-1] = {} - + if tCount >= 1 + @code_work_tests[tCount-1] = {} + end @code_work_tests = paginateHelper @code_work_tests,30 - @page = (params['page'] || 1).to_i - 1 #1111111111 + @page = (params['page'] || 1).to_i - 1 #取出需要的那一页数据 tStart = @page*30 diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 7a226f50d..8ee153456 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -3,6 +3,13 @@ class BlogsController < ApplicationController before_filter :find_user def index @article = BlogComment.new + + @topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.updated_on desc") + + #分页 + @topics = paginateHelper @topics,10 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| format.html {render :layout=>'new_base_user'} end diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index edbce26d3..cfc43ca47 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -1,226 +1,46 @@ -
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> -
-
- <% if activity.author.id == User.current.id || User.current.admin? %> - - <%end%> -
- <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% end %> - TO - <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%> - <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> - 已设为首页 - <% end %> -
-
- - <% if activity.sticky == 1%> - 置顶 - <% end%> - <% if activity.locked%> -        - <% end%> -
-
- 发帖时间:<%= format_time(activity.created_on) %> -
-
- 更新时间:<%= format_time(activity.updated_on) %> -
-
- <% if activity.parent_id.nil? %> - <% content= activity.content%> - <% else %> - <% content= activity.parent.content%> - <% end %> - <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %> - -
- - - -
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> -
- -
+
+

博客列表

+
+ 排序: + 时间 + 人气
- <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> -
-
-
回复 - <%= count>0 ? "(#{count})" : "" %> - - <% if activity.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - <% end %> - -
-
<%#=format_date(activity.updated_on)%>
- <%if count > 3 %> - - <% end %> -
- - <% activity= activity.parent ? activity.parent : activity%> - <% replies_all_i = 0 %> - <% if count > 0 %> -
-
    - <% activity.children.reorder("created_on desc").each do |reply|%> - - <% replies_all_i=replies_all_i+1 %> -
  • -
    - <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> -
    -
    -
    - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> - <%= format_time(reply.created_on) %> - - <% if reply.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> - <% end %> - -
    -
    - <%= reply.content.html_safe %> -
    -
    -
    -
  • +
    + <% topics.each do |activity| %> +
      +
    • + <% if activity.parent_id.nil? %> + <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "c_red ml10" %> + <% else %> + <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "c_red ml10"%> <% end %> -
    -
    - <% end %> - - <% if !activity.locked? %> -
    -
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    -
    - <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%> - - - - - -
    - - -
    -

    - <% end%> -
    -
    -
    -
    + <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> + [已设为首页] + <% end %> + + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
  • + 发帖时间:<%= format_time(activity.created_on) %> + 更新时间:<%= format_time(activity.updated_on) %> +

    + <%= count>0 ? "(#{count})" : "" %> + 回复 + | + <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %> + +

    +
  • -
    +
<% end %> +
- diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb index f3fd1aa61..af9fc1c0f 100644 --- a/app/views/blogs/_article_list.html.erb +++ b/app/views/blogs/_article_list.html.erb @@ -51,44 +51,9 @@ <% end %> <% if topics%> - <% topics.each do |topic| %> - - <% if topic %> - <%= render :partial => 'blogs/article', :locals => {:activity => topic, :user_activity_id => topic.id} %> - <% end %> - <% end %> - - <%# if topics.count == 10 %> - - <%# end %> + <%= render :partial => 'blogs/article', :locals => {:topics => topics} %> <% end%>
- +
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 834ccf9d6..97589721e 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -3,7 +3,7 @@ var apiUrl = '/api/v1/'; var debug = false; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'http://localhost:3000/api/v1/'; + apiUrl = 'https://www.trustie.net/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ From 85055f2a8443c1fec7c15d8e979d9e84df1e2763 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Apr 2016 09:39:21 +0800 Subject: [PATCH 269/507] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blogs_controller.rb | 14 +++++++++++++- app/views/blogs/_article.html.erb | 14 ++++++++++++-- app/views/blogs/index.js.erb | 0 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 app/views/blogs/index.js.erb diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 8ee153456..dcdb4846c 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -4,12 +4,20 @@ class BlogsController < ApplicationController def index @article = BlogComment.new - @topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.updated_on desc") + @order, @b_sort = params[:order] || 1, params[:sort] || "desc" + + sort_name = @order == 1 ? "created_on" : "" + + + @topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.#{sort_name} #{@b_sort}") #分页 + @topics = paginateHelper @topics,10 @page = (params['page'] || 1).to_i - 1 + + respond_to do |format| format.html {render :layout=>'new_base_user'} end @@ -62,4 +70,8 @@ class BlogsController < ApplicationController def find_user @user = User.find(params[:user_id]) end + + def blogsort + + end end diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index cfc43ca47..7b8ccb5d3 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -2,8 +2,18 @@

博客列表

排序: - 时间 - 人气 + + + <%= link_to "时间", user_blog_sort_blog_path(:sort => @score, :order => 1, :search => " "), :class => "sortTxt", :remote => true %> + <% if @order == 1 %> + <%= link_to "", user_blog_sort_blog_path(:sort => @score, :order => 1, :search => " "), :class => "#{@score == 'desc' ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> + + <%= link_to "人气", user_blog_sort_blog_path(:sort => @score, :order => 2, :search => " "), :class => "sortTxt", :remote => true %> + <% if @order == 2 %> + <%= link_to "", user_blog_sort_blog_path(:sort => @score, :order => 2, :search => " "), :class => "#{@score == 'desc' ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> +
diff --git a/app/views/blogs/index.js.erb b/app/views/blogs/index.js.erb new file mode 100644 index 000000000..e69de29bb From e8048f8eb71065fcc7d5b11e5ae9145478cc4488 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Apr 2016 10:09:52 +0800 Subject: [PATCH 270/507] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93=E6=97=B6=E9=97=B4UTC=E4=B8=8E=E5=8C=97=E4=BA=AC?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E7=9A=84=E8=BD=AC=E6=8D=A2=20=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=9B=BD=E9=99=85=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/repositories_helper.rb | 6 ++++++ app/views/repositories/_dir_list_content.html.erb | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 8d1f11c57..3cf781f76 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -52,6 +52,12 @@ module RepositoriesHelper end end + def translate_time time + case time + when time.include("") + end + end + # 获取diff内容行号 def diff_line_num content content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i diff --git a/app/views/repositories/_dir_list_content.html.erb b/app/views/repositories/_dir_list_content.html.erb index 79ed44b99..60c4aa3bf 100644 --- a/app/views/repositories/_dir_list_content.html.erb +++ b/app/views/repositories/_dir_list_content.html.erb @@ -43,7 +43,11 @@
- +
<%# end %> From 8e254ff7220d2d70cc19a9bb2bdb9ad480886d75 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Apr 2016 10:38:36 +0800 Subject: [PATCH 271/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1loading=E5=BC=B9?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/app.html | 8 +++++++- public/javascripts/wechat/app.js | 24 +++++++++++++++++++++--- public/stylesheets/weui/weixin.css | 8 +++++++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index eb97a8360..5b2f4e9ec 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -13,7 +13,13 @@ -
+
+
+
+ 加载中... +
+
+
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index bedd79ed4..984d9a9b2 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,9 +1,9 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'https://www.trustie.net/api/v1/'; + apiUrl = 'http://localhost:3000/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ @@ -399,7 +399,7 @@ app.directive('textAutoHeight', function($timeout){ } }); -app.config(['$routeProvider',function ($routeProvider) { +app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProvider) { $routeProvider .when('/activities', { templateUrl: 'activities.html', @@ -436,4 +436,22 @@ app.config(['$routeProvider',function ($routeProvider) { .otherwise({ redirectTo: '/activities' }); + $httpProvider.interceptors.push('timestampMarker'); +}]); + +//loading +app.factory('timestampMarker', ["$rootScope", function ($rootScope) { + var timestampMarker = { + request: function (config) { + $rootScope.loading = true; + config.requestTimestamp = new Date().getTime(); + return config; + }, + response: function (response) { + // $rootScope.loading = false; + response.config.responseTimestamp = new Date().getTime(); + return response; + } + }; + return timestampMarker; }]); diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 3872bb649..d79ad16ae 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -64,4 +64,10 @@ a.underline {text-decoration:underline;} .post-reply-trigger {font-size:13px;} .post-input-container {padding-right:2px;} .post-reply-input {width:100%; height:28px; line-height:28px; border:1px solid #e6e6e6; outline:none; padding:0; margin:0; border-radius:3px;} -.post-reply-submit {font-size:13px; padding:3px 8px; color:#fff; background-color:#269ac9; outline:none; border:none; display:inline-block;} \ No newline at end of file +.post-reply-submit {font-size:13px; padding:3px 8px; color:#fff; background-color:#269ac9; outline:none; border:none; display:inline-block;} + +/* loading 弹框*/ +.loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(0, 0, 0, 0.3); overflow:hidden;} +.loading-box {position:absolute; top:50%; background:white; width:160px; height:72px; left:50%; margin-top:-36px; margin-left:-80px; text-align:center;} +.loading-box img {margin-top: 12px; text-align: center;} +.loading-box span {display: block;} \ No newline at end of file From ba171c49cc7abe6f30f7db2fd98432943014bdb6 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Apr 2016 10:42:06 +0800 Subject: [PATCH 272/507] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=20=E6=94=B9=E6=88=90?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 329dee898..82e6f871f 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -25,7 +25,7 @@
- <%=link_to "统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %> + <%=link_to "代码统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %>
<%# 针对公开项目:用户必须创建了项目,否则用户无法同步 %> <% if User.current.id != @project.user_id %> From d538d1967bda900187bab90633027d349d61d340 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Thu, 21 Apr 2016 11:16:32 +0800 Subject: [PATCH 273/507] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=95=8C=E9=9D=A2=E4=BB=A3=E7=A0=81=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8404=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 22 ++++++++++++++++++++-- app/views/admin/code_work_tests.html.erb | 16 ++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index e6e0ec087..8ae20972c 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -610,15 +610,33 @@ class AdminController < ApplicationController tStart = @page*30 @code_work_tests = CodeTests.find_by_sql("select * from code_tests order by id desc limit #{tStart},30 ") - #取出各个作业是否是模拟答题的 + #取出各个作品是否是模拟答题的 is_test = {} + #作品是否存在 + link_swork = {} + #作业是否存在 + link_hwork = {} @code_work_tests.each do |test| + #作品是否存在 if is_test[test['student_work_id']] != nil + test['link_swork'] = link_swork[test['student_work_id']] test['is_test'] = is_test[test['student_work_id']] else - test['is_test'] = StudentWork.find(test['student_work_id']).is_test + work = StudentWork.where("id=?",test['student_work_id']).first + test['link_swork'] = !work.nil? + test['is_test'] = work.nil? ? false : work.is_test #test['is_test'] = CodeTests.find_by_sql("select is_test from student_works where id = #{test['student_work_id']}").first['is_test'] is_test[test['student_work_id']] = test['is_test'] + link_swork[test['student_work_id']] = test['link_swork'] + end + + #作业是否存在 + if link_hwork[test['homework_id']] != nil + test['link_hwork'] = link_hwork[test['homework_id']] + else + hwork = HomeworkCommon.where("id=?",test['homework_id']).first + test['link_hwork'] = !hwork.nil? + link_hwork[test['homework_id']] = test['link_hwork'] end end diff --git a/app/views/admin/code_work_tests.html.erb b/app/views/admin/code_work_tests.html.erb index cb113f1e6..64c3a41e1 100644 --- a/app/views/admin/code_work_tests.html.erb +++ b/app/views/admin/code_work_tests.html.erb @@ -37,13 +37,21 @@ <% if test['homework_id'] != nil %> "> '> - <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> + <% if test['link_hwork'] %> + <%=link_to(test['homework_id'], student_work_index_path(:homework => test['homework_id']))%> + <% else %> + <%= test['homework_id'] %> + <% end %> '> - <% if !test['is_test'] %> - <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%> + <% if test['link_swork'] && test['link_hwork'] %> + <% if !test['is_test'] %> + <%=link_to(test['student_work_id'], student_work_index_path(:homework => test['homework_id'],:student_work_id=>test['student_work_id']))%> + <% else %> + <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%> + <% end %> <% else %> - <%=link_to(test['student_work_id'], new_user_commit_homework_users_path(homework_id: test['homework_id'], is_test: true))%> + <%= test['student_work_id'] %> <% end %> From 42076a137dffd8b19472e75457dd6e75a9ea18ff Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Apr 2016 11:19:21 +0800 Subject: [PATCH 274/507] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 2 -- app/views/projects/show.html.erb | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 380e880ad..0edd11129 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -586,8 +586,6 @@ update end end end - # @static_month__per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 2) - # @static_week_per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 3) rescue render_404 return diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 72a419f55..c0bb15ab4 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -29,7 +29,7 @@
- <% unless @project.gpid.nil? || @project.project_score.changeset_num == 0 %> + <% unless @project.gpid.nil? || @project.project_score.changeset_num == 0 || @project.rep_statics.blank? %>
<%= render :partial => "rep_static" %> From 0bab42256c6e6c6d54c9cf0b61553d42205788e0 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Apr 2016 11:21:29 +0800 Subject: [PATCH 275/507] =?UTF-8?q?=E5=BE=AE=E4=BF=A1loading=E5=BC=B9?= =?UTF-8?q?=E6=A1=86=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/app.html | 2 +- public/images/wechat/loading.gif | Bin 0 -> 3878 bytes public/javascripts/wechat/app.js | 2 +- public/stylesheets/weui/weixin.css | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) create mode 100755 public/images/wechat/loading.gif diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index 5b2f4e9ec..187439468 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -16,7 +16,7 @@
- 加载中... + 加载中...
diff --git a/public/images/wechat/loading.gif b/public/images/wechat/loading.gif new file mode 100755 index 0000000000000000000000000000000000000000..b806bf34c396900414f74b8e591e85333f9ab38f GIT binary patch literal 3878 zcmeH|X;@R|w#RoSGLVEM1PJpc3 z)c|7EQVY%~Dq#?`dPHq4dTI}Yden1!1?#y-Z`FMd--d-3CcJk!OvuDr#@WT(+uU`)j5BK!+ymsx{-Me?MUcEXrG-R<@ zE?>U<-FM%a&E~18so~+_d-v{zg@t|n_17m(oVa=O=DBm{5D3J>hY!8Iylr3_U)^#uI}&e7YGC%9v)s^UOqlPPEJlKDJdKdr?$41#bPBSBy8Wledo@dzP`R1 zjmB!VZrZe|rlw})%9TQ)aM7YgR4O$oDJeBI)nqaS2M2H6x-~jFy0x{nsHkZ5>eZE% zm5GUoN~O}x%`G=K7l}j?2m~6978n?))9KvZ-HAlvym|AaQYo2CX0zGLmMv4MR8>_~ znVFe6IXQdx?p3SRAt529rKMV}cFUG6SS)tkx^-!3X<1oW+1c6q_wN^pME?H%ix)3u zGMVSkpFecy(2*lY9z1vu6%{pq{(KMw@pybgLxWf>?&|6q85vo#W(^93((Cn+k&y=u z9FWOmb#--PV`FdMzJ-$Z|JVN^1AcEEm&RqJ$BJZeTqYXeBlKJ;!MX3@cSCWiGfbdmiBXrD7yqf>zq%&<@eo5KNl zJSHbRg2&@50J&@qm&Jx|UMMG=AHm~uBO!UbyXeqtI^|k^nne2hT+mkxy})45@>wiM z^2|+POpR_Givy|K9)rsbg)Bn#n@bFGV`z!q|9u3BO0UorY7K>&63`w|p0C+xh@nHI zzb&Cy`$yOkJ@egimVf4+I+>+9D>N3ISJ4G!4)uUx*= zckx2+`EzH_oIZ83r~9iDUv_fxbT8UY;KAG&fflsxyU5av~D&jyNm^?SMie;81h$dxJ!wfM#HUz17%{Pyq85 zfMLAiyR9}0#yKQww7YGvisYZz8sF1CT#K34vf6Ze0)Qc&wVdZ@`%!Q=^4KhbB5X#x zAc<_qY1l<6`-SwH8)QN_;segdo6`0L3w*6WL%*ra(c8V{nAH||Ls4(XQt^p^|}W-=k&rO5@?Na*&6q!qwuUJwOd2LBhO#hM4p{3^Xfw(3+hPzFPz z7>pZvj3K0emTK(>+e`?DsEpQrl+*Qc1eobHvq^42bUU>wjb_rWzeG{lNVU;chR0_Y z&~_~u#8i6WX?b}QRjLXCzOEo#%#8ikwKv2I__Q6Kbi-r2hLb#)Q<9hhe3Q1*la^P_|B& z#$?{JM|)(_V3}~PJZJz7I0H^ld5i!H>lH5pUC=0JSG+9%X%ouVz6GJRz=PAc@-0+82PLxS6>pC&skmi6;L@^n)?$ zBxd9=YB~E`AfgRV;C-Q9{?sNieU*FWI^eis{mPS>2>2Wf27++|93hzUcQD#P-!hDI z&}p%4$3PWXiVqi?2ZW%D4=!VBu(5xKE6aS$B%bc{4&Sz|i$Ox+{DW9;tmH|`Xp$}j zyidC8K=7E)f{DngyxlaNP&hsTj&vdx1%#aTt4XO7Bru~*Bpa-9)j`7t>uC8^qRO zB7CDv>pUB4_V8gHZxD-?3?&8Pvd+JnP4mQ2b8@(=!N;AERg_PAE#1IyGyi$hv5s`V z9iO`&2r3%LP)jH)a`%s`+v|38W%V9`dGhdWra2M{MB)Th%w8|TKiCFH_7;@iE8!}H z+~!6iFjJ>yC_`?jO|V5!4D-+oA4ag6;UCoN zHy9cO(+H4@X0-2M2uQY8ix?<_(LEM?GdPQ%C7nlXeyL9eq8csNdu2w>D!! zViwIy=cOEFa49 zPLpF=+GPz|R6Yl{dxxhO@BVTOaCcVLE~*hdIliA3SI75ro>t$hg2Co;<_ut<+POoR zJMFT<|}?k zO&y{^uO`R!1JNDM`8W5kJG-r}clIX1g>y#MKnV;&b&_sj+>Z|4B=|P_2uKV`HL-fl zxg1Ivs%wQg@(2^ZkW{yC+0<}yZnhUl?q z_kJEL6x-7%ui#|t0xoU7mWW~EVKJ}iV?lS5{KV{S+HXT_i}0sN)C|%51T*nO4jwa? zFf8Eu`#!9IaQdiuP{L^R8&Sq**aHl_lN3X;4fK1flUqQ_ZO{Sj?4Fg_ID+)V@%X!D zHcX@u(RjG2LD4=c^o{k&ZWoHI6p!GAIHl>ZxcxH$E6!?*Ju38%t;9UK|5GC&aA7O) z7_e4-Ckbt2Y*+&u75eA0eq=oTX2J)z^#T9OkZ^F0%-*ctZ^U!un}rP%ozQ7QPfqW) z4pgC+TMIEg?P7{+SbkyS>?FYtTo^P|=1@zlrQ-tnEYh}5Bb)h#s8!Z}bS;(feRc3p zcPik4AG>eDrB<;o-Q{tX-606kjWnQwRI_h#)?`TiQNIe)^Hnd?-VTy`m#6PQk zBn9iYl?Vhhp~VKkmR_YG@b}0mpsFMMBaC zf5I+ZUqM*S#)Pu})M fET*=AWU~c81@IXYd6nZpR-glBGkK`r1T6eFH3|s_ literal 0 HcmV?d00001 diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 984d9a9b2..241c88129 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -377,7 +377,7 @@ app.directive('textAutoHeight', function($timeout){ link: function(scope, element, attr){ scope.text = '点击展开'; $timeout(function(){ - var e = element.parent().children().eq(4); + var e = element.parent().children().eq(5); var height = e[0].scrollHeight; var offsetHeight = e[0].offsetHeight; if(height>90){ diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 92aeec9cf..21fde54bb 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -73,7 +73,7 @@ a.underline {text-decoration:underline;} .praised-icon {background:url(/images/wechat/wechat_icon.png) -100px -76px no-repeat; width:20px; height:18px; display:inline-block; vertical-align:middle;} /* loading 弹框*/ -.loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(0, 0, 0, 0.3); overflow:hidden;} +.loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(206, 206, 206, 0.3); overflow:hidden;} .loading-box {position:absolute; top:50%; background:white; width:160px; height:72px; left:50%; margin-top:-36px; margin-left:-80px; text-align:center;} -.loading-box img {margin-top: 12px; text-align: center;} +.loading-box img {margin-top: 3px; text-align: center;} .loading-box span {display: block;} From 2345eb9d644730310786e791913965677740bd40 Mon Sep 17 00:00:00 2001 From: txz Date: Thu, 21 Apr 2016 11:22:52 +0800 Subject: [PATCH 276/507] =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 241c88129..0a6b97e5b 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,9 +1,9 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = '/api/v1/'; -var debug = true; //调试标志,如果在本地请置为true +var debug = false; //调试标志,如果在本地请置为true if(debug===true){ - apiUrl = 'http://localhost:3000/api/v1/'; + apiUrl = 'https://www.trustie.net/api/v1/'; } app.factory('auth', function($http,$routeParams, $cookies, $q){ From 81f8559c48f2cd9cdfcbc9887eeea657d6de47be Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Apr 2016 16:04:00 +0800 Subject: [PATCH 277/507] =?UTF-8?q?gitlab=E7=89=88=E6=9C=AC=E5=BA=93?= =?UTF-8?q?=E6=88=90=E5=91=98=E5=90=8C=E6=AD=A5=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/gitlab.rake | 16 ++++++++++++++++ lib/trustie/gitlab/sync.rb | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/tasks/gitlab.rake b/lib/tasks/gitlab.rake index 729c9245f..bf43551c6 100644 --- a/lib/tasks/gitlab.rake +++ b/lib/tasks/gitlab.rake @@ -11,6 +11,22 @@ namespace :gitlab do end end + task :members => :environment do + projects = Project.where("gpid is not null") + s = Trustie::Gitlab::Sync.new + g = Gitlab.client + projects.each do |project| + begin + if project.members.count != g.team_members(project.gpid).count + puts project.id + s.only_members(project) + end + rescue => e + puts e + end + end + end + desc "update user password" task :password => :environment do s = Trustie::Gitlab::Sync.new diff --git a/lib/trustie/gitlab/sync.rb b/lib/trustie/gitlab/sync.rb index 2f4f77c53..3520098a9 100644 --- a/lib/trustie/gitlab/sync.rb +++ b/lib/trustie/gitlab/sync.rb @@ -122,7 +122,7 @@ module Trustie project.members.each do |m| begin gid = m.user.gid - unless gid + if gid.nil? gid = sync_user(m.user).id end self.g.add_team_member(project.gpid, gid, get_gitlab_role(m)) From cb2033c80f84f981e14b62a5f0b5d8fd016567f2 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Apr 2016 16:20:29 +0800 Subject: [PATCH 278/507] =?UTF-8?q?=E5=8E=BB=E6=8E=89rake=E4=B8=AD?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/gitlab.rake | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/tasks/gitlab.rake b/lib/tasks/gitlab.rake index bf43551c6..7893195ac 100644 --- a/lib/tasks/gitlab.rake +++ b/lib/tasks/gitlab.rake @@ -18,7 +18,6 @@ namespace :gitlab do projects.each do |project| begin if project.members.count != g.team_members(project.gpid).count - puts project.id s.only_members(project) end rescue => e From 98da0ce6cad1cb3fb9804056995640f38b5dcf6f Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Apr 2016 16:33:20 +0800 Subject: [PATCH 279/507] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/projects/zh.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 8bf3f03be..076b905c3 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -89,11 +89,10 @@ zh: project_module_repository: 版本库 project_module_create_repository: 创建版本库 project_gitlab_create_repository: 新版本库 - project_gitlab_create_double_message: 亲,您已经创建了一个同名的版本库,换个特别点的名字同名的概率就会变小哦~ + project_gitlab_create_double_message: 温馨提示:您已经创建了一个同名的版本库! project_gitlab_fork_double_message: 亲,您已经有了一个相同名字的版本库,所以不能fork改版本库~ project_gitlab_fork_own: 您好,您当前所fork的项目为您自己创建的项目,平台暂时不提供fork自己项目的功能,敬请谅解! - label_project_more: 更多 project_module_news: 新闻 project_module_wiki: Wiki From 16348654a543834867a6e847220ce58ec03e50b0 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 21 Apr 2016 17:00:30 +0800 Subject: [PATCH 280/507] =?UTF-8?q?=E5=90=AF=E7=94=A8=E5=8C=BF=E8=AF=84?= =?UTF-8?q?=E5=92=8C=E7=A6=81=E7=94=A8=E5=8C=BF=E8=AF=84=E6=97=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=AF=84=E5=88=86=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 18 ++++++++++++++++-- app/controllers/users_controller.rb | 12 ++++++++++-- .../_set_score_rule_detail.html.erb | 8 ++++---- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 49e6ec290..28e2e192b 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -73,11 +73,17 @@ class HomeworkCommonController < ApplicationController else @homework.publish_time = params[:homework_common][:publish_time] end + homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] - @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0 + if params[:homework_common][:anonymous_comment] && params[:homework_common][:anonymous_comment] != @homework.anonymous_comment + if @homework.anonymous_comment == 1 + homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 1.0 : 0.4 + else + homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 + end + end - homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 homework_detail_manual.comment_status = 1 end @@ -94,6 +100,13 @@ class HomeworkCommonController < ApplicationController @homework.homework_detail_programing ||= HomeworkDetailPrograming.new @homework_detail_programing = @homework.homework_detail_programing @homework_detail_programing.language = params[:language_type].to_i + if params[:homework_common][:anonymous_comment] && params[:homework_common][:anonymous_comment] != @homework.anonymous_comment + if @homework.anonymous_comment == 1 + @homework_detail_programing.ta_proportion = 0.6 + else + @homework_detail_programing.ta_proportion = 0.5 + end + end @homework.homework_tests.delete_all inputs = params[:program][:input] @@ -116,6 +129,7 @@ class HomeworkCommonController < ApplicationController @homework_detail_group.base_on_project = params[:base_on_project].to_i end + @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0 if @homework.save @homework_detail_manual.save if @homework_detail_manual @homework_detail_programing.save if @homework_detail_programing diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a15f37274..7392ed8ff 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -750,7 +750,11 @@ class UsersController < ApplicationController render_attachment_warning_if_needed(homework) homework_detail_manual = HomeworkDetailManual.new - homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 + if homework.anonymous_comment == 1 + homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 1.0 : 0.4 + else + homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 + end if homework.publish_time > Date.today homework_detail_manual.comment_status = 0 else @@ -766,7 +770,11 @@ class UsersController < ApplicationController if homework.homework_type == 2 homework_detail_programing = HomeworkDetailPrograming.new homework.homework_detail_programing = homework_detail_programing - homework_detail_programing.ta_proportion = 0.5 + if homework.anonymous_comment == 1 + homework_detail_programing.ta_proportion = 0.6 + else + homework_detail_programing.ta_proportion = 0.5 + end homework_detail_programing.language = params[:language_type].to_i inputs = params[:program][:input] diff --git a/app/views/student_work/_set_score_rule_detail.html.erb b/app/views/student_work/_set_score_rule_detail.html.erb index 28ca9e785..edef7053c 100644 --- a/app/views/student_work/_set_score_rule_detail.html.erb +++ b/app/views/student_work/_set_score_rule_detail.html.erb @@ -19,21 +19,21 @@ <% else%> <% end%> From 3fe2e81c0e56e37350c2ce9f1a60ae9b74fb3d94 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 21 Apr 2016 17:01:57 +0800 Subject: [PATCH 281/507] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AF=84=E5=88=86?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=97=B6=E6=AF=94=E4=BE=8BNAN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_homework_form.html.erb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 9689ecda0..a6c7236df 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -15,6 +15,11 @@ <% if edit_mode && homework.is_group_homework? %> $("#GroupPopupBox a.group_save_btn").click(); <% end %> + <% if edit_mode %> + $("#anonymous_comment").on('click',function(){ + $("#anonymous_hint").show(); + }); + <% end %> }); function checked_val() { if ($("#anonymous_comment").is(":checked")) { @@ -174,7 +179,8 @@ <% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
- 禁用匿评 + 禁用匿评 +
<% end %>
From e23262225a39f49a313b052d1427753461d2521f Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Apr 2016 10:34:45 +0800 Subject: [PATCH 282/507] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E5=90=8D?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=98=AF=E5=85=A8=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 571bba1b9..305c82f97 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -44,7 +44,7 @@ class Repository < ActiveRecord::Base # validates_uniqueness_of :identifier, :allow_blank => true validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph) # donwcase letters, digits, dashes, underscores but not digits only - validates_format_of :identifier, :with => /^[a-z0-9_\-]+$/, :allow_blank => true + validates_format_of :identifier, :with => /^[a-zA-Z0-9_\-]*[a-zA-Z_\-]+[a-zA-Z0-9_\-]*$/, :allow_blank => true # Checks if the SCM is enabled when creating a repository validate :repo_create_validation, :on => :create From aaeec3ab6c59138cd07c7f51c0141ef7865146f6 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Apr 2016 10:58:41 +0800 Subject: [PATCH 283/507] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93show?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=BB=A3=E7=A0=81=E7=AE=80=E5=8C=96=E5=B0=81?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 25 ++++------------------ 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 0edd11129..b73ecf9b9 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -325,27 +325,11 @@ update end end - # unless @repository.gitlab? - # # redirect_to to_gitlab_project_repository_path(@project, @repository) - # render :to_gitlab - # return - # end - - #if( !User.current.member_of?(@project) || @project.hidden_repo) - # @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty? - - # :name, :path, :kind, :size, :lastrev, :changeset @entries = @repository.entries(@path, @rev) - # @trees = g.trees(project, @path) @changeset = @repository.find_changeset_by_name(@rev) - #@project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT - #@ip = RepositoriesHelper::REPO_IP_ADDRESS - if request.xhr? @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) else - #Modified by young - # (show_error_not_found; return) unless @entries g = Gitlab.client @changesets = g.commits(@project.gpid, :ref_name => @rev) g_project = g.project(@project.gpid) @@ -360,17 +344,16 @@ update if @changesets_all_count != @project.project_score.changeset_num && @changesets_all_count != 0 update_commits_count(@project, @changesets_all_count) end - # end # 最近一次提交 @changesets_latest_coimmit = @changesets[0] unless @changesets[0].blank? update_commits_date(@project, @changesets_latest_coimmit) end @creator = User.where("id =?", @project.user_id).first.try(:login) - @properties = @repository.properties(@path, @rev) - @repositories = @project.repositories - project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT - ip = RepositoriesHelper::REPO_IP_ADDRESS + # @properties = @repository.properties(@path, @rev) + # @repositories = @project.repositories + # project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT + # ip = RepositoriesHelper::REPO_IP_ADDRESS gitlab_address = Redmine::Configuration['gitlab_address'] if @repository.type.to_s == "Repository::Gitlab" @repos_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git" From c4bd78e4421ee2531361ddca0a10b68b2efd77b5 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Apr 2016 12:44:37 +0800 Subject: [PATCH 284/507] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=BF=98=E5=8E=9F=E5=8F=8A=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/message.rb b/app/models/message.rb index f5df220a0..bb12473be 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -80,7 +80,7 @@ class Message < ActiveRecord::Base # after_create :add_author_as_watcher, :reset_counters!, :add_boards_count after_update :update_messages_board, :update_activity after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score - after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count + after_create :act_as_course_activity, :act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count #before_save :be_user_score scope :visible, lambda {|*args| @@ -257,13 +257,13 @@ class Message < ActiveRecord::Base def act_as_system_message if self.course if self.parent_id.nil? # 主贴 - self.course.members.each do |m| + self.course.members.includes(:user).each do |m| if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) end end else # 回帖 - self.course.members.each do |m| + self.course.members.includes(:user).each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) end @@ -271,13 +271,13 @@ class Message < ActiveRecord::Base end elsif self.project # 项目相关 if self.parent_id.nil? # 主贴 - self.project.members.each do |m| + self.project.members.includes(:user).each do |m| if m.user_id != self.author_id self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) end end else # 回帖 - self.project.members.each do |m| + self.project.members.includes(:user).each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) end From 5c5d2121937d30d59597953b2e2caef12b13478a Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 22 Apr 2016 13:52:33 +0800 Subject: [PATCH 285/507] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blogs_controller.rb | 36 +++++-- app/views/blogs/_article.html.erb | 118 +++++++++++++---------- app/views/blogs/_article_list.html.erb | 2 +- app/views/blogs/index.js.erb | 1 + app/views/layouts/new_base_user.html.erb | 2 +- public/javascripts/homework.js | 6 ++ public/stylesheets/new_user.css | 21 ++-- 7 files changed, 118 insertions(+), 68 deletions(-) diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index dcdb4846c..8a725dcca 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -1,24 +1,44 @@ class BlogsController < ApplicationController before_filter :find_blog,:except => [:index,:create,:new,:set_homepage, :cancel_homepage] before_filter :find_user + include PraiseTreadHelper + def index @article = BlogComment.new - @order, @b_sort = params[:order] || 1, params[:sort] || "desc" + @order, @b_sort,@type = params[:order] || 1, params[:sort] || 2, params[:type] || 1 - sort_name = @order == 1 ? "created_on" : "" + #确定 sort_type + if @order.to_i == @type.to_i + @b_sort = @b_sort.to_i == 1 ? 2 : 1 + else + @b_sort = 1 + end + sort_name = "updated_on" - @topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.#{sort_name} #{@b_sort}") + sort_type = @b_sort == 1 ? "desc" : "asc" + + @topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.#{sort_name} #{sort_type}") + + #根据 赞+回复数排序 + if @order.to_i == 2 + @type = 2 + @b_sort == 1 ? @topics = @topics.sort{|x,y| get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) <=> get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) } : @topics = @topics.sort{|x,y| get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) <=> get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) } + else + @type = 1 + end #分页 - - @topics = paginateHelper @topics,10 - @page = (params['page'] || 1).to_i - 1 - - + @limit = 10 + @is_remote = true + @atta_count = @topics.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset + @topics = paginateHelper @topics,@limit respond_to do |format| + format.js format.html {render :layout=>'new_base_user'} end end diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index 7b8ccb5d3..4b733c0f9 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -1,56 +1,70 @@ -
-

博客列表

-
- 排序: +
+
+
+

博客列表

+
+ 排序: + <%= link_to "时间", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %> + <% if @type.to_i == 1 %> + <%= link_to "", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> + <%= link_to "人气", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %> + <% if @type.to_i == 2 %> + <%= link_to "", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> - - <%= link_to "时间", user_blog_sort_blog_path(:sort => @score, :order => 1, :search => " "), :class => "sortTxt", :remote => true %> - <% if @order == 1 %> - <%= link_to "", user_blog_sort_blog_path(:sort => @score, :order => 1, :search => " "), :class => "#{@score == 'desc' ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> - <% end %> - - <%= link_to "人气", user_blog_sort_blog_path(:sort => @score, :order => 2, :search => " "), :class => "sortTxt", :remote => true %> - <% if @order == 2 %> - <%= link_to "", user_blog_sort_blog_path(:sort => @score, :order => 2, :search => " "), :class => "#{@score == 'desc' ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> - <% end %> - -
-
-
- <% topics.each do |activity| %> -
    -
  • - <% if activity.parent_id.nil? %> - <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "c_red ml10" %> - <% else %> - <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "c_red ml10"%> - <% end %> - <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> - [已设为首页] - <% end %> -
  • - <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> -
  • - 发帖时间:<%= format_time(activity.created_on) %> - 更新时间:<%= format_time(activity.updated_on) %> -

    - <%= count>0 ? "(#{count})" : "" %> - 回复 - | - <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %> - -

    -
  • +
    +
+
+ <% topics.each do |activity| %> +
    +
  • + <% if activity.parent_id.nil? %> + <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl" %> + <% else %> + <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl"%> + <% end %> + <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> + [已设为首页] + <% end %> +
    +
  • + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
  • + 发帖时间:<%= format_time(activity.created_on) %> + 更新时间:<%= format_time(activity.updated_on) %> +

    + <%= count>0 ? "(#{count})" : "" %> + 回复 + | + <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %> + +

    +
  • +
    +
+ <% end %> +
+
    + <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %> +
- - <% end %> - +
-
+ \ No newline at end of file diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb index af9fc1c0f..c52fa017e 100644 --- a/app/views/blogs/_article_list.html.erb +++ b/app/views/blogs/_article_list.html.erb @@ -38,7 +38,7 @@
-
+
<%= @user.name%>的博客
diff --git a/app/views/blogs/index.js.erb b/app/views/blogs/index.js.erb index e69de29bb..6c8835f6f 100644 --- a/app/views/blogs/index.js.erb +++ b/app/views/blogs/index.js.erb @@ -0,0 +1 @@ +$("#blog-list").html('<%= escape_javascript( render :partial => 'blogs/article', :locals => {:topics => @topics} ) %>'); \ No newline at end of file diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index f3bd827a4..4e1064b7f 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -7,7 +7,7 @@ <%= csrf_meta_tag %> <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'share','new_user', 'user_leftside','prettify','users','application',:media => 'all' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'share','new_user', 'user_leftside','prettify','users',:media => 'all' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_heads %> <%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%> diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index 7aed347b0..e2268ca3b 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -22,6 +22,8 @@ $(function(){ }; var test_program = function(cb){ + $('#test-program-btn').hide() + var homework_id = $('#test-program-btn').attr('data-homework-id'); var student_work_id = $('#test-program-btn').attr('data-student-work-id'); var src = $('#program-src').val(); @@ -29,6 +31,7 @@ $(function(){ var is_test = $('input[name=is_test]').val(); if(!valid_form()){ + $('#test-program-btn').show() return; } /* @@ -83,12 +86,14 @@ $(function(){ if (r) { $(".HomeWorkCon form").submit(); } + $('#test-program-btn').show() return; } //2 超时 -2 编译错误 测试结束 if (data.status == 2 || data.status == -2 || tSeq >= tCount ){ if (typeof cb == 'function') {cb(data); return;} + $('#test-program-btn').show() return; } @@ -100,6 +105,7 @@ $(function(){ } else { alert("对不起,服务器繁忙请稍后再试!"); } + $('#test-program-btn').show() return; }); }; diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 141205078..8f72b0a52 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1499,18 +1499,19 @@ a:hover.Blue-btn{ background:#3598db; color:#fff;} .box-con-a{ width:170px; margin:0 auto; margin-top:10px;} /*博客列表界面样式*/ +a{text-decoration:none} .listbox{ width:730px; background-color:#fff; border:1px solid #ddd; padding:10px; } -.bloglistbox{ min-height:690px;} +/*.bloglistbox{ min-height:690px;}*/ .list-h2{ font-size:16px; font-weight:bold; color:#000; border-bottom:2px solid #269ac9; padding-bottom:5px;} .category{ padding:10px 0; border-bottom:1px solid #ddd;} .category a,.category span{ float:left; margin-right:5px;} .grayTxt{ color:#9093a6;} -.sortTxt{ color:#000;} -.sortTxt:hover{ color:#28be6c;} +.category a.sortTxt{ color:#9093a6;} +.category .sortTxt:hover{ color:#28be6c;} a.sortupbtn{ background: url(../images/liststyle.png) 0 3px no-repeat; width:12px; height:17px; display:block; margin-right:10px; cursor:pointer;} -a.sortdownbtn{ background: url(../images/liststyle.png) 0 -12px no-repeat; width:12px; height:17px; display:block;cursor:pointer; } +a.sortdownbtn{ background: url(../images/liststyle.png) 0 -12px no-repeat; width:12px; height:17px; display:block;margin-right:10px;cursor:pointer; } .item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;} -a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; width:708px;} +.list-file a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:635px;} a:hover.list-title{ color:#269ac9;} .c_red{ font-weight:normal; font-size:12px;} .list-file{ padding:10px 0; border-bottom:1px dashed #ddd;} @@ -1531,4 +1532,12 @@ a.messages-title{font-size:14px; font-weight: bold; color:#000;white-space:nowra a:hover.messages-title{ color:#269ac9;} .massages-content{ width:710px; color:#424242; max-height:65px; overflow:hidden; margin:10px 0;margin-left:15px; line-height:1.9;} .red-cir-btn{ background:#e74c3c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;} -.green-cir-btn{ background:#28be6c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;} \ No newline at end of file +.green-cir-btn{ background:#28be6c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;} + +/****翻页***/ +ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } +ul.wlist li{float: left;} +ul.wlist li a{ border:1px solid #15bccf; padding: 1px 4px 1px 4px; margin-left:3px;} +ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;} +/*.wlist_select { background-color:#64bdd9; color:#fff; padding: 1px 5px 0px 5px; margin-left:3px;margin-top: -2px; border:1px solid #64bdd9;}*/ +.wlist_select a{background-color: #64bdd9;cursor: default;} \ No newline at end of file From f6a5ffc6a5e5d9cfb7735665f1ade898b9e9c799 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 22 Apr 2016 14:13:24 +0800 Subject: [PATCH 286/507] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E7=82=B9=E5=87=BB=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E7=84=B6=E5=90=8E=E6=8C=89=E9=92=AE=E6=B6=88=E5=A4=B1=E7=AD=89?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E8=BF=94=E5=9B=9E=E6=89=8D=E5=87=BA=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/new_user_commit_homework.html.erb | 2 +- public/javascripts/homework.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb index e84b7a95e..4d2a091eb 100644 --- a/app/views/users/new_user_commit_homework.html.erb +++ b/app/views/users/new_user_commit_homework.html.erb @@ -107,7 +107,7 @@
测试代码 <% if @is_test %> - <%=link_to '返 回',homework_common_index_path(:course => @course.id),:class=>'fr mt6' %> + <%=link_to '返 回',homework_common_index_path(:course => @course.id),:class=>'fr mt6',:style =>'line-height:30px;' %> <% else @is_test %> 提交代码 <% end %> diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index 7aed347b0..391774f0b 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -22,6 +22,7 @@ $(function(){ }; var test_program = function(cb){ + $('#test-program-btn').hide(); var homework_id = $('#test-program-btn').attr('data-homework-id'); var student_work_id = $('#test-program-btn').attr('data-student-work-id'); var src = $('#program-src').val(); @@ -29,6 +30,7 @@ $(function(){ var is_test = $('input[name=is_test]').val(); if(!valid_form()){ + $('#test-program-btn').show(); return; } /* @@ -78,17 +80,19 @@ $(function(){ $('.ProResult').prepend(html); if (data.status==0 && is_test != 'true') { - if (typeof cb == 'function') {cb(data); return;} + if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); return;} var r=confirm("答题正确,是否立刻提交?"); if (r) { $(".HomeWorkCon form").submit(); } + $('#test-program-btn').show(); return; } //2 超时 -2 编译错误 测试结束 if (data.status == 2 || data.status == -2 || tSeq >= tCount ){ - if (typeof cb == 'function') {cb(data); return;} + if (typeof cb == 'function') {cb(data);$('#test-program-btn').show(); return;} + $('#test-program-btn').show(); return; } @@ -100,6 +104,7 @@ $(function(){ } else { alert("对不起,服务器繁忙请稍后再试!"); } + $('#test-program-btn').show(); return; }); }; From a985f6fee1a8333b5419fa9c7c931a63f2c9315d Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 Apr 2016 14:14:21 +0800 Subject: [PATCH 287/507] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E5=B8=96=E5=AD=90/?= =?UTF-8?q?=E5=9B=9E=E5=B8=96=E4=B8=8D=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/message.rb b/app/models/message.rb index 58b0c1b9e..9a32dc590 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -83,7 +83,7 @@ class Message < ActiveRecord::Base # after_create :add_author_as_watcher, :reset_counters!, :add_boards_count after_update :update_messages_board, :update_activity after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score - after_create :act_as_course_activity, :act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count + after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count #before_save :be_user_score scope :visible, lambda {|*args| From e2b18b3f4804c56eb5a2b4c43ad5059eab575a48 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 22 Apr 2016 16:32:59 +0800 Subject: [PATCH 288/507] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 28e2e192b..34bce7236 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -78,9 +78,9 @@ class HomeworkCommonController < ApplicationController @homework.course_id = params[:course_id] if params[:homework_common][:anonymous_comment] && params[:homework_common][:anonymous_comment] != @homework.anonymous_comment if @homework.anonymous_comment == 1 - homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 1.0 : 0.4 + homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 1.0 : 0.4 else - homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 + homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 0.6 : 0.3 end end From dcb150559e1bf6a4ae1882dd71ba0c2f0097a1da Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 22 Apr 2016 16:37:01 +0800 Subject: [PATCH 289/507] =?UTF-8?q?angularjs=E8=B7=AF=E5=BE=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1234567 | 2 +- public/assets/wechat/app.html | 8 +- public/javascripts/wechat/angular-cookies.js | 321 + public/javascripts/wechat/angular-route.js | 991 + .../wechat/angular-sanitize.min.js | 16 + public/javascripts/wechat/angular.js | 28826 ++++++++++++++++ public/stylesheets/weui/weixin.css | 2 +- 7 files changed, 30160 insertions(+), 6 deletions(-) create mode 100644 public/javascripts/wechat/angular-cookies.js create mode 100644 public/javascripts/wechat/angular-route.js create mode 100644 public/javascripts/wechat/angular-sanitize.min.js create mode 100644 public/javascripts/wechat/angular.js diff --git a/1234567 b/1234567 index 327c92785..198a53918 100644 --- a/1234567 +++ b/1234567 @@ -1 +1 @@ -{"access_token":"x7GUTe-MLoVPMzId82-3VSdCsO6sq5cOJZCmIN-yUjDcohfI00t2lzPkNKdRhETLUBptZRQ--v-IBQTG-o5iRZZv-EelOBX7K96DcPMFt9rdzwNu7XerNnZw_ncGYncSLHXeACAQMC","expires_in":7200,"got_token_at":1461133885} \ No newline at end of file +{"access_token":"GrEg56Sg5QRM7IXghWlaDzNd-7iaQsqX2acszXkSTFwOh_OxtN_UNIJsj9rlSZeSkZSofQwd0KvFGv_StzARHeLw81JllcI3a3VuXgZ_cjbQnM3m00g0HiLtTniQFsEIUVIdABAPQD","expires_in":7200,"got_token_at":1461314104} \ No newline at end of file diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index 187439468..7caa318b6 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -22,10 +22,10 @@
- - - - + + + + diff --git a/public/javascripts/wechat/angular-cookies.js b/public/javascripts/wechat/angular-cookies.js new file mode 100644 index 000000000..848e0932d --- /dev/null +++ b/public/javascripts/wechat/angular-cookies.js @@ -0,0 +1,321 @@ +/** + * @license AngularJS v1.4.6 + * (c) 2010-2015 Google, Inc. http://angularjs.org + * License: MIT + */ +(function(window, angular, undefined) {'use strict'; + +/** + * @ngdoc module + * @name ngCookies + * @description + * + * # ngCookies + * + * The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies. + * + * + *
+ * + * See {@link ngCookies.$cookies `$cookies`} for usage. + */ + + +angular.module('ngCookies', ['ng']). + /** + * @ngdoc provider + * @name $cookiesProvider + * @description + * Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service. + * */ + provider('$cookies', [function $CookiesProvider() { + /** + * @ngdoc property + * @name $cookiesProvider#defaults + * @description + * + * Object containing default options to pass when setting cookies. + * + * The object may have following properties: + * + * - **path** - `{string}` - The cookie will be available only for this path and its + * sub-paths. By default, this would be the URL that appears in your base tag. + * - **domain** - `{string}` - The cookie will be available only for this domain and + * its sub-domains. For obvious security reasons the user agent will not accept the + * cookie if the current domain is not a sub domain or equals to the requested domain. + * - **expires** - `{string|Date}` - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" + * or a Date object indicating the exact date/time this cookie will expire. + * - **secure** - `{boolean}` - The cookie will be available only in secured connection. + * + * Note: by default the address that appears in your `` tag will be used as path. + * This is important so that cookies will be visible for all routes in case html5mode is enabled + * + **/ + var defaults = this.defaults = {}; + + function calcOptions(options) { + return options ? angular.extend({}, defaults, options) : defaults; + } + + /** + * @ngdoc service + * @name $cookies + * + * @description + * Provides read/write access to browser's cookies. + * + *
+ * Up until Angular 1.3, `$cookies` exposed properties that represented the + * current browser cookie values. In version 1.4, this behavior has changed, and + * `$cookies` now provides a standard api of getters, setters etc. + *
+ * + * Requires the {@link ngCookies `ngCookies`} module to be installed. + * + * @example + * + * ```js + * angular.module('cookiesExample', ['ngCookies']) + * .controller('ExampleController', ['$cookies', function($cookies) { + * // Retrieving a cookie + * var favoriteCookie = $cookies.get('myFavorite'); + * // Setting a cookie + * $cookies.put('myFavorite', 'oatmeal'); + * }]); + * ``` + */ + this.$get = ['$$cookieReader', '$$cookieWriter', function($$cookieReader, $$cookieWriter) { + return { + /** + * @ngdoc method + * @name $cookies#get + * + * @description + * Returns the value of given cookie key + * + * @param {string} key Id to use for lookup. + * @returns {string} Raw cookie value. + */ + get: function(key) { + return $$cookieReader()[key]; + }, + + /** + * @ngdoc method + * @name $cookies#getObject + * + * @description + * Returns the deserialized value of given cookie key + * + * @param {string} key Id to use for lookup. + * @returns {Object} Deserialized cookie value. + */ + getObject: function(key) { + var value = this.get(key); + return value ? angular.fromJson(value) : value; + }, + + /** + * @ngdoc method + * @name $cookies#getAll + * + * @description + * Returns a key value object with all the cookies + * + * @returns {Object} All cookies + */ + getAll: function() { + return $$cookieReader(); + }, + + /** + * @ngdoc method + * @name $cookies#put + * + * @description + * Sets a value for given cookie key + * + * @param {string} key Id for the `value`. + * @param {string} value Raw value to be stored. + * @param {Object=} options Options object. + * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} + */ + put: function(key, value, options) { + $$cookieWriter(key, value, calcOptions(options)); + }, + + /** + * @ngdoc method + * @name $cookies#putObject + * + * @description + * Serializes and sets a value for given cookie key + * + * @param {string} key Id for the `value`. + * @param {Object} value Value to be stored. + * @param {Object=} options Options object. + * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} + */ + putObject: function(key, value, options) { + this.put(key, angular.toJson(value), options); + }, + + /** + * @ngdoc method + * @name $cookies#remove + * + * @description + * Remove given cookie + * + * @param {string} key Id of the key-value pair to delete. + * @param {Object=} options Options object. + * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} + */ + remove: function(key, options) { + $$cookieWriter(key, undefined, calcOptions(options)); + } + }; + }]; + }]); + +angular.module('ngCookies'). +/** + * @ngdoc service + * @name $cookieStore + * @deprecated + * @requires $cookies + * + * @description + * Provides a key-value (string-object) storage, that is backed by session cookies. + * Objects put or retrieved from this storage are automatically serialized or + * deserialized by angular's toJson/fromJson. + * + * Requires the {@link ngCookies `ngCookies`} module to be installed. + * + *
+ * **Note:** The $cookieStore service is **deprecated**. + * Please use the {@link ngCookies.$cookies `$cookies`} service instead. + *
+ * + * @example + * + * ```js + * angular.module('cookieStoreExample', ['ngCookies']) + * .controller('ExampleController', ['$cookieStore', function($cookieStore) { + * // Put cookie + * $cookieStore.put('myFavorite','oatmeal'); + * // Get cookie + * var favoriteCookie = $cookieStore.get('myFavorite'); + * // Removing a cookie + * $cookieStore.remove('myFavorite'); + * }]); + * ``` + */ + factory('$cookieStore', ['$cookies', function($cookies) { + + return { + /** + * @ngdoc method + * @name $cookieStore#get + * + * @description + * Returns the value of given cookie key + * + * @param {string} key Id to use for lookup. + * @returns {Object} Deserialized cookie value, undefined if the cookie does not exist. + */ + get: function(key) { + return $cookies.getObject(key); + }, + + /** + * @ngdoc method + * @name $cookieStore#put + * + * @description + * Sets a value for given cookie key + * + * @param {string} key Id for the `value`. + * @param {Object} value Value to be stored. + */ + put: function(key, value) { + $cookies.putObject(key, value); + }, + + /** + * @ngdoc method + * @name $cookieStore#remove + * + * @description + * Remove given cookie + * + * @param {string} key Id of the key-value pair to delete. + */ + remove: function(key) { + $cookies.remove(key); + } + }; + + }]); + +/** + * @name $$cookieWriter + * @requires $document + * + * @description + * This is a private service for writing cookies + * + * @param {string} name Cookie name + * @param {string=} value Cookie value (if undefined, cookie will be deleted) + * @param {Object=} options Object with options that need to be stored for the cookie. + */ +function $$CookieWriter($document, $log, $browser) { + var cookiePath = $browser.baseHref(); + var rawDocument = $document[0]; + + function buildCookieString(name, value, options) { + var path, expires; + options = options || {}; + expires = options.expires; + path = angular.isDefined(options.path) ? options.path : cookiePath; + if (angular.isUndefined(value)) { + expires = 'Thu, 01 Jan 1970 00:00:00 GMT'; + value = ''; + } + if (angular.isString(expires)) { + expires = new Date(expires); + } + + var str = encodeURIComponent(name) + '=' + encodeURIComponent(value); + str += path ? ';path=' + path : ''; + str += options.domain ? ';domain=' + options.domain : ''; + str += expires ? ';expires=' + expires.toUTCString() : ''; + str += options.secure ? ';secure' : ''; + + // per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum: + // - 300 cookies + // - 20 cookies per unique domain + // - 4096 bytes per cookie + var cookieLength = str.length + 1; + if (cookieLength > 4096) { + $log.warn("Cookie '" + name + + "' possibly not set or overflowed because it was too large (" + + cookieLength + " > 4096 bytes)!"); + } + + return str; + } + + return function(name, value, options) { + rawDocument.cookie = buildCookieString(name, value, options); + }; +} + +$$CookieWriter.$inject = ['$document', '$log', '$browser']; + +angular.module('ngCookies').provider('$$cookieWriter', function $$CookieWriterProvider() { + this.$get = $$CookieWriter; +}); + + +})(window, window.angular); diff --git a/public/javascripts/wechat/angular-route.js b/public/javascripts/wechat/angular-route.js new file mode 100644 index 000000000..09c8a20bc --- /dev/null +++ b/public/javascripts/wechat/angular-route.js @@ -0,0 +1,991 @@ +/** + * @license AngularJS v1.4.6 + * (c) 2010-2015 Google, Inc. http://angularjs.org + * License: MIT + */ +(function(window, angular, undefined) {'use strict'; + +/** + * @ngdoc module + * @name ngRoute + * @description + * + * # ngRoute + * + * The `ngRoute` module provides routing and deeplinking services and directives for angular apps. + * + * ## Example + * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. + * + * + *
+ */ + /* global -ngRouteModule */ +var ngRouteModule = angular.module('ngRoute', ['ng']). + provider('$route', $RouteProvider), + $routeMinErr = angular.$$minErr('ngRoute'); + +/** + * @ngdoc provider + * @name $routeProvider + * + * @description + * + * Used for configuring routes. + * + * ## Example + * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. + * + * ## Dependencies + * Requires the {@link ngRoute `ngRoute`} module to be installed. + */ +function $RouteProvider() { + function inherit(parent, extra) { + return angular.extend(Object.create(parent), extra); + } + + var routes = {}; + + /** + * @ngdoc method + * @name $routeProvider#when + * + * @param {string} path Route path (matched against `$location.path`). If `$location.path` + * contains redundant trailing slash or is missing one, the route will still match and the + * `$location.path` will be updated to add or drop the trailing slash to exactly match the + * route definition. + * + * * `path` can contain named groups starting with a colon: e.g. `:name`. All characters up + * to the next slash are matched and stored in `$routeParams` under the given `name` + * when the route matches. + * * `path` can contain named groups starting with a colon and ending with a star: + * e.g.`:name*`. All characters are eagerly stored in `$routeParams` under the given `name` + * when the route matches. + * * `path` can contain optional named groups with a question mark: e.g.`:name?`. + * + * For example, routes like `/color/:color/largecode/:largecode*\/edit` will match + * `/color/brown/largecode/code/with/slashes/edit` and extract: + * + * * `color: brown` + * * `largecode: code/with/slashes`. + * + * + * @param {Object} route Mapping information to be assigned to `$route.current` on route + * match. + * + * Object properties: + * + * - `controller` – `{(string|function()=}` – Controller fn that should be associated with + * newly created scope or the name of a {@link angular.Module#controller registered + * controller} if passed as a string. + * - `controllerAs` – `{string=}` – An identifier name for a reference to the controller. + * If present, the controller will be published to scope under the `controllerAs` name. + * - `template` – `{string=|function()=}` – html template as a string or a function that + * returns an html template as a string which should be used by {@link + * ngRoute.directive:ngView ngView} or {@link ng.directive:ngInclude ngInclude} directives. + * This property takes precedence over `templateUrl`. + * + * If `template` is a function, it will be called with the following parameters: + * + * - `{Array.}` - route parameters extracted from the current + * `$location.path()` by applying the current route + * + * - `templateUrl` – `{string=|function()=}` – path or function that returns a path to an html + * template that should be used by {@link ngRoute.directive:ngView ngView}. + * + * If `templateUrl` is a function, it will be called with the following parameters: + * + * - `{Array.}` - route parameters extracted from the current + * `$location.path()` by applying the current route + * + * - `resolve` - `{Object.=}` - An optional map of dependencies which should + * be injected into the controller. If any of these dependencies are promises, the router + * will wait for them all to be resolved or one to be rejected before the controller is + * instantiated. + * If all the promises are resolved successfully, the values of the resolved promises are + * injected and {@link ngRoute.$route#$routeChangeSuccess $routeChangeSuccess} event is + * fired. If any of the promises are rejected the + * {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired. The map object + * is: + * + * - `key` – `{string}`: a name of a dependency to be injected into the controller. + * - `factory` - `{string|function}`: If `string` then it is an alias for a service. + * Otherwise if function, then it is {@link auto.$injector#invoke injected} + * and the return value is treated as the dependency. If the result is a promise, it is + * resolved before its value is injected into the controller. Be aware that + * `ngRoute.$routeParams` will still refer to the previous route within these resolve + * functions. Use `$route.current.params` to access the new route parameters, instead. + * + * - `redirectTo` – {(string|function())=} – value to update + * {@link ng.$location $location} path with and trigger route redirection. + * + * If `redirectTo` is a function, it will be called with the following parameters: + * + * - `{Object.}` - route parameters extracted from the current + * `$location.path()` by applying the current route templateUrl. + * - `{string}` - current `$location.path()` + * - `{Object}` - current `$location.search()` + * + * The custom `redirectTo` function is expected to return a string which will be used + * to update `$location.path()` and `$location.search()`. + * + * - `[reloadOnSearch=true]` - {boolean=} - reload route when only `$location.search()` + * or `$location.hash()` changes. + * + * If the option is set to `false` and url in the browser changes, then + * `$routeUpdate` event is broadcasted on the root scope. + * + * - `[caseInsensitiveMatch=false]` - {boolean=} - match routes without being case sensitive + * + * If the option is set to `true`, then the particular route can be matched without being + * case sensitive + * + * @returns {Object} self + * + * @description + * Adds a new route definition to the `$route` service. + */ + this.when = function(path, route) { + //copy original route object to preserve params inherited from proto chain + var routeCopy = angular.copy(route); + if (angular.isUndefined(routeCopy.reloadOnSearch)) { + routeCopy.reloadOnSearch = true; + } + if (angular.isUndefined(routeCopy.caseInsensitiveMatch)) { + routeCopy.caseInsensitiveMatch = this.caseInsensitiveMatch; + } + routes[path] = angular.extend( + routeCopy, + path && pathRegExp(path, routeCopy) + ); + + // create redirection for trailing slashes + if (path) { + var redirectPath = (path[path.length - 1] == '/') + ? path.substr(0, path.length - 1) + : path + '/'; + + routes[redirectPath] = angular.extend( + {redirectTo: path}, + pathRegExp(redirectPath, routeCopy) + ); + } + + return this; + }; + + /** + * @ngdoc property + * @name $routeProvider#caseInsensitiveMatch + * @description + * + * A boolean property indicating if routes defined + * using this provider should be matched using a case insensitive + * algorithm. Defaults to `false`. + */ + this.caseInsensitiveMatch = false; + + /** + * @param path {string} path + * @param opts {Object} options + * @return {?Object} + * + * @description + * Normalizes the given path, returning a regular expression + * and the original path. + * + * Inspired by pathRexp in visionmedia/express/lib/utils.js. + */ + function pathRegExp(path, opts) { + var insensitive = opts.caseInsensitiveMatch, + ret = { + originalPath: path, + regexp: path + }, + keys = ret.keys = []; + + path = path + .replace(/([().])/g, '\\$1') + .replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option) { + var optional = option === '?' ? option : null; + var star = option === '*' ? option : null; + keys.push({ name: key, optional: !!optional }); + slash = slash || ''; + return '' + + (optional ? '' : slash) + + '(?:' + + (optional ? slash : '') + + (star && '(.+?)' || '([^/]+)') + + (optional || '') + + ')' + + (optional || ''); + }) + .replace(/([\/$\*])/g, '\\$1'); + + ret.regexp = new RegExp('^' + path + '$', insensitive ? 'i' : ''); + return ret; + } + + /** + * @ngdoc method + * @name $routeProvider#otherwise + * + * @description + * Sets route definition that will be used on route change when no other route definition + * is matched. + * + * @param {Object|string} params Mapping information to be assigned to `$route.current`. + * If called with a string, the value maps to `redirectTo`. + * @returns {Object} self + */ + this.otherwise = function(params) { + if (typeof params === 'string') { + params = {redirectTo: params}; + } + this.when(null, params); + return this; + }; + + + this.$get = ['$rootScope', + '$location', + '$routeParams', + '$q', + '$injector', + '$templateRequest', + '$sce', + function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce) { + + /** + * @ngdoc service + * @name $route + * @requires $location + * @requires $routeParams + * + * @property {Object} current Reference to the current route definition. + * The route definition contains: + * + * - `controller`: The controller constructor as define in route definition. + * - `locals`: A map of locals which is used by {@link ng.$controller $controller} service for + * controller instantiation. The `locals` contain + * the resolved values of the `resolve` map. Additionally the `locals` also contain: + * + * - `$scope` - The current route scope. + * - `$template` - The current route template HTML. + * + * @property {Object} routes Object with all route configuration Objects as its properties. + * + * @description + * `$route` is used for deep-linking URLs to controllers and views (HTML partials). + * It watches `$location.url()` and tries to map the path to an existing route definition. + * + * Requires the {@link ngRoute `ngRoute`} module to be installed. + * + * You can define routes through {@link ngRoute.$routeProvider $routeProvider}'s API. + * + * The `$route` service is typically used in conjunction with the + * {@link ngRoute.directive:ngView `ngView`} directive and the + * {@link ngRoute.$routeParams `$routeParams`} service. + * + * @example + * This example shows how changing the URL hash causes the `$route` to match a route against the + * URL, and the `ngView` pulls in the partial. + * + * + * + *
+ * Choose: + * Moby | + * Moby: Ch1 | + * Gatsby | + * Gatsby: Ch4 | + * Scarlet Letter
+ * + *
+ * + *
+ * + *
$location.path() = {{$location.path()}}
+ *
$route.current.templateUrl = {{$route.current.templateUrl}}
+ *
$route.current.params = {{$route.current.params}}
+ *
$route.current.scope.name = {{$route.current.scope.name}}
+ *
$routeParams = {{$routeParams}}
+ *
+ *
+ * + * + * controller: {{name}}
+ * Book Id: {{params.bookId}}
+ *
+ * + * + * controller: {{name}}
+ * Book Id: {{params.bookId}}
+ * Chapter Id: {{params.chapterId}} + *
+ * + * + * angular.module('ngRouteExample', ['ngRoute']) + * + * .controller('MainController', function($scope, $route, $routeParams, $location) { + * $scope.$route = $route; + * $scope.$location = $location; + * $scope.$routeParams = $routeParams; + * }) + * + * .controller('BookController', function($scope, $routeParams) { + * $scope.name = "BookController"; + * $scope.params = $routeParams; + * }) + * + * .controller('ChapterController', function($scope, $routeParams) { + * $scope.name = "ChapterController"; + * $scope.params = $routeParams; + * }) + * + * .config(function($routeProvider, $locationProvider) { + * $routeProvider + * .when('/Book/:bookId', { + * templateUrl: 'book.html', + * controller: 'BookController', + * resolve: { + * // I will cause a 1 second delay + * delay: function($q, $timeout) { + * var delay = $q.defer(); + * $timeout(delay.resolve, 1000); + * return delay.promise; + * } + * } + * }) + * .when('/Book/:bookId/ch/:chapterId', { + * templateUrl: 'chapter.html', + * controller: 'ChapterController' + * }); + * + * // configure html5 to get links working on jsfiddle + * $locationProvider.html5Mode(true); + * }); + * + * + * + * + * it('should load and compile correct template', function() { + * element(by.linkText('Moby: Ch1')).click(); + * var content = element(by.css('[ng-view]')).getText(); + * expect(content).toMatch(/controller\: ChapterController/); + * expect(content).toMatch(/Book Id\: Moby/); + * expect(content).toMatch(/Chapter Id\: 1/); + * + * element(by.partialLinkText('Scarlet')).click(); + * + * content = element(by.css('[ng-view]')).getText(); + * expect(content).toMatch(/controller\: BookController/); + * expect(content).toMatch(/Book Id\: Scarlet/); + * }); + * + *
+ */ + + /** + * @ngdoc event + * @name $route#$routeChangeStart + * @eventType broadcast on root scope + * @description + * Broadcasted before a route change. At this point the route services starts + * resolving all of the dependencies needed for the route change to occur. + * Typically this involves fetching the view template as well as any dependencies + * defined in `resolve` route property. Once all of the dependencies are resolved + * `$routeChangeSuccess` is fired. + * + * The route change (and the `$location` change that triggered it) can be prevented + * by calling `preventDefault` method of the event. See {@link ng.$rootScope.Scope#$on} + * for more details about event object. + * + * @param {Object} angularEvent Synthetic event object. + * @param {Route} next Future route information. + * @param {Route} current Current route information. + */ + + /** + * @ngdoc event + * @name $route#$routeChangeSuccess + * @eventType broadcast on root scope + * @description + * Broadcasted after a route change has happened successfully. + * The `resolve` dependencies are now available in the `current.locals` property. + * + * {@link ngRoute.directive:ngView ngView} listens for the directive + * to instantiate the controller and render the view. + * + * @param {Object} angularEvent Synthetic event object. + * @param {Route} current Current route information. + * @param {Route|Undefined} previous Previous route information, or undefined if current is + * first route entered. + */ + + /** + * @ngdoc event + * @name $route#$routeChangeError + * @eventType broadcast on root scope + * @description + * Broadcasted if any of the resolve promises are rejected. + * + * @param {Object} angularEvent Synthetic event object + * @param {Route} current Current route information. + * @param {Route} previous Previous route information. + * @param {Route} rejection Rejection of the promise. Usually the error of the failed promise. + */ + + /** + * @ngdoc event + * @name $route#$routeUpdate + * @eventType broadcast on root scope + * @description + * The `reloadOnSearch` property has been set to false, and we are reusing the same + * instance of the Controller. + * + * @param {Object} angularEvent Synthetic event object + * @param {Route} current Current/previous route information. + */ + + var forceReload = false, + preparedRoute, + preparedRouteIsUpdateOnly, + $route = { + routes: routes, + + /** + * @ngdoc method + * @name $route#reload + * + * @description + * Causes `$route` service to reload the current route even if + * {@link ng.$location $location} hasn't changed. + * + * As a result of that, {@link ngRoute.directive:ngView ngView} + * creates new scope and reinstantiates the controller. + */ + reload: function() { + forceReload = true; + $rootScope.$evalAsync(function() { + // Don't support cancellation of a reload for now... + prepareRoute(); + commitRoute(); + }); + }, + + /** + * @ngdoc method + * @name $route#updateParams + * + * @description + * Causes `$route` service to update the current URL, replacing + * current route parameters with those specified in `newParams`. + * Provided property names that match the route's path segment + * definitions will be interpolated into the location's path, while + * remaining properties will be treated as query params. + * + * @param {!Object} newParams mapping of URL parameter names to values + */ + updateParams: function(newParams) { + if (this.current && this.current.$$route) { + newParams = angular.extend({}, this.current.params, newParams); + $location.path(interpolate(this.current.$$route.originalPath, newParams)); + // interpolate modifies newParams, only query params are left + $location.search(newParams); + } else { + throw $routeMinErr('norout', 'Tried updating route when with no current route'); + } + } + }; + + $rootScope.$on('$locationChangeStart', prepareRoute); + $rootScope.$on('$locationChangeSuccess', commitRoute); + + return $route; + + ///////////////////////////////////////////////////// + + /** + * @param on {string} current url + * @param route {Object} route regexp to match the url against + * @return {?Object} + * + * @description + * Check if the route matches the current url. + * + * Inspired by match in + * visionmedia/express/lib/router/router.js. + */ + function switchRouteMatcher(on, route) { + var keys = route.keys, + params = {}; + + if (!route.regexp) return null; + + var m = route.regexp.exec(on); + if (!m) return null; + + for (var i = 1, len = m.length; i < len; ++i) { + var key = keys[i - 1]; + + var val = m[i]; + + if (key && val) { + params[key.name] = val; + } + } + return params; + } + + function prepareRoute($locationEvent) { + var lastRoute = $route.current; + + preparedRoute = parseRoute(); + preparedRouteIsUpdateOnly = preparedRoute && lastRoute && preparedRoute.$$route === lastRoute.$$route + && angular.equals(preparedRoute.pathParams, lastRoute.pathParams) + && !preparedRoute.reloadOnSearch && !forceReload; + + if (!preparedRouteIsUpdateOnly && (lastRoute || preparedRoute)) { + if ($rootScope.$broadcast('$routeChangeStart', preparedRoute, lastRoute).defaultPrevented) { + if ($locationEvent) { + $locationEvent.preventDefault(); + } + } + } + } + + function commitRoute() { + var lastRoute = $route.current; + var nextRoute = preparedRoute; + + if (preparedRouteIsUpdateOnly) { + lastRoute.params = nextRoute.params; + angular.copy(lastRoute.params, $routeParams); + $rootScope.$broadcast('$routeUpdate', lastRoute); + } else if (nextRoute || lastRoute) { + forceReload = false; + $route.current = nextRoute; + if (nextRoute) { + if (nextRoute.redirectTo) { + if (angular.isString(nextRoute.redirectTo)) { + $location.path(interpolate(nextRoute.redirectTo, nextRoute.params)).search(nextRoute.params) + .replace(); + } else { + $location.url(nextRoute.redirectTo(nextRoute.pathParams, $location.path(), $location.search())) + .replace(); + } + } + } + + $q.when(nextRoute). + then(function() { + if (nextRoute) { + var locals = angular.extend({}, nextRoute.resolve), + template, templateUrl; + + angular.forEach(locals, function(value, key) { + locals[key] = angular.isString(value) ? + $injector.get(value) : $injector.invoke(value, null, null, key); + }); + + if (angular.isDefined(template = nextRoute.template)) { + if (angular.isFunction(template)) { + template = template(nextRoute.params); + } + } else if (angular.isDefined(templateUrl = nextRoute.templateUrl)) { + if (angular.isFunction(templateUrl)) { + templateUrl = templateUrl(nextRoute.params); + } + if (angular.isDefined(templateUrl)) { + nextRoute.loadedTemplateUrl = $sce.valueOf(templateUrl); + template = $templateRequest(templateUrl); + } + } + if (angular.isDefined(template)) { + locals['$template'] = template; + } + return $q.all(locals); + } + }). + then(function(locals) { + // after route change + if (nextRoute == $route.current) { + if (nextRoute) { + nextRoute.locals = locals; + angular.copy(nextRoute.params, $routeParams); + } + $rootScope.$broadcast('$routeChangeSuccess', nextRoute, lastRoute); + } + }, function(error) { + if (nextRoute == $route.current) { + $rootScope.$broadcast('$routeChangeError', nextRoute, lastRoute, error); + } + }); + } + } + + + /** + * @returns {Object} the current active route, by matching it against the URL + */ + function parseRoute() { + // Match a route + var params, match; + angular.forEach(routes, function(route, path) { + if (!match && (params = switchRouteMatcher($location.path(), route))) { + match = inherit(route, { + params: angular.extend({}, $location.search(), params), + pathParams: params}); + match.$$route = route; + } + }); + // No route matched; fallback to "otherwise" route + return match || routes[null] && inherit(routes[null], {params: {}, pathParams:{}}); + } + + /** + * @returns {string} interpolation of the redirect path with the parameters + */ + function interpolate(string, params) { + var result = []; + angular.forEach((string || '').split(':'), function(segment, i) { + if (i === 0) { + result.push(segment); + } else { + var segmentMatch = segment.match(/(\w+)(?:[?*])?(.*)/); + var key = segmentMatch[1]; + result.push(params[key]); + result.push(segmentMatch[2] || ''); + delete params[key]; + } + }); + return result.join(''); + } + }]; +} + +ngRouteModule.provider('$routeParams', $RouteParamsProvider); + + +/** + * @ngdoc service + * @name $routeParams + * @requires $route + * + * @description + * The `$routeParams` service allows you to retrieve the current set of route parameters. + * + * Requires the {@link ngRoute `ngRoute`} module to be installed. + * + * The route parameters are a combination of {@link ng.$location `$location`}'s + * {@link ng.$location#search `search()`} and {@link ng.$location#path `path()`}. + * The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched. + * + * In case of parameter name collision, `path` params take precedence over `search` params. + * + * The service guarantees that the identity of the `$routeParams` object will remain unchanged + * (but its properties will likely change) even when a route change occurs. + * + * Note that the `$routeParams` are only updated *after* a route change completes successfully. + * This means that you cannot rely on `$routeParams` being correct in route resolve functions. + * Instead you can use `$route.current.params` to access the new route's parameters. + * + * @example + * ```js + * // Given: + * // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby + * // Route: /Chapter/:chapterId/Section/:sectionId + * // + * // Then + * $routeParams ==> {chapterId:'1', sectionId:'2', search:'moby'} + * ``` + */ +function $RouteParamsProvider() { + this.$get = function() { return {}; }; +} + +ngRouteModule.directive('ngView', ngViewFactory); +ngRouteModule.directive('ngView', ngViewFillContentFactory); + + +/** + * @ngdoc directive + * @name ngView + * @restrict ECA + * + * @description + * # Overview + * `ngView` is a directive that complements the {@link ngRoute.$route $route} service by + * including the rendered template of the current route into the main layout (`index.html`) file. + * Every time the current route changes, the included view changes with it according to the + * configuration of the `$route` service. + * + * Requires the {@link ngRoute `ngRoute`} module to be installed. + * + * @animations + * enter - animation is used to bring new content into the browser. + * leave - animation is used to animate existing content away. + * + * The enter and leave animation occur concurrently. + * + * @scope + * @priority 400 + * @param {string=} onload Expression to evaluate whenever the view updates. + * + * @param {string=} autoscroll Whether `ngView` should call {@link ng.$anchorScroll + * $anchorScroll} to scroll the viewport after the view is updated. + * + * - If the attribute is not set, disable scrolling. + * - If the attribute is set without value, enable scrolling. + * - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated + * as an expression yields a truthy value. + * @example + + +
+ Choose: + Moby | + Moby: Ch1 | + Gatsby | + Gatsby: Ch4 | + Scarlet Letter
+ +
+
+
+
+ +
$location.path() = {{main.$location.path()}}
+
$route.current.templateUrl = {{main.$route.current.templateUrl}}
+
$route.current.params = {{main.$route.current.params}}
+
$routeParams = {{main.$routeParams}}
+
+
+ + +
+ controller: {{book.name}}
+ Book Id: {{book.params.bookId}}
+
+
+ + +
+ controller: {{chapter.name}}
+ Book Id: {{chapter.params.bookId}}
+ Chapter Id: {{chapter.params.chapterId}} +
+
+ + + .view-animate-container { + position:relative; + height:100px!important; + background:white; + border:1px solid black; + height:40px; + overflow:hidden; + } + + .view-animate { + padding:10px; + } + + .view-animate.ng-enter, .view-animate.ng-leave { + transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s; + + display:block; + width:100%; + border-left:1px solid black; + + position:absolute; + top:0; + left:0; + right:0; + bottom:0; + padding:10px; + } + + .view-animate.ng-enter { + left:100%; + } + .view-animate.ng-enter.ng-enter-active { + left:0; + } + .view-animate.ng-leave.ng-leave-active { + left:-100%; + } + + + + angular.module('ngViewExample', ['ngRoute', 'ngAnimate']) + .config(['$routeProvider', '$locationProvider', + function($routeProvider, $locationProvider) { + $routeProvider + .when('/Book/:bookId', { + templateUrl: 'book.html', + controller: 'BookCtrl', + controllerAs: 'book' + }) + .when('/Book/:bookId/ch/:chapterId', { + templateUrl: 'chapter.html', + controller: 'ChapterCtrl', + controllerAs: 'chapter' + }); + + $locationProvider.html5Mode(true); + }]) + .controller('MainCtrl', ['$route', '$routeParams', '$location', + function($route, $routeParams, $location) { + this.$route = $route; + this.$location = $location; + this.$routeParams = $routeParams; + }]) + .controller('BookCtrl', ['$routeParams', function($routeParams) { + this.name = "BookCtrl"; + this.params = $routeParams; + }]) + .controller('ChapterCtrl', ['$routeParams', function($routeParams) { + this.name = "ChapterCtrl"; + this.params = $routeParams; + }]); + + + + + it('should load and compile correct template', function() { + element(by.linkText('Moby: Ch1')).click(); + var content = element(by.css('[ng-view]')).getText(); + expect(content).toMatch(/controller\: ChapterCtrl/); + expect(content).toMatch(/Book Id\: Moby/); + expect(content).toMatch(/Chapter Id\: 1/); + + element(by.partialLinkText('Scarlet')).click(); + + content = element(by.css('[ng-view]')).getText(); + expect(content).toMatch(/controller\: BookCtrl/); + expect(content).toMatch(/Book Id\: Scarlet/); + }); + +
+ */ + + +/** + * @ngdoc event + * @name ngView#$viewContentLoaded + * @eventType emit on the current ngView scope + * @description + * Emitted every time the ngView content is reloaded. + */ +ngViewFactory.$inject = ['$route', '$anchorScroll', '$animate']; +function ngViewFactory($route, $anchorScroll, $animate) { + return { + restrict: 'ECA', + terminal: true, + priority: 400, + transclude: 'element', + link: function(scope, $element, attr, ctrl, $transclude) { + var currentScope, + currentElement, + previousLeaveAnimation, + autoScrollExp = attr.autoscroll, + onloadExp = attr.onload || ''; + + scope.$on('$routeChangeSuccess', update); + update(); + + function cleanupLastView() { + if (previousLeaveAnimation) { + $animate.cancel(previousLeaveAnimation); + previousLeaveAnimation = null; + } + + if (currentScope) { + currentScope.$destroy(); + currentScope = null; + } + if (currentElement) { + previousLeaveAnimation = $animate.leave(currentElement); + previousLeaveAnimation.then(function() { + previousLeaveAnimation = null; + }); + currentElement = null; + } + } + + function update() { + var locals = $route.current && $route.current.locals, + template = locals && locals.$template; + + if (angular.isDefined(template)) { + var newScope = scope.$new(); + var current = $route.current; + + // Note: This will also link all children of ng-view that were contained in the original + // html. If that content contains controllers, ... they could pollute/change the scope. + // However, using ng-view on an element with additional content does not make sense... + // Note: We can't remove them in the cloneAttchFn of $transclude as that + // function is called before linking the content, which would apply child + // directives to non existing elements. + var clone = $transclude(newScope, function(clone) { + $animate.enter(clone, null, currentElement || $element).then(function onNgViewEnter() { + if (angular.isDefined(autoScrollExp) + && (!autoScrollExp || scope.$eval(autoScrollExp))) { + $anchorScroll(); + } + }); + cleanupLastView(); + }); + + currentElement = clone; + currentScope = current.scope = newScope; + currentScope.$emit('$viewContentLoaded'); + currentScope.$eval(onloadExp); + } else { + cleanupLastView(); + } + } + } + }; +} + +// This directive is called during the $transclude call of the first `ngView` directive. +// It will replace and compile the content of the element with the loaded template. +// We need this directive so that the element content is already filled when +// the link function of another directive on the same element as ngView +// is called. +ngViewFillContentFactory.$inject = ['$compile', '$controller', '$route']; +function ngViewFillContentFactory($compile, $controller, $route) { + return { + restrict: 'ECA', + priority: -400, + link: function(scope, $element) { + var current = $route.current, + locals = current.locals; + + $element.html(locals.$template); + + var link = $compile($element.contents()); + + if (current.controller) { + locals.$scope = scope; + var controller = $controller(current.controller, locals); + if (current.controllerAs) { + scope[current.controllerAs] = controller; + } + $element.data('$ngControllerController', controller); + $element.children().data('$ngControllerController', controller); + } + + link(scope); + } + }; +} + + +})(window, window.angular); diff --git a/public/javascripts/wechat/angular-sanitize.min.js b/public/javascripts/wechat/angular-sanitize.min.js new file mode 100644 index 000000000..020e21aa9 --- /dev/null +++ b/public/javascripts/wechat/angular-sanitize.min.js @@ -0,0 +1,16 @@ +/* + AngularJS v1.4.6 + (c) 2010-2015 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(n,h,p){'use strict';function E(a){var f=[];r(f,h.noop).chars(a);return f.join("")}function g(a,f){var d={},c=a.split(","),b;for(b=0;b=c;d--)f.end&&f.end(e[d]);e.length=c}}"string"!==typeof a&&(a=null===a||"undefined"===typeof a?"":""+a);var b,k,e=[],m=a,l;for(e.last=function(){return e[e.length-1]};a;){l="";k=!0;if(e.last()&&w[e.last()])a=a.replace(new RegExp("([\\W\\w]*)<\\s*\\/\\s*"+e.last()+"[^>]*>","i"),function(a,b){b=b.replace(H,"$1").replace(I,"$1");f.chars&&f.chars(q(b));return""}),c("",e.last());else{if(0===a.indexOf("\x3c!--"))b=a.indexOf("--",4),0<=b&&a.lastIndexOf("--\x3e", +b)===b&&(f.comment&&f.comment(a.substring(4,b)),a=a.substring(b+3),k=!1);else if(x.test(a)){if(b=a.match(x))a=a.replace(b[0],""),k=!1}else if(J.test(a)){if(b=a.match(y))a=a.substring(b[0].length),b[0].replace(y,c),k=!1}else K.test(a)&&((b=a.match(z))?(b[4]&&(a=a.substring(b[0].length),b[0].replace(z,d)),k=!1):(l+="<",a=a.substring(1)));k&&(b=a.indexOf("<"),l+=0>b?a:a.substring(0,b),a=0>b?"":a.substring(b),f.chars&&f.chars(q(l)))}if(a==m)throw L("badparse",a);m=a}c()}function q(a){if(!a)return"";A.innerHTML= +a.replace(//g,">")}function r(a,f){var d=!1,c=h.bind(a,a.push);return{start:function(a,k,e){a=h.lowercase(a);!d&&w[a]&&(d=a);d||!0!==C[a]||(c("<"),c(a),h.forEach(k,function(d,e){var k=h.lowercase(e),g="img"===a&&"src"===k|| +"background"===k;!0!==O[k]||!0===D[k]&&!f(d,g)||(c(" "),c(e),c('="'),c(B(d)),c('"'))}),c(e?"/>":">"))},end:function(a){a=h.lowercase(a);d||!0!==C[a]||(c(""));a==d&&(d=!1)},chars:function(a){d||c(B(a))}}}var L=h.$$minErr("$sanitize"),z=/^<((?:[a-zA-Z])[\w:-]*)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*(>?)/,y=/^<\/\s*([\w:-]+)[^>]*>/,G=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,K=/^]*?)>/i, +I=/"\u201d\u2019]/i,d=/^mailto:/i;return function(c,b){function k(a){a&&g.push(E(a))}function e(a, +c){g.push("');k(c);g.push("")}if(!c)return c;for(var m,l=c,g=[],n,p;m=l.match(f);)n=m[0],m[2]||m[4]||(n=(m[3]?"http://":"mailto:")+n),p=m.index,k(l.substr(0,p)),e(n,m[0].replace(d,"")),l=l.substring(p+m[0].length);k(l);return a(g.join(""))}}])})(window,window.angular); +//# sourceMappingURL=angular-sanitize.min.js.map diff --git a/public/javascripts/wechat/angular.js b/public/javascripts/wechat/angular.js new file mode 100644 index 000000000..e5f7bd0f7 --- /dev/null +++ b/public/javascripts/wechat/angular.js @@ -0,0 +1,28826 @@ +/** + * @license AngularJS v1.4.6 + * (c) 2010-2015 Google, Inc. http://angularjs.org + * License: MIT + */ +(function(window, document, undefined) {'use strict'; + +/** + * @description + * + * This object provides a utility for producing rich Error messages within + * Angular. It can be called as follows: + * + * var exampleMinErr = minErr('example'); + * throw exampleMinErr('one', 'This {0} is {1}', foo, bar); + * + * The above creates an instance of minErr in the example namespace. The + * resulting error will have a namespaced error code of example.one. The + * resulting error will replace {0} with the value of foo, and {1} with the + * value of bar. The object is not restricted in the number of arguments it can + * take. + * + * If fewer arguments are specified than necessary for interpolation, the extra + * interpolation markers will be preserved in the final string. + * + * Since data will be parsed statically during a build step, some restrictions + * are applied with respect to how minErr instances are created and called. + * Instances should have names of the form namespaceMinErr for a minErr created + * using minErr('namespace') . Error codes, namespaces and template strings + * should all be static strings, not variables or general expressions. + * + * @param {string} module The namespace to use for the new minErr instance. + * @param {function} ErrorConstructor Custom error constructor to be instantiated when returning + * error from returned function, for cases when a particular type of error is useful. + * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance + */ + +function minErr(module, ErrorConstructor) { + ErrorConstructor = ErrorConstructor || Error; + return function() { + var SKIP_INDEXES = 2; + + var templateArgs = arguments, + code = templateArgs[0], + message = '[' + (module ? module + ':' : '') + code + '] ', + template = templateArgs[1], + paramPrefix, i; + + message += template.replace(/\{\d+\}/g, function(match) { + var index = +match.slice(1, -1), + shiftedIndex = index + SKIP_INDEXES; + + if (shiftedIndex < templateArgs.length) { + return toDebugString(templateArgs[shiftedIndex]); + } + + return match; + }); + + message += '\nhttp://errors.angularjs.org/1.4.6/' + + (module ? module + '/' : '') + code; + + for (i = SKIP_INDEXES, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') { + message += paramPrefix + 'p' + (i - SKIP_INDEXES) + '=' + + encodeURIComponent(toDebugString(templateArgs[i])); + } + + return new ErrorConstructor(message); + }; +} + +/* We need to tell jshint what variables are being exported */ +/* global angular: true, + msie: true, + jqLite: true, + jQuery: true, + slice: true, + splice: true, + push: true, + toString: true, + ngMinErr: true, + angularModule: true, + uid: true, + REGEX_STRING_REGEXP: true, + VALIDITY_STATE_PROPERTY: true, + + lowercase: true, + uppercase: true, + manualLowercase: true, + manualUppercase: true, + nodeName_: true, + isArrayLike: true, + forEach: true, + forEachSorted: true, + reverseParams: true, + nextUid: true, + setHashKey: true, + extend: true, + toInt: true, + inherit: true, + merge: true, + noop: true, + identity: true, + valueFn: true, + isUndefined: true, + isDefined: true, + isObject: true, + isBlankObject: true, + isString: true, + isNumber: true, + isDate: true, + isArray: true, + isFunction: true, + isRegExp: true, + isWindow: true, + isScope: true, + isFile: true, + isFormData: true, + isBlob: true, + isBoolean: true, + isPromiseLike: true, + trim: true, + escapeForRegexp: true, + isElement: true, + makeMap: true, + includes: true, + arrayRemove: true, + copy: true, + shallowCopy: true, + equals: true, + csp: true, + jq: true, + concat: true, + sliceArgs: true, + bind: true, + toJsonReplacer: true, + toJson: true, + fromJson: true, + convertTimezoneToLocal: true, + timezoneToOffset: true, + startingTag: true, + tryDecodeURIComponent: true, + parseKeyValue: true, + toKeyValue: true, + encodeUriSegment: true, + encodeUriQuery: true, + angularInit: true, + bootstrap: true, + getTestability: true, + snake_case: true, + bindJQuery: true, + assertArg: true, + assertArgFn: true, + assertNotHasOwnProperty: true, + getter: true, + getBlockNodes: true, + hasOwnProperty: true, + createMap: true, + + NODE_TYPE_ELEMENT: true, + NODE_TYPE_ATTRIBUTE: true, + NODE_TYPE_TEXT: true, + NODE_TYPE_COMMENT: true, + NODE_TYPE_DOCUMENT: true, + NODE_TYPE_DOCUMENT_FRAGMENT: true, +*/ + +//////////////////////////////////// + +/** + * @ngdoc module + * @name ng + * @module ng + * @description + * + * # ng (core module) + * The ng module is loaded by default when an AngularJS application is started. The module itself + * contains the essential components for an AngularJS application to function. The table below + * lists a high level breakdown of each of the services/factories, filters, directives and testing + * components available within this core module. + * + *
+ */ + +var REGEX_STRING_REGEXP = /^\/(.+)\/([a-z]*)$/; + +// The name of a form control's ValidityState property. +// This is used so that it's possible for internal tests to create mock ValidityStates. +var VALIDITY_STATE_PROPERTY = 'validity'; + +/** + * @ngdoc function + * @name angular.lowercase + * @module ng + * @kind function + * + * @description Converts the specified string to lowercase. + * @param {string} string String to be converted to lowercase. + * @returns {string} Lowercased string. + */ +var lowercase = function(string) {return isString(string) ? string.toLowerCase() : string;}; +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * @ngdoc function + * @name angular.uppercase + * @module ng + * @kind function + * + * @description Converts the specified string to uppercase. + * @param {string} string String to be converted to uppercase. + * @returns {string} Uppercased string. + */ +var uppercase = function(string) {return isString(string) ? string.toUpperCase() : string;}; + + +var manualLowercase = function(s) { + /* jshint bitwise: false */ + return isString(s) + ? s.replace(/[A-Z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) | 32);}) + : s; +}; +var manualUppercase = function(s) { + /* jshint bitwise: false */ + return isString(s) + ? s.replace(/[a-z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) & ~32);}) + : s; +}; + + +// String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish +// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods +// with correct but slower alternatives. +if ('i' !== 'I'.toLowerCase()) { + lowercase = manualLowercase; + uppercase = manualUppercase; +} + + +var + msie, // holds major version number for IE, or NaN if UA is not IE. + jqLite, // delay binding since jQuery could be loaded after us. + jQuery, // delay binding + slice = [].slice, + splice = [].splice, + push = [].push, + toString = Object.prototype.toString, + getPrototypeOf = Object.getPrototypeOf, + ngMinErr = minErr('ng'), + + /** @name angular */ + angular = window.angular || (window.angular = {}), + angularModule, + uid = 0; + +/** + * documentMode is an IE-only property + * http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx + */ +msie = document.documentMode; + + +/** + * @private + * @param {*} obj + * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, + * String ...) + */ +function isArrayLike(obj) { + if (obj == null || isWindow(obj)) { + return false; + } + + // Support: iOS 8.2 (not reproducible in simulator) + // "length" in obj used to prevent JIT error (gh-11508) + var length = "length" in Object(obj) && obj.length; + + if (obj.nodeType === NODE_TYPE_ELEMENT && length) { + return true; + } + + return isString(obj) || isArray(obj) || length === 0 || + typeof length === 'number' && length > 0 && (length - 1) in obj; +} + +/** + * @ngdoc function + * @name angular.forEach + * @module ng + * @kind function + * + * @description + * Invokes the `iterator` function once for each item in `obj` collection, which can be either an + * object or an array. The `iterator` function is invoked with `iterator(value, key, obj)`, where `value` + * is the value of an object property or an array element, `key` is the object property key or + * array element index and obj is the `obj` itself. Specifying a `context` for the function is optional. + * + * It is worth noting that `.forEach` does not iterate over inherited properties because it filters + * using the `hasOwnProperty` method. + * + * Unlike ES262's + * [Array.prototype.forEach](http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.18), + * Providing 'undefined' or 'null' values for `obj` will not throw a TypeError, but rather just + * return the value provided. + * + ```js + var values = {name: 'misko', gender: 'male'}; + var log = []; + angular.forEach(values, function(value, key) { + this.push(key + ': ' + value); + }, log); + expect(log).toEqual(['name: misko', 'gender: male']); + ``` + * + * @param {Object|Array} obj Object to iterate over. + * @param {Function} iterator Iterator function. + * @param {Object=} context Object to become context (`this`) for the iterator function. + * @returns {Object|Array} Reference to `obj`. + */ + +function forEach(obj, iterator, context) { + var key, length; + if (obj) { + if (isFunction(obj)) { + for (key in obj) { + // Need to check if hasOwnProperty exists, + // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function + if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) { + iterator.call(context, obj[key], key, obj); + } + } + } else if (isArray(obj) || isArrayLike(obj)) { + var isPrimitive = typeof obj !== 'object'; + for (key = 0, length = obj.length; key < length; key++) { + if (isPrimitive || key in obj) { + iterator.call(context, obj[key], key, obj); + } + } + } else if (obj.forEach && obj.forEach !== forEach) { + obj.forEach(iterator, context, obj); + } else if (isBlankObject(obj)) { + // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty + for (key in obj) { + iterator.call(context, obj[key], key, obj); + } + } else if (typeof obj.hasOwnProperty === 'function') { + // Slow path for objects inheriting Object.prototype, hasOwnProperty check needed + for (key in obj) { + if (obj.hasOwnProperty(key)) { + iterator.call(context, obj[key], key, obj); + } + } + } else { + // Slow path for objects which do not have a method `hasOwnProperty` + for (key in obj) { + if (hasOwnProperty.call(obj, key)) { + iterator.call(context, obj[key], key, obj); + } + } + } + } + return obj; +} + +function forEachSorted(obj, iterator, context) { + var keys = Object.keys(obj).sort(); + for (var i = 0; i < keys.length; i++) { + iterator.call(context, obj[keys[i]], keys[i]); + } + return keys; +} + + +/** + * when using forEach the params are value, key, but it is often useful to have key, value. + * @param {function(string, *)} iteratorFn + * @returns {function(*, string)} + */ +function reverseParams(iteratorFn) { + return function(value, key) { iteratorFn(key, value); }; +} + +/** + * A consistent way of creating unique IDs in angular. + * + * Using simple numbers allows us to generate 28.6 million unique ids per second for 10 years before + * we hit number precision issues in JavaScript. + * + * Math.pow(2,53) / 60 / 60 / 24 / 365 / 10 = 28.6M + * + * @returns {number} an unique alpha-numeric string + */ +function nextUid() { + return ++uid; +} + + +/** + * Set or clear the hashkey for an object. + * @param obj object + * @param h the hashkey (!truthy to delete the hashkey) + */ +function setHashKey(obj, h) { + if (h) { + obj.$$hashKey = h; + } else { + delete obj.$$hashKey; + } +} + + +function baseExtend(dst, objs, deep) { + var h = dst.$$hashKey; + + for (var i = 0, ii = objs.length; i < ii; ++i) { + var obj = objs[i]; + if (!isObject(obj) && !isFunction(obj)) continue; + var keys = Object.keys(obj); + for (var j = 0, jj = keys.length; j < jj; j++) { + var key = keys[j]; + var src = obj[key]; + + if (deep && isObject(src)) { + if (isDate(src)) { + dst[key] = new Date(src.valueOf()); + } else if (isRegExp(src)) { + dst[key] = new RegExp(src); + } else { + if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {}; + baseExtend(dst[key], [src], true); + } + } else { + dst[key] = src; + } + } + } + + setHashKey(dst, h); + return dst; +} + +/** + * @ngdoc function + * @name angular.extend + * @module ng + * @kind function + * + * @description + * Extends the destination object `dst` by copying own enumerable properties from the `src` object(s) + * to `dst`. You can specify multiple `src` objects. If you want to preserve original objects, you can do so + * by passing an empty object as the target: `var object = angular.extend({}, object1, object2)`. + * + * **Note:** Keep in mind that `angular.extend` does not support recursive merge (deep copy). Use + * {@link angular.merge} for this. + * + * @param {Object} dst Destination object. + * @param {...Object} src Source object(s). + * @returns {Object} Reference to `dst`. + */ +function extend(dst) { + return baseExtend(dst, slice.call(arguments, 1), false); +} + + +/** +* @ngdoc function +* @name angular.merge +* @module ng +* @kind function +* +* @description +* Deeply extends the destination object `dst` by copying own enumerable properties from the `src` object(s) +* to `dst`. You can specify multiple `src` objects. If you want to preserve original objects, you can do so +* by passing an empty object as the target: `var object = angular.merge({}, object1, object2)`. +* +* Unlike {@link angular.extend extend()}, `merge()` recursively descends into object properties of source +* objects, performing a deep copy. +* +* @param {Object} dst Destination object. +* @param {...Object} src Source object(s). +* @returns {Object} Reference to `dst`. +*/ +function merge(dst) { + return baseExtend(dst, slice.call(arguments, 1), true); +} + + + +function toInt(str) { + return parseInt(str, 10); +} + + +function inherit(parent, extra) { + return extend(Object.create(parent), extra); +} + +/** + * @ngdoc function + * @name angular.noop + * @module ng + * @kind function + * + * @description + * A function that performs no operations. This function can be useful when writing code in the + * functional style. + ```js + function foo(callback) { + var result = calculateResult(); + (callback || angular.noop)(result); + } + ``` + */ +function noop() {} +noop.$inject = []; + + +/** + * @ngdoc function + * @name angular.identity + * @module ng + * @kind function + * + * @description + * A function that returns its first argument. This function is useful when writing code in the + * functional style. + * + ```js + function transformer(transformationFn, value) { + return (transformationFn || angular.identity)(value); + }; + ``` + * @param {*} value to be returned. + * @returns {*} the value passed in. + */ +function identity($) {return $;} +identity.$inject = []; + + +function valueFn(value) {return function() {return value;};} + +function hasCustomToString(obj) { + return isFunction(obj.toString) && obj.toString !== Object.prototype.toString; +} + + +/** + * @ngdoc function + * @name angular.isUndefined + * @module ng + * @kind function + * + * @description + * Determines if a reference is undefined. + * + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is undefined. + */ +function isUndefined(value) {return typeof value === 'undefined';} + + +/** + * @ngdoc function + * @name angular.isDefined + * @module ng + * @kind function + * + * @description + * Determines if a reference is defined. + * + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is defined. + */ +function isDefined(value) {return typeof value !== 'undefined';} + + +/** + * @ngdoc function + * @name angular.isObject + * @module ng + * @kind function + * + * @description + * Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not + * considered to be objects. Note that JavaScript arrays are objects. + * + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is an `Object` but not `null`. + */ +function isObject(value) { + // http://jsperf.com/isobject4 + return value !== null && typeof value === 'object'; +} + + +/** + * Determine if a value is an object with a null prototype + * + * @returns {boolean} True if `value` is an `Object` with a null prototype + */ +function isBlankObject(value) { + return value !== null && typeof value === 'object' && !getPrototypeOf(value); +} + + +/** + * @ngdoc function + * @name angular.isString + * @module ng + * @kind function + * + * @description + * Determines if a reference is a `String`. + * + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is a `String`. + */ +function isString(value) {return typeof value === 'string';} + + +/** + * @ngdoc function + * @name angular.isNumber + * @module ng + * @kind function + * + * @description + * Determines if a reference is a `Number`. + * + * This includes the "special" numbers `NaN`, `+Infinity` and `-Infinity`. + * + * If you wish to exclude these then you can use the native + * [`isFinite'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite) + * method. + * + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is a `Number`. + */ +function isNumber(value) {return typeof value === 'number';} + + +/** + * @ngdoc function + * @name angular.isDate + * @module ng + * @kind function + * + * @description + * Determines if a value is a date. + * + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is a `Date`. + */ +function isDate(value) { + return toString.call(value) === '[object Date]'; +} + + +/** + * @ngdoc function + * @name angular.isArray + * @module ng + * @kind function + * + * @description + * Determines if a reference is an `Array`. + * + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is an `Array`. + */ +var isArray = Array.isArray; + +/** + * @ngdoc function + * @name angular.isFunction + * @module ng + * @kind function + * + * @description + * Determines if a reference is a `Function`. + * + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is a `Function`. + */ +function isFunction(value) {return typeof value === 'function';} + + +/** + * Determines if a value is a regular expression object. + * + * @private + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is a `RegExp`. + */ +function isRegExp(value) { + return toString.call(value) === '[object RegExp]'; +} + + +/** + * Checks if `obj` is a window object. + * + * @private + * @param {*} obj Object to check + * @returns {boolean} True if `obj` is a window obj. + */ +function isWindow(obj) { + return obj && obj.window === obj; +} + + +function isScope(obj) { + return obj && obj.$evalAsync && obj.$watch; +} + + +function isFile(obj) { + return toString.call(obj) === '[object File]'; +} + + +function isFormData(obj) { + return toString.call(obj) === '[object FormData]'; +} + + +function isBlob(obj) { + return toString.call(obj) === '[object Blob]'; +} + + +function isBoolean(value) { + return typeof value === 'boolean'; +} + + +function isPromiseLike(obj) { + return obj && isFunction(obj.then); +} + + +var TYPED_ARRAY_REGEXP = /^\[object (Uint8(Clamped)?)|(Uint16)|(Uint32)|(Int8)|(Int16)|(Int32)|(Float(32)|(64))Array\]$/; +function isTypedArray(value) { + return TYPED_ARRAY_REGEXP.test(toString.call(value)); +} + + +var trim = function(value) { + return isString(value) ? value.trim() : value; +}; + +// Copied from: +// http://docs.closure-library.googlecode.com/git/local_closure_goog_string_string.js.source.html#line1021 +// Prereq: s is a string. +var escapeForRegexp = function(s) { + return s.replace(/([-()\[\]{}+?*.$\^|,:#= 0) { + array.splice(index, 1); + } + return index; +} + +/** + * @ngdoc function + * @name angular.copy + * @module ng + * @kind function + * + * @description + * Creates a deep copy of `source`, which should be an object or an array. + * + * * If no destination is supplied, a copy of the object or array is created. + * * If a destination is provided, all of its elements (for arrays) or properties (for objects) + * are deleted and then all elements/properties from the source are copied to it. + * * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned. + * * If `source` is identical to 'destination' an exception will be thrown. + * + * @param {*} source The source that will be used to make a copy. + * Can be any type, including primitives, `null`, and `undefined`. + * @param {(Object|Array)=} destination Destination into which the source is copied. If + * provided, must be of the same type as `source`. + * @returns {*} The copy or updated `destination`, if `destination` was specified. + * + * @example + + +
+
+ Name:
+ E-mail:
+ Gender: male + female
+ + +
+
form = {{user | json}}
+
master = {{master | json}}
+
+ + +
+
+ */ +function copy(source, destination, stackSource, stackDest) { + if (isWindow(source) || isScope(source)) { + throw ngMinErr('cpws', + "Can't copy! Making copies of Window or Scope instances is not supported."); + } + if (isTypedArray(destination)) { + throw ngMinErr('cpta', + "Can't copy! TypedArray destination cannot be mutated."); + } + + if (!destination) { + destination = source; + if (isObject(source)) { + var index; + if (stackSource && (index = stackSource.indexOf(source)) !== -1) { + return stackDest[index]; + } + + // TypedArray, Date and RegExp have specific copy functionality and must be + // pushed onto the stack before returning. + // Array and other objects create the base object and recurse to copy child + // objects. The array/object will be pushed onto the stack when recursed. + if (isArray(source)) { + return copy(source, [], stackSource, stackDest); + } else if (isTypedArray(source)) { + destination = new source.constructor(source); + } else if (isDate(source)) { + destination = new Date(source.getTime()); + } else if (isRegExp(source)) { + destination = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]); + destination.lastIndex = source.lastIndex; + } else if (isFunction(source.cloneNode)) { + destination = source.cloneNode(true); + } else { + var emptyObject = Object.create(getPrototypeOf(source)); + return copy(source, emptyObject, stackSource, stackDest); + } + + if (stackDest) { + stackSource.push(source); + stackDest.push(destination); + } + } + } else { + if (source === destination) throw ngMinErr('cpi', + "Can't copy! Source and destination are identical."); + + stackSource = stackSource || []; + stackDest = stackDest || []; + + if (isObject(source)) { + stackSource.push(source); + stackDest.push(destination); + } + + var result, key; + if (isArray(source)) { + destination.length = 0; + for (var i = 0; i < source.length; i++) { + destination.push(copy(source[i], null, stackSource, stackDest)); + } + } else { + var h = destination.$$hashKey; + if (isArray(destination)) { + destination.length = 0; + } else { + forEach(destination, function(value, key) { + delete destination[key]; + }); + } + if (isBlankObject(source)) { + // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty + for (key in source) { + destination[key] = copy(source[key], null, stackSource, stackDest); + } + } else if (source && typeof source.hasOwnProperty === 'function') { + // Slow path, which must rely on hasOwnProperty + for (key in source) { + if (source.hasOwnProperty(key)) { + destination[key] = copy(source[key], null, stackSource, stackDest); + } + } + } else { + // Slowest path --- hasOwnProperty can't be called as a method + for (key in source) { + if (hasOwnProperty.call(source, key)) { + destination[key] = copy(source[key], null, stackSource, stackDest); + } + } + } + setHashKey(destination,h); + } + } + return destination; +} + +/** + * Creates a shallow copy of an object, an array or a primitive. + * + * Assumes that there are no proto properties for objects. + */ +function shallowCopy(src, dst) { + if (isArray(src)) { + dst = dst || []; + + for (var i = 0, ii = src.length; i < ii; i++) { + dst[i] = src[i]; + } + } else if (isObject(src)) { + dst = dst || {}; + + for (var key in src) { + if (!(key.charAt(0) === '$' && key.charAt(1) === '$')) { + dst[key] = src[key]; + } + } + } + + return dst || src; +} + + +/** + * @ngdoc function + * @name angular.equals + * @module ng + * @kind function + * + * @description + * Determines if two objects or two values are equivalent. Supports value types, regular + * expressions, arrays and objects. + * + * Two objects or values are considered equivalent if at least one of the following is true: + * + * * Both objects or values pass `===` comparison. + * * Both objects or values are of the same type and all of their properties are equal by + * comparing them with `angular.equals`. + * * Both values are NaN. (In JavaScript, NaN == NaN => false. But we consider two NaN as equal) + * * Both values represent the same regular expression (In JavaScript, + * /abc/ == /abc/ => false. But we consider two regular expressions as equal when their textual + * representation matches). + * + * During a property comparison, properties of `function` type and properties with names + * that begin with `$` are ignored. + * + * Scope and DOMWindow objects are being compared only by identify (`===`). + * + * @param {*} o1 Object or value to compare. + * @param {*} o2 Object or value to compare. + * @returns {boolean} True if arguments are equal. + */ +function equals(o1, o2) { + if (o1 === o2) return true; + if (o1 === null || o2 === null) return false; + if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN + var t1 = typeof o1, t2 = typeof o2, length, key, keySet; + if (t1 == t2) { + if (t1 == 'object') { + if (isArray(o1)) { + if (!isArray(o2)) return false; + if ((length = o1.length) == o2.length) { + for (key = 0; key < length; key++) { + if (!equals(o1[key], o2[key])) return false; + } + return true; + } + } else if (isDate(o1)) { + if (!isDate(o2)) return false; + return equals(o1.getTime(), o2.getTime()); + } else if (isRegExp(o1)) { + return isRegExp(o2) ? o1.toString() == o2.toString() : false; + } else { + if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) || + isArray(o2) || isDate(o2) || isRegExp(o2)) return false; + keySet = createMap(); + for (key in o1) { + if (key.charAt(0) === '$' || isFunction(o1[key])) continue; + if (!equals(o1[key], o2[key])) return false; + keySet[key] = true; + } + for (key in o2) { + if (!(key in keySet) && + key.charAt(0) !== '$' && + isDefined(o2[key]) && + !isFunction(o2[key])) return false; + } + return true; + } + } + } + return false; +} + +var csp = function() { + if (!isDefined(csp.rules)) { + + + var ngCspElement = (document.querySelector('[ng-csp]') || + document.querySelector('[data-ng-csp]')); + + if (ngCspElement) { + var ngCspAttribute = ngCspElement.getAttribute('ng-csp') || + ngCspElement.getAttribute('data-ng-csp'); + csp.rules = { + noUnsafeEval: !ngCspAttribute || (ngCspAttribute.indexOf('no-unsafe-eval') !== -1), + noInlineStyle: !ngCspAttribute || (ngCspAttribute.indexOf('no-inline-style') !== -1) + }; + } else { + csp.rules = { + noUnsafeEval: noUnsafeEval(), + noInlineStyle: false + }; + } + } + + return csp.rules; + + function noUnsafeEval() { + try { + /* jshint -W031, -W054 */ + new Function(''); + /* jshint +W031, +W054 */ + return false; + } catch (e) { + return true; + } + } +}; + +/** + * @ngdoc directive + * @module ng + * @name ngJq + * + * @element ANY + * @param {string=} ngJq the name of the library available under `window` + * to be used for angular.element + * @description + * Use this directive to force the angular.element library. This should be + * used to force either jqLite by leaving ng-jq blank or setting the name of + * the jquery variable under window (eg. jQuery). + * + * Since angular looks for this directive when it is loaded (doesn't wait for the + * DOMContentLoaded event), it must be placed on an element that comes before the script + * which loads angular. Also, only the first instance of `ng-jq` will be used and all + * others ignored. + * + * @example + * This example shows how to force jqLite using the `ngJq` directive to the `html` tag. + ```html + + + ... + ... + + ``` + * @example + * This example shows how to use a jQuery based library of a different name. + * The library name must be available at the top most 'window'. + ```html + + + ... + ... + + ``` + */ +var jq = function() { + if (isDefined(jq.name_)) return jq.name_; + var el; + var i, ii = ngAttrPrefixes.length, prefix, name; + for (i = 0; i < ii; ++i) { + prefix = ngAttrPrefixes[i]; + if (el = document.querySelector('[' + prefix.replace(':', '\\:') + 'jq]')) { + name = el.getAttribute(prefix + 'jq'); + break; + } + } + + return (jq.name_ = name); +}; + +function concat(array1, array2, index) { + return array1.concat(slice.call(array2, index)); +} + +function sliceArgs(args, startIndex) { + return slice.call(args, startIndex || 0); +} + + +/* jshint -W101 */ +/** + * @ngdoc function + * @name angular.bind + * @module ng + * @kind function + * + * @description + * Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for + * `fn`). You can supply optional `args` that are prebound to the function. This feature is also + * known as [partial application](http://en.wikipedia.org/wiki/Partial_application), as + * distinguished from [function currying](http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application). + * + * @param {Object} self Context which `fn` should be evaluated in. + * @param {function()} fn Function to be bound. + * @param {...*} args Optional arguments to be prebound to the `fn` function call. + * @returns {function()} Function that wraps the `fn` with all the specified bindings. + */ +/* jshint +W101 */ +function bind(self, fn) { + var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : []; + if (isFunction(fn) && !(fn instanceof RegExp)) { + return curryArgs.length + ? function() { + return arguments.length + ? fn.apply(self, concat(curryArgs, arguments, 0)) + : fn.apply(self, curryArgs); + } + : function() { + return arguments.length + ? fn.apply(self, arguments) + : fn.call(self); + }; + } else { + // in IE, native methods are not functions so they cannot be bound (note: they don't need to be) + return fn; + } +} + + +function toJsonReplacer(key, value) { + var val = value; + + if (typeof key === 'string' && key.charAt(0) === '$' && key.charAt(1) === '$') { + val = undefined; + } else if (isWindow(value)) { + val = '$WINDOW'; + } else if (value && document === value) { + val = '$DOCUMENT'; + } else if (isScope(value)) { + val = '$SCOPE'; + } + + return val; +} + + +/** + * @ngdoc function + * @name angular.toJson + * @module ng + * @kind function + * + * @description + * Serializes input into a JSON-formatted string. Properties with leading $$ characters will be + * stripped since angular uses this notation internally. + * + * @param {Object|Array|Date|string|number} obj Input to be serialized into JSON. + * @param {boolean|number} [pretty=2] If set to true, the JSON output will contain newlines and whitespace. + * If set to an integer, the JSON output will contain that many spaces per indentation. + * @returns {string|undefined} JSON-ified string representing `obj`. + */ +function toJson(obj, pretty) { + if (typeof obj === 'undefined') return undefined; + if (!isNumber(pretty)) { + pretty = pretty ? 2 : null; + } + return JSON.stringify(obj, toJsonReplacer, pretty); +} + + +/** + * @ngdoc function + * @name angular.fromJson + * @module ng + * @kind function + * + * @description + * Deserializes a JSON string. + * + * @param {string} json JSON string to deserialize. + * @returns {Object|Array|string|number} Deserialized JSON string. + */ +function fromJson(json) { + return isString(json) + ? JSON.parse(json) + : json; +} + + +function timezoneToOffset(timezone, fallback) { + var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000; + return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset; +} + + +function addDateMinutes(date, minutes) { + date = new Date(date.getTime()); + date.setMinutes(date.getMinutes() + minutes); + return date; +} + + +function convertTimezoneToLocal(date, timezone, reverse) { + reverse = reverse ? -1 : 1; + var timezoneOffset = timezoneToOffset(timezone, date.getTimezoneOffset()); + return addDateMinutes(date, reverse * (timezoneOffset - date.getTimezoneOffset())); +} + + +/** + * @returns {string} Returns the string representation of the element. + */ +function startingTag(element) { + element = jqLite(element).clone(); + try { + // turns out IE does not let you set .html() on elements which + // are not allowed to have children. So we just ignore it. + element.empty(); + } catch (e) {} + var elemHtml = jqLite('
').append(element).html(); + try { + return element[0].nodeType === NODE_TYPE_TEXT ? lowercase(elemHtml) : + elemHtml. + match(/^(<[^>]+>)/)[1]. + replace(/^<([\w\-]+)/, function(match, nodeName) { return '<' + lowercase(nodeName); }); + } catch (e) { + return lowercase(elemHtml); + } + +} + + +///////////////////////////////////////////////// + +/** + * Tries to decode the URI component without throwing an exception. + * + * @private + * @param str value potential URI component to check. + * @returns {boolean} True if `value` can be decoded + * with the decodeURIComponent function. + */ +function tryDecodeURIComponent(value) { + try { + return decodeURIComponent(value); + } catch (e) { + // Ignore any invalid uri component + } +} + + +/** + * Parses an escaped url query string into key-value pairs. + * @returns {Object.} + */ +function parseKeyValue(/**string*/keyValue) { + var obj = {}; + forEach((keyValue || "").split('&'), function(keyValue) { + var splitPoint, key, val; + if (keyValue) { + key = keyValue = keyValue.replace(/\+/g,'%20'); + splitPoint = keyValue.indexOf('='); + if (splitPoint !== -1) { + key = keyValue.substring(0, splitPoint); + val = keyValue.substring(splitPoint + 1); + } + key = tryDecodeURIComponent(key); + if (isDefined(key)) { + val = isDefined(val) ? tryDecodeURIComponent(val) : true; + if (!hasOwnProperty.call(obj, key)) { + obj[key] = val; + } else if (isArray(obj[key])) { + obj[key].push(val); + } else { + obj[key] = [obj[key],val]; + } + } + } + }); + return obj; +} + +function toKeyValue(obj) { + var parts = []; + forEach(obj, function(value, key) { + if (isArray(value)) { + forEach(value, function(arrayValue) { + parts.push(encodeUriQuery(key, true) + + (arrayValue === true ? '' : '=' + encodeUriQuery(arrayValue, true))); + }); + } else { + parts.push(encodeUriQuery(key, true) + + (value === true ? '' : '=' + encodeUriQuery(value, true))); + } + }); + return parts.length ? parts.join('&') : ''; +} + + +/** + * We need our custom method because encodeURIComponent is too aggressive and doesn't follow + * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path + * segments: + * segment = *pchar + * pchar = unreserved / pct-encoded / sub-delims / ":" / "@" + * pct-encoded = "%" HEXDIG HEXDIG + * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" + * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" + * / "*" / "+" / "," / ";" / "=" + */ +function encodeUriSegment(val) { + return encodeUriQuery(val, true). + replace(/%26/gi, '&'). + replace(/%3D/gi, '='). + replace(/%2B/gi, '+'); +} + + +/** + * This method is intended for encoding *key* or *value* parts of query component. We need a custom + * method because encodeURIComponent is too aggressive and encodes stuff that doesn't have to be + * encoded per http://tools.ietf.org/html/rfc3986: + * query = *( pchar / "/" / "?" ) + * pchar = unreserved / pct-encoded / sub-delims / ":" / "@" + * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" + * pct-encoded = "%" HEXDIG HEXDIG + * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" + * / "*" / "+" / "," / ";" / "=" + */ +function encodeUriQuery(val, pctEncodeSpaces) { + return encodeURIComponent(val). + replace(/%40/gi, '@'). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%3B/gi, ';'). + replace(/%20/g, (pctEncodeSpaces ? '%20' : '+')); +} + +var ngAttrPrefixes = ['ng-', 'data-ng-', 'ng:', 'x-ng-']; + +function getNgAttribute(element, ngAttr) { + var attr, i, ii = ngAttrPrefixes.length; + for (i = 0; i < ii; ++i) { + attr = ngAttrPrefixes[i] + ngAttr; + if (isString(attr = element.getAttribute(attr))) { + return attr; + } + } + return null; +} + +/** + * @ngdoc directive + * @name ngApp + * @module ng + * + * @element ANY + * @param {angular.Module} ngApp an optional application + * {@link angular.module module} name to load. + * @param {boolean=} ngStrictDi if this attribute is present on the app element, the injector will be + * created in "strict-di" mode. This means that the application will fail to invoke functions which + * do not use explicit function annotation (and are thus unsuitable for minification), as described + * in {@link guide/di the Dependency Injection guide}, and useful debugging info will assist in + * tracking down the root of these bugs. + * + * @description + * + * Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive + * designates the **root element** of the application and is typically placed near the root element + * of the page - e.g. on the `` or `` tags. + * + * Only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp` + * found in the document will be used to define the root element to auto-bootstrap as an + * application. To run multiple applications in an HTML document you must manually bootstrap them using + * {@link angular.bootstrap} instead. AngularJS applications cannot be nested within each other. + * + * You can specify an **AngularJS module** to be used as the root module for the application. This + * module will be loaded into the {@link auto.$injector} when the application is bootstrapped. It + * should contain the application code needed or have dependencies on other modules that will + * contain the code. See {@link angular.module} for more information. + * + * In the example below if the `ngApp` directive were not placed on the `html` element then the + * document would not be compiled, the `AppController` would not be instantiated and the `{{ a+b }}` + * would not be resolved to `3`. + * + * `ngApp` is the easiest, and most common way to bootstrap an application. + * + + +
+ I can add: {{a}} + {{b}} = {{ a+b }} +
+
+ + angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) { + $scope.a = 1; + $scope.b = 2; + }); + +
+ * + * Using `ngStrictDi`, you would see something like this: + * + + +
+
+ I can add: {{a}} + {{b}} = {{ a+b }} + +

This renders because the controller does not fail to + instantiate, by using explicit annotation style (see + script.js for details) +

+
+ +
+ Name:
+ Hello, {{name}}! + +

This renders because the controller does not fail to + instantiate, by using explicit annotation style + (see script.js for details) +

+
+ +
+ I can add: {{a}} + {{b}} = {{ a+b }} + +

The controller could not be instantiated, due to relying + on automatic function annotations (which are disabled in + strict mode). As such, the content of this section is not + interpolated, and there should be an error in your web console. +

+
+
+
+ + angular.module('ngAppStrictDemo', []) + // BadController will fail to instantiate, due to relying on automatic function annotation, + // rather than an explicit annotation + .controller('BadController', function($scope) { + $scope.a = 1; + $scope.b = 2; + }) + // Unlike BadController, GoodController1 and GoodController2 will not fail to be instantiated, + // due to using explicit annotations using the array style and $inject property, respectively. + .controller('GoodController1', ['$scope', function($scope) { + $scope.a = 1; + $scope.b = 2; + }]) + .controller('GoodController2', GoodController2); + function GoodController2($scope) { + $scope.name = "World"; + } + GoodController2.$inject = ['$scope']; + + + div[ng-controller] { + margin-bottom: 1em; + -webkit-border-radius: 4px; + border-radius: 4px; + border: 1px solid; + padding: .5em; + } + div[ng-controller^=Good] { + border-color: #d6e9c6; + background-color: #dff0d8; + color: #3c763d; + } + div[ng-controller^=Bad] { + border-color: #ebccd1; + background-color: #f2dede; + color: #a94442; + margin-bottom: 0; + } + +
+ */ +function angularInit(element, bootstrap) { + var appElement, + module, + config = {}; + + // The element `element` has priority over any other element + forEach(ngAttrPrefixes, function(prefix) { + var name = prefix + 'app'; + + if (!appElement && element.hasAttribute && element.hasAttribute(name)) { + appElement = element; + module = element.getAttribute(name); + } + }); + forEach(ngAttrPrefixes, function(prefix) { + var name = prefix + 'app'; + var candidate; + + if (!appElement && (candidate = element.querySelector('[' + name.replace(':', '\\:') + ']'))) { + appElement = candidate; + module = candidate.getAttribute(name); + } + }); + if (appElement) { + config.strictDi = getNgAttribute(appElement, "strict-di") !== null; + bootstrap(appElement, module ? [module] : [], config); + } +} + +/** + * @ngdoc function + * @name angular.bootstrap + * @module ng + * @description + * Use this function to manually start up angular application. + * + * See: {@link guide/bootstrap Bootstrap} + * + * Note that Protractor based end-to-end tests cannot use this function to bootstrap manually. + * They must use {@link ng.directive:ngApp ngApp}. + * + * Angular will detect if it has been loaded into the browser more than once and only allow the + * first loaded script to be bootstrapped and will report a warning to the browser console for + * each of the subsequent scripts. This prevents strange results in applications, where otherwise + * multiple instances of Angular try to work on the DOM. + * + * ```html + * + * + * + *
+ * {{greeting}} + *
+ * + * + * + * + * + * ``` + * + * @param {DOMElement} element DOM element which is the root of angular application. + * @param {Array=} modules an array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a `config` block. + * See: {@link angular.module modules} + * @param {Object=} config an object for defining configuration options for the application. The + * following keys are supported: + * + * * `strictDi` - disable automatic function annotation for the application. This is meant to + * assist in finding bugs which break minified code. Defaults to `false`. + * + * @returns {auto.$injector} Returns the newly created injector for this app. + */ +function bootstrap(element, modules, config) { + if (!isObject(config)) config = {}; + var defaultConfig = { + strictDi: false + }; + config = extend(defaultConfig, config); + var doBootstrap = function() { + element = jqLite(element); + + if (element.injector()) { + var tag = (element[0] === document) ? 'document' : startingTag(element); + //Encode angle brackets to prevent input from being sanitized to empty string #8683 + throw ngMinErr( + 'btstrpd', + "App Already Bootstrapped with this Element '{0}'", + tag.replace(//,'>')); + } + + modules = modules || []; + modules.unshift(['$provide', function($provide) { + $provide.value('$rootElement', element); + }]); + + if (config.debugInfoEnabled) { + // Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`. + modules.push(['$compileProvider', function($compileProvider) { + $compileProvider.debugInfoEnabled(true); + }]); + } + + modules.unshift('ng'); + var injector = createInjector(modules, config.strictDi); + injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', + function bootstrapApply(scope, element, compile, injector) { + scope.$apply(function() { + element.data('$injector', injector); + compile(element)(scope); + }); + }] + ); + return injector; + }; + + var NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/; + var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; + + if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) { + config.debugInfoEnabled = true; + window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, ''); + } + + if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { + return doBootstrap(); + } + + window.name = window.name.replace(NG_DEFER_BOOTSTRAP, ''); + angular.resumeBootstrap = function(extraModules) { + forEach(extraModules, function(module) { + modules.push(module); + }); + return doBootstrap(); + }; + + if (isFunction(angular.resumeDeferredBootstrap)) { + angular.resumeDeferredBootstrap(); + } +} + +/** + * @ngdoc function + * @name angular.reloadWithDebugInfo + * @module ng + * @description + * Use this function to reload the current application with debug information turned on. + * This takes precedence over a call to `$compileProvider.debugInfoEnabled(false)`. + * + * See {@link ng.$compileProvider#debugInfoEnabled} for more. + */ +function reloadWithDebugInfo() { + window.name = 'NG_ENABLE_DEBUG_INFO!' + window.name; + window.location.reload(); +} + +/** + * @name angular.getTestability + * @module ng + * @description + * Get the testability service for the instance of Angular on the given + * element. + * @param {DOMElement} element DOM element which is the root of angular application. + */ +function getTestability(rootElement) { + var injector = angular.element(rootElement).injector(); + if (!injector) { + throw ngMinErr('test', + 'no injector found for element argument to getTestability'); + } + return injector.get('$$testability'); +} + +var SNAKE_CASE_REGEXP = /[A-Z]/g; +function snake_case(name, separator) { + separator = separator || '_'; + return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) { + return (pos ? separator : '') + letter.toLowerCase(); + }); +} + +var bindJQueryFired = false; +var skipDestroyOnNextJQueryCleanData; +function bindJQuery() { + var originalCleanData; + + if (bindJQueryFired) { + return; + } + + // bind to jQuery if present; + var jqName = jq(); + jQuery = isUndefined(jqName) ? window.jQuery : // use jQuery (if present) + !jqName ? undefined : // use jqLite + window[jqName]; // use jQuery specified by `ngJq` + + // Use jQuery if it exists with proper functionality, otherwise default to us. + // Angular 1.2+ requires jQuery 1.7+ for on()/off() support. + // Angular 1.3+ technically requires at least jQuery 2.1+ but it may work with older + // versions. It will not work for sure with jQuery <1.7, though. + if (jQuery && jQuery.fn.on) { + jqLite = jQuery; + extend(jQuery.fn, { + scope: JQLitePrototype.scope, + isolateScope: JQLitePrototype.isolateScope, + controller: JQLitePrototype.controller, + injector: JQLitePrototype.injector, + inheritedData: JQLitePrototype.inheritedData + }); + + // All nodes removed from the DOM via various jQuery APIs like .remove() + // are passed through jQuery.cleanData. Monkey-patch this method to fire + // the $destroy event on all removed nodes. + originalCleanData = jQuery.cleanData; + jQuery.cleanData = function(elems) { + var events; + if (!skipDestroyOnNextJQueryCleanData) { + for (var i = 0, elem; (elem = elems[i]) != null; i++) { + events = jQuery._data(elem, "events"); + if (events && events.$destroy) { + jQuery(elem).triggerHandler('$destroy'); + } + } + } else { + skipDestroyOnNextJQueryCleanData = false; + } + originalCleanData(elems); + }; + } else { + jqLite = JQLite; + } + + angular.element = jqLite; + + // Prevent double-proxying. + bindJQueryFired = true; +} + +/** + * throw error if the argument is falsy. + */ +function assertArg(arg, name, reason) { + if (!arg) { + throw ngMinErr('areq', "Argument '{0}' is {1}", (name || '?'), (reason || "required")); + } + return arg; +} + +function assertArgFn(arg, name, acceptArrayAnnotation) { + if (acceptArrayAnnotation && isArray(arg)) { + arg = arg[arg.length - 1]; + } + + assertArg(isFunction(arg), name, 'not a function, got ' + + (arg && typeof arg === 'object' ? arg.constructor.name || 'Object' : typeof arg)); + return arg; +} + +/** + * throw error if the name given is hasOwnProperty + * @param {String} name the name to test + * @param {String} context the context in which the name is used, such as module or directive + */ +function assertNotHasOwnProperty(name, context) { + if (name === 'hasOwnProperty') { + throw ngMinErr('badname', "hasOwnProperty is not a valid {0} name", context); + } +} + +/** + * Return the value accessible from the object by path. Any undefined traversals are ignored + * @param {Object} obj starting object + * @param {String} path path to traverse + * @param {boolean} [bindFnToScope=true] + * @returns {Object} value as accessible by path + */ +//TODO(misko): this function needs to be removed +function getter(obj, path, bindFnToScope) { + if (!path) return obj; + var keys = path.split('.'); + var key; + var lastInstance = obj; + var len = keys.length; + + for (var i = 0; i < len; i++) { + key = keys[i]; + if (obj) { + obj = (lastInstance = obj)[key]; + } + } + if (!bindFnToScope && isFunction(obj)) { + return bind(lastInstance, obj); + } + return obj; +} + +/** + * Return the DOM siblings between the first and last node in the given array. + * @param {Array} array like object + * @returns {Array} the inputted object or a jqLite collection containing the nodes + */ +function getBlockNodes(nodes) { + // TODO(perf): update `nodes` instead of creating a new object? + var node = nodes[0]; + var endNode = nodes[nodes.length - 1]; + var blockNodes; + + for (var i = 1; node !== endNode && (node = node.nextSibling); i++) { + if (blockNodes || nodes[i] !== node) { + if (!blockNodes) { + blockNodes = jqLite(slice.call(nodes, 0, i)); + } + blockNodes.push(node); + } + } + + return blockNodes || nodes; +} + + +/** + * Creates a new object without a prototype. This object is useful for lookup without having to + * guard against prototypically inherited properties via hasOwnProperty. + * + * Related micro-benchmarks: + * - http://jsperf.com/object-create2 + * - http://jsperf.com/proto-map-lookup/2 + * - http://jsperf.com/for-in-vs-object-keys2 + * + * @returns {Object} + */ +function createMap() { + return Object.create(null); +} + +var NODE_TYPE_ELEMENT = 1; +var NODE_TYPE_ATTRIBUTE = 2; +var NODE_TYPE_TEXT = 3; +var NODE_TYPE_COMMENT = 8; +var NODE_TYPE_DOCUMENT = 9; +var NODE_TYPE_DOCUMENT_FRAGMENT = 11; + +/** + * @ngdoc type + * @name angular.Module + * @module ng + * @description + * + * Interface for configuring angular {@link angular.module modules}. + */ + +function setupModuleLoader(window) { + + var $injectorMinErr = minErr('$injector'); + var ngMinErr = minErr('ng'); + + function ensure(obj, name, factory) { + return obj[name] || (obj[name] = factory()); + } + + var angular = ensure(window, 'angular', Object); + + // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap + angular.$$minErr = angular.$$minErr || minErr; + + return ensure(angular, 'module', function() { + /** @type {Object.} */ + var modules = {}; + + /** + * @ngdoc function + * @name angular.module + * @module ng + * @description + * + * The `angular.module` is a global place for creating, registering and retrieving Angular + * modules. + * All modules (angular core or 3rd party) that should be available to an application must be + * registered using this mechanism. + * + * Passing one argument retrieves an existing {@link angular.Module}, + * whereas passing more than one argument creates a new {@link angular.Module} + * + * + * # Module + * + * A module is a collection of services, directives, controllers, filters, and configuration information. + * `angular.module` is used to configure the {@link auto.$injector $injector}. + * + * ```js + * // Create a new module + * var myModule = angular.module('myModule', []); + * + * // register a new service + * myModule.value('appName', 'MyCoolApp'); + * + * // configure existing services inside initialization blocks. + * myModule.config(['$locationProvider', function($locationProvider) { + * // Configure existing providers + * $locationProvider.hashPrefix('!'); + * }]); + * ``` + * + * Then you can create an injector and load your modules like this: + * + * ```js + * var injector = angular.injector(['ng', 'myModule']) + * ``` + * + * However it's more likely that you'll just use + * {@link ng.directive:ngApp ngApp} or + * {@link angular.bootstrap} to simplify this process for you. + * + * @param {!string} name The name of the module to create or retrieve. + * @param {!Array.=} requires If specified then new module is being created. If + * unspecified then the module is being retrieved for further configuration. + * @param {Function=} configFn Optional configuration function for the module. Same as + * {@link angular.Module#config Module#config()}. + * @returns {module} new module with the {@link angular.Module} api. + */ + return function module(name, requires, configFn) { + var assertNotHasOwnProperty = function(name, context) { + if (name === 'hasOwnProperty') { + throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context); + } + }; + + assertNotHasOwnProperty(name, 'module'); + if (requires && modules.hasOwnProperty(name)) { + modules[name] = null; + } + return ensure(modules, name, function() { + if (!requires) { + throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled " + + "the module name or forgot to load it. If registering a module ensure that you " + + "specify the dependencies as the second argument.", name); + } + + /** @type {!Array.>} */ + var invokeQueue = []; + + /** @type {!Array.} */ + var configBlocks = []; + + /** @type {!Array.} */ + var runBlocks = []; + + var config = invokeLater('$injector', 'invoke', 'push', configBlocks); + + /** @type {angular.Module} */ + var moduleInstance = { + // Private state + _invokeQueue: invokeQueue, + _configBlocks: configBlocks, + _runBlocks: runBlocks, + + /** + * @ngdoc property + * @name angular.Module#requires + * @module ng + * + * @description + * Holds the list of modules which the injector will load before the current module is + * loaded. + */ + requires: requires, + + /** + * @ngdoc property + * @name angular.Module#name + * @module ng + * + * @description + * Name of the module. + */ + name: name, + + + /** + * @ngdoc method + * @name angular.Module#provider + * @module ng + * @param {string} name service name + * @param {Function} providerType Construction function for creating new instance of the + * service. + * @description + * See {@link auto.$provide#provider $provide.provider()}. + */ + provider: invokeLaterAndSetModuleName('$provide', 'provider'), + + /** + * @ngdoc method + * @name angular.Module#factory + * @module ng + * @param {string} name service name + * @param {Function} providerFunction Function for creating new instance of the service. + * @description + * See {@link auto.$provide#factory $provide.factory()}. + */ + factory: invokeLaterAndSetModuleName('$provide', 'factory'), + + /** + * @ngdoc method + * @name angular.Module#service + * @module ng + * @param {string} name service name + * @param {Function} constructor A constructor function that will be instantiated. + * @description + * See {@link auto.$provide#service $provide.service()}. + */ + service: invokeLaterAndSetModuleName('$provide', 'service'), + + /** + * @ngdoc method + * @name angular.Module#value + * @module ng + * @param {string} name service name + * @param {*} object Service instance object. + * @description + * See {@link auto.$provide#value $provide.value()}. + */ + value: invokeLater('$provide', 'value'), + + /** + * @ngdoc method + * @name angular.Module#constant + * @module ng + * @param {string} name constant name + * @param {*} object Constant value. + * @description + * Because the constant are fixed, they get applied before other provide methods. + * See {@link auto.$provide#constant $provide.constant()}. + */ + constant: invokeLater('$provide', 'constant', 'unshift'), + + /** + * @ngdoc method + * @name angular.Module#decorator + * @module ng + * @param {string} The name of the service to decorate. + * @param {Function} This function will be invoked when the service needs to be + * instantiated and should return the decorated service instance. + * @description + * See {@link auto.$provide#decorator $provide.decorator()}. + */ + decorator: invokeLaterAndSetModuleName('$provide', 'decorator'), + + /** + * @ngdoc method + * @name angular.Module#animation + * @module ng + * @param {string} name animation name + * @param {Function} animationFactory Factory function for creating new instance of an + * animation. + * @description + * + * **NOTE**: animations take effect only if the **ngAnimate** module is loaded. + * + * + * Defines an animation hook that can be later used with + * {@link $animate $animate} service and directives that use this service. + * + * ```js + * module.animation('.animation-name', function($inject1, $inject2) { + * return { + * eventName : function(element, done) { + * //code to run the animation + * //once complete, then run done() + * return function cancellationFunction(element) { + * //code to cancel the animation + * } + * } + * } + * }) + * ``` + * + * See {@link ng.$animateProvider#register $animateProvider.register()} and + * {@link ngAnimate ngAnimate module} for more information. + */ + animation: invokeLaterAndSetModuleName('$animateProvider', 'register'), + + /** + * @ngdoc method + * @name angular.Module#filter + * @module ng + * @param {string} name Filter name - this must be a valid angular expression identifier + * @param {Function} filterFactory Factory function for creating new instance of filter. + * @description + * See {@link ng.$filterProvider#register $filterProvider.register()}. + * + *
+ * **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`. + * Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace + * your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores + * (`myapp_subsection_filterx`). + *
+ */ + filter: invokeLaterAndSetModuleName('$filterProvider', 'register'), + + /** + * @ngdoc method + * @name angular.Module#controller + * @module ng + * @param {string|Object} name Controller name, or an object map of controllers where the + * keys are the names and the values are the constructors. + * @param {Function} constructor Controller constructor function. + * @description + * See {@link ng.$controllerProvider#register $controllerProvider.register()}. + */ + controller: invokeLaterAndSetModuleName('$controllerProvider', 'register'), + + /** + * @ngdoc method + * @name angular.Module#directive + * @module ng + * @param {string|Object} name Directive name, or an object map of directives where the + * keys are the names and the values are the factories. + * @param {Function} directiveFactory Factory function for creating new instance of + * directives. + * @description + * See {@link ng.$compileProvider#directive $compileProvider.directive()}. + */ + directive: invokeLaterAndSetModuleName('$compileProvider', 'directive'), + + /** + * @ngdoc method + * @name angular.Module#config + * @module ng + * @param {Function} configFn Execute this function on module load. Useful for service + * configuration. + * @description + * Use this method to register work which needs to be performed on module loading. + * For more about how to configure services, see + * {@link providers#provider-recipe Provider Recipe}. + */ + config: config, + + /** + * @ngdoc method + * @name angular.Module#run + * @module ng + * @param {Function} initializationFn Execute this function after injector creation. + * Useful for application initialization. + * @description + * Use this method to register work which should be performed when the injector is done + * loading all modules. + */ + run: function(block) { + runBlocks.push(block); + return this; + } + }; + + if (configFn) { + config(configFn); + } + + return moduleInstance; + + /** + * @param {string} provider + * @param {string} method + * @param {String=} insertMethod + * @returns {angular.Module} + */ + function invokeLater(provider, method, insertMethod, queue) { + if (!queue) queue = invokeQueue; + return function() { + queue[insertMethod || 'push']([provider, method, arguments]); + return moduleInstance; + }; + } + + /** + * @param {string} provider + * @param {string} method + * @returns {angular.Module} + */ + function invokeLaterAndSetModuleName(provider, method) { + return function(recipeName, factoryFunction) { + if (factoryFunction && isFunction(factoryFunction)) factoryFunction.$$moduleName = name; + invokeQueue.push([provider, method, arguments]); + return moduleInstance; + }; + } + }); + }; + }); + +} + +/* global: toDebugString: true */ + +function serializeObject(obj) { + var seen = []; + + return JSON.stringify(obj, function(key, val) { + val = toJsonReplacer(key, val); + if (isObject(val)) { + + if (seen.indexOf(val) >= 0) return '...'; + + seen.push(val); + } + return val; + }); +} + +function toDebugString(obj) { + if (typeof obj === 'function') { + return obj.toString().replace(/ \{[\s\S]*$/, ''); + } else if (isUndefined(obj)) { + return 'undefined'; + } else if (typeof obj !== 'string') { + return serializeObject(obj); + } + return obj; +} + +/* global angularModule: true, + version: true, + + $CompileProvider, + + htmlAnchorDirective, + inputDirective, + inputDirective, + formDirective, + scriptDirective, + selectDirective, + styleDirective, + optionDirective, + ngBindDirective, + ngBindHtmlDirective, + ngBindTemplateDirective, + ngClassDirective, + ngClassEvenDirective, + ngClassOddDirective, + ngCloakDirective, + ngControllerDirective, + ngFormDirective, + ngHideDirective, + ngIfDirective, + ngIncludeDirective, + ngIncludeFillContentDirective, + ngInitDirective, + ngNonBindableDirective, + ngPluralizeDirective, + ngRepeatDirective, + ngShowDirective, + ngStyleDirective, + ngSwitchDirective, + ngSwitchWhenDirective, + ngSwitchDefaultDirective, + ngOptionsDirective, + ngTranscludeDirective, + ngModelDirective, + ngListDirective, + ngChangeDirective, + patternDirective, + patternDirective, + requiredDirective, + requiredDirective, + minlengthDirective, + minlengthDirective, + maxlengthDirective, + maxlengthDirective, + ngValueDirective, + ngModelOptionsDirective, + ngAttributeAliasDirectives, + ngEventDirectives, + + $AnchorScrollProvider, + $AnimateProvider, + $CoreAnimateCssProvider, + $$CoreAnimateQueueProvider, + $$CoreAnimateRunnerProvider, + $BrowserProvider, + $CacheFactoryProvider, + $ControllerProvider, + $DocumentProvider, + $ExceptionHandlerProvider, + $FilterProvider, + $$ForceReflowProvider, + $InterpolateProvider, + $IntervalProvider, + $$HashMapProvider, + $HttpProvider, + $HttpParamSerializerProvider, + $HttpParamSerializerJQLikeProvider, + $HttpBackendProvider, + $LocationProvider, + $LogProvider, + $ParseProvider, + $RootScopeProvider, + $QProvider, + $$QProvider, + $$SanitizeUriProvider, + $SceProvider, + $SceDelegateProvider, + $SnifferProvider, + $TemplateCacheProvider, + $TemplateRequestProvider, + $$TestabilityProvider, + $TimeoutProvider, + $$RAFProvider, + $WindowProvider, + $$jqLiteProvider, + $$CookieReaderProvider +*/ + + +/** + * @ngdoc object + * @name angular.version + * @module ng + * @description + * An object that contains information about the current AngularJS version. + * + * This object has the following properties: + * + * - `full` – `{string}` – Full version string, such as "0.9.18". + * - `major` – `{number}` – Major version number, such as "0". + * - `minor` – `{number}` – Minor version number, such as "9". + * - `dot` – `{number}` – Dot version number, such as "18". + * - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat". + */ +var version = { + full: '1.4.6', // all of these placeholder strings will be replaced by grunt's + major: 1, // package task + minor: 4, + dot: 6, + codeName: 'multiplicative-elevation' +}; + + +function publishExternalAPI(angular) { + extend(angular, { + 'bootstrap': bootstrap, + 'copy': copy, + 'extend': extend, + 'merge': merge, + 'equals': equals, + 'element': jqLite, + 'forEach': forEach, + 'injector': createInjector, + 'noop': noop, + 'bind': bind, + 'toJson': toJson, + 'fromJson': fromJson, + 'identity': identity, + 'isUndefined': isUndefined, + 'isDefined': isDefined, + 'isString': isString, + 'isFunction': isFunction, + 'isObject': isObject, + 'isNumber': isNumber, + 'isElement': isElement, + 'isArray': isArray, + 'version': version, + 'isDate': isDate, + 'lowercase': lowercase, + 'uppercase': uppercase, + 'callbacks': {counter: 0}, + 'getTestability': getTestability, + '$$minErr': minErr, + '$$csp': csp, + 'reloadWithDebugInfo': reloadWithDebugInfo + }); + + angularModule = setupModuleLoader(window); + + angularModule('ng', ['ngLocale'], ['$provide', + function ngModule($provide) { + // $$sanitizeUriProvider needs to be before $compileProvider as it is used by it. + $provide.provider({ + $$sanitizeUri: $$SanitizeUriProvider + }); + $provide.provider('$compile', $CompileProvider). + directive({ + a: htmlAnchorDirective, + input: inputDirective, + textarea: inputDirective, + form: formDirective, + script: scriptDirective, + select: selectDirective, + style: styleDirective, + option: optionDirective, + ngBind: ngBindDirective, + ngBindHtml: ngBindHtmlDirective, + ngBindTemplate: ngBindTemplateDirective, + ngClass: ngClassDirective, + ngClassEven: ngClassEvenDirective, + ngClassOdd: ngClassOddDirective, + ngCloak: ngCloakDirective, + ngController: ngControllerDirective, + ngForm: ngFormDirective, + ngHide: ngHideDirective, + ngIf: ngIfDirective, + ngInclude: ngIncludeDirective, + ngInit: ngInitDirective, + ngNonBindable: ngNonBindableDirective, + ngPluralize: ngPluralizeDirective, + ngRepeat: ngRepeatDirective, + ngShow: ngShowDirective, + ngStyle: ngStyleDirective, + ngSwitch: ngSwitchDirective, + ngSwitchWhen: ngSwitchWhenDirective, + ngSwitchDefault: ngSwitchDefaultDirective, + ngOptions: ngOptionsDirective, + ngTransclude: ngTranscludeDirective, + ngModel: ngModelDirective, + ngList: ngListDirective, + ngChange: ngChangeDirective, + pattern: patternDirective, + ngPattern: patternDirective, + required: requiredDirective, + ngRequired: requiredDirective, + minlength: minlengthDirective, + ngMinlength: minlengthDirective, + maxlength: maxlengthDirective, + ngMaxlength: maxlengthDirective, + ngValue: ngValueDirective, + ngModelOptions: ngModelOptionsDirective + }). + directive({ + ngInclude: ngIncludeFillContentDirective + }). + directive(ngAttributeAliasDirectives). + directive(ngEventDirectives); + $provide.provider({ + $anchorScroll: $AnchorScrollProvider, + $animate: $AnimateProvider, + $animateCss: $CoreAnimateCssProvider, + $$animateQueue: $$CoreAnimateQueueProvider, + $$AnimateRunner: $$CoreAnimateRunnerProvider, + $browser: $BrowserProvider, + $cacheFactory: $CacheFactoryProvider, + $controller: $ControllerProvider, + $document: $DocumentProvider, + $exceptionHandler: $ExceptionHandlerProvider, + $filter: $FilterProvider, + $$forceReflow: $$ForceReflowProvider, + $interpolate: $InterpolateProvider, + $interval: $IntervalProvider, + $http: $HttpProvider, + $httpParamSerializer: $HttpParamSerializerProvider, + $httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider, + $httpBackend: $HttpBackendProvider, + $location: $LocationProvider, + $log: $LogProvider, + $parse: $ParseProvider, + $rootScope: $RootScopeProvider, + $q: $QProvider, + $$q: $$QProvider, + $sce: $SceProvider, + $sceDelegate: $SceDelegateProvider, + $sniffer: $SnifferProvider, + $templateCache: $TemplateCacheProvider, + $templateRequest: $TemplateRequestProvider, + $$testability: $$TestabilityProvider, + $timeout: $TimeoutProvider, + $window: $WindowProvider, + $$rAF: $$RAFProvider, + $$jqLite: $$jqLiteProvider, + $$HashMap: $$HashMapProvider, + $$cookieReader: $$CookieReaderProvider + }); + } + ]); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Any commits to this file should be reviewed with security in mind. * + * Changes to this file can potentially create security vulnerabilities. * + * An approval from 2 Core members with history of modifying * + * this file is required. * + * * + * Does the change somehow allow for arbitrary javascript to be executed? * + * Or allows for someone to change the prototype of built-in objects? * + * Or gives undesired access to variables likes document or window? * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* global JQLitePrototype: true, + addEventListenerFn: true, + removeEventListenerFn: true, + BOOLEAN_ATTR: true, + ALIASED_ATTR: true, +*/ + +////////////////////////////////// +//JQLite +////////////////////////////////// + +/** + * @ngdoc function + * @name angular.element + * @module ng + * @kind function + * + * @description + * Wraps a raw DOM element or HTML string as a [jQuery](http://jquery.com) element. + * + * If jQuery is available, `angular.element` is an alias for the + * [jQuery](http://api.jquery.com/jQuery/) function. If jQuery is not available, `angular.element` + * delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite." + * + *
jqLite is a tiny, API-compatible subset of jQuery that allows + * Angular to manipulate the DOM in a cross-browser compatible way. **jqLite** implements only the most + * commonly needed functionality with the goal of having a very small footprint.
+ * + * To use `jQuery`, simply ensure it is loaded before the `angular.js` file. + * + *
**Note:** all element references in Angular are always wrapped with jQuery or + * jqLite; they are never raw DOM references.
+ * + * ## Angular's jqLite + * jqLite provides only the following jQuery methods: + * + * - [`addClass()`](http://api.jquery.com/addClass/) + * - [`after()`](http://api.jquery.com/after/) + * - [`append()`](http://api.jquery.com/append/) + * - [`attr()`](http://api.jquery.com/attr/) - Does not support functions as parameters + * - [`bind()`](http://api.jquery.com/bind/) - Does not support namespaces, selectors or eventData + * - [`children()`](http://api.jquery.com/children/) - Does not support selectors + * - [`clone()`](http://api.jquery.com/clone/) + * - [`contents()`](http://api.jquery.com/contents/) + * - [`css()`](http://api.jquery.com/css/) - Only retrieves inline-styles, does not call `getComputedStyle()`. As a setter, does not convert numbers to strings or append 'px'. + * - [`data()`](http://api.jquery.com/data/) + * - [`detach()`](http://api.jquery.com/detach/) + * - [`empty()`](http://api.jquery.com/empty/) + * - [`eq()`](http://api.jquery.com/eq/) + * - [`find()`](http://api.jquery.com/find/) - Limited to lookups by tag name + * - [`hasClass()`](http://api.jquery.com/hasClass/) + * - [`html()`](http://api.jquery.com/html/) + * - [`next()`](http://api.jquery.com/next/) - Does not support selectors + * - [`on()`](http://api.jquery.com/on/) - Does not support namespaces, selectors or eventData + * - [`off()`](http://api.jquery.com/off/) - Does not support namespaces, selectors or event object as parameter + * - [`one()`](http://api.jquery.com/one/) - Does not support namespaces or selectors + * - [`parent()`](http://api.jquery.com/parent/) - Does not support selectors + * - [`prepend()`](http://api.jquery.com/prepend/) + * - [`prop()`](http://api.jquery.com/prop/) + * - [`ready()`](http://api.jquery.com/ready/) + * - [`remove()`](http://api.jquery.com/remove/) + * - [`removeAttr()`](http://api.jquery.com/removeAttr/) + * - [`removeClass()`](http://api.jquery.com/removeClass/) + * - [`removeData()`](http://api.jquery.com/removeData/) + * - [`replaceWith()`](http://api.jquery.com/replaceWith/) + * - [`text()`](http://api.jquery.com/text/) + * - [`toggleClass()`](http://api.jquery.com/toggleClass/) + * - [`triggerHandler()`](http://api.jquery.com/triggerHandler/) - Passes a dummy event object to handlers. + * - [`unbind()`](http://api.jquery.com/unbind/) - Does not support namespaces or event object as parameter + * - [`val()`](http://api.jquery.com/val/) + * - [`wrap()`](http://api.jquery.com/wrap/) + * + * ## jQuery/jqLite Extras + * Angular also provides the following additional methods and events to both jQuery and jqLite: + * + * ### Events + * - `$destroy` - AngularJS intercepts all jqLite/jQuery's DOM destruction apis and fires this event + * on all DOM nodes being removed. This can be used to clean up any 3rd party bindings to the DOM + * element before it is removed. + * + * ### Methods + * - `controller(name)` - retrieves the controller of the current element or its parent. By default + * retrieves controller associated with the `ngController` directive. If `name` is provided as + * camelCase directive name, then the controller for this directive will be retrieved (e.g. + * `'ngModel'`). + * - `injector()` - retrieves the injector of the current element or its parent. + * - `scope()` - retrieves the {@link ng.$rootScope.Scope scope} of the current + * element or its parent. Requires {@link guide/production#disabling-debug-data Debug Data} to + * be enabled. + * - `isolateScope()` - retrieves an isolate {@link ng.$rootScope.Scope scope} if one is attached directly to the + * current element. This getter should be used only on elements that contain a directive which starts a new isolate + * scope. Calling `scope()` on this element always returns the original non-isolate scope. + * Requires {@link guide/production#disabling-debug-data Debug Data} to be enabled. + * - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top + * parent element is reached. + * + * @param {string|DOMElement} element HTML string or DOMElement to be wrapped into jQuery. + * @returns {Object} jQuery object. + */ + +JQLite.expando = 'ng339'; + +var jqCache = JQLite.cache = {}, + jqId = 1, + addEventListenerFn = function(element, type, fn) { + element.addEventListener(type, fn, false); + }, + removeEventListenerFn = function(element, type, fn) { + element.removeEventListener(type, fn, false); + }; + +/* + * !!! This is an undocumented "private" function !!! + */ +JQLite._data = function(node) { + //jQuery always returns an object on cache miss + return this.cache[node[this.expando]] || {}; +}; + +function jqNextId() { return ++jqId; } + + +var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; +var MOZ_HACK_REGEXP = /^moz([A-Z])/; +var MOUSE_EVENT_MAP= { mouseleave: "mouseout", mouseenter: "mouseover"}; +var jqLiteMinErr = minErr('jqLite'); + +/** + * Converts snake_case to camelCase. + * Also there is special case for Moz prefix starting with upper case letter. + * @param name Name to normalize + */ +function camelCase(name) { + return name. + replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) { + return offset ? letter.toUpperCase() : letter; + }). + replace(MOZ_HACK_REGEXP, 'Moz$1'); +} + +var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; +var HTML_REGEXP = /<|&#?\w+;/; +var TAG_NAME_REGEXP = /<([\w:]+)/; +var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; + +var wrapMap = { + 'option': [1, ''], + + 'thead': [1, '', '
'], + 'col': [2, '', '
'], + 'tr': [2, '', '
'], + 'td': [3, '', '
'], + '_default': [0, "", ""] +}; + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + + +function jqLiteIsTextNode(html) { + return !HTML_REGEXP.test(html); +} + +function jqLiteAcceptsData(node) { + // The window object can accept data but has no nodeType + // Otherwise we are only interested in elements (1) and documents (9) + var nodeType = node.nodeType; + return nodeType === NODE_TYPE_ELEMENT || !nodeType || nodeType === NODE_TYPE_DOCUMENT; +} + +function jqLiteHasData(node) { + for (var key in jqCache[node.ng339]) { + return true; + } + return false; +} + +function jqLiteBuildFragment(html, context) { + var tmp, tag, wrap, + fragment = context.createDocumentFragment(), + nodes = [], i; + + if (jqLiteIsTextNode(html)) { + // Convert non-html into a text node + nodes.push(context.createTextNode(html)); + } else { + // Convert html into DOM nodes + tmp = tmp || fragment.appendChild(context.createElement("div")); + tag = (TAG_NAME_REGEXP.exec(html) || ["", ""])[1].toLowerCase(); + wrap = wrapMap[tag] || wrapMap._default; + tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1>") + wrap[2]; + + // Descend through wrappers to the right content + i = wrap[0]; + while (i--) { + tmp = tmp.lastChild; + } + + nodes = concat(nodes, tmp.childNodes); + + tmp = fragment.firstChild; + tmp.textContent = ""; + } + + // Remove wrapper from fragment + fragment.textContent = ""; + fragment.innerHTML = ""; // Clear inner HTML + forEach(nodes, function(node) { + fragment.appendChild(node); + }); + + return fragment; +} + +function jqLiteParseHTML(html, context) { + context = context || document; + var parsed; + + if ((parsed = SINGLE_TAG_REGEXP.exec(html))) { + return [context.createElement(parsed[1])]; + } + + if ((parsed = jqLiteBuildFragment(html, context))) { + return parsed.childNodes; + } + + return []; +} + +///////////////////////////////////////////// +function JQLite(element) { + if (element instanceof JQLite) { + return element; + } + + var argIsString; + + if (isString(element)) { + element = trim(element); + argIsString = true; + } + if (!(this instanceof JQLite)) { + if (argIsString && element.charAt(0) != '<') { + throw jqLiteMinErr('nosel', 'Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element'); + } + return new JQLite(element); + } + + if (argIsString) { + jqLiteAddNodes(this, jqLiteParseHTML(element)); + } else { + jqLiteAddNodes(this, element); + } +} + +function jqLiteClone(element) { + return element.cloneNode(true); +} + +function jqLiteDealoc(element, onlyDescendants) { + if (!onlyDescendants) jqLiteRemoveData(element); + + if (element.querySelectorAll) { + var descendants = element.querySelectorAll('*'); + for (var i = 0, l = descendants.length; i < l; i++) { + jqLiteRemoveData(descendants[i]); + } + } +} + +function jqLiteOff(element, type, fn, unsupported) { + if (isDefined(unsupported)) throw jqLiteMinErr('offargs', 'jqLite#off() does not support the `selector` argument'); + + var expandoStore = jqLiteExpandoStore(element); + var events = expandoStore && expandoStore.events; + var handle = expandoStore && expandoStore.handle; + + if (!handle) return; //no listeners registered + + if (!type) { + for (type in events) { + if (type !== '$destroy') { + removeEventListenerFn(element, type, handle); + } + delete events[type]; + } + } else { + forEach(type.split(' '), function(type) { + if (isDefined(fn)) { + var listenerFns = events[type]; + arrayRemove(listenerFns || [], fn); + if (listenerFns && listenerFns.length > 0) { + return; + } + } + + removeEventListenerFn(element, type, handle); + delete events[type]; + }); + } +} + +function jqLiteRemoveData(element, name) { + var expandoId = element.ng339; + var expandoStore = expandoId && jqCache[expandoId]; + + if (expandoStore) { + if (name) { + delete expandoStore.data[name]; + return; + } + + if (expandoStore.handle) { + if (expandoStore.events.$destroy) { + expandoStore.handle({}, '$destroy'); + } + jqLiteOff(element); + } + delete jqCache[expandoId]; + element.ng339 = undefined; // don't delete DOM expandos. IE and Chrome don't like it + } +} + + +function jqLiteExpandoStore(element, createIfNecessary) { + var expandoId = element.ng339, + expandoStore = expandoId && jqCache[expandoId]; + + if (createIfNecessary && !expandoStore) { + element.ng339 = expandoId = jqNextId(); + expandoStore = jqCache[expandoId] = {events: {}, data: {}, handle: undefined}; + } + + return expandoStore; +} + + +function jqLiteData(element, key, value) { + if (jqLiteAcceptsData(element)) { + + var isSimpleSetter = isDefined(value); + var isSimpleGetter = !isSimpleSetter && key && !isObject(key); + var massGetter = !key; + var expandoStore = jqLiteExpandoStore(element, !isSimpleGetter); + var data = expandoStore && expandoStore.data; + + if (isSimpleSetter) { // data('key', value) + data[key] = value; + } else { + if (massGetter) { // data() + return data; + } else { + if (isSimpleGetter) { // data('key') + // don't force creation of expandoStore if it doesn't exist yet + return data && data[key]; + } else { // mass-setter: data({key1: val1, key2: val2}) + extend(data, key); + } + } + } + } +} + +function jqLiteHasClass(element, selector) { + if (!element.getAttribute) return false; + return ((" " + (element.getAttribute('class') || '') + " ").replace(/[\n\t]/g, " "). + indexOf(" " + selector + " ") > -1); +} + +function jqLiteRemoveClass(element, cssClasses) { + if (cssClasses && element.setAttribute) { + forEach(cssClasses.split(' '), function(cssClass) { + element.setAttribute('class', trim( + (" " + (element.getAttribute('class') || '') + " ") + .replace(/[\n\t]/g, " ") + .replace(" " + trim(cssClass) + " ", " ")) + ); + }); + } +} + +function jqLiteAddClass(element, cssClasses) { + if (cssClasses && element.setAttribute) { + var existingClasses = (' ' + (element.getAttribute('class') || '') + ' ') + .replace(/[\n\t]/g, " "); + + forEach(cssClasses.split(' '), function(cssClass) { + cssClass = trim(cssClass); + if (existingClasses.indexOf(' ' + cssClass + ' ') === -1) { + existingClasses += cssClass + ' '; + } + }); + + element.setAttribute('class', trim(existingClasses)); + } +} + + +function jqLiteAddNodes(root, elements) { + // THIS CODE IS VERY HOT. Don't make changes without benchmarking. + + if (elements) { + + // if a Node (the most common case) + if (elements.nodeType) { + root[root.length++] = elements; + } else { + var length = elements.length; + + // if an Array or NodeList and not a Window + if (typeof length === 'number' && elements.window !== elements) { + if (length) { + for (var i = 0; i < length; i++) { + root[root.length++] = elements[i]; + } + } + } else { + root[root.length++] = elements; + } + } + } +} + + +function jqLiteController(element, name) { + return jqLiteInheritedData(element, '$' + (name || 'ngController') + 'Controller'); +} + +function jqLiteInheritedData(element, name, value) { + // if element is the document object work with the html element instead + // this makes $(document).scope() possible + if (element.nodeType == NODE_TYPE_DOCUMENT) { + element = element.documentElement; + } + var names = isArray(name) ? name : [name]; + + while (element) { + for (var i = 0, ii = names.length; i < ii; i++) { + if (isDefined(value = jqLite.data(element, names[i]))) return value; + } + + // If dealing with a document fragment node with a host element, and no parent, use the host + // element as the parent. This enables directives within a Shadow DOM or polyfilled Shadow DOM + // to lookup parent controllers. + element = element.parentNode || (element.nodeType === NODE_TYPE_DOCUMENT_FRAGMENT && element.host); + } +} + +function jqLiteEmpty(element) { + jqLiteDealoc(element, true); + while (element.firstChild) { + element.removeChild(element.firstChild); + } +} + +function jqLiteRemove(element, keepData) { + if (!keepData) jqLiteDealoc(element); + var parent = element.parentNode; + if (parent) parent.removeChild(element); +} + + +function jqLiteDocumentLoaded(action, win) { + win = win || window; + if (win.document.readyState === 'complete') { + // Force the action to be run async for consistent behaviour + // from the action's point of view + // i.e. it will definitely not be in a $apply + win.setTimeout(action); + } else { + // No need to unbind this handler as load is only ever called once + jqLite(win).on('load', action); + } +} + +////////////////////////////////////////// +// Functions which are declared directly. +////////////////////////////////////////// +var JQLitePrototype = JQLite.prototype = { + ready: function(fn) { + var fired = false; + + function trigger() { + if (fired) return; + fired = true; + fn(); + } + + // check if document is already loaded + if (document.readyState === 'complete') { + setTimeout(trigger); + } else { + this.on('DOMContentLoaded', trigger); // works for modern browsers and IE9 + // we can not use jqLite since we are not done loading and jQuery could be loaded later. + // jshint -W064 + JQLite(window).on('load', trigger); // fallback to window.onload for others + // jshint +W064 + } + }, + toString: function() { + var value = []; + forEach(this, function(e) { value.push('' + e);}); + return '[' + value.join(', ') + ']'; + }, + + eq: function(index) { + return (index >= 0) ? jqLite(this[index]) : jqLite(this[this.length + index]); + }, + + length: 0, + push: push, + sort: [].sort, + splice: [].splice +}; + +////////////////////////////////////////// +// Functions iterating getter/setters. +// these functions return self on setter and +// value on get. +////////////////////////////////////////// +var BOOLEAN_ATTR = {}; +forEach('multiple,selected,checked,disabled,readOnly,required,open'.split(','), function(value) { + BOOLEAN_ATTR[lowercase(value)] = value; +}); +var BOOLEAN_ELEMENTS = {}; +forEach('input,select,option,textarea,button,form,details'.split(','), function(value) { + BOOLEAN_ELEMENTS[value] = true; +}); +var ALIASED_ATTR = { + 'ngMinlength': 'minlength', + 'ngMaxlength': 'maxlength', + 'ngMin': 'min', + 'ngMax': 'max', + 'ngPattern': 'pattern' +}; + +function getBooleanAttrName(element, name) { + // check dom last since we will most likely fail on name + var booleanAttr = BOOLEAN_ATTR[name.toLowerCase()]; + + // booleanAttr is here twice to minimize DOM access + return booleanAttr && BOOLEAN_ELEMENTS[nodeName_(element)] && booleanAttr; +} + +function getAliasedAttrName(name) { + return ALIASED_ATTR[name]; +} + +forEach({ + data: jqLiteData, + removeData: jqLiteRemoveData, + hasData: jqLiteHasData +}, function(fn, name) { + JQLite[name] = fn; +}); + +forEach({ + data: jqLiteData, + inheritedData: jqLiteInheritedData, + + scope: function(element) { + // Can't use jqLiteData here directly so we stay compatible with jQuery! + return jqLite.data(element, '$scope') || jqLiteInheritedData(element.parentNode || element, ['$isolateScope', '$scope']); + }, + + isolateScope: function(element) { + // Can't use jqLiteData here directly so we stay compatible with jQuery! + return jqLite.data(element, '$isolateScope') || jqLite.data(element, '$isolateScopeNoTemplate'); + }, + + controller: jqLiteController, + + injector: function(element) { + return jqLiteInheritedData(element, '$injector'); + }, + + removeAttr: function(element, name) { + element.removeAttribute(name); + }, + + hasClass: jqLiteHasClass, + + css: function(element, name, value) { + name = camelCase(name); + + if (isDefined(value)) { + element.style[name] = value; + } else { + return element.style[name]; + } + }, + + attr: function(element, name, value) { + var nodeType = element.nodeType; + if (nodeType === NODE_TYPE_TEXT || nodeType === NODE_TYPE_ATTRIBUTE || nodeType === NODE_TYPE_COMMENT) { + return; + } + var lowercasedName = lowercase(name); + if (BOOLEAN_ATTR[lowercasedName]) { + if (isDefined(value)) { + if (!!value) { + element[name] = true; + element.setAttribute(name, lowercasedName); + } else { + element[name] = false; + element.removeAttribute(lowercasedName); + } + } else { + return (element[name] || + (element.attributes.getNamedItem(name) || noop).specified) + ? lowercasedName + : undefined; + } + } else if (isDefined(value)) { + element.setAttribute(name, value); + } else if (element.getAttribute) { + // the extra argument "2" is to get the right thing for a.href in IE, see jQuery code + // some elements (e.g. Document) don't have get attribute, so return undefined + var ret = element.getAttribute(name, 2); + // normalize non-existing attributes to undefined (as jQuery) + return ret === null ? undefined : ret; + } + }, + + prop: function(element, name, value) { + if (isDefined(value)) { + element[name] = value; + } else { + return element[name]; + } + }, + + text: (function() { + getText.$dv = ''; + return getText; + + function getText(element, value) { + if (isUndefined(value)) { + var nodeType = element.nodeType; + return (nodeType === NODE_TYPE_ELEMENT || nodeType === NODE_TYPE_TEXT) ? element.textContent : ''; + } + element.textContent = value; + } + })(), + + val: function(element, value) { + if (isUndefined(value)) { + if (element.multiple && nodeName_(element) === 'select') { + var result = []; + forEach(element.options, function(option) { + if (option.selected) { + result.push(option.value || option.text); + } + }); + return result.length === 0 ? null : result; + } + return element.value; + } + element.value = value; + }, + + html: function(element, value) { + if (isUndefined(value)) { + return element.innerHTML; + } + jqLiteDealoc(element, true); + element.innerHTML = value; + }, + + empty: jqLiteEmpty +}, function(fn, name) { + /** + * Properties: writes return selection, reads return first value + */ + JQLite.prototype[name] = function(arg1, arg2) { + var i, key; + var nodeCount = this.length; + + // jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it + // in a way that survives minification. + // jqLiteEmpty takes no arguments but is a setter. + if (fn !== jqLiteEmpty && + (isUndefined((fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController)) ? arg1 : arg2))) { + if (isObject(arg1)) { + + // we are a write, but the object properties are the key/values + for (i = 0; i < nodeCount; i++) { + if (fn === jqLiteData) { + // data() takes the whole object in jQuery + fn(this[i], arg1); + } else { + for (key in arg1) { + fn(this[i], key, arg1[key]); + } + } + } + // return self for chaining + return this; + } else { + // we are a read, so read the first child. + // TODO: do we still need this? + var value = fn.$dv; + // Only if we have $dv do we iterate over all, otherwise it is just the first element. + var jj = (isUndefined(value)) ? Math.min(nodeCount, 1) : nodeCount; + for (var j = 0; j < jj; j++) { + var nodeValue = fn(this[j], arg1, arg2); + value = value ? value + nodeValue : nodeValue; + } + return value; + } + } else { + // we are a write, so apply to all children + for (i = 0; i < nodeCount; i++) { + fn(this[i], arg1, arg2); + } + // return self for chaining + return this; + } + }; +}); + +function createEventHandler(element, events) { + var eventHandler = function(event, type) { + // jQuery specific api + event.isDefaultPrevented = function() { + return event.defaultPrevented; + }; + + var eventFns = events[type || event.type]; + var eventFnsLength = eventFns ? eventFns.length : 0; + + if (!eventFnsLength) return; + + if (isUndefined(event.immediatePropagationStopped)) { + var originalStopImmediatePropagation = event.stopImmediatePropagation; + event.stopImmediatePropagation = function() { + event.immediatePropagationStopped = true; + + if (event.stopPropagation) { + event.stopPropagation(); + } + + if (originalStopImmediatePropagation) { + originalStopImmediatePropagation.call(event); + } + }; + } + + event.isImmediatePropagationStopped = function() { + return event.immediatePropagationStopped === true; + }; + + // Copy event handlers in case event handlers array is modified during execution. + if ((eventFnsLength > 1)) { + eventFns = shallowCopy(eventFns); + } + + for (var i = 0; i < eventFnsLength; i++) { + if (!event.isImmediatePropagationStopped()) { + eventFns[i].call(element, event); + } + } + }; + + // TODO: this is a hack for angularMocks/clearDataCache that makes it possible to deregister all + // events on `element` + eventHandler.elem = element; + return eventHandler; +} + +////////////////////////////////////////// +// Functions iterating traversal. +// These functions chain results into a single +// selector. +////////////////////////////////////////// +forEach({ + removeData: jqLiteRemoveData, + + on: function jqLiteOn(element, type, fn, unsupported) { + if (isDefined(unsupported)) throw jqLiteMinErr('onargs', 'jqLite#on() does not support the `selector` or `eventData` parameters'); + + // Do not add event handlers to non-elements because they will not be cleaned up. + if (!jqLiteAcceptsData(element)) { + return; + } + + var expandoStore = jqLiteExpandoStore(element, true); + var events = expandoStore.events; + var handle = expandoStore.handle; + + if (!handle) { + handle = expandoStore.handle = createEventHandler(element, events); + } + + // http://jsperf.com/string-indexof-vs-split + var types = type.indexOf(' ') >= 0 ? type.split(' ') : [type]; + var i = types.length; + + while (i--) { + type = types[i]; + var eventFns = events[type]; + + if (!eventFns) { + events[type] = []; + + if (type === 'mouseenter' || type === 'mouseleave') { + // Refer to jQuery's implementation of mouseenter & mouseleave + // Read about mouseenter and mouseleave: + // http://www.quirksmode.org/js/events_mouse.html#link8 + + jqLiteOn(element, MOUSE_EVENT_MAP[type], function(event) { + var target = this, related = event.relatedTarget; + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if (!related || (related !== target && !target.contains(related))) { + handle(event, type); + } + }); + + } else { + if (type !== '$destroy') { + addEventListenerFn(element, type, handle); + } + } + eventFns = events[type]; + } + eventFns.push(fn); + } + }, + + off: jqLiteOff, + + one: function(element, type, fn) { + element = jqLite(element); + + //add the listener twice so that when it is called + //you can remove the original function and still be + //able to call element.off(ev, fn) normally + element.on(type, function onFn() { + element.off(type, fn); + element.off(type, onFn); + }); + element.on(type, fn); + }, + + replaceWith: function(element, replaceNode) { + var index, parent = element.parentNode; + jqLiteDealoc(element); + forEach(new JQLite(replaceNode), function(node) { + if (index) { + parent.insertBefore(node, index.nextSibling); + } else { + parent.replaceChild(node, element); + } + index = node; + }); + }, + + children: function(element) { + var children = []; + forEach(element.childNodes, function(element) { + if (element.nodeType === NODE_TYPE_ELEMENT) { + children.push(element); + } + }); + return children; + }, + + contents: function(element) { + return element.contentDocument || element.childNodes || []; + }, + + append: function(element, node) { + var nodeType = element.nodeType; + if (nodeType !== NODE_TYPE_ELEMENT && nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT) return; + + node = new JQLite(node); + + for (var i = 0, ii = node.length; i < ii; i++) { + var child = node[i]; + element.appendChild(child); + } + }, + + prepend: function(element, node) { + if (element.nodeType === NODE_TYPE_ELEMENT) { + var index = element.firstChild; + forEach(new JQLite(node), function(child) { + element.insertBefore(child, index); + }); + } + }, + + wrap: function(element, wrapNode) { + wrapNode = jqLite(wrapNode).eq(0).clone()[0]; + var parent = element.parentNode; + if (parent) { + parent.replaceChild(wrapNode, element); + } + wrapNode.appendChild(element); + }, + + remove: jqLiteRemove, + + detach: function(element) { + jqLiteRemove(element, true); + }, + + after: function(element, newElement) { + var index = element, parent = element.parentNode; + newElement = new JQLite(newElement); + + for (var i = 0, ii = newElement.length; i < ii; i++) { + var node = newElement[i]; + parent.insertBefore(node, index.nextSibling); + index = node; + } + }, + + addClass: jqLiteAddClass, + removeClass: jqLiteRemoveClass, + + toggleClass: function(element, selector, condition) { + if (selector) { + forEach(selector.split(' '), function(className) { + var classCondition = condition; + if (isUndefined(classCondition)) { + classCondition = !jqLiteHasClass(element, className); + } + (classCondition ? jqLiteAddClass : jqLiteRemoveClass)(element, className); + }); + } + }, + + parent: function(element) { + var parent = element.parentNode; + return parent && parent.nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT ? parent : null; + }, + + next: function(element) { + return element.nextElementSibling; + }, + + find: function(element, selector) { + if (element.getElementsByTagName) { + return element.getElementsByTagName(selector); + } else { + return []; + } + }, + + clone: jqLiteClone, + + triggerHandler: function(element, event, extraParameters) { + + var dummyEvent, eventFnsCopy, handlerArgs; + var eventName = event.type || event; + var expandoStore = jqLiteExpandoStore(element); + var events = expandoStore && expandoStore.events; + var eventFns = events && events[eventName]; + + if (eventFns) { + // Create a dummy event to pass to the handlers + dummyEvent = { + preventDefault: function() { this.defaultPrevented = true; }, + isDefaultPrevented: function() { return this.defaultPrevented === true; }, + stopImmediatePropagation: function() { this.immediatePropagationStopped = true; }, + isImmediatePropagationStopped: function() { return this.immediatePropagationStopped === true; }, + stopPropagation: noop, + type: eventName, + target: element + }; + + // If a custom event was provided then extend our dummy event with it + if (event.type) { + dummyEvent = extend(dummyEvent, event); + } + + // Copy event handlers in case event handlers array is modified during execution. + eventFnsCopy = shallowCopy(eventFns); + handlerArgs = extraParameters ? [dummyEvent].concat(extraParameters) : [dummyEvent]; + + forEach(eventFnsCopy, function(fn) { + if (!dummyEvent.isImmediatePropagationStopped()) { + fn.apply(element, handlerArgs); + } + }); + } + } +}, function(fn, name) { + /** + * chaining functions + */ + JQLite.prototype[name] = function(arg1, arg2, arg3) { + var value; + + for (var i = 0, ii = this.length; i < ii; i++) { + if (isUndefined(value)) { + value = fn(this[i], arg1, arg2, arg3); + if (isDefined(value)) { + // any function which returns a value needs to be wrapped + value = jqLite(value); + } + } else { + jqLiteAddNodes(value, fn(this[i], arg1, arg2, arg3)); + } + } + return isDefined(value) ? value : this; + }; + + // bind legacy bind/unbind to on/off + JQLite.prototype.bind = JQLite.prototype.on; + JQLite.prototype.unbind = JQLite.prototype.off; +}); + + +// Provider for private $$jqLite service +function $$jqLiteProvider() { + this.$get = function $$jqLite() { + return extend(JQLite, { + hasClass: function(node, classes) { + if (node.attr) node = node[0]; + return jqLiteHasClass(node, classes); + }, + addClass: function(node, classes) { + if (node.attr) node = node[0]; + return jqLiteAddClass(node, classes); + }, + removeClass: function(node, classes) { + if (node.attr) node = node[0]; + return jqLiteRemoveClass(node, classes); + } + }); + }; +} + +/** + * Computes a hash of an 'obj'. + * Hash of a: + * string is string + * number is number as string + * object is either result of calling $$hashKey function on the object or uniquely generated id, + * that is also assigned to the $$hashKey property of the object. + * + * @param obj + * @returns {string} hash string such that the same input will have the same hash string. + * The resulting string key is in 'type:hashKey' format. + */ +function hashKey(obj, nextUidFn) { + var key = obj && obj.$$hashKey; + + if (key) { + if (typeof key === 'function') { + key = obj.$$hashKey(); + } + return key; + } + + var objType = typeof obj; + if (objType == 'function' || (objType == 'object' && obj !== null)) { + key = obj.$$hashKey = objType + ':' + (nextUidFn || nextUid)(); + } else { + key = objType + ':' + obj; + } + + return key; +} + +/** + * HashMap which can use objects as keys + */ +function HashMap(array, isolatedUid) { + if (isolatedUid) { + var uid = 0; + this.nextUid = function() { + return ++uid; + }; + } + forEach(array, this.put, this); +} +HashMap.prototype = { + /** + * Store key value pair + * @param key key to store can be any type + * @param value value to store can be any type + */ + put: function(key, value) { + this[hashKey(key, this.nextUid)] = value; + }, + + /** + * @param key + * @returns {Object} the value for the key + */ + get: function(key) { + return this[hashKey(key, this.nextUid)]; + }, + + /** + * Remove the key/value pair + * @param key + */ + remove: function(key) { + var value = this[key = hashKey(key, this.nextUid)]; + delete this[key]; + return value; + } +}; + +var $$HashMapProvider = [function() { + this.$get = [function() { + return HashMap; + }]; +}]; + +/** + * @ngdoc function + * @module ng + * @name angular.injector + * @kind function + * + * @description + * Creates an injector object that can be used for retrieving services as well as for + * dependency injection (see {@link guide/di dependency injection}). + * + * @param {Array.} modules A list of module functions or their aliases. See + * {@link angular.module}. The `ng` module must be explicitly added. + * @param {boolean=} [strictDi=false] Whether the injector should be in strict mode, which + * disallows argument name annotation inference. + * @returns {injector} Injector object. See {@link auto.$injector $injector}. + * + * @example + * Typical usage + * ```js + * // create an injector + * var $injector = angular.injector(['ng']); + * + * // use the injector to kick off your application + * // use the type inference to auto inject arguments, or use implicit injection + * $injector.invoke(function($rootScope, $compile, $document) { + * $compile($document)($rootScope); + * $rootScope.$digest(); + * }); + * ``` + * + * Sometimes you want to get access to the injector of a currently running Angular app + * from outside Angular. Perhaps, you want to inject and compile some markup after the + * application has been bootstrapped. You can do this using the extra `injector()` added + * to JQuery/jqLite elements. See {@link angular.element}. + * + * *This is fairly rare but could be the case if a third party library is injecting the + * markup.* + * + * In the following example a new block of HTML containing a `ng-controller` + * directive is added to the end of the document body by JQuery. We then compile and link + * it into the current AngularJS scope. + * + * ```js + * var $div = $('
{{content.label}}
'); + * $(document.body).append($div); + * + * angular.element(document).injector().invoke(function($compile) { + * var scope = angular.element($div).scope(); + * $compile($div)(scope); + * }); + * ``` + */ + + +/** + * @ngdoc module + * @name auto + * @description + * + * Implicit module which gets automatically added to each {@link auto.$injector $injector}. + */ + +var FN_ARGS = /^[^\(]*\(\s*([^\)]*)\)/m; +var FN_ARG_SPLIT = /,/; +var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/; +var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; +var $injectorMinErr = minErr('$injector'); + +function anonFn(fn) { + // For anonymous functions, showing at the very least the function signature can help in + // debugging. + var fnText = fn.toString().replace(STRIP_COMMENTS, ''), + args = fnText.match(FN_ARGS); + if (args) { + return 'function(' + (args[1] || '').replace(/[\s\r\n]+/, ' ') + ')'; + } + return 'fn'; +} + +function annotate(fn, strictDi, name) { + var $inject, + fnText, + argDecl, + last; + + if (typeof fn === 'function') { + if (!($inject = fn.$inject)) { + $inject = []; + if (fn.length) { + if (strictDi) { + if (!isString(name) || !name) { + name = fn.name || anonFn(fn); + } + throw $injectorMinErr('strictdi', + '{0} is not using explicit annotation and cannot be invoked in strict mode', name); + } + fnText = fn.toString().replace(STRIP_COMMENTS, ''); + argDecl = fnText.match(FN_ARGS); + forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) { + arg.replace(FN_ARG, function(all, underscore, name) { + $inject.push(name); + }); + }); + } + fn.$inject = $inject; + } + } else if (isArray(fn)) { + last = fn.length - 1; + assertArgFn(fn[last], 'fn'); + $inject = fn.slice(0, last); + } else { + assertArgFn(fn, 'fn', true); + } + return $inject; +} + +/////////////////////////////////////// + +/** + * @ngdoc service + * @name $injector + * + * @description + * + * `$injector` is used to retrieve object instances as defined by + * {@link auto.$provide provider}, instantiate types, invoke methods, + * and load modules. + * + * The following always holds true: + * + * ```js + * var $injector = angular.injector(); + * expect($injector.get('$injector')).toBe($injector); + * expect($injector.invoke(function($injector) { + * return $injector; + * })).toBe($injector); + * ``` + * + * # Injection Function Annotation + * + * JavaScript does not have annotations, and annotations are needed for dependency injection. The + * following are all valid ways of annotating function with injection arguments and are equivalent. + * + * ```js + * // inferred (only works if code not minified/obfuscated) + * $injector.invoke(function(serviceA){}); + * + * // annotated + * function explicit(serviceA) {}; + * explicit.$inject = ['serviceA']; + * $injector.invoke(explicit); + * + * // inline + * $injector.invoke(['serviceA', function(serviceA){}]); + * ``` + * + * ## Inference + * + * In JavaScript calling `toString()` on a function returns the function definition. The definition + * can then be parsed and the function arguments can be extracted. This method of discovering + * annotations is disallowed when the injector is in strict mode. + * *NOTE:* This does not work with minification, and obfuscation tools since these tools change the + * argument names. + * + * ## `$inject` Annotation + * By adding an `$inject` property onto a function the injection parameters can be specified. + * + * ## Inline + * As an array of injection names, where the last item in the array is the function to call. + */ + +/** + * @ngdoc method + * @name $injector#get + * + * @description + * Return an instance of the service. + * + * @param {string} name The name of the instance to retrieve. + * @param {string=} caller An optional string to provide the origin of the function call for error messages. + * @return {*} The instance. + */ + +/** + * @ngdoc method + * @name $injector#invoke + * + * @description + * Invoke the method and supply the method arguments from the `$injector`. + * + * @param {Function|Array.} fn The injectable function to invoke. Function parameters are + * injected according to the {@link guide/di $inject Annotation} rules. + * @param {Object=} self The `this` for the invoked method. + * @param {Object=} locals Optional object. If preset then any argument names are read from this + * object first, before the `$injector` is consulted. + * @returns {*} the value returned by the invoked `fn` function. + */ + +/** + * @ngdoc method + * @name $injector#has + * + * @description + * Allows the user to query if the particular service exists. + * + * @param {string} name Name of the service to query. + * @returns {boolean} `true` if injector has given service. + */ + +/** + * @ngdoc method + * @name $injector#instantiate + * @description + * Create a new instance of JS type. The method takes a constructor function, invokes the new + * operator, and supplies all of the arguments to the constructor function as specified by the + * constructor annotation. + * + * @param {Function} Type Annotated constructor function. + * @param {Object=} locals Optional object. If preset then any argument names are read from this + * object first, before the `$injector` is consulted. + * @returns {Object} new instance of `Type`. + */ + +/** + * @ngdoc method + * @name $injector#annotate + * + * @description + * Returns an array of service names which the function is requesting for injection. This API is + * used by the injector to determine which services need to be injected into the function when the + * function is invoked. There are three ways in which the function can be annotated with the needed + * dependencies. + * + * # Argument names + * + * The simplest form is to extract the dependencies from the arguments of the function. This is done + * by converting the function into a string using `toString()` method and extracting the argument + * names. + * ```js + * // Given + * function MyController($scope, $route) { + * // ... + * } + * + * // Then + * expect(injector.annotate(MyController)).toEqual(['$scope', '$route']); + * ``` + * + * You can disallow this method by using strict injection mode. + * + * This method does not work with code minification / obfuscation. For this reason the following + * annotation strategies are supported. + * + * # The `$inject` property + * + * If a function has an `$inject` property and its value is an array of strings, then the strings + * represent names of services to be injected into the function. + * ```js + * // Given + * var MyController = function(obfuscatedScope, obfuscatedRoute) { + * // ... + * } + * // Define function dependencies + * MyController['$inject'] = ['$scope', '$route']; + * + * // Then + * expect(injector.annotate(MyController)).toEqual(['$scope', '$route']); + * ``` + * + * # The array notation + * + * It is often desirable to inline Injected functions and that's when setting the `$inject` property + * is very inconvenient. In these situations using the array notation to specify the dependencies in + * a way that survives minification is a better choice: + * + * ```js + * // We wish to write this (not minification / obfuscation safe) + * injector.invoke(function($compile, $rootScope) { + * // ... + * }); + * + * // We are forced to write break inlining + * var tmpFn = function(obfuscatedCompile, obfuscatedRootScope) { + * // ... + * }; + * tmpFn.$inject = ['$compile', '$rootScope']; + * injector.invoke(tmpFn); + * + * // To better support inline function the inline annotation is supported + * injector.invoke(['$compile', '$rootScope', function(obfCompile, obfRootScope) { + * // ... + * }]); + * + * // Therefore + * expect(injector.annotate( + * ['$compile', '$rootScope', function(obfus_$compile, obfus_$rootScope) {}]) + * ).toEqual(['$compile', '$rootScope']); + * ``` + * + * @param {Function|Array.} fn Function for which dependent service names need to + * be retrieved as described above. + * + * @param {boolean=} [strictDi=false] Disallow argument name annotation inference. + * + * @returns {Array.} The names of the services which the function requires. + */ + + + + +/** + * @ngdoc service + * @name $provide + * + * @description + * + * The {@link auto.$provide $provide} service has a number of methods for registering components + * with the {@link auto.$injector $injector}. Many of these functions are also exposed on + * {@link angular.Module}. + * + * An Angular **service** is a singleton object created by a **service factory**. These **service + * factories** are functions which, in turn, are created by a **service provider**. + * The **service providers** are constructor functions. When instantiated they must contain a + * property called `$get`, which holds the **service factory** function. + * + * When you request a service, the {@link auto.$injector $injector} is responsible for finding the + * correct **service provider**, instantiating it and then calling its `$get` **service factory** + * function to get the instance of the **service**. + * + * Often services have no configuration options and there is no need to add methods to the service + * provider. The provider will be no more than a constructor function with a `$get` property. For + * these cases the {@link auto.$provide $provide} service has additional helper methods to register + * services without specifying a provider. + * + * * {@link auto.$provide#provider provider(provider)} - registers a **service provider** with the + * {@link auto.$injector $injector} + * * {@link auto.$provide#constant constant(obj)} - registers a value/object that can be accessed by + * providers and services. + * * {@link auto.$provide#value value(obj)} - registers a value/object that can only be accessed by + * services, not providers. + * * {@link auto.$provide#factory factory(fn)} - registers a service **factory function**, `fn`, + * that will be wrapped in a **service provider** object, whose `$get` property will contain the + * given factory function. + * * {@link auto.$provide#service service(class)} - registers a **constructor function**, `class` + * that will be wrapped in a **service provider** object, whose `$get` property will instantiate + * a new object using the given constructor function. + * + * See the individual methods for more information and examples. + */ + +/** + * @ngdoc method + * @name $provide#provider + * @description + * + * Register a **provider function** with the {@link auto.$injector $injector}. Provider functions + * are constructor functions, whose instances are responsible for "providing" a factory for a + * service. + * + * Service provider names start with the name of the service they provide followed by `Provider`. + * For example, the {@link ng.$log $log} service has a provider called + * {@link ng.$logProvider $logProvider}. + * + * Service provider objects can have additional methods which allow configuration of the provider + * and its service. Importantly, you can configure what kind of service is created by the `$get` + * method, or how that service will act. For example, the {@link ng.$logProvider $logProvider} has a + * method {@link ng.$logProvider#debugEnabled debugEnabled} + * which lets you specify whether the {@link ng.$log $log} service will log debug messages to the + * console or not. + * + * @param {string} name The name of the instance. NOTE: the provider will be available under `name + + 'Provider'` key. + * @param {(Object|function())} provider If the provider is: + * + * - `Object`: then it should have a `$get` method. The `$get` method will be invoked using + * {@link auto.$injector#invoke $injector.invoke()} when an instance needs to be created. + * - `Constructor`: a new instance of the provider will be created using + * {@link auto.$injector#instantiate $injector.instantiate()}, then treated as `object`. + * + * @returns {Object} registered provider instance + + * @example + * + * The following example shows how to create a simple event tracking service and register it using + * {@link auto.$provide#provider $provide.provider()}. + * + * ```js + * // Define the eventTracker provider + * function EventTrackerProvider() { + * var trackingUrl = '/track'; + * + * // A provider method for configuring where the tracked events should been saved + * this.setTrackingUrl = function(url) { + * trackingUrl = url; + * }; + * + * // The service factory function + * this.$get = ['$http', function($http) { + * var trackedEvents = {}; + * return { + * // Call this to track an event + * event: function(event) { + * var count = trackedEvents[event] || 0; + * count += 1; + * trackedEvents[event] = count; + * return count; + * }, + * // Call this to save the tracked events to the trackingUrl + * save: function() { + * $http.post(trackingUrl, trackedEvents); + * } + * }; + * }]; + * } + * + * describe('eventTracker', function() { + * var postSpy; + * + * beforeEach(module(function($provide) { + * // Register the eventTracker provider + * $provide.provider('eventTracker', EventTrackerProvider); + * })); + * + * beforeEach(module(function(eventTrackerProvider) { + * // Configure eventTracker provider + * eventTrackerProvider.setTrackingUrl('/custom-track'); + * })); + * + * it('tracks events', inject(function(eventTracker) { + * expect(eventTracker.event('login')).toEqual(1); + * expect(eventTracker.event('login')).toEqual(2); + * })); + * + * it('saves to the tracking url', inject(function(eventTracker, $http) { + * postSpy = spyOn($http, 'post'); + * eventTracker.event('login'); + * eventTracker.save(); + * expect(postSpy).toHaveBeenCalled(); + * expect(postSpy.mostRecentCall.args[0]).not.toEqual('/track'); + * expect(postSpy.mostRecentCall.args[0]).toEqual('/custom-track'); + * expect(postSpy.mostRecentCall.args[1]).toEqual({ 'login': 1 }); + * })); + * }); + * ``` + */ + +/** + * @ngdoc method + * @name $provide#factory + * @description + * + * Register a **service factory**, which will be called to return the service instance. + * This is short for registering a service where its provider consists of only a `$get` property, + * which is the given service factory function. + * You should use {@link auto.$provide#factory $provide.factory(getFn)} if you do not need to + * configure your service in a provider. + * + * @param {string} name The name of the instance. + * @param {Function|Array.} $getFn The injectable $getFn for the instance creation. + * Internally this is a short hand for `$provide.provider(name, {$get: $getFn})`. + * @returns {Object} registered provider instance + * + * @example + * Here is an example of registering a service + * ```js + * $provide.factory('ping', ['$http', function($http) { + * return function ping() { + * return $http.send('/ping'); + * }; + * }]); + * ``` + * You would then inject and use this service like this: + * ```js + * someModule.controller('Ctrl', ['ping', function(ping) { + * ping(); + * }]); + * ``` + */ + + +/** + * @ngdoc method + * @name $provide#service + * @description + * + * Register a **service constructor**, which will be invoked with `new` to create the service + * instance. + * This is short for registering a service where its provider's `$get` property is the service + * constructor function that will be used to instantiate the service instance. + * + * You should use {@link auto.$provide#service $provide.service(class)} if you define your service + * as a type/class. + * + * @param {string} name The name of the instance. + * @param {Function|Array.} constructor An injectable class (constructor function) + * that will be instantiated. + * @returns {Object} registered provider instance + * + * @example + * Here is an example of registering a service using + * {@link auto.$provide#service $provide.service(class)}. + * ```js + * var Ping = function($http) { + * this.$http = $http; + * }; + * + * Ping.$inject = ['$http']; + * + * Ping.prototype.send = function() { + * return this.$http.get('/ping'); + * }; + * $provide.service('ping', Ping); + * ``` + * You would then inject and use this service like this: + * ```js + * someModule.controller('Ctrl', ['ping', function(ping) { + * ping.send(); + * }]); + * ``` + */ + + +/** + * @ngdoc method + * @name $provide#value + * @description + * + * Register a **value service** with the {@link auto.$injector $injector}, such as a string, a + * number, an array, an object or a function. This is short for registering a service where its + * provider's `$get` property is a factory function that takes no arguments and returns the **value + * service**. + * + * Value services are similar to constant services, except that they cannot be injected into a + * module configuration function (see {@link angular.Module#config}) but they can be overridden by + * an Angular + * {@link auto.$provide#decorator decorator}. + * + * @param {string} name The name of the instance. + * @param {*} value The value. + * @returns {Object} registered provider instance + * + * @example + * Here are some examples of creating value services. + * ```js + * $provide.value('ADMIN_USER', 'admin'); + * + * $provide.value('RoleLookup', { admin: 0, writer: 1, reader: 2 }); + * + * $provide.value('halfOf', function(value) { + * return value / 2; + * }); + * ``` + */ + + +/** + * @ngdoc method + * @name $provide#constant + * @description + * + * Register a **constant service**, such as a string, a number, an array, an object or a function, + * with the {@link auto.$injector $injector}. Unlike {@link auto.$provide#value value} it can be + * injected into a module configuration function (see {@link angular.Module#config}) and it cannot + * be overridden by an Angular {@link auto.$provide#decorator decorator}. + * + * @param {string} name The name of the constant. + * @param {*} value The constant value. + * @returns {Object} registered instance + * + * @example + * Here a some examples of creating constants: + * ```js + * $provide.constant('SHARD_HEIGHT', 306); + * + * $provide.constant('MY_COLOURS', ['red', 'blue', 'grey']); + * + * $provide.constant('double', function(value) { + * return value * 2; + * }); + * ``` + */ + + +/** + * @ngdoc method + * @name $provide#decorator + * @description + * + * Register a **service decorator** with the {@link auto.$injector $injector}. A service decorator + * intercepts the creation of a service, allowing it to override or modify the behaviour of the + * service. The object returned by the decorator may be the original service, or a new service + * object which replaces or wraps and delegates to the original service. + * + * @param {string} name The name of the service to decorate. + * @param {Function|Array.} decorator This function will be invoked when the service needs to be + * instantiated and should return the decorated service instance. The function is called using + * the {@link auto.$injector#invoke injector.invoke} method and is therefore fully injectable. + * Local injection arguments: + * + * * `$delegate` - The original service instance, which can be monkey patched, configured, + * decorated or delegated to. + * + * @example + * Here we decorate the {@link ng.$log $log} service to convert warnings to errors by intercepting + * calls to {@link ng.$log#error $log.warn()}. + * ```js + * $provide.decorator('$log', ['$delegate', function($delegate) { + * $delegate.warn = $delegate.error; + * return $delegate; + * }]); + * ``` + */ + + +function createInjector(modulesToLoad, strictDi) { + strictDi = (strictDi === true); + var INSTANTIATING = {}, + providerSuffix = 'Provider', + path = [], + loadedModules = new HashMap([], true), + providerCache = { + $provide: { + provider: supportObject(provider), + factory: supportObject(factory), + service: supportObject(service), + value: supportObject(value), + constant: supportObject(constant), + decorator: decorator + } + }, + providerInjector = (providerCache.$injector = + createInternalInjector(providerCache, function(serviceName, caller) { + if (angular.isString(caller)) { + path.push(caller); + } + throw $injectorMinErr('unpr', "Unknown provider: {0}", path.join(' <- ')); + })), + instanceCache = {}, + instanceInjector = (instanceCache.$injector = + createInternalInjector(instanceCache, function(serviceName, caller) { + var provider = providerInjector.get(serviceName + providerSuffix, caller); + return instanceInjector.invoke(provider.$get, provider, undefined, serviceName); + })); + + + forEach(loadModules(modulesToLoad), function(fn) { if (fn) instanceInjector.invoke(fn); }); + + return instanceInjector; + + //////////////////////////////////// + // $provider + //////////////////////////////////// + + function supportObject(delegate) { + return function(key, value) { + if (isObject(key)) { + forEach(key, reverseParams(delegate)); + } else { + return delegate(key, value); + } + }; + } + + function provider(name, provider_) { + assertNotHasOwnProperty(name, 'service'); + if (isFunction(provider_) || isArray(provider_)) { + provider_ = providerInjector.instantiate(provider_); + } + if (!provider_.$get) { + throw $injectorMinErr('pget', "Provider '{0}' must define $get factory method.", name); + } + return providerCache[name + providerSuffix] = provider_; + } + + function enforceReturnValue(name, factory) { + return function enforcedReturnValue() { + var result = instanceInjector.invoke(factory, this); + if (isUndefined(result)) { + throw $injectorMinErr('undef', "Provider '{0}' must return a value from $get factory method.", name); + } + return result; + }; + } + + function factory(name, factoryFn, enforce) { + return provider(name, { + $get: enforce !== false ? enforceReturnValue(name, factoryFn) : factoryFn + }); + } + + function service(name, constructor) { + return factory(name, ['$injector', function($injector) { + return $injector.instantiate(constructor); + }]); + } + + function value(name, val) { return factory(name, valueFn(val), false); } + + function constant(name, value) { + assertNotHasOwnProperty(name, 'constant'); + providerCache[name] = value; + instanceCache[name] = value; + } + + function decorator(serviceName, decorFn) { + var origProvider = providerInjector.get(serviceName + providerSuffix), + orig$get = origProvider.$get; + + origProvider.$get = function() { + var origInstance = instanceInjector.invoke(orig$get, origProvider); + return instanceInjector.invoke(decorFn, null, {$delegate: origInstance}); + }; + } + + //////////////////////////////////// + // Module Loading + //////////////////////////////////// + function loadModules(modulesToLoad) { + assertArg(isUndefined(modulesToLoad) || isArray(modulesToLoad), 'modulesToLoad', 'not an array'); + var runBlocks = [], moduleFn; + forEach(modulesToLoad, function(module) { + if (loadedModules.get(module)) return; + loadedModules.put(module, true); + + function runInvokeQueue(queue) { + var i, ii; + for (i = 0, ii = queue.length; i < ii; i++) { + var invokeArgs = queue[i], + provider = providerInjector.get(invokeArgs[0]); + + provider[invokeArgs[1]].apply(provider, invokeArgs[2]); + } + } + + try { + if (isString(module)) { + moduleFn = angularModule(module); + runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks); + runInvokeQueue(moduleFn._invokeQueue); + runInvokeQueue(moduleFn._configBlocks); + } else if (isFunction(module)) { + runBlocks.push(providerInjector.invoke(module)); + } else if (isArray(module)) { + runBlocks.push(providerInjector.invoke(module)); + } else { + assertArgFn(module, 'module'); + } + } catch (e) { + if (isArray(module)) { + module = module[module.length - 1]; + } + if (e.message && e.stack && e.stack.indexOf(e.message) == -1) { + // Safari & FF's stack traces don't contain error.message content + // unlike those of Chrome and IE + // So if stack doesn't contain message, we create a new string that contains both. + // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here. + /* jshint -W022 */ + e = e.message + '\n' + e.stack; + } + throw $injectorMinErr('modulerr', "Failed to instantiate module {0} due to:\n{1}", + module, e.stack || e.message || e); + } + }); + return runBlocks; + } + + //////////////////////////////////// + // internal Injector + //////////////////////////////////// + + function createInternalInjector(cache, factory) { + + function getService(serviceName, caller) { + if (cache.hasOwnProperty(serviceName)) { + if (cache[serviceName] === INSTANTIATING) { + throw $injectorMinErr('cdep', 'Circular dependency found: {0}', + serviceName + ' <- ' + path.join(' <- ')); + } + return cache[serviceName]; + } else { + try { + path.unshift(serviceName); + cache[serviceName] = INSTANTIATING; + return cache[serviceName] = factory(serviceName, caller); + } catch (err) { + if (cache[serviceName] === INSTANTIATING) { + delete cache[serviceName]; + } + throw err; + } finally { + path.shift(); + } + } + } + + function invoke(fn, self, locals, serviceName) { + if (typeof locals === 'string') { + serviceName = locals; + locals = null; + } + + var args = [], + $inject = createInjector.$$annotate(fn, strictDi, serviceName), + length, i, + key; + + for (i = 0, length = $inject.length; i < length; i++) { + key = $inject[i]; + if (typeof key !== 'string') { + throw $injectorMinErr('itkn', + 'Incorrect injection token! Expected service name as string, got {0}', key); + } + args.push( + locals && locals.hasOwnProperty(key) + ? locals[key] + : getService(key, serviceName) + ); + } + if (isArray(fn)) { + fn = fn[length]; + } + + // http://jsperf.com/angularjs-invoke-apply-vs-switch + // #5388 + return fn.apply(self, args); + } + + function instantiate(Type, locals, serviceName) { + // Check if Type is annotated and use just the given function at n-1 as parameter + // e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]); + // Object creation: http://jsperf.com/create-constructor/2 + var instance = Object.create((isArray(Type) ? Type[Type.length - 1] : Type).prototype || null); + var returnedValue = invoke(Type, instance, locals, serviceName); + + return isObject(returnedValue) || isFunction(returnedValue) ? returnedValue : instance; + } + + return { + invoke: invoke, + instantiate: instantiate, + get: getService, + annotate: createInjector.$$annotate, + has: function(name) { + return providerCache.hasOwnProperty(name + providerSuffix) || cache.hasOwnProperty(name); + } + }; + } +} + +createInjector.$$annotate = annotate; + +/** + * @ngdoc provider + * @name $anchorScrollProvider + * + * @description + * Use `$anchorScrollProvider` to disable automatic scrolling whenever + * {@link ng.$location#hash $location.hash()} changes. + */ +function $AnchorScrollProvider() { + + var autoScrollingEnabled = true; + + /** + * @ngdoc method + * @name $anchorScrollProvider#disableAutoScrolling + * + * @description + * By default, {@link ng.$anchorScroll $anchorScroll()} will automatically detect changes to + * {@link ng.$location#hash $location.hash()} and scroll to the element matching the new hash.
+ * Use this method to disable automatic scrolling. + * + * If automatic scrolling is disabled, one must explicitly call + * {@link ng.$anchorScroll $anchorScroll()} in order to scroll to the element related to the + * current hash. + */ + this.disableAutoScrolling = function() { + autoScrollingEnabled = false; + }; + + /** + * @ngdoc service + * @name $anchorScroll + * @kind function + * @requires $window + * @requires $location + * @requires $rootScope + * + * @description + * When called, it scrolls to the element related to the specified `hash` or (if omitted) to the + * current value of {@link ng.$location#hash $location.hash()}, according to the rules specified + * in the + * [HTML5 spec](http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document). + * + * It also watches the {@link ng.$location#hash $location.hash()} and automatically scrolls to + * match any anchor whenever it changes. This can be disabled by calling + * {@link ng.$anchorScrollProvider#disableAutoScrolling $anchorScrollProvider.disableAutoScrolling()}. + * + * Additionally, you can use its {@link ng.$anchorScroll#yOffset yOffset} property to specify a + * vertical scroll-offset (either fixed or dynamic). + * + * @param {string=} hash The hash specifying the element to scroll to. If omitted, the value of + * {@link ng.$location#hash $location.hash()} will be used. + * + * @property {(number|function|jqLite)} yOffset + * If set, specifies a vertical scroll-offset. This is often useful when there are fixed + * positioned elements at the top of the page, such as navbars, headers etc. + * + * `yOffset` can be specified in various ways: + * - **number**: A fixed number of pixels to be used as offset.

+ * - **function**: A getter function called everytime `$anchorScroll()` is executed. Must return + * a number representing the offset (in pixels).

+ * - **jqLite**: A jqLite/jQuery element to be used for specifying the offset. The distance from + * the top of the page to the element's bottom will be used as offset.
+ * **Note**: The element will be taken into account only as long as its `position` is set to + * `fixed`. This option is useful, when dealing with responsive navbars/headers that adjust + * their height and/or positioning according to the viewport's size. + * + *
+ *
+ * In order for `yOffset` to work properly, scrolling should take place on the document's root and + * not some child element. + *
+ * + * @example + + +
+ Go to bottom + You're at the bottom! +
+
+ + angular.module('anchorScrollExample', []) + .controller('ScrollController', ['$scope', '$location', '$anchorScroll', + function ($scope, $location, $anchorScroll) { + $scope.gotoBottom = function() { + // set the location.hash to the id of + // the element you wish to scroll to. + $location.hash('bottom'); + + // call $anchorScroll() + $anchorScroll(); + }; + }]); + + + #scrollArea { + height: 280px; + overflow: auto; + } + + #bottom { + display: block; + margin-top: 2000px; + } + +
+ * + *
+ * The example below illustrates the use of a vertical scroll-offset (specified as a fixed value). + * See {@link ng.$anchorScroll#yOffset $anchorScroll.yOffset} for more details. + * + * @example + + + +
+ Anchor {{x}} of 5 +
+
+ + angular.module('anchorScrollOffsetExample', []) + .run(['$anchorScroll', function($anchorScroll) { + $anchorScroll.yOffset = 50; // always scroll by 50 extra pixels + }]) + .controller('headerCtrl', ['$anchorScroll', '$location', '$scope', + function ($anchorScroll, $location, $scope) { + $scope.gotoAnchor = function(x) { + var newHash = 'anchor' + x; + if ($location.hash() !== newHash) { + // set the $location.hash to `newHash` and + // $anchorScroll will automatically scroll to it + $location.hash('anchor' + x); + } else { + // call $anchorScroll() explicitly, + // since $location.hash hasn't changed + $anchorScroll(); + } + }; + } + ]); + + + body { + padding-top: 50px; + } + + .anchor { + border: 2px dashed DarkOrchid; + padding: 10px 10px 200px 10px; + } + + .fixed-header { + background-color: rgba(0, 0, 0, 0.2); + height: 50px; + position: fixed; + top: 0; left: 0; right: 0; + } + + .fixed-header > a { + display: inline-block; + margin: 5px 15px; + } + +
+ */ + this.$get = ['$window', '$location', '$rootScope', function($window, $location, $rootScope) { + var document = $window.document; + + // Helper function to get first anchor from a NodeList + // (using `Array#some()` instead of `angular#forEach()` since it's more performant + // and working in all supported browsers.) + function getFirstAnchor(list) { + var result = null; + Array.prototype.some.call(list, function(element) { + if (nodeName_(element) === 'a') { + result = element; + return true; + } + }); + return result; + } + + function getYOffset() { + + var offset = scroll.yOffset; + + if (isFunction(offset)) { + offset = offset(); + } else if (isElement(offset)) { + var elem = offset[0]; + var style = $window.getComputedStyle(elem); + if (style.position !== 'fixed') { + offset = 0; + } else { + offset = elem.getBoundingClientRect().bottom; + } + } else if (!isNumber(offset)) { + offset = 0; + } + + return offset; + } + + function scrollTo(elem) { + if (elem) { + elem.scrollIntoView(); + + var offset = getYOffset(); + + if (offset) { + // `offset` is the number of pixels we should scroll UP in order to align `elem` properly. + // This is true ONLY if the call to `elem.scrollIntoView()` initially aligns `elem` at the + // top of the viewport. + // + // IF the number of pixels from the top of `elem` to the end of the page's content is less + // than the height of the viewport, then `elem.scrollIntoView()` will align the `elem` some + // way down the page. + // + // This is often the case for elements near the bottom of the page. + // + // In such cases we do not need to scroll the whole `offset` up, just the difference between + // the top of the element and the offset, which is enough to align the top of `elem` at the + // desired position. + var elemTop = elem.getBoundingClientRect().top; + $window.scrollBy(0, elemTop - offset); + } + } else { + $window.scrollTo(0, 0); + } + } + + function scroll(hash) { + hash = isString(hash) ? hash : $location.hash(); + var elm; + + // empty hash, scroll to the top of the page + if (!hash) scrollTo(null); + + // element with given id + else if ((elm = document.getElementById(hash))) scrollTo(elm); + + // first anchor with given name :-D + else if ((elm = getFirstAnchor(document.getElementsByName(hash)))) scrollTo(elm); + + // no element and hash == 'top', scroll to the top of the page + else if (hash === 'top') scrollTo(null); + } + + // does not scroll when user clicks on anchor link that is currently on + // (no url change, no $location.hash() change), browser native does scroll + if (autoScrollingEnabled) { + $rootScope.$watch(function autoScrollWatch() {return $location.hash();}, + function autoScrollWatchAction(newVal, oldVal) { + // skip the initial scroll if $location.hash is empty + if (newVal === oldVal && newVal === '') return; + + jqLiteDocumentLoaded(function() { + $rootScope.$evalAsync(scroll); + }); + }); + } + + return scroll; + }]; +} + +var $animateMinErr = minErr('$animate'); +var ELEMENT_NODE = 1; +var NG_ANIMATE_CLASSNAME = 'ng-animate'; + +function mergeClasses(a,b) { + if (!a && !b) return ''; + if (!a) return b; + if (!b) return a; + if (isArray(a)) a = a.join(' '); + if (isArray(b)) b = b.join(' '); + return a + ' ' + b; +} + +function extractElementNode(element) { + for (var i = 0; i < element.length; i++) { + var elm = element[i]; + if (elm.nodeType === ELEMENT_NODE) { + return elm; + } + } +} + +function splitClasses(classes) { + if (isString(classes)) { + classes = classes.split(' '); + } + + // Use createMap() to prevent class assumptions involving property names in + // Object.prototype + var obj = createMap(); + forEach(classes, function(klass) { + // sometimes the split leaves empty string values + // incase extra spaces were applied to the options + if (klass.length) { + obj[klass] = true; + } + }); + return obj; +} + +// if any other type of options value besides an Object value is +// passed into the $animate.method() animation then this helper code +// will be run which will ignore it. While this patch is not the +// greatest solution to this, a lot of existing plugins depend on +// $animate to either call the callback (< 1.2) or return a promise +// that can be changed. This helper function ensures that the options +// are wiped clean incase a callback function is provided. +function prepareAnimateOptions(options) { + return isObject(options) + ? options + : {}; +} + +var $$CoreAnimateRunnerProvider = function() { + this.$get = ['$q', '$$rAF', function($q, $$rAF) { + function AnimateRunner() {} + AnimateRunner.all = noop; + AnimateRunner.chain = noop; + AnimateRunner.prototype = { + end: noop, + cancel: noop, + resume: noop, + pause: noop, + complete: noop, + then: function(pass, fail) { + return $q(function(resolve) { + $$rAF(function() { + resolve(); + }); + }).then(pass, fail); + } + }; + return AnimateRunner; + }]; +}; + +// this is prefixed with Core since it conflicts with +// the animateQueueProvider defined in ngAnimate/animateQueue.js +var $$CoreAnimateQueueProvider = function() { + var postDigestQueue = new HashMap(); + var postDigestElements = []; + + this.$get = ['$$AnimateRunner', '$rootScope', + function($$AnimateRunner, $rootScope) { + return { + enabled: noop, + on: noop, + off: noop, + pin: noop, + + push: function(element, event, options, domOperation) { + domOperation && domOperation(); + + options = options || {}; + options.from && element.css(options.from); + options.to && element.css(options.to); + + if (options.addClass || options.removeClass) { + addRemoveClassesPostDigest(element, options.addClass, options.removeClass); + } + + return new $$AnimateRunner(); // jshint ignore:line + } + }; + + + function updateData(data, classes, value) { + var changed = false; + if (classes) { + classes = isString(classes) ? classes.split(' ') : + isArray(classes) ? classes : []; + forEach(classes, function(className) { + if (className) { + changed = true; + data[className] = value; + } + }); + } + return changed; + } + + function handleCSSClassChanges() { + forEach(postDigestElements, function(element) { + var data = postDigestQueue.get(element); + if (data) { + var existing = splitClasses(element.attr('class')); + var toAdd = ''; + var toRemove = ''; + forEach(data, function(status, className) { + var hasClass = !!existing[className]; + if (status !== hasClass) { + if (status) { + toAdd += (toAdd.length ? ' ' : '') + className; + } else { + toRemove += (toRemove.length ? ' ' : '') + className; + } + } + }); + + forEach(element, function(elm) { + toAdd && jqLiteAddClass(elm, toAdd); + toRemove && jqLiteRemoveClass(elm, toRemove); + }); + postDigestQueue.remove(element); + } + }); + postDigestElements.length = 0; + } + + + function addRemoveClassesPostDigest(element, add, remove) { + var data = postDigestQueue.get(element) || {}; + + var classesAdded = updateData(data, add, true); + var classesRemoved = updateData(data, remove, false); + + if (classesAdded || classesRemoved) { + + postDigestQueue.put(element, data); + postDigestElements.push(element); + + if (postDigestElements.length === 1) { + $rootScope.$$postDigest(handleCSSClassChanges); + } + } + } + }]; +}; + +/** + * @ngdoc provider + * @name $animateProvider + * + * @description + * Default implementation of $animate that doesn't perform any animations, instead just + * synchronously performs DOM updates and resolves the returned runner promise. + * + * In order to enable animations the `ngAnimate` module has to be loaded. + * + * To see the functional implementation check out `src/ngAnimate/animate.js`. + */ +var $AnimateProvider = ['$provide', function($provide) { + var provider = this; + + this.$$registeredAnimations = Object.create(null); + + /** + * @ngdoc method + * @name $animateProvider#register + * + * @description + * Registers a new injectable animation factory function. The factory function produces the + * animation object which contains callback functions for each event that is expected to be + * animated. + * + * * `eventFn`: `function(element, ... , doneFunction, options)` + * The element to animate, the `doneFunction` and the options fed into the animation. Depending + * on the type of animation additional arguments will be injected into the animation function. The + * list below explains the function signatures for the different animation methods: + * + * - setClass: function(element, addedClasses, removedClasses, doneFunction, options) + * - addClass: function(element, addedClasses, doneFunction, options) + * - removeClass: function(element, removedClasses, doneFunction, options) + * - enter, leave, move: function(element, doneFunction, options) + * - animate: function(element, fromStyles, toStyles, doneFunction, options) + * + * Make sure to trigger the `doneFunction` once the animation is fully complete. + * + * ```js + * return { + * //enter, leave, move signature + * eventFn : function(element, done, options) { + * //code to run the animation + * //once complete, then run done() + * return function endFunction(wasCancelled) { + * //code to cancel the animation + * } + * } + * } + * ``` + * + * @param {string} name The name of the animation (this is what the class-based CSS value will be compared to). + * @param {Function} factory The factory function that will be executed to return the animation + * object. + */ + this.register = function(name, factory) { + if (name && name.charAt(0) !== '.') { + throw $animateMinErr('notcsel', "Expecting class selector starting with '.' got '{0}'.", name); + } + + var key = name + '-animation'; + provider.$$registeredAnimations[name.substr(1)] = key; + $provide.factory(key, factory); + }; + + /** + * @ngdoc method + * @name $animateProvider#classNameFilter + * + * @description + * Sets and/or returns the CSS class regular expression that is checked when performing + * an animation. Upon bootstrap the classNameFilter value is not set at all and will + * therefore enable $animate to attempt to perform an animation on any element that is triggered. + * When setting the `classNameFilter` value, animations will only be performed on elements + * that successfully match the filter expression. This in turn can boost performance + * for low-powered devices as well as applications containing a lot of structural operations. + * @param {RegExp=} expression The className expression which will be checked against all animations + * @return {RegExp} The current CSS className expression value. If null then there is no expression value + */ + this.classNameFilter = function(expression) { + if (arguments.length === 1) { + this.$$classNameFilter = (expression instanceof RegExp) ? expression : null; + if (this.$$classNameFilter) { + var reservedRegex = new RegExp("(\\s+|\\/)" + NG_ANIMATE_CLASSNAME + "(\\s+|\\/)"); + if (reservedRegex.test(this.$$classNameFilter.toString())) { + throw $animateMinErr('nongcls','$animateProvider.classNameFilter(regex) prohibits accepting a regex value which matches/contains the "{0}" CSS class.', NG_ANIMATE_CLASSNAME); + + } + } + } + return this.$$classNameFilter; + }; + + this.$get = ['$$animateQueue', function($$animateQueue) { + function domInsert(element, parentElement, afterElement) { + // if for some reason the previous element was removed + // from the dom sometime before this code runs then let's + // just stick to using the parent element as the anchor + if (afterElement) { + var afterNode = extractElementNode(afterElement); + if (afterNode && !afterNode.parentNode && !afterNode.previousElementSibling) { + afterElement = null; + } + } + afterElement ? afterElement.after(element) : parentElement.prepend(element); + } + + /** + * @ngdoc service + * @name $animate + * @description The $animate service exposes a series of DOM utility methods that provide support + * for animation hooks. The default behavior is the application of DOM operations, however, + * when an animation is detected (and animations are enabled), $animate will do the heavy lifting + * to ensure that animation runs with the triggered DOM operation. + * + * By default $animate doesn't trigger an animations. This is because the `ngAnimate` module isn't + * included and only when it is active then the animation hooks that `$animate` triggers will be + * functional. Once active then all structural `ng-` directives will trigger animations as they perform + * their DOM-related operations (enter, leave and move). Other directives such as `ngClass`, + * `ngShow`, `ngHide` and `ngMessages` also provide support for animations. + * + * It is recommended that the`$animate` service is always used when executing DOM-related procedures within directives. + * + * To learn more about enabling animation support, click here to visit the + * {@link ngAnimate ngAnimate module page}. + */ + return { + // we don't call it directly since non-existant arguments may + // be interpreted as null within the sub enabled function + + /** + * + * @ngdoc method + * @name $animate#on + * @kind function + * @description Sets up an event listener to fire whenever the animation event (enter, leave, move, etc...) + * has fired on the given element or among any of its children. Once the listener is fired, the provided callback + * is fired with the following params: + * + * ```js + * $animate.on('enter', container, + * function callback(element, phase) { + * // cool we detected an enter animation within the container + * } + * ); + * ``` + * + * @param {string} event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...) + * @param {DOMElement} container the container element that will capture each of the animation events that are fired on itself + * as well as among its children + * @param {Function} callback the callback function that will be fired when the listener is triggered + * + * The arguments present in the callback function are: + * * `element` - The captured DOM element that the animation was fired on. + * * `phase` - The phase of the animation. The two possible phases are **start** (when the animation starts) and **close** (when it ends). + */ + on: $$animateQueue.on, + + /** + * + * @ngdoc method + * @name $animate#off + * @kind function + * @description Deregisters an event listener based on the event which has been associated with the provided element. This method + * can be used in three different ways depending on the arguments: + * + * ```js + * // remove all the animation event listeners listening for `enter` + * $animate.off('enter'); + * + * // remove all the animation event listeners listening for `enter` on the given element and its children + * $animate.off('enter', container); + * + * // remove the event listener function provided by `listenerFn` that is set + * // to listen for `enter` on the given `element` as well as its children + * $animate.off('enter', container, callback); + * ``` + * + * @param {string} event the animation event (e.g. enter, leave, move, addClass, removeClass, etc...) + * @param {DOMElement=} container the container element the event listener was placed on + * @param {Function=} callback the callback function that was registered as the listener + */ + off: $$animateQueue.off, + + /** + * @ngdoc method + * @name $animate#pin + * @kind function + * @description Associates the provided element with a host parent element to allow the element to be animated even if it exists + * outside of the DOM structure of the Angular application. By doing so, any animation triggered via `$animate` can be issued on the + * element despite being outside the realm of the application or within another application. Say for example if the application + * was bootstrapped on an element that is somewhere inside of the `` tag, but we wanted to allow for an element to be situated + * as a direct child of `document.body`, then this can be achieved by pinning the element via `$animate.pin(element)`. Keep in mind + * that calling `$animate.pin(element, parentElement)` will not actually insert into the DOM anywhere; it will just create the association. + * + * Note that this feature is only active when the `ngAnimate` module is used. + * + * @param {DOMElement} element the external element that will be pinned + * @param {DOMElement} parentElement the host parent element that will be associated with the external element + */ + pin: $$animateQueue.pin, + + /** + * + * @ngdoc method + * @name $animate#enabled + * @kind function + * @description Used to get and set whether animations are enabled or not on the entire application or on an element and its children. This + * function can be called in four ways: + * + * ```js + * // returns true or false + * $animate.enabled(); + * + * // changes the enabled state for all animations + * $animate.enabled(false); + * $animate.enabled(true); + * + * // returns true or false if animations are enabled for an element + * $animate.enabled(element); + * + * // changes the enabled state for an element and its children + * $animate.enabled(element, true); + * $animate.enabled(element, false); + * ``` + * + * @param {DOMElement=} element the element that will be considered for checking/setting the enabled state + * @param {boolean=} enabled whether or not the animations will be enabled for the element + * + * @return {boolean} whether or not animations are enabled + */ + enabled: $$animateQueue.enabled, + + /** + * @ngdoc method + * @name $animate#cancel + * @kind function + * @description Cancels the provided animation. + * + * @param {Promise} animationPromise The animation promise that is returned when an animation is started. + */ + cancel: function(runner) { + runner.end && runner.end(); + }, + + /** + * + * @ngdoc method + * @name $animate#enter + * @kind function + * @description Inserts the element into the DOM either after the `after` element (if provided) or + * as the first child within the `parent` element and then triggers an animation. + * A promise is returned that will be resolved during the next digest once the animation + * has completed. + * + * @param {DOMElement} element the element which will be inserted into the DOM + * @param {DOMElement} parent the parent element which will append the element as + * a child (so long as the after element is not present) + * @param {DOMElement=} after the sibling element after which the element will be appended + * @param {object=} options an optional collection of options/styles that will be applied to the element + * + * @return {Promise} the animation callback promise + */ + enter: function(element, parent, after, options) { + parent = parent && jqLite(parent); + after = after && jqLite(after); + parent = parent || after.parent(); + domInsert(element, parent, after); + return $$animateQueue.push(element, 'enter', prepareAnimateOptions(options)); + }, + + /** + * + * @ngdoc method + * @name $animate#move + * @kind function + * @description Inserts (moves) the element into its new position in the DOM either after + * the `after` element (if provided) or as the first child within the `parent` element + * and then triggers an animation. A promise is returned that will be resolved + * during the next digest once the animation has completed. + * + * @param {DOMElement} element the element which will be moved into the new DOM position + * @param {DOMElement} parent the parent element which will append the element as + * a child (so long as the after element is not present) + * @param {DOMElement=} after the sibling element after which the element will be appended + * @param {object=} options an optional collection of options/styles that will be applied to the element + * + * @return {Promise} the animation callback promise + */ + move: function(element, parent, after, options) { + parent = parent && jqLite(parent); + after = after && jqLite(after); + parent = parent || after.parent(); + domInsert(element, parent, after); + return $$animateQueue.push(element, 'move', prepareAnimateOptions(options)); + }, + + /** + * @ngdoc method + * @name $animate#leave + * @kind function + * @description Triggers an animation and then removes the element from the DOM. + * When the function is called a promise is returned that will be resolved during the next + * digest once the animation has completed. + * + * @param {DOMElement} element the element which will be removed from the DOM + * @param {object=} options an optional collection of options/styles that will be applied to the element + * + * @return {Promise} the animation callback promise + */ + leave: function(element, options) { + return $$animateQueue.push(element, 'leave', prepareAnimateOptions(options), function() { + element.remove(); + }); + }, + + /** + * @ngdoc method + * @name $animate#addClass + * @kind function + * + * @description Triggers an addClass animation surrounding the addition of the provided CSS class(es). Upon + * execution, the addClass operation will only be handled after the next digest and it will not trigger an + * animation if element already contains the CSS class or if the class is removed at a later step. + * Note that class-based animations are treated differently compared to structural animations + * (like enter, move and leave) since the CSS classes may be added/removed at different points + * depending if CSS or JavaScript animations are used. + * + * @param {DOMElement} element the element which the CSS classes will be applied to + * @param {string} className the CSS class(es) that will be added (multiple classes are separated via spaces) + * @param {object=} options an optional collection of options/styles that will be applied to the element + * + * @return {Promise} the animation callback promise + */ + addClass: function(element, className, options) { + options = prepareAnimateOptions(options); + options.addClass = mergeClasses(options.addclass, className); + return $$animateQueue.push(element, 'addClass', options); + }, + + /** + * @ngdoc method + * @name $animate#removeClass + * @kind function + * + * @description Triggers a removeClass animation surrounding the removal of the provided CSS class(es). Upon + * execution, the removeClass operation will only be handled after the next digest and it will not trigger an + * animation if element does not contain the CSS class or if the class is added at a later step. + * Note that class-based animations are treated differently compared to structural animations + * (like enter, move and leave) since the CSS classes may be added/removed at different points + * depending if CSS or JavaScript animations are used. + * + * @param {DOMElement} element the element which the CSS classes will be applied to + * @param {string} className the CSS class(es) that will be removed (multiple classes are separated via spaces) + * @param {object=} options an optional collection of options/styles that will be applied to the element + * + * @return {Promise} the animation callback promise + */ + removeClass: function(element, className, options) { + options = prepareAnimateOptions(options); + options.removeClass = mergeClasses(options.removeClass, className); + return $$animateQueue.push(element, 'removeClass', options); + }, + + /** + * @ngdoc method + * @name $animate#setClass + * @kind function + * + * @description Performs both the addition and removal of a CSS classes on an element and (during the process) + * triggers an animation surrounding the class addition/removal. Much like `$animate.addClass` and + * `$animate.removeClass`, `setClass` will only evaluate the classes being added/removed once a digest has + * passed. Note that class-based animations are treated differently compared to structural animations + * (like enter, move and leave) since the CSS classes may be added/removed at different points + * depending if CSS or JavaScript animations are used. + * + * @param {DOMElement} element the element which the CSS classes will be applied to + * @param {string} add the CSS class(es) that will be added (multiple classes are separated via spaces) + * @param {string} remove the CSS class(es) that will be removed (multiple classes are separated via spaces) + * @param {object=} options an optional collection of options/styles that will be applied to the element + * + * @return {Promise} the animation callback promise + */ + setClass: function(element, add, remove, options) { + options = prepareAnimateOptions(options); + options.addClass = mergeClasses(options.addClass, add); + options.removeClass = mergeClasses(options.removeClass, remove); + return $$animateQueue.push(element, 'setClass', options); + }, + + /** + * @ngdoc method + * @name $animate#animate + * @kind function + * + * @description Performs an inline animation on the element which applies the provided to and from CSS styles to the element. + * If any detected CSS transition, keyframe or JavaScript matches the provided className value then the animation will take + * on the provided styles. For example, if a transition animation is set for the given className then the provided from and + * to styles will be applied alongside the given transition. If a JavaScript animation is detected then the provided styles + * will be given in as function paramters into the `animate` method (or as apart of the `options` parameter). + * + * @param {DOMElement} element the element which the CSS styles will be applied to + * @param {object} from the from (starting) CSS styles that will be applied to the element and across the animation. + * @param {object} to the to (destination) CSS styles that will be applied to the element and across the animation. + * @param {string=} className an optional CSS class that will be applied to the element for the duration of the animation. If + * this value is left as empty then a CSS class of `ng-inline-animate` will be applied to the element. + * (Note that if no animation is detected then this value will not be appplied to the element.) + * @param {object=} options an optional collection of options/styles that will be applied to the element + * + * @return {Promise} the animation callback promise + */ + animate: function(element, from, to, className, options) { + options = prepareAnimateOptions(options); + options.from = options.from ? extend(options.from, from) : from; + options.to = options.to ? extend(options.to, to) : to; + + className = className || 'ng-inline-animate'; + options.tempClasses = mergeClasses(options.tempClasses, className); + return $$animateQueue.push(element, 'animate', options); + } + }; + }]; +}]; + +/** + * @ngdoc service + * @name $animateCss + * @kind object + * + * @description + * This is the core version of `$animateCss`. By default, only when the `ngAnimate` is included, + * then the `$animateCss` service will actually perform animations. + * + * Click here {@link ngAnimate.$animateCss to read the documentation for $animateCss}. + */ +var $CoreAnimateCssProvider = function() { + this.$get = ['$$rAF', '$q', function($$rAF, $q) { + + var RAFPromise = function() {}; + RAFPromise.prototype = { + done: function(cancel) { + this.defer && this.defer[cancel === true ? 'reject' : 'resolve'](); + }, + end: function() { + this.done(); + }, + cancel: function() { + this.done(true); + }, + getPromise: function() { + if (!this.defer) { + this.defer = $q.defer(); + } + return this.defer.promise; + }, + then: function(f1,f2) { + return this.getPromise().then(f1,f2); + }, + 'catch': function(f1) { + return this.getPromise()['catch'](f1); + }, + 'finally': function(f1) { + return this.getPromise()['finally'](f1); + } + }; + + return function(element, options) { + if (options.from) { + element.css(options.from); + options.from = null; + } + + var closed, runner = new RAFPromise(); + return { + start: run, + end: run + }; + + function run() { + $$rAF(function() { + close(); + if (!closed) { + runner.done(); + } + closed = true; + }); + return runner; + } + + function close() { + if (options.addClass) { + element.addClass(options.addClass); + options.addClass = null; + } + if (options.removeClass) { + element.removeClass(options.removeClass); + options.removeClass = null; + } + if (options.to) { + element.css(options.to); + options.to = null; + } + } + }; + }]; +}; + +/* global stripHash: true */ + +/** + * ! This is a private undocumented service ! + * + * @name $browser + * @requires $log + * @description + * This object has two goals: + * + * - hide all the global state in the browser caused by the window object + * - abstract away all the browser specific features and inconsistencies + * + * For tests we provide {@link ngMock.$browser mock implementation} of the `$browser` + * service, which can be used for convenient testing of the application without the interaction with + * the real browser apis. + */ +/** + * @param {object} window The global window object. + * @param {object} document jQuery wrapped document. + * @param {object} $log window.console or an object with the same interface. + * @param {object} $sniffer $sniffer service + */ +function Browser(window, document, $log, $sniffer) { + var self = this, + rawDocument = document[0], + location = window.location, + history = window.history, + setTimeout = window.setTimeout, + clearTimeout = window.clearTimeout, + pendingDeferIds = {}; + + self.isMock = false; + + var outstandingRequestCount = 0; + var outstandingRequestCallbacks = []; + + // TODO(vojta): remove this temporary api + self.$$completeOutstandingRequest = completeOutstandingRequest; + self.$$incOutstandingRequestCount = function() { outstandingRequestCount++; }; + + /** + * Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks` + * counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed. + */ + function completeOutstandingRequest(fn) { + try { + fn.apply(null, sliceArgs(arguments, 1)); + } finally { + outstandingRequestCount--; + if (outstandingRequestCount === 0) { + while (outstandingRequestCallbacks.length) { + try { + outstandingRequestCallbacks.pop()(); + } catch (e) { + $log.error(e); + } + } + } + } + } + + function getHash(url) { + var index = url.indexOf('#'); + return index === -1 ? '' : url.substr(index); + } + + /** + * @private + * Note: this method is used only by scenario runner + * TODO(vojta): prefix this method with $$ ? + * @param {function()} callback Function that will be called when no outstanding request + */ + self.notifyWhenNoOutstandingRequests = function(callback) { + if (outstandingRequestCount === 0) { + callback(); + } else { + outstandingRequestCallbacks.push(callback); + } + }; + + ////////////////////////////////////////////////////////////// + // URL API + ////////////////////////////////////////////////////////////// + + var cachedState, lastHistoryState, + lastBrowserUrl = location.href, + baseElement = document.find('base'), + pendingLocation = null; + + cacheState(); + lastHistoryState = cachedState; + + /** + * @name $browser#url + * + * @description + * GETTER: + * Without any argument, this method just returns current value of location.href. + * + * SETTER: + * With at least one argument, this method sets url to new value. + * If html5 history api supported, pushState/replaceState is used, otherwise + * location.href/location.replace is used. + * Returns its own instance to allow chaining + * + * NOTE: this api is intended for use only by the $location service. Please use the + * {@link ng.$location $location service} to change url. + * + * @param {string} url New url (when used as setter) + * @param {boolean=} replace Should new url replace current history record? + * @param {object=} state object to use with pushState/replaceState + */ + self.url = function(url, replace, state) { + // In modern browsers `history.state` is `null` by default; treating it separately + // from `undefined` would cause `$browser.url('/foo')` to change `history.state` + // to undefined via `pushState`. Instead, let's change `undefined` to `null` here. + if (isUndefined(state)) { + state = null; + } + + // Android Browser BFCache causes location, history reference to become stale. + if (location !== window.location) location = window.location; + if (history !== window.history) history = window.history; + + // setter + if (url) { + var sameState = lastHistoryState === state; + + // Don't change anything if previous and current URLs and states match. This also prevents + // IE<10 from getting into redirect loop when in LocationHashbangInHtml5Url mode. + // See https://github.com/angular/angular.js/commit/ffb2701 + if (lastBrowserUrl === url && (!$sniffer.history || sameState)) { + return self; + } + var sameBase = lastBrowserUrl && stripHash(lastBrowserUrl) === stripHash(url); + lastBrowserUrl = url; + lastHistoryState = state; + // Don't use history API if only the hash changed + // due to a bug in IE10/IE11 which leads + // to not firing a `hashchange` nor `popstate` event + // in some cases (see #9143). + if ($sniffer.history && (!sameBase || !sameState)) { + history[replace ? 'replaceState' : 'pushState'](state, '', url); + cacheState(); + // Do the assignment again so that those two variables are referentially identical. + lastHistoryState = cachedState; + } else { + if (!sameBase || pendingLocation) { + pendingLocation = url; + } + if (replace) { + location.replace(url); + } else if (!sameBase) { + location.href = url; + } else { + location.hash = getHash(url); + } + if (location.href !== url) { + pendingLocation = url; + } + } + return self; + // getter + } else { + // - pendingLocation is needed as browsers don't allow to read out + // the new location.href if a reload happened or if there is a bug like in iOS 9 (see + // https://openradar.appspot.com/22186109). + // - the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172 + return pendingLocation || location.href.replace(/%27/g,"'"); + } + }; + + /** + * @name $browser#state + * + * @description + * This method is a getter. + * + * Return history.state or null if history.state is undefined. + * + * @returns {object} state + */ + self.state = function() { + return cachedState; + }; + + var urlChangeListeners = [], + urlChangeInit = false; + + function cacheStateAndFireUrlChange() { + pendingLocation = null; + cacheState(); + fireUrlChange(); + } + + function getCurrentState() { + try { + return history.state; + } catch (e) { + // MSIE can reportedly throw when there is no state (UNCONFIRMED). + } + } + + // This variable should be used *only* inside the cacheState function. + var lastCachedState = null; + function cacheState() { + // This should be the only place in $browser where `history.state` is read. + cachedState = getCurrentState(); + cachedState = isUndefined(cachedState) ? null : cachedState; + + // Prevent callbacks fo fire twice if both hashchange & popstate were fired. + if (equals(cachedState, lastCachedState)) { + cachedState = lastCachedState; + } + lastCachedState = cachedState; + } + + function fireUrlChange() { + if (lastBrowserUrl === self.url() && lastHistoryState === cachedState) { + return; + } + + lastBrowserUrl = self.url(); + lastHistoryState = cachedState; + forEach(urlChangeListeners, function(listener) { + listener(self.url(), cachedState); + }); + } + + /** + * @name $browser#onUrlChange + * + * @description + * Register callback function that will be called, when url changes. + * + * It's only called when the url is changed from outside of angular: + * - user types different url into address bar + * - user clicks on history (forward/back) button + * - user clicks on a link + * + * It's not called when url is changed by $browser.url() method + * + * The listener gets called with new url as parameter. + * + * NOTE: this api is intended for use only by the $location service. Please use the + * {@link ng.$location $location service} to monitor url changes in angular apps. + * + * @param {function(string)} listener Listener function to be called when url changes. + * @return {function(string)} Returns the registered listener fn - handy if the fn is anonymous. + */ + self.onUrlChange = function(callback) { + // TODO(vojta): refactor to use node's syntax for events + if (!urlChangeInit) { + // We listen on both (hashchange/popstate) when available, as some browsers (e.g. Opera) + // don't fire popstate when user change the address bar and don't fire hashchange when url + // changed by push/replaceState + + // html5 history api - popstate event + if ($sniffer.history) jqLite(window).on('popstate', cacheStateAndFireUrlChange); + // hashchange event + jqLite(window).on('hashchange', cacheStateAndFireUrlChange); + + urlChangeInit = true; + } + + urlChangeListeners.push(callback); + return callback; + }; + + /** + * @private + * Remove popstate and hashchange handler from window. + * + * NOTE: this api is intended for use only by $rootScope. + */ + self.$$applicationDestroyed = function() { + jqLite(window).off('hashchange popstate', cacheStateAndFireUrlChange); + }; + + /** + * Checks whether the url has changed outside of Angular. + * Needs to be exported to be able to check for changes that have been done in sync, + * as hashchange/popstate events fire in async. + */ + self.$$checkUrlChange = fireUrlChange; + + ////////////////////////////////////////////////////////////// + // Misc API + ////////////////////////////////////////////////////////////// + + /** + * @name $browser#baseHref + * + * @description + * Returns current + * (always relative - without domain) + * + * @returns {string} The current base href + */ + self.baseHref = function() { + var href = baseElement.attr('href'); + return href ? href.replace(/^(https?\:)?\/\/[^\/]*/, '') : ''; + }; + + /** + * @name $browser#defer + * @param {function()} fn A function, who's execution should be deferred. + * @param {number=} [delay=0] of milliseconds to defer the function execution. + * @returns {*} DeferId that can be used to cancel the task via `$browser.defer.cancel()`. + * + * @description + * Executes a fn asynchronously via `setTimeout(fn, delay)`. + * + * Unlike when calling `setTimeout` directly, in test this function is mocked and instead of using + * `setTimeout` in tests, the fns are queued in an array, which can be programmatically flushed + * via `$browser.defer.flush()`. + * + */ + self.defer = function(fn, delay) { + var timeoutId; + outstandingRequestCount++; + timeoutId = setTimeout(function() { + delete pendingDeferIds[timeoutId]; + completeOutstandingRequest(fn); + }, delay || 0); + pendingDeferIds[timeoutId] = true; + return timeoutId; + }; + + + /** + * @name $browser#defer.cancel + * + * @description + * Cancels a deferred task identified with `deferId`. + * + * @param {*} deferId Token returned by the `$browser.defer` function. + * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully + * canceled. + */ + self.defer.cancel = function(deferId) { + if (pendingDeferIds[deferId]) { + delete pendingDeferIds[deferId]; + clearTimeout(deferId); + completeOutstandingRequest(noop); + return true; + } + return false; + }; + +} + +function $BrowserProvider() { + this.$get = ['$window', '$log', '$sniffer', '$document', + function($window, $log, $sniffer, $document) { + return new Browser($window, $document, $log, $sniffer); + }]; +} + +/** + * @ngdoc service + * @name $cacheFactory + * + * @description + * Factory that constructs {@link $cacheFactory.Cache Cache} objects and gives access to + * them. + * + * ```js + * + * var cache = $cacheFactory('cacheId'); + * expect($cacheFactory.get('cacheId')).toBe(cache); + * expect($cacheFactory.get('noSuchCacheId')).not.toBeDefined(); + * + * cache.put("key", "value"); + * cache.put("another key", "another value"); + * + * // We've specified no options on creation + * expect(cache.info()).toEqual({id: 'cacheId', size: 2}); + * + * ``` + * + * + * @param {string} cacheId Name or id of the newly created cache. + * @param {object=} options Options object that specifies the cache behavior. Properties: + * + * - `{number=}` `capacity` — turns the cache into LRU cache. + * + * @returns {object} Newly created cache object with the following set of methods: + * + * - `{object}` `info()` — Returns id, size, and options of cache. + * - `{{*}}` `put({string} key, {*} value)` — Puts a new key-value pair into the cache and returns + * it. + * - `{{*}}` `get({string} key)` — Returns cached value for `key` or undefined for cache miss. + * - `{void}` `remove({string} key)` — Removes a key-value pair from the cache. + * - `{void}` `removeAll()` — Removes all cached values. + * - `{void}` `destroy()` — Removes references to this cache from $cacheFactory. + * + * @example + + +
+ + + + +

Cached Values

+
+ + : + +
+ +

Cache Info

+
+ + : + +
+
+
+ + angular.module('cacheExampleApp', []). + controller('CacheController', ['$scope', '$cacheFactory', function($scope, $cacheFactory) { + $scope.keys = []; + $scope.cache = $cacheFactory('cacheId'); + $scope.put = function(key, value) { + if (isUndefined($scope.cache.get(key))) { + $scope.keys.push(key); + } + $scope.cache.put(key, isUndefined(value) ? null : value); + }; + }]); + + + p { + margin: 10px 0 3px; + } + +
+ */ +function $CacheFactoryProvider() { + + this.$get = function() { + var caches = {}; + + function cacheFactory(cacheId, options) { + if (cacheId in caches) { + throw minErr('$cacheFactory')('iid', "CacheId '{0}' is already taken!", cacheId); + } + + var size = 0, + stats = extend({}, options, {id: cacheId}), + data = {}, + capacity = (options && options.capacity) || Number.MAX_VALUE, + lruHash = {}, + freshEnd = null, + staleEnd = null; + + /** + * @ngdoc type + * @name $cacheFactory.Cache + * + * @description + * A cache object used to store and retrieve data, primarily used by + * {@link $http $http} and the {@link ng.directive:script script} directive to cache + * templates and other data. + * + * ```js + * angular.module('superCache') + * .factory('superCache', ['$cacheFactory', function($cacheFactory) { + * return $cacheFactory('super-cache'); + * }]); + * ``` + * + * Example test: + * + * ```js + * it('should behave like a cache', inject(function(superCache) { + * superCache.put('key', 'value'); + * superCache.put('another key', 'another value'); + * + * expect(superCache.info()).toEqual({ + * id: 'super-cache', + * size: 2 + * }); + * + * superCache.remove('another key'); + * expect(superCache.get('another key')).toBeUndefined(); + * + * superCache.removeAll(); + * expect(superCache.info()).toEqual({ + * id: 'super-cache', + * size: 0 + * }); + * })); + * ``` + */ + return caches[cacheId] = { + + /** + * @ngdoc method + * @name $cacheFactory.Cache#put + * @kind function + * + * @description + * Inserts a named entry into the {@link $cacheFactory.Cache Cache} object to be + * retrieved later, and incrementing the size of the cache if the key was not already + * present in the cache. If behaving like an LRU cache, it will also remove stale + * entries from the set. + * + * It will not insert undefined values into the cache. + * + * @param {string} key the key under which the cached data is stored. + * @param {*} value the value to store alongside the key. If it is undefined, the key + * will not be stored. + * @returns {*} the value stored. + */ + put: function(key, value) { + if (isUndefined(value)) return; + if (capacity < Number.MAX_VALUE) { + var lruEntry = lruHash[key] || (lruHash[key] = {key: key}); + + refresh(lruEntry); + } + + if (!(key in data)) size++; + data[key] = value; + + if (size > capacity) { + this.remove(staleEnd.key); + } + + return value; + }, + + /** + * @ngdoc method + * @name $cacheFactory.Cache#get + * @kind function + * + * @description + * Retrieves named data stored in the {@link $cacheFactory.Cache Cache} object. + * + * @param {string} key the key of the data to be retrieved + * @returns {*} the value stored. + */ + get: function(key) { + if (capacity < Number.MAX_VALUE) { + var lruEntry = lruHash[key]; + + if (!lruEntry) return; + + refresh(lruEntry); + } + + return data[key]; + }, + + + /** + * @ngdoc method + * @name $cacheFactory.Cache#remove + * @kind function + * + * @description + * Removes an entry from the {@link $cacheFactory.Cache Cache} object. + * + * @param {string} key the key of the entry to be removed + */ + remove: function(key) { + if (capacity < Number.MAX_VALUE) { + var lruEntry = lruHash[key]; + + if (!lruEntry) return; + + if (lruEntry == freshEnd) freshEnd = lruEntry.p; + if (lruEntry == staleEnd) staleEnd = lruEntry.n; + link(lruEntry.n,lruEntry.p); + + delete lruHash[key]; + } + + delete data[key]; + size--; + }, + + + /** + * @ngdoc method + * @name $cacheFactory.Cache#removeAll + * @kind function + * + * @description + * Clears the cache object of any entries. + */ + removeAll: function() { + data = {}; + size = 0; + lruHash = {}; + freshEnd = staleEnd = null; + }, + + + /** + * @ngdoc method + * @name $cacheFactory.Cache#destroy + * @kind function + * + * @description + * Destroys the {@link $cacheFactory.Cache Cache} object entirely, + * removing it from the {@link $cacheFactory $cacheFactory} set. + */ + destroy: function() { + data = null; + stats = null; + lruHash = null; + delete caches[cacheId]; + }, + + + /** + * @ngdoc method + * @name $cacheFactory.Cache#info + * @kind function + * + * @description + * Retrieve information regarding a particular {@link $cacheFactory.Cache Cache}. + * + * @returns {object} an object with the following properties: + *
    + *
  • **id**: the id of the cache instance
  • + *
  • **size**: the number of entries kept in the cache instance
  • + *
  • **...**: any additional properties from the options object when creating the + * cache.
  • + *
+ */ + info: function() { + return extend({}, stats, {size: size}); + } + }; + + + /** + * makes the `entry` the freshEnd of the LRU linked list + */ + function refresh(entry) { + if (entry != freshEnd) { + if (!staleEnd) { + staleEnd = entry; + } else if (staleEnd == entry) { + staleEnd = entry.n; + } + + link(entry.n, entry.p); + link(entry, freshEnd); + freshEnd = entry; + freshEnd.n = null; + } + } + + + /** + * bidirectionally links two entries of the LRU linked list + */ + function link(nextEntry, prevEntry) { + if (nextEntry != prevEntry) { + if (nextEntry) nextEntry.p = prevEntry; //p stands for previous, 'prev' didn't minify + if (prevEntry) prevEntry.n = nextEntry; //n stands for next, 'next' didn't minify + } + } + } + + + /** + * @ngdoc method + * @name $cacheFactory#info + * + * @description + * Get information about all the caches that have been created + * + * @returns {Object} - key-value map of `cacheId` to the result of calling `cache#info` + */ + cacheFactory.info = function() { + var info = {}; + forEach(caches, function(cache, cacheId) { + info[cacheId] = cache.info(); + }); + return info; + }; + + + /** + * @ngdoc method + * @name $cacheFactory#get + * + * @description + * Get access to a cache object by the `cacheId` used when it was created. + * + * @param {string} cacheId Name or id of a cache to access. + * @returns {object} Cache object identified by the cacheId or undefined if no such cache. + */ + cacheFactory.get = function(cacheId) { + return caches[cacheId]; + }; + + + return cacheFactory; + }; +} + +/** + * @ngdoc service + * @name $templateCache + * + * @description + * The first time a template is used, it is loaded in the template cache for quick retrieval. You + * can load templates directly into the cache in a `script` tag, or by consuming the + * `$templateCache` service directly. + * + * Adding via the `script` tag: + * + * ```html + * + * ``` + * + * **Note:** the `script` tag containing the template does not need to be included in the `head` of + * the document, but it must be a descendent of the {@link ng.$rootElement $rootElement} (IE, + * element with ng-app attribute), otherwise the template will be ignored. + * + * Adding via the `$templateCache` service: + * + * ```js + * var myApp = angular.module('myApp', []); + * myApp.run(function($templateCache) { + * $templateCache.put('templateId.html', 'This is the content of the template'); + * }); + * ``` + * + * To retrieve the template later, simply use it in your HTML: + * ```html + *
+ * ``` + * + * or get it via Javascript: + * ```js + * $templateCache.get('templateId.html') + * ``` + * + * See {@link ng.$cacheFactory $cacheFactory}. + * + */ +function $TemplateCacheProvider() { + this.$get = ['$cacheFactory', function($cacheFactory) { + return $cacheFactory('templates'); + }]; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Any commits to this file should be reviewed with security in mind. * + * Changes to this file can potentially create security vulnerabilities. * + * An approval from 2 Core members with history of modifying * + * this file is required. * + * * + * Does the change somehow allow for arbitrary javascript to be executed? * + * Or allows for someone to change the prototype of built-in objects? * + * Or gives undesired access to variables likes document or window? * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* ! VARIABLE/FUNCTION NAMING CONVENTIONS THAT APPLY TO THIS FILE! + * + * DOM-related variables: + * + * - "node" - DOM Node + * - "element" - DOM Element or Node + * - "$node" or "$element" - jqLite-wrapped node or element + * + * + * Compiler related stuff: + * + * - "linkFn" - linking fn of a single directive + * - "nodeLinkFn" - function that aggregates all linking fns for a particular node + * - "childLinkFn" - function that aggregates all linking fns for child nodes of a particular node + * - "compositeLinkFn" - function that aggregates all linking fns for a compilation root (nodeList) + */ + + +/** + * @ngdoc service + * @name $compile + * @kind function + * + * @description + * Compiles an HTML string or DOM into a template and produces a template function, which + * can then be used to link {@link ng.$rootScope.Scope `scope`} and the template together. + * + * The compilation is a process of walking the DOM tree and matching DOM elements to + * {@link ng.$compileProvider#directive directives}. + * + *
+ * **Note:** This document is an in-depth reference of all directive options. + * For a gentle introduction to directives with examples of common use cases, + * see the {@link guide/directive directive guide}. + *
+ * + * ## Comprehensive Directive API + * + * There are many different options for a directive. + * + * The difference resides in the return value of the factory function. + * You can either return a "Directive Definition Object" (see below) that defines the directive properties, + * or just the `postLink` function (all other properties will have the default values). + * + *
+ * **Best Practice:** It's recommended to use the "directive definition object" form. + *
+ * + * Here's an example directive declared with a Directive Definition Object: + * + * ```js + * var myModule = angular.module(...); + * + * myModule.directive('directiveName', function factory(injectables) { + * var directiveDefinitionObject = { + * priority: 0, + * template: '
', // or // function(tElement, tAttrs) { ... }, + * // or + * // templateUrl: 'directive.html', // or // function(tElement, tAttrs) { ... }, + * transclude: false, + * restrict: 'A', + * templateNamespace: 'html', + * scope: false, + * controller: function($scope, $element, $attrs, $transclude, otherInjectables) { ... }, + * controllerAs: 'stringIdentifier', + * bindToController: false, + * require: 'siblingDirectiveName', // or // ['^parentDirectiveName', '?optionalDirectiveName', '?^optionalParent'], + * compile: function compile(tElement, tAttrs, transclude) { + * return { + * pre: function preLink(scope, iElement, iAttrs, controller) { ... }, + * post: function postLink(scope, iElement, iAttrs, controller) { ... } + * } + * // or + * // return function postLink( ... ) { ... } + * }, + * // or + * // link: { + * // pre: function preLink(scope, iElement, iAttrs, controller) { ... }, + * // post: function postLink(scope, iElement, iAttrs, controller) { ... } + * // } + * // or + * // link: function postLink( ... ) { ... } + * }; + * return directiveDefinitionObject; + * }); + * ``` + * + *
+ * **Note:** Any unspecified options will use the default value. You can see the default values below. + *
+ * + * Therefore the above can be simplified as: + * + * ```js + * var myModule = angular.module(...); + * + * myModule.directive('directiveName', function factory(injectables) { + * var directiveDefinitionObject = { + * link: function postLink(scope, iElement, iAttrs) { ... } + * }; + * return directiveDefinitionObject; + * // or + * // return function postLink(scope, iElement, iAttrs) { ... } + * }); + * ``` + * + * + * + * ### Directive Definition Object + * + * The directive definition object provides instructions to the {@link ng.$compile + * compiler}. The attributes are: + * + * #### `multiElement` + * When this property is set to true, the HTML compiler will collect DOM nodes between + * nodes with the attributes `directive-name-start` and `directive-name-end`, and group them + * together as the directive elements. It is recommended that this feature be used on directives + * which are not strictly behavioural (such as {@link ngClick}), and which + * do not manipulate or replace child nodes (such as {@link ngInclude}). + * + * #### `priority` + * When there are multiple directives defined on a single DOM element, sometimes it + * is necessary to specify the order in which the directives are applied. The `priority` is used + * to sort the directives before their `compile` functions get called. Priority is defined as a + * number. Directives with greater numerical `priority` are compiled first. Pre-link functions + * are also run in priority order, but post-link functions are run in reverse order. The order + * of directives with the same priority is undefined. The default priority is `0`. + * + * #### `terminal` + * If set to true then the current `priority` will be the last set of directives + * which will execute (any directives at the current priority will still execute + * as the order of execution on same `priority` is undefined). Note that expressions + * and other directives used in the directive's template will also be excluded from execution. + * + * #### `scope` + * The scope property can be `true`, an object or a falsy value: + * + * * **falsy:** No scope will be created for the directive. The directive will use its parent's scope. + * + * * **`true`:** A new child scope that prototypically inherits from its parent will be created for + * the directive's element. If multiple directives on the same element request a new scope, + * only one new scope is created. The new scope rule does not apply for the root of the template + * since the root of the template always gets a new scope. + * + * * **`{...}` (an object hash):** A new "isolate" scope is created for the directive's element. The + * 'isolate' scope differs from normal scope in that it does not prototypically inherit from its parent + * scope. This is useful when creating reusable components, which should not accidentally read or modify + * data in the parent scope. + * + * The 'isolate' scope object hash defines a set of local scope properties derived from attributes on the + * directive's element. These local properties are useful for aliasing values for templates. The keys in + * the object hash map to the name of the property on the isolate scope; the values define how the property + * is bound to the parent scope, via matching attributes on the directive's element: + * + * * `@` or `@attr` - bind a local scope property to the value of DOM attribute. The result is + * always a string since DOM attributes are strings. If no `attr` name is specified then the + * attribute name is assumed to be the same as the local name. + * Given `` and widget definition + * of `scope: { localName:'@myAttr' }`, then widget scope property `localName` will reflect + * the interpolated value of `hello {{name}}`. As the `name` attribute changes so will the + * `localName` property on the widget scope. The `name` is read from the parent scope (not + * component scope). + * + * * `=` or `=attr` - set up bi-directional binding between a local scope property and the + * parent scope property of name defined via the value of the `attr` attribute. If no `attr` + * name is specified then the attribute name is assumed to be the same as the local name. + * Given `` and widget definition of + * `scope: { localModel:'=myAttr' }`, then widget scope property `localModel` will reflect the + * value of `parentModel` on the parent scope. Any changes to `parentModel` will be reflected + * in `localModel` and any changes in `localModel` will reflect in `parentModel`. If the parent + * scope property doesn't exist, it will throw a NON_ASSIGNABLE_MODEL_EXPRESSION exception. You + * can avoid this behavior using `=?` or `=?attr` in order to flag the property as optional. If + * you want to shallow watch for changes (i.e. $watchCollection instead of $watch) you can use + * `=*` or `=*attr` (`=*?` or `=*?attr` if the property is optional). + * + * * `&` or `&attr` - provides a way to execute an expression in the context of the parent scope. + * If no `attr` name is specified then the attribute name is assumed to be the same as the + * local name. Given `` and widget definition of + * `scope: { localFn:'&myAttr' }`, then isolate scope property `localFn` will point to + * a function wrapper for the `count = count + value` expression. Often it's desirable to + * pass data from the isolated scope via an expression to the parent scope, this can be + * done by passing a map of local variable names and values into the expression wrapper fn. + * For example, if the expression is `increment(amount)` then we can specify the amount value + * by calling the `localFn` as `localFn({amount: 22})`. + * + * In general it's possible to apply more than one directive to one element, but there might be limitations + * depending on the type of scope required by the directives. The following points will help explain these limitations. + * For simplicity only two directives are taken into account, but it is also applicable for several directives: + * + * * **no scope** + **no scope** => Two directives which don't require their own scope will use their parent's scope + * * **child scope** + **no scope** => Both directives will share one single child scope + * * **child scope** + **child scope** => Both directives will share one single child scope + * * **isolated scope** + **no scope** => The isolated directive will use it's own created isolated scope. The other directive will use + * its parent's scope + * * **isolated scope** + **child scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives cannot + * be applied to the same element. + * * **isolated scope** + **isolated scope** => **Won't work!** Only one scope can be related to one element. Therefore these directives + * cannot be applied to the same element. + * + * + * #### `bindToController` + * When an isolate scope is used for a component (see above), and `controllerAs` is used, `bindToController: true` will + * allow a component to have its properties bound to the controller, rather than to scope. When the controller + * is instantiated, the initial values of the isolate scope bindings are already available. + * + * #### `controller` + * Controller constructor function. The controller is instantiated before the + * pre-linking phase and can be accessed by other directives (see + * `require` attribute). This allows the directives to communicate with each other and augment + * each other's behavior. The controller is injectable (and supports bracket notation) with the following locals: + * + * * `$scope` - Current scope associated with the element + * * `$element` - Current element + * * `$attrs` - Current attributes object for the element + * * `$transclude` - A transclude linking function pre-bound to the correct transclusion scope: + * `function([scope], cloneLinkingFn, futureParentElement)`. + * * `scope`: optional argument to override the scope. + * * `cloneLinkingFn`: optional argument to create clones of the original transcluded content. + * * `futureParentElement`: + * * defines the parent to which the `cloneLinkingFn` will add the cloned elements. + * * default: `$element.parent()` resp. `$element` for `transclude:'element'` resp. `transclude:true`. + * * only needed for transcludes that are allowed to contain non html elements (e.g. SVG elements) + * and when the `cloneLinkinFn` is passed, + * as those elements need to created and cloned in a special way when they are defined outside their + * usual containers (e.g. like ``). + * * See also the `directive.templateNamespace` property. + * + * + * #### `require` + * Require another directive and inject its controller as the fourth argument to the linking function. The + * `require` takes a string name (or array of strings) of the directive(s) to pass in. If an array is used, the + * injected argument will be an array in corresponding order. If no such directive can be + * found, or if the directive does not have a controller, then an error is raised (unless no link function + * is specified, in which case error checking is skipped). The name can be prefixed with: + * + * * (no prefix) - Locate the required controller on the current element. Throw an error if not found. + * * `?` - Attempt to locate the required controller or pass `null` to the `link` fn if not found. + * * `^` - Locate the required controller by searching the element and its parents. Throw an error if not found. + * * `^^` - Locate the required controller by searching the element's parents. Throw an error if not found. + * * `?^` - Attempt to locate the required controller by searching the element and its parents or pass + * `null` to the `link` fn if not found. + * * `?^^` - Attempt to locate the required controller by searching the element's parents, or pass + * `null` to the `link` fn if not found. + * + * + * #### `controllerAs` + * Identifier name for a reference to the controller in the directive's scope. + * This allows the controller to be referenced from the directive template. This is especially + * useful when a directive is used as component, i.e. with an `isolate` scope. It's also possible + * to use it in a directive without an `isolate` / `new` scope, but you need to be aware that the + * `controllerAs` reference might overwrite a property that already exists on the parent scope. + * + * + * #### `restrict` + * String of subset of `EACM` which restricts the directive to a specific directive + * declaration style. If omitted, the defaults (elements and attributes) are used. + * + * * `E` - Element name (default): `` + * * `A` - Attribute (default): `
` + * * `C` - Class: `
` + * * `M` - Comment: `` + * + * + * #### `templateNamespace` + * String representing the document type used by the markup in the template. + * AngularJS needs this information as those elements need to be created and cloned + * in a special way when they are defined outside their usual containers like `` and ``. + * + * * `html` - All root nodes in the template are HTML. Root nodes may also be + * top-level elements such as `` or ``. + * * `svg` - The root nodes in the template are SVG elements (excluding ``). + * * `math` - The root nodes in the template are MathML elements (excluding ``). + * + * If no `templateNamespace` is specified, then the namespace is considered to be `html`. + * + * #### `template` + * HTML markup that may: + * * Replace the contents of the directive's element (default). + * * Replace the directive's element itself (if `replace` is true - DEPRECATED). + * * Wrap the contents of the directive's element (if `transclude` is true). + * + * Value may be: + * + * * A string. For example `
{{delete_str}}
`. + * * A function which takes two arguments `tElement` and `tAttrs` (described in the `compile` + * function api below) and returns a string value. + * + * + * #### `templateUrl` + * This is similar to `template` but the template is loaded from the specified URL, asynchronously. + * + * Because template loading is asynchronous the compiler will suspend compilation of directives on that element + * for later when the template has been resolved. In the meantime it will continue to compile and link + * sibling and parent elements as though this element had not contained any directives. + * + * The compiler does not suspend the entire compilation to wait for templates to be loaded because this + * would result in the whole app "stalling" until all templates are loaded asynchronously - even in the + * case when only one deeply nested directive has `templateUrl`. + * + * Template loading is asynchronous even if the template has been preloaded into the {@link $templateCache} + * + * You can specify `templateUrl` as a string representing the URL or as a function which takes two + * arguments `tElement` and `tAttrs` (described in the `compile` function api below) and returns + * a string value representing the url. In either case, the template URL is passed through {@link + * $sce#getTrustedResourceUrl $sce.getTrustedResourceUrl}. + * + * + * #### `replace` ([*DEPRECATED*!], will be removed in next major release - i.e. v2.0) + * specify what the template should replace. Defaults to `false`. + * + * * `true` - the template will replace the directive's element. + * * `false` - the template will replace the contents of the directive's element. + * + * The replacement process migrates all of the attributes / classes from the old element to the new + * one. See the {@link guide/directive#template-expanding-directive + * Directives Guide} for an example. + * + * There are very few scenarios where element replacement is required for the application function, + * the main one being reusable custom components that are used within SVG contexts + * (because SVG doesn't work with custom elements in the DOM tree). + * + * #### `transclude` + * Extract the contents of the element where the directive appears and make it available to the directive. + * The contents are compiled and provided to the directive as a **transclusion function**. See the + * {@link $compile#transclusion Transclusion} section below. + * + * There are two kinds of transclusion depending upon whether you want to transclude just the contents of the + * directive's element or the entire element: + * + * * `true` - transclude the content (i.e. the child nodes) of the directive's element. + * * `'element'` - transclude the whole of the directive's element including any directives on this + * element that defined at a lower priority than this directive. When used, the `template` + * property is ignored. + * + * + * #### `compile` + * + * ```js + * function compile(tElement, tAttrs, transclude) { ... } + * ``` + * + * The compile function deals with transforming the template DOM. Since most directives do not do + * template transformation, it is not used often. The compile function takes the following arguments: + * + * * `tElement` - template element - The element where the directive has been declared. It is + * safe to do template transformation on the element and child elements only. + * + * * `tAttrs` - template attributes - Normalized list of attributes declared on this element shared + * between all directive compile functions. + * + * * `transclude` - [*DEPRECATED*!] A transclude linking function: `function(scope, cloneLinkingFn)` + * + *
+ * **Note:** The template instance and the link instance may be different objects if the template has + * been cloned. For this reason it is **not** safe to do anything other than DOM transformations that + * apply to all cloned DOM nodes within the compile function. Specifically, DOM listener registration + * should be done in a linking function rather than in a compile function. + *
+ + *
+ * **Note:** The compile function cannot handle directives that recursively use themselves in their + * own templates or compile functions. Compiling these directives results in an infinite loop and a + * stack overflow errors. + * + * This can be avoided by manually using $compile in the postLink function to imperatively compile + * a directive's template instead of relying on automatic template compilation via `template` or + * `templateUrl` declaration or manual compilation inside the compile function. + *
+ * + *
+ * **Note:** The `transclude` function that is passed to the compile function is deprecated, as it + * e.g. does not know about the right outer scope. Please use the transclude function that is passed + * to the link function instead. + *
+ + * A compile function can have a return value which can be either a function or an object. + * + * * returning a (post-link) function - is equivalent to registering the linking function via the + * `link` property of the config object when the compile function is empty. + * + * * returning an object with function(s) registered via `pre` and `post` properties - allows you to + * control when a linking function should be called during the linking phase. See info about + * pre-linking and post-linking functions below. + * + * + * #### `link` + * This property is used only if the `compile` property is not defined. + * + * ```js + * function link(scope, iElement, iAttrs, controller, transcludeFn) { ... } + * ``` + * + * The link function is responsible for registering DOM listeners as well as updating the DOM. It is + * executed after the template has been cloned. This is where most of the directive logic will be + * put. + * + * * `scope` - {@link ng.$rootScope.Scope Scope} - The scope to be used by the + * directive for registering {@link ng.$rootScope.Scope#$watch watches}. + * + * * `iElement` - instance element - The element where the directive is to be used. It is safe to + * manipulate the children of the element only in `postLink` function since the children have + * already been linked. + * + * * `iAttrs` - instance attributes - Normalized list of attributes declared on this element shared + * between all directive linking functions. + * + * * `controller` - the directive's required controller instance(s) - Instances are shared + * among all directives, which allows the directives to use the controllers as a communication + * channel. The exact value depends on the directive's `require` property: + * * no controller(s) required: the directive's own controller, or `undefined` if it doesn't have one + * * `string`: the controller instance + * * `array`: array of controller instances + * + * If a required controller cannot be found, and it is optional, the instance is `null`, + * otherwise the {@link error:$compile:ctreq Missing Required Controller} error is thrown. + * + * Note that you can also require the directive's own controller - it will be made available like + * any other controller. + * + * * `transcludeFn` - A transclude linking function pre-bound to the correct transclusion scope. + * This is the same as the `$transclude` + * parameter of directive controllers, see there for details. + * `function([scope], cloneLinkingFn, futureParentElement)`. + * + * #### Pre-linking function + * + * Executed before the child elements are linked. Not safe to do DOM transformation since the + * compiler linking function will fail to locate the correct elements for linking. + * + * #### Post-linking function + * + * Executed after the child elements are linked. + * + * Note that child elements that contain `templateUrl` directives will not have been compiled + * and linked since they are waiting for their template to load asynchronously and their own + * compilation and linking has been suspended until that occurs. + * + * It is safe to do DOM transformation in the post-linking function on elements that are not waiting + * for their async templates to be resolved. + * + * + * ### Transclusion + * + * Transclusion is the process of extracting a collection of DOM elements from one part of the DOM and + * copying them to another part of the DOM, while maintaining their connection to the original AngularJS + * scope from where they were taken. + * + * Transclusion is used (often with {@link ngTransclude}) to insert the + * original contents of a directive's element into a specified place in the template of the directive. + * The benefit of transclusion, over simply moving the DOM elements manually, is that the transcluded + * content has access to the properties on the scope from which it was taken, even if the directive + * has isolated scope. + * See the {@link guide/directive#creating-a-directive-that-wraps-other-elements Directives Guide}. + * + * This makes it possible for the widget to have private state for its template, while the transcluded + * content has access to its originating scope. + * + *
+ * **Note:** When testing an element transclude directive you must not place the directive at the root of the + * DOM fragment that is being compiled. See {@link guide/unit-testing#testing-transclusion-directives + * Testing Transclusion Directives}. + *
+ * + * #### Transclusion Functions + * + * When a directive requests transclusion, the compiler extracts its contents and provides a **transclusion + * function** to the directive's `link` function and `controller`. This transclusion function is a special + * **linking function** that will return the compiled contents linked to a new transclusion scope. + * + *
+ * If you are just using {@link ngTransclude} then you don't need to worry about this function, since + * ngTransclude will deal with it for us. + *
+ * + * If you want to manually control the insertion and removal of the transcluded content in your directive + * then you must use this transclude function. When you call a transclude function it returns a a jqLite/JQuery + * object that contains the compiled DOM, which is linked to the correct transclusion scope. + * + * When you call a transclusion function you can pass in a **clone attach function**. This function accepts + * two parameters, `function(clone, scope) { ... }`, where the `clone` is a fresh compiled copy of your transcluded + * content and the `scope` is the newly created transclusion scope, to which the clone is bound. + * + *
+ * **Best Practice**: Always provide a `cloneFn` (clone attach function) when you call a translude function + * since you then get a fresh clone of the original DOM and also have access to the new transclusion scope. + *
+ * + * It is normal practice to attach your transcluded content (`clone`) to the DOM inside your **clone + * attach function**: + * + * ```js + * var transcludedContent, transclusionScope; + * + * $transclude(function(clone, scope) { + * element.append(clone); + * transcludedContent = clone; + * transclusionScope = scope; + * }); + * ``` + * + * Later, if you want to remove the transcluded content from your DOM then you should also destroy the + * associated transclusion scope: + * + * ```js + * transcludedContent.remove(); + * transclusionScope.$destroy(); + * ``` + * + *
+ * **Best Practice**: if you intend to add and remove transcluded content manually in your directive + * (by calling the transclude function to get the DOM and calling `element.remove()` to remove it), + * then you are also responsible for calling `$destroy` on the transclusion scope. + *
+ * + * The built-in DOM manipulation directives, such as {@link ngIf}, {@link ngSwitch} and {@link ngRepeat} + * automatically destroy their transluded clones as necessary so you do not need to worry about this if + * you are simply using {@link ngTransclude} to inject the transclusion into your directive. + * + * + * #### Transclusion Scopes + * + * When you call a transclude function it returns a DOM fragment that is pre-bound to a **transclusion + * scope**. This scope is special, in that it is a child of the directive's scope (and so gets destroyed + * when the directive's scope gets destroyed) but it inherits the properties of the scope from which it + * was taken. + * + * For example consider a directive that uses transclusion and isolated scope. The DOM hierarchy might look + * like this: + * + * ```html + *
+ *
+ *
+ *
+ *
+ *
+ * ``` + * + * The `$parent` scope hierarchy will look like this: + * + * ``` + * - $rootScope + * - isolate + * - transclusion + * ``` + * + * but the scopes will inherit prototypically from different scopes to their `$parent`. + * + * ``` + * - $rootScope + * - transclusion + * - isolate + * ``` + * + * + * ### Attributes + * + * The {@link ng.$compile.directive.Attributes Attributes} object - passed as a parameter in the + * `link()` or `compile()` functions. It has a variety of uses. + * + * accessing *Normalized attribute names:* + * Directives like 'ngBind' can be expressed in many ways: 'ng:bind', `data-ng-bind`, or 'x-ng-bind'. + * the attributes object allows for normalized access to + * the attributes. + * + * * *Directive inter-communication:* All directives share the same instance of the attributes + * object which allows the directives to use the attributes object as inter directive + * communication. + * + * * *Supports interpolation:* Interpolation attributes are assigned to the attribute object + * allowing other directives to read the interpolated value. + * + * * *Observing interpolated attributes:* Use `$observe` to observe the value changes of attributes + * that contain interpolation (e.g. `src="{{bar}}"`). Not only is this very efficient but it's also + * the only way to easily get the actual value because during the linking phase the interpolation + * hasn't been evaluated yet and so the value is at this time set to `undefined`. + * + * ```js + * function linkingFn(scope, elm, attrs, ctrl) { + * // get the attribute value + * console.log(attrs.ngModel); + * + * // change the attribute + * attrs.$set('ngModel', 'new value'); + * + * // observe changes to interpolated attribute + * attrs.$observe('ngModel', function(value) { + * console.log('ngModel has changed value to ' + value); + * }); + * } + * ``` + * + * ## Example + * + *
+ * **Note**: Typically directives are registered with `module.directive`. The example below is + * to illustrate how `$compile` works. + *
+ * + + + +
+
+
+
+
+
+ + it('should auto compile', function() { + var textarea = $('textarea'); + var output = $('div[compile]'); + // The initial state reads 'Hello Angular'. + expect(output.getText()).toBe('Hello Angular'); + textarea.clear(); + textarea.sendKeys('{{name}}!'); + expect(output.getText()).toBe('Angular!'); + }); + +
+ + * + * + * @param {string|DOMElement} element Element or HTML string to compile into a template function. + * @param {function(angular.Scope, cloneAttachFn=)} transclude function available to directives - DEPRECATED. + * + *
+ * **Note:** Passing a `transclude` function to the $compile function is deprecated, as it + * e.g. will not use the right outer scope. Please pass the transclude function as a + * `parentBoundTranscludeFn` to the link function instead. + *
+ * + * @param {number} maxPriority only apply directives lower than given priority (Only effects the + * root element(s), not their children) + * @returns {function(scope, cloneAttachFn=, options=)} a link function which is used to bind template + * (a DOM element/tree) to a scope. Where: + * + * * `scope` - A {@link ng.$rootScope.Scope Scope} to bind to. + * * `cloneAttachFn` - If `cloneAttachFn` is provided, then the link function will clone the + * `template` and call the `cloneAttachFn` function allowing the caller to attach the + * cloned elements to the DOM document at the appropriate place. The `cloneAttachFn` is + * called as:
`cloneAttachFn(clonedElement, scope)` where: + * + * * `clonedElement` - is a clone of the original `element` passed into the compiler. + * * `scope` - is the current scope with which the linking function is working with. + * + * * `options` - An optional object hash with linking options. If `options` is provided, then the following + * keys may be used to control linking behavior: + * + * * `parentBoundTranscludeFn` - the transclude function made available to + * directives; if given, it will be passed through to the link functions of + * directives found in `element` during compilation. + * * `transcludeControllers` - an object hash with keys that map controller names + * to controller instances; if given, it will make the controllers + * available to directives. + * * `futureParentElement` - defines the parent to which the `cloneAttachFn` will add + * the cloned elements; only needed for transcludes that are allowed to contain non html + * elements (e.g. SVG elements). See also the directive.controller property. + * + * Calling the linking function returns the element of the template. It is either the original + * element passed in, or the clone of the element if the `cloneAttachFn` is provided. + * + * After linking the view is not updated until after a call to $digest which typically is done by + * Angular automatically. + * + * If you need access to the bound view, there are two ways to do it: + * + * - If you are not asking the linking function to clone the template, create the DOM element(s) + * before you send them to the compiler and keep this reference around. + * ```js + * var element = $compile('

{{total}}

')(scope); + * ``` + * + * - if on the other hand, you need the element to be cloned, the view reference from the original + * example would not point to the clone, but rather to the original template that was cloned. In + * this case, you can access the clone via the cloneAttachFn: + * ```js + * var templateElement = angular.element('

{{total}}

'), + * scope = ....; + * + * var clonedElement = $compile(templateElement)(scope, function(clonedElement, scope) { + * //attach the clone to DOM document at the right place + * }); + * + * //now we have reference to the cloned DOM via `clonedElement` + * ``` + * + * + * For information on how the compiler works, see the + * {@link guide/compiler Angular HTML Compiler} section of the Developer Guide. + */ + +var $compileMinErr = minErr('$compile'); + +/** + * @ngdoc provider + * @name $compileProvider + * + * @description + */ +$CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider']; +function $CompileProvider($provide, $$sanitizeUriProvider) { + var hasDirectives = {}, + Suffix = 'Directive', + COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\w\-]+)\s+(.*)$/, + CLASS_DIRECTIVE_REGEXP = /(([\w\-]+)(?:\:([^;]+))?;?)/, + ALL_OR_NOTHING_ATTRS = makeMap('ngSrc,ngSrcset,src,srcset'), + REQUIRE_PREFIX_REGEXP = /^(?:(\^\^?)?(\?)?(\^\^?)?)?/; + + // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes + // The assumption is that future DOM event attribute names will begin with + // 'on' and be composed of only English letters. + var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; + + function parseIsolateBindings(scope, directiveName, isController) { + var LOCAL_REGEXP = /^\s*([@&]|=(\*?))(\??)\s*(\w*)\s*$/; + + var bindings = {}; + + forEach(scope, function(definition, scopeName) { + var match = definition.match(LOCAL_REGEXP); + + if (!match) { + throw $compileMinErr('iscp', + "Invalid {3} for directive '{0}'." + + " Definition: {... {1}: '{2}' ...}", + directiveName, scopeName, definition, + (isController ? "controller bindings definition" : + "isolate scope definition")); + } + + bindings[scopeName] = { + mode: match[1][0], + collection: match[2] === '*', + optional: match[3] === '?', + attrName: match[4] || scopeName + }; + }); + + return bindings; + } + + function parseDirectiveBindings(directive, directiveName) { + var bindings = { + isolateScope: null, + bindToController: null + }; + if (isObject(directive.scope)) { + if (directive.bindToController === true) { + bindings.bindToController = parseIsolateBindings(directive.scope, + directiveName, true); + bindings.isolateScope = {}; + } else { + bindings.isolateScope = parseIsolateBindings(directive.scope, + directiveName, false); + } + } + if (isObject(directive.bindToController)) { + bindings.bindToController = + parseIsolateBindings(directive.bindToController, directiveName, true); + } + if (isObject(bindings.bindToController)) { + var controller = directive.controller; + var controllerAs = directive.controllerAs; + if (!controller) { + // There is no controller, there may or may not be a controllerAs property + throw $compileMinErr('noctrl', + "Cannot bind to controller without directive '{0}'s controller.", + directiveName); + } else if (!identifierForController(controller, controllerAs)) { + // There is a controller, but no identifier or controllerAs property + throw $compileMinErr('noident', + "Cannot bind to controller without identifier for directive '{0}'.", + directiveName); + } + } + return bindings; + } + + function assertValidDirectiveName(name) { + var letter = name.charAt(0); + if (!letter || letter !== lowercase(letter)) { + throw $compileMinErr('baddir', "Directive name '{0}' is invalid. The first character must be a lowercase letter", name); + } + if (name !== name.trim()) { + throw $compileMinErr('baddir', + "Directive name '{0}' is invalid. The name should not contain leading or trailing whitespaces", + name); + } + } + + /** + * @ngdoc method + * @name $compileProvider#directive + * @kind function + * + * @description + * Register a new directive with the compiler. + * + * @param {string|Object} name Name of the directive in camel-case (i.e. ngBind which + * will match as ng-bind), or an object map of directives where the keys are the + * names and the values are the factories. + * @param {Function|Array} directiveFactory An injectable directive factory function. See + * {@link guide/directive} for more info. + * @returns {ng.$compileProvider} Self for chaining. + */ + this.directive = function registerDirective(name, directiveFactory) { + assertNotHasOwnProperty(name, 'directive'); + if (isString(name)) { + assertValidDirectiveName(name); + assertArg(directiveFactory, 'directiveFactory'); + if (!hasDirectives.hasOwnProperty(name)) { + hasDirectives[name] = []; + $provide.factory(name + Suffix, ['$injector', '$exceptionHandler', + function($injector, $exceptionHandler) { + var directives = []; + forEach(hasDirectives[name], function(directiveFactory, index) { + try { + var directive = $injector.invoke(directiveFactory); + if (isFunction(directive)) { + directive = { compile: valueFn(directive) }; + } else if (!directive.compile && directive.link) { + directive.compile = valueFn(directive.link); + } + directive.priority = directive.priority || 0; + directive.index = index; + directive.name = directive.name || name; + directive.require = directive.require || (directive.controller && directive.name); + directive.restrict = directive.restrict || 'EA'; + var bindings = directive.$$bindings = + parseDirectiveBindings(directive, directive.name); + if (isObject(bindings.isolateScope)) { + directive.$$isolateBindings = bindings.isolateScope; + } + directive.$$moduleName = directiveFactory.$$moduleName; + directives.push(directive); + } catch (e) { + $exceptionHandler(e); + } + }); + return directives; + }]); + } + hasDirectives[name].push(directiveFactory); + } else { + forEach(name, reverseParams(registerDirective)); + } + return this; + }; + + + /** + * @ngdoc method + * @name $compileProvider#aHrefSanitizationWhitelist + * @kind function + * + * @description + * Retrieves or overrides the default regular expression that is used for whitelisting of safe + * urls during a[href] sanitization. + * + * The sanitization is a security measure aimed at preventing XSS attacks via html links. + * + * Any url about to be assigned to a[href] via data-binding is first normalized and turned into + * an absolute url. Afterwards, the url is matched against the `aHrefSanitizationWhitelist` + * regular expression. If a match is found, the original url is written into the dom. Otherwise, + * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM. + * + * @param {RegExp=} regexp New regexp to whitelist urls with. + * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for + * chaining otherwise. + */ + this.aHrefSanitizationWhitelist = function(regexp) { + if (isDefined(regexp)) { + $$sanitizeUriProvider.aHrefSanitizationWhitelist(regexp); + return this; + } else { + return $$sanitizeUriProvider.aHrefSanitizationWhitelist(); + } + }; + + + /** + * @ngdoc method + * @name $compileProvider#imgSrcSanitizationWhitelist + * @kind function + * + * @description + * Retrieves or overrides the default regular expression that is used for whitelisting of safe + * urls during img[src] sanitization. + * + * The sanitization is a security measure aimed at prevent XSS attacks via html links. + * + * Any url about to be assigned to img[src] via data-binding is first normalized and turned into + * an absolute url. Afterwards, the url is matched against the `imgSrcSanitizationWhitelist` + * regular expression. If a match is found, the original url is written into the dom. Otherwise, + * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM. + * + * @param {RegExp=} regexp New regexp to whitelist urls with. + * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for + * chaining otherwise. + */ + this.imgSrcSanitizationWhitelist = function(regexp) { + if (isDefined(regexp)) { + $$sanitizeUriProvider.imgSrcSanitizationWhitelist(regexp); + return this; + } else { + return $$sanitizeUriProvider.imgSrcSanitizationWhitelist(); + } + }; + + /** + * @ngdoc method + * @name $compileProvider#debugInfoEnabled + * + * @param {boolean=} enabled update the debugInfoEnabled state if provided, otherwise just return the + * current debugInfoEnabled state + * @returns {*} current value if used as getter or itself (chaining) if used as setter + * + * @kind function + * + * @description + * Call this method to enable/disable various debug runtime information in the compiler such as adding + * binding information and a reference to the current scope on to DOM elements. + * If enabled, the compiler will add the following to DOM elements that have been bound to the scope + * * `ng-binding` CSS class + * * `$binding` data property containing an array of the binding expressions + * + * You may want to disable this in production for a significant performance boost. See + * {@link guide/production#disabling-debug-data Disabling Debug Data} for more. + * + * The default value is true. + */ + var debugInfoEnabled = true; + this.debugInfoEnabled = function(enabled) { + if (isDefined(enabled)) { + debugInfoEnabled = enabled; + return this; + } + return debugInfoEnabled; + }; + + this.$get = [ + '$injector', '$interpolate', '$exceptionHandler', '$templateRequest', '$parse', + '$controller', '$rootScope', '$document', '$sce', '$animate', '$$sanitizeUri', + function($injector, $interpolate, $exceptionHandler, $templateRequest, $parse, + $controller, $rootScope, $document, $sce, $animate, $$sanitizeUri) { + + var Attributes = function(element, attributesToCopy) { + if (attributesToCopy) { + var keys = Object.keys(attributesToCopy); + var i, l, key; + + for (i = 0, l = keys.length; i < l; i++) { + key = keys[i]; + this[key] = attributesToCopy[key]; + } + } else { + this.$attr = {}; + } + + this.$$element = element; + }; + + Attributes.prototype = { + /** + * @ngdoc method + * @name $compile.directive.Attributes#$normalize + * @kind function + * + * @description + * Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with `x-` or + * `data-`) to its normalized, camelCase form. + * + * Also there is special case for Moz prefix starting with upper case letter. + * + * For further information check out the guide on {@link guide/directive#matching-directives Matching Directives} + * + * @param {string} name Name to normalize + */ + $normalize: directiveNormalize, + + + /** + * @ngdoc method + * @name $compile.directive.Attributes#$addClass + * @kind function + * + * @description + * Adds the CSS class value specified by the classVal parameter to the element. If animations + * are enabled then an animation will be triggered for the class addition. + * + * @param {string} classVal The className value that will be added to the element + */ + $addClass: function(classVal) { + if (classVal && classVal.length > 0) { + $animate.addClass(this.$$element, classVal); + } + }, + + /** + * @ngdoc method + * @name $compile.directive.Attributes#$removeClass + * @kind function + * + * @description + * Removes the CSS class value specified by the classVal parameter from the element. If + * animations are enabled then an animation will be triggered for the class removal. + * + * @param {string} classVal The className value that will be removed from the element + */ + $removeClass: function(classVal) { + if (classVal && classVal.length > 0) { + $animate.removeClass(this.$$element, classVal); + } + }, + + /** + * @ngdoc method + * @name $compile.directive.Attributes#$updateClass + * @kind function + * + * @description + * Adds and removes the appropriate CSS class values to the element based on the difference + * between the new and old CSS class values (specified as newClasses and oldClasses). + * + * @param {string} newClasses The current CSS className value + * @param {string} oldClasses The former CSS className value + */ + $updateClass: function(newClasses, oldClasses) { + var toAdd = tokenDifference(newClasses, oldClasses); + if (toAdd && toAdd.length) { + $animate.addClass(this.$$element, toAdd); + } + + var toRemove = tokenDifference(oldClasses, newClasses); + if (toRemove && toRemove.length) { + $animate.removeClass(this.$$element, toRemove); + } + }, + + /** + * Set a normalized attribute on the element in a way such that all directives + * can share the attribute. This function properly handles boolean attributes. + * @param {string} key Normalized key. (ie ngAttribute) + * @param {string|boolean} value The value to set. If `null` attribute will be deleted. + * @param {boolean=} writeAttr If false, does not write the value to DOM element attribute. + * Defaults to true. + * @param {string=} attrName Optional none normalized name. Defaults to key. + */ + $set: function(key, value, writeAttr, attrName) { + // TODO: decide whether or not to throw an error if "class" + //is set through this function since it may cause $updateClass to + //become unstable. + + var node = this.$$element[0], + booleanKey = getBooleanAttrName(node, key), + aliasedKey = getAliasedAttrName(key), + observer = key, + nodeName; + + if (booleanKey) { + this.$$element.prop(key, value); + attrName = booleanKey; + } else if (aliasedKey) { + this[aliasedKey] = value; + observer = aliasedKey; + } + + this[key] = value; + + // translate normalized key to actual key + if (attrName) { + this.$attr[key] = attrName; + } else { + attrName = this.$attr[key]; + if (!attrName) { + this.$attr[key] = attrName = snake_case(key, '-'); + } + } + + nodeName = nodeName_(this.$$element); + + if ((nodeName === 'a' && key === 'href') || + (nodeName === 'img' && key === 'src')) { + // sanitize a[href] and img[src] values + this[key] = value = $$sanitizeUri(value, key === 'src'); + } else if (nodeName === 'img' && key === 'srcset') { + // sanitize img[srcset] values + var result = ""; + + // first check if there are spaces because it's not the same pattern + var trimmedSrcset = trim(value); + // ( 999x ,| 999w ,| ,|, ) + var srcPattern = /(\s+\d+x\s*,|\s+\d+w\s*,|\s+,|,\s+)/; + var pattern = /\s/.test(trimmedSrcset) ? srcPattern : /(,)/; + + // split srcset into tuple of uri and descriptor except for the last item + var rawUris = trimmedSrcset.split(pattern); + + // for each tuples + var nbrUrisWith2parts = Math.floor(rawUris.length / 2); + for (var i = 0; i < nbrUrisWith2parts; i++) { + var innerIdx = i * 2; + // sanitize the uri + result += $$sanitizeUri(trim(rawUris[innerIdx]), true); + // add the descriptor + result += (" " + trim(rawUris[innerIdx + 1])); + } + + // split the last item into uri and descriptor + var lastTuple = trim(rawUris[i * 2]).split(/\s/); + + // sanitize the last uri + result += $$sanitizeUri(trim(lastTuple[0]), true); + + // and add the last descriptor if any + if (lastTuple.length === 2) { + result += (" " + trim(lastTuple[1])); + } + this[key] = value = result; + } + + if (writeAttr !== false) { + if (value === null || isUndefined(value)) { + this.$$element.removeAttr(attrName); + } else { + this.$$element.attr(attrName, value); + } + } + + // fire observers + var $$observers = this.$$observers; + $$observers && forEach($$observers[observer], function(fn) { + try { + fn(value); + } catch (e) { + $exceptionHandler(e); + } + }); + }, + + + /** + * @ngdoc method + * @name $compile.directive.Attributes#$observe + * @kind function + * + * @description + * Observes an interpolated attribute. + * + * The observer function will be invoked once during the next `$digest` following + * compilation. The observer is then invoked whenever the interpolated value + * changes. + * + * @param {string} key Normalized key. (ie ngAttribute) . + * @param {function(interpolatedValue)} fn Function that will be called whenever + the interpolated value of the attribute changes. + * See the {@link guide/directive#text-and-attribute-bindings Directives} guide for more info. + * @returns {function()} Returns a deregistration function for this observer. + */ + $observe: function(key, fn) { + var attrs = this, + $$observers = (attrs.$$observers || (attrs.$$observers = createMap())), + listeners = ($$observers[key] || ($$observers[key] = [])); + + listeners.push(fn); + $rootScope.$evalAsync(function() { + if (!listeners.$$inter && attrs.hasOwnProperty(key) && !isUndefined(attrs[key])) { + // no one registered attribute interpolation function, so lets call it manually + fn(attrs[key]); + } + }); + + return function() { + arrayRemove(listeners, fn); + }; + } + }; + + + function safeAddClass($element, className) { + try { + $element.addClass(className); + } catch (e) { + // ignore, since it means that we are trying to set class on + // SVG element, where class name is read-only. + } + } + + + var startSymbol = $interpolate.startSymbol(), + endSymbol = $interpolate.endSymbol(), + denormalizeTemplate = (startSymbol == '{{' || endSymbol == '}}') + ? identity + : function denormalizeTemplate(template) { + return template.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol); + }, + NG_ATTR_BINDING = /^ngAttr[A-Z]/; + + compile.$$addBindingInfo = debugInfoEnabled ? function $$addBindingInfo($element, binding) { + var bindings = $element.data('$binding') || []; + + if (isArray(binding)) { + bindings = bindings.concat(binding); + } else { + bindings.push(binding); + } + + $element.data('$binding', bindings); + } : noop; + + compile.$$addBindingClass = debugInfoEnabled ? function $$addBindingClass($element) { + safeAddClass($element, 'ng-binding'); + } : noop; + + compile.$$addScopeInfo = debugInfoEnabled ? function $$addScopeInfo($element, scope, isolated, noTemplate) { + var dataName = isolated ? (noTemplate ? '$isolateScopeNoTemplate' : '$isolateScope') : '$scope'; + $element.data(dataName, scope); + } : noop; + + compile.$$addScopeClass = debugInfoEnabled ? function $$addScopeClass($element, isolated) { + safeAddClass($element, isolated ? 'ng-isolate-scope' : 'ng-scope'); + } : noop; + + return compile; + + //================================ + + function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, + previousCompileContext) { + if (!($compileNodes instanceof jqLite)) { + // jquery always rewraps, whereas we need to preserve the original selector so that we can + // modify it. + $compileNodes = jqLite($compileNodes); + } + // We can not compile top level text elements since text nodes can be merged and we will + // not be able to attach scope data to them, so we will wrap them in + forEach($compileNodes, function(node, index) { + if (node.nodeType == NODE_TYPE_TEXT && node.nodeValue.match(/\S+/) /* non-empty */ ) { + $compileNodes[index] = jqLite(node).wrap('').parent()[0]; + } + }); + var compositeLinkFn = + compileNodes($compileNodes, transcludeFn, $compileNodes, + maxPriority, ignoreDirective, previousCompileContext); + compile.$$addScopeClass($compileNodes); + var namespace = null; + return function publicLinkFn(scope, cloneConnectFn, options) { + assertArg(scope, 'scope'); + + options = options || {}; + var parentBoundTranscludeFn = options.parentBoundTranscludeFn, + transcludeControllers = options.transcludeControllers, + futureParentElement = options.futureParentElement; + + // When `parentBoundTranscludeFn` is passed, it is a + // `controllersBoundTransclude` function (it was previously passed + // as `transclude` to directive.link) so we must unwrap it to get + // its `boundTranscludeFn` + if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) { + parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude; + } + + if (!namespace) { + namespace = detectNamespaceForChildElements(futureParentElement); + } + var $linkNode; + if (namespace !== 'html') { + // When using a directive with replace:true and templateUrl the $compileNodes + // (or a child element inside of them) + // might change, so we need to recreate the namespace adapted compileNodes + // for call to the link function. + // Note: This will already clone the nodes... + $linkNode = jqLite( + wrapTemplate(namespace, jqLite('
').append($compileNodes).html()) + ); + } else if (cloneConnectFn) { + // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart + // and sometimes changes the structure of the DOM. + $linkNode = JQLitePrototype.clone.call($compileNodes); + } else { + $linkNode = $compileNodes; + } + + if (transcludeControllers) { + for (var controllerName in transcludeControllers) { + $linkNode.data('$' + controllerName + 'Controller', transcludeControllers[controllerName].instance); + } + } + + compile.$$addScopeInfo($linkNode, scope); + + if (cloneConnectFn) cloneConnectFn($linkNode, scope); + if (compositeLinkFn) compositeLinkFn(scope, $linkNode, $linkNode, parentBoundTranscludeFn); + return $linkNode; + }; + } + + function detectNamespaceForChildElements(parentElement) { + // TODO: Make this detect MathML as well... + var node = parentElement && parentElement[0]; + if (!node) { + return 'html'; + } else { + return nodeName_(node) !== 'foreignobject' && node.toString().match(/SVG/) ? 'svg' : 'html'; + } + } + + /** + * Compile function matches each node in nodeList against the directives. Once all directives + * for a particular node are collected their compile functions are executed. The compile + * functions return values - the linking functions - are combined into a composite linking + * function, which is the a linking function for the node. + * + * @param {NodeList} nodeList an array of nodes or NodeList to compile + * @param {function(angular.Scope, cloneAttachFn=)} transcludeFn A linking function, where the + * scope argument is auto-generated to the new child of the transcluded parent scope. + * @param {DOMElement=} $rootElement If the nodeList is the root of the compilation tree then + * the rootElement must be set the jqLite collection of the compile root. This is + * needed so that the jqLite collection items can be replaced with widgets. + * @param {number=} maxPriority Max directive priority. + * @returns {Function} A composite linking function of all of the matched directives or null. + */ + function compileNodes(nodeList, transcludeFn, $rootElement, maxPriority, ignoreDirective, + previousCompileContext) { + var linkFns = [], + attrs, directives, nodeLinkFn, childNodes, childLinkFn, linkFnFound, nodeLinkFnFound; + + for (var i = 0; i < nodeList.length; i++) { + attrs = new Attributes(); + + // we must always refer to nodeList[i] since the nodes can be replaced underneath us. + directives = collectDirectives(nodeList[i], [], attrs, i === 0 ? maxPriority : undefined, + ignoreDirective); + + nodeLinkFn = (directives.length) + ? applyDirectivesToNode(directives, nodeList[i], attrs, transcludeFn, $rootElement, + null, [], [], previousCompileContext) + : null; + + if (nodeLinkFn && nodeLinkFn.scope) { + compile.$$addScopeClass(attrs.$$element); + } + + childLinkFn = (nodeLinkFn && nodeLinkFn.terminal || + !(childNodes = nodeList[i].childNodes) || + !childNodes.length) + ? null + : compileNodes(childNodes, + nodeLinkFn ? ( + (nodeLinkFn.transcludeOnThisElement || !nodeLinkFn.templateOnThisElement) + && nodeLinkFn.transclude) : transcludeFn); + + if (nodeLinkFn || childLinkFn) { + linkFns.push(i, nodeLinkFn, childLinkFn); + linkFnFound = true; + nodeLinkFnFound = nodeLinkFnFound || nodeLinkFn; + } + + //use the previous context only for the first element in the virtual group + previousCompileContext = null; + } + + // return a linking function if we have found anything, null otherwise + return linkFnFound ? compositeLinkFn : null; + + function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) { + var nodeLinkFn, childLinkFn, node, childScope, i, ii, idx, childBoundTranscludeFn; + var stableNodeList; + + + if (nodeLinkFnFound) { + // copy nodeList so that if a nodeLinkFn removes or adds an element at this DOM level our + // offsets don't get screwed up + var nodeListLength = nodeList.length; + stableNodeList = new Array(nodeListLength); + + // create a sparse array by only copying the elements which have a linkFn + for (i = 0; i < linkFns.length; i+=3) { + idx = linkFns[i]; + stableNodeList[idx] = nodeList[idx]; + } + } else { + stableNodeList = nodeList; + } + + for (i = 0, ii = linkFns.length; i < ii;) { + node = stableNodeList[linkFns[i++]]; + nodeLinkFn = linkFns[i++]; + childLinkFn = linkFns[i++]; + + if (nodeLinkFn) { + if (nodeLinkFn.scope) { + childScope = scope.$new(); + compile.$$addScopeInfo(jqLite(node), childScope); + var destroyBindings = nodeLinkFn.$$destroyBindings; + if (destroyBindings) { + nodeLinkFn.$$destroyBindings = null; + childScope.$on('$destroyed', destroyBindings); + } + } else { + childScope = scope; + } + + if (nodeLinkFn.transcludeOnThisElement) { + childBoundTranscludeFn = createBoundTranscludeFn( + scope, nodeLinkFn.transclude, parentBoundTranscludeFn); + + } else if (!nodeLinkFn.templateOnThisElement && parentBoundTranscludeFn) { + childBoundTranscludeFn = parentBoundTranscludeFn; + + } else if (!parentBoundTranscludeFn && transcludeFn) { + childBoundTranscludeFn = createBoundTranscludeFn(scope, transcludeFn); + + } else { + childBoundTranscludeFn = null; + } + + nodeLinkFn(childLinkFn, childScope, node, $rootElement, childBoundTranscludeFn, + nodeLinkFn); + + } else if (childLinkFn) { + childLinkFn(scope, node.childNodes, undefined, parentBoundTranscludeFn); + } + } + } + } + + function createBoundTranscludeFn(scope, transcludeFn, previousBoundTranscludeFn) { + + var boundTranscludeFn = function(transcludedScope, cloneFn, controllers, futureParentElement, containingScope) { + + if (!transcludedScope) { + transcludedScope = scope.$new(false, containingScope); + transcludedScope.$$transcluded = true; + } + + return transcludeFn(transcludedScope, cloneFn, { + parentBoundTranscludeFn: previousBoundTranscludeFn, + transcludeControllers: controllers, + futureParentElement: futureParentElement + }); + }; + + return boundTranscludeFn; + } + + /** + * Looks for directives on the given node and adds them to the directive collection which is + * sorted. + * + * @param node Node to search. + * @param directives An array to which the directives are added to. This array is sorted before + * the function returns. + * @param attrs The shared attrs object which is used to populate the normalized attributes. + * @param {number=} maxPriority Max directive priority. + */ + function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { + var nodeType = node.nodeType, + attrsMap = attrs.$attr, + match, + className; + + switch (nodeType) { + case NODE_TYPE_ELEMENT: /* Element */ + // use the node name: + addDirective(directives, + directiveNormalize(nodeName_(node)), 'E', maxPriority, ignoreDirective); + + // iterate over the attributes + for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, + j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { + var attrStartName = false; + var attrEndName = false; + + attr = nAttrs[j]; + name = attr.name; + value = trim(attr.value); + + // support ngAttr attribute binding + ngAttrName = directiveNormalize(name); + if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) { + name = name.replace(PREFIX_REGEXP, '') + .substr(8).replace(/_(.)/g, function(match, letter) { + return letter.toUpperCase(); + }); + } + + var directiveNName = ngAttrName.replace(/(Start|End)$/, ''); + if (directiveIsMultiElement(directiveNName)) { + if (ngAttrName === directiveNName + 'Start') { + attrStartName = name; + attrEndName = name.substr(0, name.length - 5) + 'end'; + name = name.substr(0, name.length - 6); + } + } + + nName = directiveNormalize(name.toLowerCase()); + attrsMap[nName] = name; + if (isNgAttr || !attrs.hasOwnProperty(nName)) { + attrs[nName] = value; + if (getBooleanAttrName(node, nName)) { + attrs[nName] = true; // presence means true + } + } + addAttrInterpolateDirective(node, directives, value, nName, isNgAttr); + addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName, + attrEndName); + } + + // use class as directive + className = node.className; + if (isObject(className)) { + // Maybe SVGAnimatedString + className = className.animVal; + } + if (isString(className) && className !== '') { + while (match = CLASS_DIRECTIVE_REGEXP.exec(className)) { + nName = directiveNormalize(match[2]); + if (addDirective(directives, nName, 'C', maxPriority, ignoreDirective)) { + attrs[nName] = trim(match[3]); + } + className = className.substr(match.index + match[0].length); + } + } + break; + case NODE_TYPE_TEXT: /* Text Node */ + if (msie === 11) { + // Workaround for #11781 + while (node.parentNode && node.nextSibling && node.nextSibling.nodeType === NODE_TYPE_TEXT) { + node.nodeValue = node.nodeValue + node.nextSibling.nodeValue; + node.parentNode.removeChild(node.nextSibling); + } + } + addTextInterpolateDirective(directives, node.nodeValue); + break; + case NODE_TYPE_COMMENT: /* Comment */ + try { + match = COMMENT_DIRECTIVE_REGEXP.exec(node.nodeValue); + if (match) { + nName = directiveNormalize(match[1]); + if (addDirective(directives, nName, 'M', maxPriority, ignoreDirective)) { + attrs[nName] = trim(match[2]); + } + } + } catch (e) { + // turns out that under some circumstances IE9 throws errors when one attempts to read + // comment's node value. + // Just ignore it and continue. (Can't seem to reproduce in test case.) + } + break; + } + + directives.sort(byPriority); + return directives; + } + + /** + * Given a node with an directive-start it collects all of the siblings until it finds + * directive-end. + * @param node + * @param attrStart + * @param attrEnd + * @returns {*} + */ + function groupScan(node, attrStart, attrEnd) { + var nodes = []; + var depth = 0; + if (attrStart && node.hasAttribute && node.hasAttribute(attrStart)) { + do { + if (!node) { + throw $compileMinErr('uterdir', + "Unterminated attribute, found '{0}' but no matching '{1}' found.", + attrStart, attrEnd); + } + if (node.nodeType == NODE_TYPE_ELEMENT) { + if (node.hasAttribute(attrStart)) depth++; + if (node.hasAttribute(attrEnd)) depth--; + } + nodes.push(node); + node = node.nextSibling; + } while (depth > 0); + } else { + nodes.push(node); + } + + return jqLite(nodes); + } + + /** + * Wrapper for linking function which converts normal linking function into a grouped + * linking function. + * @param linkFn + * @param attrStart + * @param attrEnd + * @returns {Function} + */ + function groupElementsLinkFnWrapper(linkFn, attrStart, attrEnd) { + return function(scope, element, attrs, controllers, transcludeFn) { + element = groupScan(element[0], attrStart, attrEnd); + return linkFn(scope, element, attrs, controllers, transcludeFn); + }; + } + + /** + * Once the directives have been collected, their compile functions are executed. This method + * is responsible for inlining directive templates as well as terminating the application + * of the directives if the terminal directive has been reached. + * + * @param {Array} directives Array of collected directives to execute their compile function. + * this needs to be pre-sorted by priority order. + * @param {Node} compileNode The raw DOM node to apply the compile functions to + * @param {Object} templateAttrs The shared attribute function + * @param {function(angular.Scope, cloneAttachFn=)} transcludeFn A linking function, where the + * scope argument is auto-generated to the new + * child of the transcluded parent scope. + * @param {JQLite} jqCollection If we are working on the root of the compile tree then this + * argument has the root jqLite array so that we can replace nodes + * on it. + * @param {Object=} originalReplaceDirective An optional directive that will be ignored when + * compiling the transclusion. + * @param {Array.} preLinkFns + * @param {Array.} postLinkFns + * @param {Object} previousCompileContext Context used for previous compilation of the current + * node + * @returns {Function} linkFn + */ + function applyDirectivesToNode(directives, compileNode, templateAttrs, transcludeFn, + jqCollection, originalReplaceDirective, preLinkFns, postLinkFns, + previousCompileContext) { + previousCompileContext = previousCompileContext || {}; + + var terminalPriority = -Number.MAX_VALUE, + newScopeDirective = previousCompileContext.newScopeDirective, + controllerDirectives = previousCompileContext.controllerDirectives, + newIsolateScopeDirective = previousCompileContext.newIsolateScopeDirective, + templateDirective = previousCompileContext.templateDirective, + nonTlbTranscludeDirective = previousCompileContext.nonTlbTranscludeDirective, + hasTranscludeDirective = false, + hasTemplate = false, + hasElementTranscludeDirective = previousCompileContext.hasElementTranscludeDirective, + $compileNode = templateAttrs.$$element = jqLite(compileNode), + directive, + directiveName, + $template, + replaceDirective = originalReplaceDirective, + childTranscludeFn = transcludeFn, + linkFn, + directiveValue; + + // executes all directives on the current element + for (var i = 0, ii = directives.length; i < ii; i++) { + directive = directives[i]; + var attrStart = directive.$$start; + var attrEnd = directive.$$end; + + // collect multiblock sections + if (attrStart) { + $compileNode = groupScan(compileNode, attrStart, attrEnd); + } + $template = undefined; + + if (terminalPriority > directive.priority) { + break; // prevent further processing of directives + } + + if (directiveValue = directive.scope) { + + // skip the check for directives with async templates, we'll check the derived sync + // directive when the template arrives + if (!directive.templateUrl) { + if (isObject(directiveValue)) { + // This directive is trying to add an isolated scope. + // Check that there is no scope of any kind already + assertNoDuplicate('new/isolated scope', newIsolateScopeDirective || newScopeDirective, + directive, $compileNode); + newIsolateScopeDirective = directive; + } else { + // This directive is trying to add a child scope. + // Check that there is no isolated scope already + assertNoDuplicate('new/isolated scope', newIsolateScopeDirective, directive, + $compileNode); + } + } + + newScopeDirective = newScopeDirective || directive; + } + + directiveName = directive.name; + + if (!directive.templateUrl && directive.controller) { + directiveValue = directive.controller; + controllerDirectives = controllerDirectives || createMap(); + assertNoDuplicate("'" + directiveName + "' controller", + controllerDirectives[directiveName], directive, $compileNode); + controllerDirectives[directiveName] = directive; + } + + if (directiveValue = directive.transclude) { + hasTranscludeDirective = true; + + // Special case ngIf and ngRepeat so that we don't complain about duplicate transclusion. + // This option should only be used by directives that know how to safely handle element transclusion, + // where the transcluded nodes are added or replaced after linking. + if (!directive.$$tlb) { + assertNoDuplicate('transclusion', nonTlbTranscludeDirective, directive, $compileNode); + nonTlbTranscludeDirective = directive; + } + + if (directiveValue == 'element') { + hasElementTranscludeDirective = true; + terminalPriority = directive.priority; + $template = $compileNode; + $compileNode = templateAttrs.$$element = + jqLite(document.createComment(' ' + directiveName + ': ' + + templateAttrs[directiveName] + ' ')); + compileNode = $compileNode[0]; + replaceWith(jqCollection, sliceArgs($template), compileNode); + + childTranscludeFn = compile($template, transcludeFn, terminalPriority, + replaceDirective && replaceDirective.name, { + // Don't pass in: + // - controllerDirectives - otherwise we'll create duplicates controllers + // - newIsolateScopeDirective or templateDirective - combining templates with + // element transclusion doesn't make sense. + // + // We need only nonTlbTranscludeDirective so that we prevent putting transclusion + // on the same element more than once. + nonTlbTranscludeDirective: nonTlbTranscludeDirective + }); + } else { + $template = jqLite(jqLiteClone(compileNode)).contents(); + $compileNode.empty(); // clear contents + childTranscludeFn = compile($template, transcludeFn); + } + } + + if (directive.template) { + hasTemplate = true; + assertNoDuplicate('template', templateDirective, directive, $compileNode); + templateDirective = directive; + + directiveValue = (isFunction(directive.template)) + ? directive.template($compileNode, templateAttrs) + : directive.template; + + directiveValue = denormalizeTemplate(directiveValue); + + if (directive.replace) { + replaceDirective = directive; + if (jqLiteIsTextNode(directiveValue)) { + $template = []; + } else { + $template = removeComments(wrapTemplate(directive.templateNamespace, trim(directiveValue))); + } + compileNode = $template[0]; + + if ($template.length != 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) { + throw $compileMinErr('tplrt', + "Template for directive '{0}' must have exactly one root element. {1}", + directiveName, ''); + } + + replaceWith(jqCollection, $compileNode, compileNode); + + var newTemplateAttrs = {$attr: {}}; + + // combine directives from the original node and from the template: + // - take the array of directives for this element + // - split it into two parts, those that already applied (processed) and those that weren't (unprocessed) + // - collect directives from the template and sort them by priority + // - combine directives as: processed + template + unprocessed + var templateDirectives = collectDirectives(compileNode, [], newTemplateAttrs); + var unprocessedDirectives = directives.splice(i + 1, directives.length - (i + 1)); + + if (newIsolateScopeDirective) { + markDirectivesAsIsolate(templateDirectives); + } + directives = directives.concat(templateDirectives).concat(unprocessedDirectives); + mergeTemplateAttributes(templateAttrs, newTemplateAttrs); + + ii = directives.length; + } else { + $compileNode.html(directiveValue); + } + } + + if (directive.templateUrl) { + hasTemplate = true; + assertNoDuplicate('template', templateDirective, directive, $compileNode); + templateDirective = directive; + + if (directive.replace) { + replaceDirective = directive; + } + + nodeLinkFn = compileTemplateUrl(directives.splice(i, directives.length - i), $compileNode, + templateAttrs, jqCollection, hasTranscludeDirective && childTranscludeFn, preLinkFns, postLinkFns, { + controllerDirectives: controllerDirectives, + newScopeDirective: (newScopeDirective !== directive) && newScopeDirective, + newIsolateScopeDirective: newIsolateScopeDirective, + templateDirective: templateDirective, + nonTlbTranscludeDirective: nonTlbTranscludeDirective + }); + ii = directives.length; + } else if (directive.compile) { + try { + linkFn = directive.compile($compileNode, templateAttrs, childTranscludeFn); + if (isFunction(linkFn)) { + addLinkFns(null, linkFn, attrStart, attrEnd); + } else if (linkFn) { + addLinkFns(linkFn.pre, linkFn.post, attrStart, attrEnd); + } + } catch (e) { + $exceptionHandler(e, startingTag($compileNode)); + } + } + + if (directive.terminal) { + nodeLinkFn.terminal = true; + terminalPriority = Math.max(terminalPriority, directive.priority); + } + + } + + nodeLinkFn.scope = newScopeDirective && newScopeDirective.scope === true; + nodeLinkFn.transcludeOnThisElement = hasTranscludeDirective; + nodeLinkFn.templateOnThisElement = hasTemplate; + nodeLinkFn.transclude = childTranscludeFn; + + previousCompileContext.hasElementTranscludeDirective = hasElementTranscludeDirective; + + // might be normal or delayed nodeLinkFn depending on if templateUrl is present + return nodeLinkFn; + + //////////////////// + + function addLinkFns(pre, post, attrStart, attrEnd) { + if (pre) { + if (attrStart) pre = groupElementsLinkFnWrapper(pre, attrStart, attrEnd); + pre.require = directive.require; + pre.directiveName = directiveName; + if (newIsolateScopeDirective === directive || directive.$$isolateScope) { + pre = cloneAndAnnotateFn(pre, {isolateScope: true}); + } + preLinkFns.push(pre); + } + if (post) { + if (attrStart) post = groupElementsLinkFnWrapper(post, attrStart, attrEnd); + post.require = directive.require; + post.directiveName = directiveName; + if (newIsolateScopeDirective === directive || directive.$$isolateScope) { + post = cloneAndAnnotateFn(post, {isolateScope: true}); + } + postLinkFns.push(post); + } + } + + + function getControllers(directiveName, require, $element, elementControllers) { + var value; + + if (isString(require)) { + var match = require.match(REQUIRE_PREFIX_REGEXP); + var name = require.substring(match[0].length); + var inheritType = match[1] || match[3]; + var optional = match[2] === '?'; + + //If only parents then start at the parent element + if (inheritType === '^^') { + $element = $element.parent(); + //Otherwise attempt getting the controller from elementControllers in case + //the element is transcluded (and has no data) and to avoid .data if possible + } else { + value = elementControllers && elementControllers[name]; + value = value && value.instance; + } + + if (!value) { + var dataName = '$' + name + 'Controller'; + value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName); + } + + if (!value && !optional) { + throw $compileMinErr('ctreq', + "Controller '{0}', required by directive '{1}', can't be found!", + name, directiveName); + } + } else if (isArray(require)) { + value = []; + for (var i = 0, ii = require.length; i < ii; i++) { + value[i] = getControllers(directiveName, require[i], $element, elementControllers); + } + } + + return value || null; + } + + function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope) { + var elementControllers = createMap(); + for (var controllerKey in controllerDirectives) { + var directive = controllerDirectives[controllerKey]; + var locals = { + $scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope, + $element: $element, + $attrs: attrs, + $transclude: transcludeFn + }; + + var controller = directive.controller; + if (controller == '@') { + controller = attrs[directive.name]; + } + + var controllerInstance = $controller(controller, locals, true, directive.controllerAs); + + // For directives with element transclusion the element is a comment, + // but jQuery .data doesn't support attaching data to comment nodes as it's hard to + // clean up (http://bugs.jquery.com/ticket/8335). + // Instead, we save the controllers for the element in a local hash and attach to .data + // later, once we have the actual element. + elementControllers[directive.name] = controllerInstance; + if (!hasElementTranscludeDirective) { + $element.data('$' + directive.name + 'Controller', controllerInstance.instance); + } + } + return elementControllers; + } + + function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn, + thisLinkFn) { + var i, ii, linkFn, controller, isolateScope, elementControllers, transcludeFn, $element, + attrs; + + if (compileNode === linkNode) { + attrs = templateAttrs; + $element = templateAttrs.$$element; + } else { + $element = jqLite(linkNode); + attrs = new Attributes($element, templateAttrs); + } + + if (newIsolateScopeDirective) { + isolateScope = scope.$new(true); + } + + if (boundTranscludeFn) { + // track `boundTranscludeFn` so it can be unwrapped if `transcludeFn` + // is later passed as `parentBoundTranscludeFn` to `publicLinkFn` + transcludeFn = controllersBoundTransclude; + transcludeFn.$$boundTransclude = boundTranscludeFn; + } + + if (controllerDirectives) { + elementControllers = setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope); + } + + if (newIsolateScopeDirective) { + // Initialize isolate scope bindings for new isolate scope directive. + compile.$$addScopeInfo($element, isolateScope, true, !(templateDirective && (templateDirective === newIsolateScopeDirective || + templateDirective === newIsolateScopeDirective.$$originalDirective))); + compile.$$addScopeClass($element, true); + isolateScope.$$isolateBindings = + newIsolateScopeDirective.$$isolateBindings; + initializeDirectiveBindings(scope, attrs, isolateScope, + isolateScope.$$isolateBindings, + newIsolateScopeDirective, isolateScope); + } + if (elementControllers) { + // Initialize bindToController bindings for new/isolate scopes + var scopeDirective = newIsolateScopeDirective || newScopeDirective; + var bindings; + var controllerForBindings; + if (scopeDirective && elementControllers[scopeDirective.name]) { + bindings = scopeDirective.$$bindings.bindToController; + controller = elementControllers[scopeDirective.name]; + + if (controller && controller.identifier && bindings) { + controllerForBindings = controller; + thisLinkFn.$$destroyBindings = + initializeDirectiveBindings(scope, attrs, controller.instance, + bindings, scopeDirective); + } + } + for (i in elementControllers) { + controller = elementControllers[i]; + var controllerResult = controller(); + + if (controllerResult !== controller.instance) { + // If the controller constructor has a return value, overwrite the instance + // from setupControllers and update the element data + controller.instance = controllerResult; + $element.data('$' + i + 'Controller', controllerResult); + if (controller === controllerForBindings) { + // Remove and re-install bindToController bindings + thisLinkFn.$$destroyBindings(); + thisLinkFn.$$destroyBindings = + initializeDirectiveBindings(scope, attrs, controllerResult, bindings, scopeDirective); + } + } + } + } + + // PRELINKING + for (i = 0, ii = preLinkFns.length; i < ii; i++) { + linkFn = preLinkFns[i]; + invokeLinkFn(linkFn, + linkFn.isolateScope ? isolateScope : scope, + $element, + attrs, + linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), + transcludeFn + ); + } + + // RECURSION + // We only pass the isolate scope, if the isolate directive has a template, + // otherwise the child elements do not belong to the isolate directive. + var scopeToChild = scope; + if (newIsolateScopeDirective && (newIsolateScopeDirective.template || newIsolateScopeDirective.templateUrl === null)) { + scopeToChild = isolateScope; + } + childLinkFn && childLinkFn(scopeToChild, linkNode.childNodes, undefined, boundTranscludeFn); + + // POSTLINKING + for (i = postLinkFns.length - 1; i >= 0; i--) { + linkFn = postLinkFns[i]; + invokeLinkFn(linkFn, + linkFn.isolateScope ? isolateScope : scope, + $element, + attrs, + linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), + transcludeFn + ); + } + + // This is the function that is injected as `$transclude`. + // Note: all arguments are optional! + function controllersBoundTransclude(scope, cloneAttachFn, futureParentElement) { + var transcludeControllers; + + // No scope passed in: + if (!isScope(scope)) { + futureParentElement = cloneAttachFn; + cloneAttachFn = scope; + scope = undefined; + } + + if (hasElementTranscludeDirective) { + transcludeControllers = elementControllers; + } + if (!futureParentElement) { + futureParentElement = hasElementTranscludeDirective ? $element.parent() : $element; + } + return boundTranscludeFn(scope, cloneAttachFn, transcludeControllers, futureParentElement, scopeToChild); + } + } + } + + function markDirectivesAsIsolate(directives) { + // mark all directives as needing isolate scope. + for (var j = 0, jj = directives.length; j < jj; j++) { + directives[j] = inherit(directives[j], {$$isolateScope: true}); + } + } + + /** + * looks up the directive and decorates it with exception handling and proper parameters. We + * call this the boundDirective. + * + * @param {string} name name of the directive to look up. + * @param {string} location The directive must be found in specific format. + * String containing any of theses characters: + * + * * `E`: element name + * * `A': attribute + * * `C`: class + * * `M`: comment + * @returns {boolean} true if directive was added. + */ + function addDirective(tDirectives, name, location, maxPriority, ignoreDirective, startAttrName, + endAttrName) { + if (name === ignoreDirective) return null; + var match = null; + if (hasDirectives.hasOwnProperty(name)) { + for (var directive, directives = $injector.get(name + Suffix), + i = 0, ii = directives.length; i < ii; i++) { + try { + directive = directives[i]; + if ((isUndefined(maxPriority) || maxPriority > directive.priority) && + directive.restrict.indexOf(location) != -1) { + if (startAttrName) { + directive = inherit(directive, {$$start: startAttrName, $$end: endAttrName}); + } + tDirectives.push(directive); + match = directive; + } + } catch (e) { $exceptionHandler(e); } + } + } + return match; + } + + + /** + * looks up the directive and returns true if it is a multi-element directive, + * and therefore requires DOM nodes between -start and -end markers to be grouped + * together. + * + * @param {string} name name of the directive to look up. + * @returns true if directive was registered as multi-element. + */ + function directiveIsMultiElement(name) { + if (hasDirectives.hasOwnProperty(name)) { + for (var directive, directives = $injector.get(name + Suffix), + i = 0, ii = directives.length; i < ii; i++) { + directive = directives[i]; + if (directive.multiElement) { + return true; + } + } + } + return false; + } + + /** + * When the element is replaced with HTML template then the new attributes + * on the template need to be merged with the existing attributes in the DOM. + * The desired effect is to have both of the attributes present. + * + * @param {object} dst destination attributes (original DOM) + * @param {object} src source attributes (from the directive template) + */ + function mergeTemplateAttributes(dst, src) { + var srcAttr = src.$attr, + dstAttr = dst.$attr, + $element = dst.$$element; + + // reapply the old attributes to the new element + forEach(dst, function(value, key) { + if (key.charAt(0) != '$') { + if (src[key] && src[key] !== value) { + value += (key === 'style' ? ';' : ' ') + src[key]; + } + dst.$set(key, value, true, srcAttr[key]); + } + }); + + // copy the new attributes on the old attrs object + forEach(src, function(value, key) { + if (key == 'class') { + safeAddClass($element, value); + dst['class'] = (dst['class'] ? dst['class'] + ' ' : '') + value; + } else if (key == 'style') { + $element.attr('style', $element.attr('style') + ';' + value); + dst['style'] = (dst['style'] ? dst['style'] + ';' : '') + value; + // `dst` will never contain hasOwnProperty as DOM parser won't let it. + // You will get an "InvalidCharacterError: DOM Exception 5" error if you + // have an attribute like "has-own-property" or "data-has-own-property", etc. + } else if (key.charAt(0) != '$' && !dst.hasOwnProperty(key)) { + dst[key] = value; + dstAttr[key] = srcAttr[key]; + } + }); + } + + + function compileTemplateUrl(directives, $compileNode, tAttrs, + $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) { + var linkQueue = [], + afterTemplateNodeLinkFn, + afterTemplateChildLinkFn, + beforeTemplateCompileNode = $compileNode[0], + origAsyncDirective = directives.shift(), + derivedSyncDirective = inherit(origAsyncDirective, { + templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective + }), + templateUrl = (isFunction(origAsyncDirective.templateUrl)) + ? origAsyncDirective.templateUrl($compileNode, tAttrs) + : origAsyncDirective.templateUrl, + templateNamespace = origAsyncDirective.templateNamespace; + + $compileNode.empty(); + + $templateRequest(templateUrl) + .then(function(content) { + var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn; + + content = denormalizeTemplate(content); + + if (origAsyncDirective.replace) { + if (jqLiteIsTextNode(content)) { + $template = []; + } else { + $template = removeComments(wrapTemplate(templateNamespace, trim(content))); + } + compileNode = $template[0]; + + if ($template.length != 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) { + throw $compileMinErr('tplrt', + "Template for directive '{0}' must have exactly one root element. {1}", + origAsyncDirective.name, templateUrl); + } + + tempTemplateAttrs = {$attr: {}}; + replaceWith($rootElement, $compileNode, compileNode); + var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs); + + if (isObject(origAsyncDirective.scope)) { + markDirectivesAsIsolate(templateDirectives); + } + directives = templateDirectives.concat(directives); + mergeTemplateAttributes(tAttrs, tempTemplateAttrs); + } else { + compileNode = beforeTemplateCompileNode; + $compileNode.html(content); + } + + directives.unshift(derivedSyncDirective); + + afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs, + childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns, + previousCompileContext); + forEach($rootElement, function(node, i) { + if (node == compileNode) { + $rootElement[i] = $compileNode[0]; + } + }); + afterTemplateChildLinkFn = compileNodes($compileNode[0].childNodes, childTranscludeFn); + + while (linkQueue.length) { + var scope = linkQueue.shift(), + beforeTemplateLinkNode = linkQueue.shift(), + linkRootElement = linkQueue.shift(), + boundTranscludeFn = linkQueue.shift(), + linkNode = $compileNode[0]; + + if (scope.$$destroyed) continue; + + if (beforeTemplateLinkNode !== beforeTemplateCompileNode) { + var oldClasses = beforeTemplateLinkNode.className; + + if (!(previousCompileContext.hasElementTranscludeDirective && + origAsyncDirective.replace)) { + // it was cloned therefore we have to clone as well. + linkNode = jqLiteClone(compileNode); + } + replaceWith(linkRootElement, jqLite(beforeTemplateLinkNode), linkNode); + + // Copy in CSS classes from original node + safeAddClass(jqLite(linkNode), oldClasses); + } + if (afterTemplateNodeLinkFn.transcludeOnThisElement) { + childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn); + } else { + childBoundTranscludeFn = boundTranscludeFn; + } + afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, linkNode, $rootElement, + childBoundTranscludeFn, afterTemplateNodeLinkFn); + } + linkQueue = null; + }); + + return function delayedNodeLinkFn(ignoreChildLinkFn, scope, node, rootElement, boundTranscludeFn) { + var childBoundTranscludeFn = boundTranscludeFn; + if (scope.$$destroyed) return; + if (linkQueue) { + linkQueue.push(scope, + node, + rootElement, + childBoundTranscludeFn); + } else { + if (afterTemplateNodeLinkFn.transcludeOnThisElement) { + childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn); + } + afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, node, rootElement, childBoundTranscludeFn, + afterTemplateNodeLinkFn); + } + }; + } + + + /** + * Sorting function for bound directives. + */ + function byPriority(a, b) { + var diff = b.priority - a.priority; + if (diff !== 0) return diff; + if (a.name !== b.name) return (a.name < b.name) ? -1 : 1; + return a.index - b.index; + } + + function assertNoDuplicate(what, previousDirective, directive, element) { + + function wrapModuleNameIfDefined(moduleName) { + return moduleName ? + (' (module: ' + moduleName + ')') : + ''; + } + + if (previousDirective) { + throw $compileMinErr('multidir', 'Multiple directives [{0}{1}, {2}{3}] asking for {4} on: {5}', + previousDirective.name, wrapModuleNameIfDefined(previousDirective.$$moduleName), + directive.name, wrapModuleNameIfDefined(directive.$$moduleName), what, startingTag(element)); + } + } + + + function addTextInterpolateDirective(directives, text) { + var interpolateFn = $interpolate(text, true); + if (interpolateFn) { + directives.push({ + priority: 0, + compile: function textInterpolateCompileFn(templateNode) { + var templateNodeParent = templateNode.parent(), + hasCompileParent = !!templateNodeParent.length; + + // When transcluding a template that has bindings in the root + // we don't have a parent and thus need to add the class during linking fn. + if (hasCompileParent) compile.$$addBindingClass(templateNodeParent); + + return function textInterpolateLinkFn(scope, node) { + var parent = node.parent(); + if (!hasCompileParent) compile.$$addBindingClass(parent); + compile.$$addBindingInfo(parent, interpolateFn.expressions); + scope.$watch(interpolateFn, function interpolateFnWatchAction(value) { + node[0].nodeValue = value; + }); + }; + } + }); + } + } + + + function wrapTemplate(type, template) { + type = lowercase(type || 'html'); + switch (type) { + case 'svg': + case 'math': + var wrapper = document.createElement('div'); + wrapper.innerHTML = '<' + type + '>' + template + ''; + return wrapper.childNodes[0].childNodes; + default: + return template; + } + } + + + function getTrustedContext(node, attrNormalizedName) { + if (attrNormalizedName == "srcdoc") { + return $sce.HTML; + } + var tag = nodeName_(node); + // maction[xlink:href] can source SVG. It's not limited to . + if (attrNormalizedName == "xlinkHref" || + (tag == "form" && attrNormalizedName == "action") || + (tag != "img" && (attrNormalizedName == "src" || + attrNormalizedName == "ngSrc"))) { + return $sce.RESOURCE_URL; + } + } + + + function addAttrInterpolateDirective(node, directives, value, name, allOrNothing) { + var trustedContext = getTrustedContext(node, name); + allOrNothing = ALL_OR_NOTHING_ATTRS[name] || allOrNothing; + + var interpolateFn = $interpolate(value, true, trustedContext, allOrNothing); + + // no interpolation found -> ignore + if (!interpolateFn) return; + + + if (name === "multiple" && nodeName_(node) === "select") { + throw $compileMinErr("selmulti", + "Binding to the 'multiple' attribute is not supported. Element: {0}", + startingTag(node)); + } + + directives.push({ + priority: 100, + compile: function() { + return { + pre: function attrInterpolatePreLinkFn(scope, element, attr) { + var $$observers = (attr.$$observers || (attr.$$observers = {})); + + if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { + throw $compileMinErr('nodomevents', + "Interpolations for HTML DOM event attributes are disallowed. Please use the " + + "ng- versions (such as ng-click instead of onclick) instead."); + } + + // If the attribute has changed since last $interpolate()ed + var newValue = attr[name]; + if (newValue !== value) { + // we need to interpolate again since the attribute value has been updated + // (e.g. by another directive's compile function) + // ensure unset/empty values make interpolateFn falsy + interpolateFn = newValue && $interpolate(newValue, true, trustedContext, allOrNothing); + value = newValue; + } + + // if attribute was updated so that there is no interpolation going on we don't want to + // register any observers + if (!interpolateFn) return; + + // initialize attr object so that it's ready in case we need the value for isolate + // scope initialization, otherwise the value would not be available from isolate + // directive's linking fn during linking phase + attr[name] = interpolateFn(scope); + + ($$observers[name] || ($$observers[name] = [])).$$inter = true; + (attr.$$observers && attr.$$observers[name].$$scope || scope). + $watch(interpolateFn, function interpolateFnWatchAction(newValue, oldValue) { + //special case for class attribute addition + removal + //so that class changes can tap into the animation + //hooks provided by the $animate service. Be sure to + //skip animations when the first digest occurs (when + //both the new and the old values are the same) since + //the CSS classes are the non-interpolated values + if (name === 'class' && newValue != oldValue) { + attr.$updateClass(newValue, oldValue); + } else { + attr.$set(name, newValue); + } + }); + } + }; + } + }); + } + + + /** + * This is a special jqLite.replaceWith, which can replace items which + * have no parents, provided that the containing jqLite collection is provided. + * + * @param {JqLite=} $rootElement The root of the compile tree. Used so that we can replace nodes + * in the root of the tree. + * @param {JqLite} elementsToRemove The jqLite element which we are going to replace. We keep + * the shell, but replace its DOM node reference. + * @param {Node} newNode The new DOM node. + */ + function replaceWith($rootElement, elementsToRemove, newNode) { + var firstElementToRemove = elementsToRemove[0], + removeCount = elementsToRemove.length, + parent = firstElementToRemove.parentNode, + i, ii; + + if ($rootElement) { + for (i = 0, ii = $rootElement.length; i < ii; i++) { + if ($rootElement[i] == firstElementToRemove) { + $rootElement[i++] = newNode; + for (var j = i, j2 = j + removeCount - 1, + jj = $rootElement.length; + j < jj; j++, j2++) { + if (j2 < jj) { + $rootElement[j] = $rootElement[j2]; + } else { + delete $rootElement[j]; + } + } + $rootElement.length -= removeCount - 1; + + // If the replaced element is also the jQuery .context then replace it + // .context is a deprecated jQuery api, so we should set it only when jQuery set it + // http://api.jquery.com/context/ + if ($rootElement.context === firstElementToRemove) { + $rootElement.context = newNode; + } + break; + } + } + } + + if (parent) { + parent.replaceChild(newNode, firstElementToRemove); + } + + // TODO(perf): what's this document fragment for? is it needed? can we at least reuse it? + var fragment = document.createDocumentFragment(); + fragment.appendChild(firstElementToRemove); + + if (jqLite.hasData(firstElementToRemove)) { + // Copy over user data (that includes Angular's $scope etc.). Don't copy private + // data here because there's no public interface in jQuery to do that and copying over + // event listeners (which is the main use of private data) wouldn't work anyway. + jqLite(newNode).data(jqLite(firstElementToRemove).data()); + + // Remove data of the replaced element. We cannot just call .remove() + // on the element it since that would deallocate scope that is needed + // for the new node. Instead, remove the data "manually". + if (!jQuery) { + delete jqLite.cache[firstElementToRemove[jqLite.expando]]; + } else { + // jQuery 2.x doesn't expose the data storage. Use jQuery.cleanData to clean up after + // the replaced element. The cleanData version monkey-patched by Angular would cause + // the scope to be trashed and we do need the very same scope to work with the new + // element. However, we cannot just cache the non-patched version and use it here as + // that would break if another library patches the method after Angular does (one + // example is jQuery UI). Instead, set a flag indicating scope destroying should be + // skipped this one time. + skipDestroyOnNextJQueryCleanData = true; + jQuery.cleanData([firstElementToRemove]); + } + } + + for (var k = 1, kk = elementsToRemove.length; k < kk; k++) { + var element = elementsToRemove[k]; + jqLite(element).remove(); // must do this way to clean up expando + fragment.appendChild(element); + delete elementsToRemove[k]; + } + + elementsToRemove[0] = newNode; + elementsToRemove.length = 1; + } + + + function cloneAndAnnotateFn(fn, annotation) { + return extend(function() { return fn.apply(null, arguments); }, fn, annotation); + } + + + function invokeLinkFn(linkFn, scope, $element, attrs, controllers, transcludeFn) { + try { + linkFn(scope, $element, attrs, controllers, transcludeFn); + } catch (e) { + $exceptionHandler(e, startingTag($element)); + } + } + + + // Set up $watches for isolate scope and controller bindings. This process + // only occurs for isolate scopes and new scopes with controllerAs. + function initializeDirectiveBindings(scope, attrs, destination, bindings, + directive, newScope) { + var onNewScopeDestroyed; + forEach(bindings, function(definition, scopeName) { + var attrName = definition.attrName, + optional = definition.optional, + mode = definition.mode, // @, =, or & + lastValue, + parentGet, parentSet, compare; + + switch (mode) { + + case '@': + if (!optional && !hasOwnProperty.call(attrs, attrName)) { + destination[scopeName] = attrs[attrName] = void 0; + } + attrs.$observe(attrName, function(value) { + if (isString(value)) { + destination[scopeName] = value; + } + }); + attrs.$$observers[attrName].$$scope = scope; + if (isString(attrs[attrName])) { + // If the attribute has been provided then we trigger an interpolation to ensure + // the value is there for use in the link fn + destination[scopeName] = $interpolate(attrs[attrName])(scope); + } + break; + + case '=': + if (!hasOwnProperty.call(attrs, attrName)) { + if (optional) break; + attrs[attrName] = void 0; + } + if (optional && !attrs[attrName]) break; + + parentGet = $parse(attrs[attrName]); + if (parentGet.literal) { + compare = equals; + } else { + compare = function(a, b) { return a === b || (a !== a && b !== b); }; + } + parentSet = parentGet.assign || function() { + // reset the change, or we will throw this exception on every $digest + lastValue = destination[scopeName] = parentGet(scope); + throw $compileMinErr('nonassign', + "Expression '{0}' used with directive '{1}' is non-assignable!", + attrs[attrName], directive.name); + }; + lastValue = destination[scopeName] = parentGet(scope); + var parentValueWatch = function parentValueWatch(parentValue) { + if (!compare(parentValue, destination[scopeName])) { + // we are out of sync and need to copy + if (!compare(parentValue, lastValue)) { + // parent changed and it has precedence + destination[scopeName] = parentValue; + } else { + // if the parent can be assigned then do so + parentSet(scope, parentValue = destination[scopeName]); + } + } + return lastValue = parentValue; + }; + parentValueWatch.$stateful = true; + var unwatch; + if (definition.collection) { + unwatch = scope.$watchCollection(attrs[attrName], parentValueWatch); + } else { + unwatch = scope.$watch($parse(attrs[attrName], parentValueWatch), null, parentGet.literal); + } + onNewScopeDestroyed = (onNewScopeDestroyed || []); + onNewScopeDestroyed.push(unwatch); + break; + + case '&': + // Don't assign Object.prototype method to scope + parentGet = attrs.hasOwnProperty(attrName) ? $parse(attrs[attrName]) : noop; + + // Don't assign noop to destination if expression is not valid + if (parentGet === noop && optional) break; + + destination[scopeName] = function(locals) { + return parentGet(scope, locals); + }; + break; + } + }); + var destroyBindings = onNewScopeDestroyed ? function destroyBindings() { + for (var i = 0, ii = onNewScopeDestroyed.length; i < ii; ++i) { + onNewScopeDestroyed[i](); + } + } : noop; + if (newScope && destroyBindings !== noop) { + newScope.$on('$destroy', destroyBindings); + return noop; + } + return destroyBindings; + } + }]; +} + +var PREFIX_REGEXP = /^((?:x|data)[\:\-_])/i; +/** + * Converts all accepted directives format into proper directive name. + * @param name Name to normalize + */ +function directiveNormalize(name) { + return camelCase(name.replace(PREFIX_REGEXP, '')); +} + +/** + * @ngdoc type + * @name $compile.directive.Attributes + * + * @description + * A shared object between directive compile / linking functions which contains normalized DOM + * element attributes. The values reflect current binding state `{{ }}`. The normalization is + * needed since all of these are treated as equivalent in Angular: + * + * ``` + * + * ``` + */ + +/** + * @ngdoc property + * @name $compile.directive.Attributes#$attr + * + * @description + * A map of DOM element attribute names to the normalized name. This is + * needed to do reverse lookup from normalized name back to actual name. + */ + + +/** + * @ngdoc method + * @name $compile.directive.Attributes#$set + * @kind function + * + * @description + * Set DOM element attribute value. + * + * + * @param {string} name Normalized element attribute name of the property to modify. The name is + * reverse-translated using the {@link ng.$compile.directive.Attributes#$attr $attr} + * property to the original name. + * @param {string} value Value to set the attribute to. The value can be an interpolated string. + */ + + + +/** + * Closure compiler type information + */ + +function nodesetLinkingFn( + /* angular.Scope */ scope, + /* NodeList */ nodeList, + /* Element */ rootElement, + /* function(Function) */ boundTranscludeFn +) {} + +function directiveLinkingFn( + /* nodesetLinkingFn */ nodesetLinkingFn, + /* angular.Scope */ scope, + /* Node */ node, + /* Element */ rootElement, + /* function(Function) */ boundTranscludeFn +) {} + +function tokenDifference(str1, str2) { + var values = '', + tokens1 = str1.split(/\s+/), + tokens2 = str2.split(/\s+/); + + outer: + for (var i = 0; i < tokens1.length; i++) { + var token = tokens1[i]; + for (var j = 0; j < tokens2.length; j++) { + if (token == tokens2[j]) continue outer; + } + values += (values.length > 0 ? ' ' : '') + token; + } + return values; +} + +function removeComments(jqNodes) { + jqNodes = jqLite(jqNodes); + var i = jqNodes.length; + + if (i <= 1) { + return jqNodes; + } + + while (i--) { + var node = jqNodes[i]; + if (node.nodeType === NODE_TYPE_COMMENT) { + splice.call(jqNodes, i, 1); + } + } + return jqNodes; +} + +var $controllerMinErr = minErr('$controller'); + + +var CNTRL_REG = /^(\S+)(\s+as\s+(\w+))?$/; +function identifierForController(controller, ident) { + if (ident && isString(ident)) return ident; + if (isString(controller)) { + var match = CNTRL_REG.exec(controller); + if (match) return match[3]; + } +} + + +/** + * @ngdoc provider + * @name $controllerProvider + * @description + * The {@link ng.$controller $controller service} is used by Angular to create new + * controllers. + * + * This provider allows controller registration via the + * {@link ng.$controllerProvider#register register} method. + */ +function $ControllerProvider() { + var controllers = {}, + globals = false; + + /** + * @ngdoc method + * @name $controllerProvider#register + * @param {string|Object} name Controller name, or an object map of controllers where the keys are + * the names and the values are the constructors. + * @param {Function|Array} constructor Controller constructor fn (optionally decorated with DI + * annotations in the array notation). + */ + this.register = function(name, constructor) { + assertNotHasOwnProperty(name, 'controller'); + if (isObject(name)) { + extend(controllers, name); + } else { + controllers[name] = constructor; + } + }; + + /** + * @ngdoc method + * @name $controllerProvider#allowGlobals + * @description If called, allows `$controller` to find controller constructors on `window` + */ + this.allowGlobals = function() { + globals = true; + }; + + + this.$get = ['$injector', '$window', function($injector, $window) { + + /** + * @ngdoc service + * @name $controller + * @requires $injector + * + * @param {Function|string} constructor If called with a function then it's considered to be the + * controller constructor function. Otherwise it's considered to be a string which is used + * to retrieve the controller constructor using the following steps: + * + * * check if a controller with given name is registered via `$controllerProvider` + * * check if evaluating the string on the current scope returns a constructor + * * if $controllerProvider#allowGlobals, check `window[constructor]` on the global + * `window` object (not recommended) + * + * The string can use the `controller as property` syntax, where the controller instance is published + * as the specified property on the `scope`; the `scope` must be injected into `locals` param for this + * to work correctly. + * + * @param {Object} locals Injection locals for Controller. + * @return {Object} Instance of given controller. + * + * @description + * `$controller` service is responsible for instantiating controllers. + * + * It's just a simple call to {@link auto.$injector $injector}, but extracted into + * a service, so that one can override this service with [BC version](https://gist.github.com/1649788). + */ + return function(expression, locals, later, ident) { + // PRIVATE API: + // param `later` --- indicates that the controller's constructor is invoked at a later time. + // If true, $controller will allocate the object with the correct + // prototype chain, but will not invoke the controller until a returned + // callback is invoked. + // param `ident` --- An optional label which overrides the label parsed from the controller + // expression, if any. + var instance, match, constructor, identifier; + later = later === true; + if (ident && isString(ident)) { + identifier = ident; + } + + if (isString(expression)) { + match = expression.match(CNTRL_REG); + if (!match) { + throw $controllerMinErr('ctrlfmt', + "Badly formed controller string '{0}'. " + + "Must match `__name__ as __id__` or `__name__`.", expression); + } + constructor = match[1], + identifier = identifier || match[3]; + expression = controllers.hasOwnProperty(constructor) + ? controllers[constructor] + : getter(locals.$scope, constructor, true) || + (globals ? getter($window, constructor, true) : undefined); + + assertArgFn(expression, constructor, true); + } + + if (later) { + // Instantiate controller later: + // This machinery is used to create an instance of the object before calling the + // controller's constructor itself. + // + // This allows properties to be added to the controller before the constructor is + // invoked. Primarily, this is used for isolate scope bindings in $compile. + // + // This feature is not intended for use by applications, and is thus not documented + // publicly. + // Object creation: http://jsperf.com/create-constructor/2 + var controllerPrototype = (isArray(expression) ? + expression[expression.length - 1] : expression).prototype; + instance = Object.create(controllerPrototype || null); + + if (identifier) { + addIdentifier(locals, identifier, instance, constructor || expression.name); + } + + var instantiate; + return instantiate = extend(function() { + var result = $injector.invoke(expression, instance, locals, constructor); + if (result !== instance && (isObject(result) || isFunction(result))) { + instance = result; + if (identifier) { + // If result changed, re-assign controllerAs value to scope. + addIdentifier(locals, identifier, instance, constructor || expression.name); + } + } + return instance; + }, { + instance: instance, + identifier: identifier + }); + } + + instance = $injector.instantiate(expression, locals, constructor); + + if (identifier) { + addIdentifier(locals, identifier, instance, constructor || expression.name); + } + + return instance; + }; + + function addIdentifier(locals, identifier, instance, name) { + if (!(locals && isObject(locals.$scope))) { + throw minErr('$controller')('noscp', + "Cannot export controller '{0}' as '{1}'! No $scope object provided via `locals`.", + name, identifier); + } + + locals.$scope[identifier] = instance; + } + }]; +} + +/** + * @ngdoc service + * @name $document + * @requires $window + * + * @description + * A {@link angular.element jQuery or jqLite} wrapper for the browser's `window.document` object. + * + * @example + + +
+

$document title:

+

window.document title:

+
+
+ + angular.module('documentExample', []) + .controller('ExampleController', ['$scope', '$document', function($scope, $document) { + $scope.title = $document[0].title; + $scope.windowTitle = angular.element(window.document)[0].title; + }]); + +
+ */ +function $DocumentProvider() { + this.$get = ['$window', function(window) { + return jqLite(window.document); + }]; +} + +/** + * @ngdoc service + * @name $exceptionHandler + * @requires ng.$log + * + * @description + * Any uncaught exception in angular expressions is delegated to this service. + * The default implementation simply delegates to `$log.error` which logs it into + * the browser console. + * + * In unit tests, if `angular-mocks.js` is loaded, this service is overridden by + * {@link ngMock.$exceptionHandler mock $exceptionHandler} which aids in testing. + * + * ## Example: + * + * ```js + * angular.module('exceptionOverride', []).factory('$exceptionHandler', function() { + * return function(exception, cause) { + * exception.message += ' (caused by "' + cause + '")'; + * throw exception; + * }; + * }); + * ``` + * + * This example will override the normal action of `$exceptionHandler`, to make angular + * exceptions fail hard when they happen, instead of just logging to the console. + * + *
+ * Note, that code executed in event-listeners (even those registered using jqLite's `on`/`bind` + * methods) does not delegate exceptions to the {@link ng.$exceptionHandler $exceptionHandler} + * (unless executed during a digest). + * + * If you wish, you can manually delegate exceptions, e.g. + * `try { ... } catch(e) { $exceptionHandler(e); }` + * + * @param {Error} exception Exception associated with the error. + * @param {string=} cause optional information about the context in which + * the error was thrown. + * + */ +function $ExceptionHandlerProvider() { + this.$get = ['$log', function($log) { + return function(exception, cause) { + $log.error.apply($log, arguments); + }; + }]; +} + +var $$ForceReflowProvider = function() { + this.$get = ['$document', function($document) { + return function(domNode) { + //the line below will force the browser to perform a repaint so + //that all the animated elements within the animation frame will + //be properly updated and drawn on screen. This is required to + //ensure that the preparation animation is properly flushed so that + //the active state picks up from there. DO NOT REMOVE THIS LINE. + //DO NOT OPTIMIZE THIS LINE. THE MINIFIER WILL REMOVE IT OTHERWISE WHICH + //WILL RESULT IN AN UNPREDICTABLE BUG THAT IS VERY HARD TO TRACK DOWN AND + //WILL TAKE YEARS AWAY FROM YOUR LIFE. + if (domNode) { + if (!domNode.nodeType && domNode instanceof jqLite) { + domNode = domNode[0]; + } + } else { + domNode = $document[0].body; + } + return domNode.offsetWidth + 1; + }; + }]; +}; + +var APPLICATION_JSON = 'application/json'; +var CONTENT_TYPE_APPLICATION_JSON = {'Content-Type': APPLICATION_JSON + ';charset=utf-8'}; +var JSON_START = /^\[|^\{(?!\{)/; +var JSON_ENDS = { + '[': /]$/, + '{': /}$/ +}; +var JSON_PROTECTION_PREFIX = /^\)\]\}',?\n/; +var $httpMinErr = minErr('$http'); +var $httpMinErrLegacyFn = function(method) { + return function() { + throw $httpMinErr('legacy', 'The method `{0}` on the promise returned from `$http` has been disabled.', method); + }; +}; + +function serializeValue(v) { + if (isObject(v)) { + return isDate(v) ? v.toISOString() : toJson(v); + } + return v; +} + + +function $HttpParamSerializerProvider() { + /** + * @ngdoc service + * @name $httpParamSerializer + * @description + * + * Default {@link $http `$http`} params serializer that converts objects to strings + * according to the following rules: + * + * * `{'foo': 'bar'}` results in `foo=bar` + * * `{'foo': Date.now()}` results in `foo=2015-04-01T09%3A50%3A49.262Z` (`toISOString()` and encoded representation of a Date object) + * * `{'foo': ['bar', 'baz']}` results in `foo=bar&foo=baz` (repeated key for each array element) + * * `{'foo': {'bar':'baz'}}` results in `foo=%7B%22bar%22%3A%22baz%22%7D"` (stringified and encoded representation of an object) + * + * Note that serializer will sort the request parameters alphabetically. + * */ + + this.$get = function() { + return function ngParamSerializer(params) { + if (!params) return ''; + var parts = []; + forEachSorted(params, function(value, key) { + if (value === null || isUndefined(value)) return; + if (isArray(value)) { + forEach(value, function(v, k) { + parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(v))); + }); + } else { + parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(value))); + } + }); + + return parts.join('&'); + }; + }; +} + +function $HttpParamSerializerJQLikeProvider() { + /** + * @ngdoc service + * @name $httpParamSerializerJQLike + * @description + * + * Alternative {@link $http `$http`} params serializer that follows + * jQuery's [`param()`](http://api.jquery.com/jquery.param/) method logic. + * The serializer will also sort the params alphabetically. + * + * To use it for serializing `$http` request parameters, set it as the `paramSerializer` property: + * + * ```js + * $http({ + * url: myUrl, + * method: 'GET', + * params: myParams, + * paramSerializer: '$httpParamSerializerJQLike' + * }); + * ``` + * + * It is also possible to set it as the default `paramSerializer` in the + * {@link $httpProvider#defaults `$httpProvider`}. + * + * Additionally, you can inject the serializer and use it explicitly, for example to serialize + * form data for submission: + * + * ```js + * .controller(function($http, $httpParamSerializerJQLike) { + * //... + * + * $http({ + * url: myUrl, + * method: 'POST', + * data: $httpParamSerializerJQLike(myData), + * headers: { + * 'Content-Type': 'application/x-www-form-urlencoded' + * } + * }); + * + * }); + * ``` + * + * */ + this.$get = function() { + return function jQueryLikeParamSerializer(params) { + if (!params) return ''; + var parts = []; + serialize(params, '', true); + return parts.join('&'); + + function serialize(toSerialize, prefix, topLevel) { + if (toSerialize === null || isUndefined(toSerialize)) return; + if (isArray(toSerialize)) { + forEach(toSerialize, function(value, index) { + serialize(value, prefix + '[' + (isObject(value) ? index : '') + ']'); + }); + } else if (isObject(toSerialize) && !isDate(toSerialize)) { + forEachSorted(toSerialize, function(value, key) { + serialize(value, prefix + + (topLevel ? '' : '[') + + key + + (topLevel ? '' : ']')); + }); + } else { + parts.push(encodeUriQuery(prefix) + '=' + encodeUriQuery(serializeValue(toSerialize))); + } + } + }; + }; +} + +function defaultHttpResponseTransform(data, headers) { + if (isString(data)) { + // Strip json vulnerability protection prefix and trim whitespace + var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim(); + + if (tempData) { + var contentType = headers('Content-Type'); + if ((contentType && (contentType.indexOf(APPLICATION_JSON) === 0)) || isJsonLike(tempData)) { + data = fromJson(tempData); + } + } + } + + return data; +} + +function isJsonLike(str) { + var jsonStart = str.match(JSON_START); + return jsonStart && JSON_ENDS[jsonStart[0]].test(str); +} + +/** + * Parse headers into key value object + * + * @param {string} headers Raw headers as a string + * @returns {Object} Parsed headers as key value object + */ +function parseHeaders(headers) { + var parsed = createMap(), i; + + function fillInParsed(key, val) { + if (key) { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + } + + if (isString(headers)) { + forEach(headers.split('\n'), function(line) { + i = line.indexOf(':'); + fillInParsed(lowercase(trim(line.substr(0, i))), trim(line.substr(i + 1))); + }); + } else if (isObject(headers)) { + forEach(headers, function(headerVal, headerKey) { + fillInParsed(lowercase(headerKey), trim(headerVal)); + }); + } + + return parsed; +} + + +/** + * Returns a function that provides access to parsed headers. + * + * Headers are lazy parsed when first requested. + * @see parseHeaders + * + * @param {(string|Object)} headers Headers to provide access to. + * @returns {function(string=)} Returns a getter function which if called with: + * + * - if called with single an argument returns a single header value or null + * - if called with no arguments returns an object containing all headers. + */ +function headersGetter(headers) { + var headersObj; + + return function(name) { + if (!headersObj) headersObj = parseHeaders(headers); + + if (name) { + var value = headersObj[lowercase(name)]; + if (value === void 0) { + value = null; + } + return value; + } + + return headersObj; + }; +} + + +/** + * Chain all given functions + * + * This function is used for both request and response transforming + * + * @param {*} data Data to transform. + * @param {function(string=)} headers HTTP headers getter fn. + * @param {number} status HTTP status code of the response. + * @param {(Function|Array.)} fns Function or an array of functions. + * @returns {*} Transformed data. + */ +function transformData(data, headers, status, fns) { + if (isFunction(fns)) { + return fns(data, headers, status); + } + + forEach(fns, function(fn) { + data = fn(data, headers, status); + }); + + return data; +} + + +function isSuccess(status) { + return 200 <= status && status < 300; +} + + +/** + * @ngdoc provider + * @name $httpProvider + * @description + * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service. + * */ +function $HttpProvider() { + /** + * @ngdoc property + * @name $httpProvider#defaults + * @description + * + * Object containing default values for all {@link ng.$http $http} requests. + * + * - **`defaults.cache`** - {Object} - an object built with {@link ng.$cacheFactory `$cacheFactory`} + * that will provide the cache for all requests who set their `cache` property to `true`. + * If you set the `defaults.cache = false` then only requests that specify their own custom + * cache object will be cached. See {@link $http#caching $http Caching} for more information. + * + * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token. + * Defaults value is `'XSRF-TOKEN'`. + * + * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the + * XSRF token. Defaults value is `'X-XSRF-TOKEN'`. + * + * - **`defaults.headers`** - {Object} - Default headers for all $http requests. + * Refer to {@link ng.$http#setting-http-headers $http} for documentation on + * setting default headers. + * - **`defaults.headers.common`** + * - **`defaults.headers.post`** + * - **`defaults.headers.put`** + * - **`defaults.headers.patch`** + * + * + * - **`defaults.paramSerializer`** - `{string|function(Object):string}` - A function + * used to the prepare string representation of request parameters (specified as an object). + * If specified as string, it is interpreted as a function registered with the {@link auto.$injector $injector}. + * Defaults to {@link ng.$httpParamSerializer $httpParamSerializer}. + * + **/ + var defaults = this.defaults = { + // transform incoming response data + transformResponse: [defaultHttpResponseTransform], + + // transform outgoing request data + transformRequest: [function(d) { + return isObject(d) && !isFile(d) && !isBlob(d) && !isFormData(d) ? toJson(d) : d; + }], + + // default headers + headers: { + common: { + 'Accept': 'application/json, text/plain, */*' + }, + post: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), + put: shallowCopy(CONTENT_TYPE_APPLICATION_JSON), + patch: shallowCopy(CONTENT_TYPE_APPLICATION_JSON) + }, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN', + + paramSerializer: '$httpParamSerializer' + }; + + var useApplyAsync = false; + /** + * @ngdoc method + * @name $httpProvider#useApplyAsync + * @description + * + * Configure $http service to combine processing of multiple http responses received at around + * the same time via {@link ng.$rootScope.Scope#$applyAsync $rootScope.$applyAsync}. This can result in + * significant performance improvement for bigger applications that make many HTTP requests + * concurrently (common during application bootstrap). + * + * Defaults to false. If no value is specified, returns the current configured value. + * + * @param {boolean=} value If true, when requests are loaded, they will schedule a deferred + * "apply" on the next tick, giving time for subsequent requests in a roughly ~10ms window + * to load and share the same digest cycle. + * + * @returns {boolean|Object} If a value is specified, returns the $httpProvider for chaining. + * otherwise, returns the current configured value. + **/ + this.useApplyAsync = function(value) { + if (isDefined(value)) { + useApplyAsync = !!value; + return this; + } + return useApplyAsync; + }; + + var useLegacyPromise = true; + /** + * @ngdoc method + * @name $httpProvider#useLegacyPromiseExtensions + * @description + * + * Configure `$http` service to return promises without the shorthand methods `success` and `error`. + * This should be used to make sure that applications work without these methods. + * + * Defaults to false. If no value is specified, returns the current configured value. + * + * @param {boolean=} value If true, `$http` will return a normal promise without the `success` and `error` methods. + * + * @returns {boolean|Object} If a value is specified, returns the $httpProvider for chaining. + * otherwise, returns the current configured value. + **/ + this.useLegacyPromiseExtensions = function(value) { + if (isDefined(value)) { + useLegacyPromise = !!value; + return this; + } + return useLegacyPromise; + }; + + /** + * @ngdoc property + * @name $httpProvider#interceptors + * @description + * + * Array containing service factories for all synchronous or asynchronous {@link ng.$http $http} + * pre-processing of request or postprocessing of responses. + * + * These service factories are ordered by request, i.e. they are applied in the same order as the + * array, on request, but reverse order, on response. + * + * {@link ng.$http#interceptors Interceptors detailed info} + **/ + var interceptorFactories = this.interceptors = []; + + this.$get = ['$httpBackend', '$$cookieReader', '$cacheFactory', '$rootScope', '$q', '$injector', + function($httpBackend, $$cookieReader, $cacheFactory, $rootScope, $q, $injector) { + + var defaultCache = $cacheFactory('$http'); + + /** + * Make sure that default param serializer is exposed as a function + */ + defaults.paramSerializer = isString(defaults.paramSerializer) ? + $injector.get(defaults.paramSerializer) : defaults.paramSerializer; + + /** + * Interceptors stored in reverse order. Inner interceptors before outer interceptors. + * The reversal is needed so that we can build up the interception chain around the + * server request. + */ + var reversedInterceptors = []; + + forEach(interceptorFactories, function(interceptorFactory) { + reversedInterceptors.unshift(isString(interceptorFactory) + ? $injector.get(interceptorFactory) : $injector.invoke(interceptorFactory)); + }); + + /** + * @ngdoc service + * @kind function + * @name $http + * @requires ng.$httpBackend + * @requires $cacheFactory + * @requires $rootScope + * @requires $q + * @requires $injector + * + * @description + * The `$http` service is a core Angular service that facilitates communication with the remote + * HTTP servers via the browser's [XMLHttpRequest](https://developer.mozilla.org/en/xmlhttprequest) + * object or via [JSONP](http://en.wikipedia.org/wiki/JSONP). + * + * For unit testing applications that use `$http` service, see + * {@link ngMock.$httpBackend $httpBackend mock}. + * + * For a higher level of abstraction, please check out the {@link ngResource.$resource + * $resource} service. + * + * The $http API is based on the {@link ng.$q deferred/promise APIs} exposed by + * the $q service. While for simple usage patterns this doesn't matter much, for advanced usage + * it is important to familiarize yourself with these APIs and the guarantees they provide. + * + * + * ## General usage + * The `$http` service is a function which takes a single argument — a configuration object — + * that is used to generate an HTTP request and returns a {@link ng.$q promise}. + * + * ```js + * // Simple GET request example : + * $http.get('/someUrl'). + * then(function(response) { + * // this callback will be called asynchronously + * // when the response is available + * }, function(response) { + * // called asynchronously if an error occurs + * // or server returns response with an error status. + * }); + * ``` + * + * ```js + * // Simple POST request example (passing data) : + * $http.post('/someUrl', {msg:'hello word!'}). + * then(function(response) { + * // this callback will be called asynchronously + * // when the response is available + * }, function(response) { + * // called asynchronously if an error occurs + * // or server returns response with an error status. + * }); + * ``` + * + * The response object has these properties: + * + * - **data** – `{string|Object}` – The response body transformed with the transform + * functions. + * - **status** – `{number}` – HTTP status code of the response. + * - **headers** – `{function([headerName])}` – Header getter function. + * - **config** – `{Object}` – The configuration object that was used to generate the request. + * - **statusText** – `{string}` – HTTP status text of the response. + * + * A response status code between 200 and 299 is considered a success status and + * will result in the success callback being called. Note that if the response is a redirect, + * XMLHttpRequest will transparently follow it, meaning that the error callback will not be + * called for such responses. + * + * ## Writing Unit Tests that use $http + * When unit testing (using {@link ngMock ngMock}), it is necessary to call + * {@link ngMock.$httpBackend#flush $httpBackend.flush()} to flush each pending + * request using trained responses. + * + * ``` + * $httpBackend.expectGET(...); + * $http.get(...); + * $httpBackend.flush(); + * ``` + * + * ## Shortcut methods + * + * Shortcut methods are also available. All shortcut methods require passing in the URL, and + * request data must be passed in for POST/PUT requests. + * + * ```js + * $http.get('/someUrl').then(successCallback); + * $http.post('/someUrl', data).then(successCallback); + * ``` + * + * Complete list of shortcut methods: + * + * - {@link ng.$http#get $http.get} + * - {@link ng.$http#head $http.head} + * - {@link ng.$http#post $http.post} + * - {@link ng.$http#put $http.put} + * - {@link ng.$http#delete $http.delete} + * - {@link ng.$http#jsonp $http.jsonp} + * - {@link ng.$http#patch $http.patch} + * + * + * ## Deprecation Notice + *
+ * The `$http` legacy promise methods `success` and `error` have been deprecated. + * Use the standard `then` method instead. + * If {@link $httpProvider#useLegacyPromiseExtensions `$httpProvider.useLegacyPromiseExtensions`} is set to + * `false` then these methods will throw {@link $http:legacy `$http/legacy`} error. + *
+ * + * ## Setting HTTP Headers + * + * The $http service will automatically add certain HTTP headers to all requests. These defaults + * can be fully configured by accessing the `$httpProvider.defaults.headers` configuration + * object, which currently contains this default configuration: + * + * - `$httpProvider.defaults.headers.common` (headers that are common for all requests): + * - `Accept: application/json, text/plain, * / *` + * - `$httpProvider.defaults.headers.post`: (header defaults for POST requests) + * - `Content-Type: application/json` + * - `$httpProvider.defaults.headers.put` (header defaults for PUT requests) + * - `Content-Type: application/json` + * + * To add or overwrite these defaults, simply add or remove a property from these configuration + * objects. To add headers for an HTTP method other than POST or PUT, simply add a new object + * with the lowercased HTTP method name as the key, e.g. + * `$httpProvider.defaults.headers.get = { 'My-Header' : 'value' }`. + * + * The defaults can also be set at runtime via the `$http.defaults` object in the same + * fashion. For example: + * + * ``` + * module.run(function($http) { + * $http.defaults.headers.common.Authorization = 'Basic YmVlcDpib29w' + * }); + * ``` + * + * In addition, you can supply a `headers` property in the config object passed when + * calling `$http(config)`, which overrides the defaults without changing them globally. + * + * To explicitly remove a header automatically added via $httpProvider.defaults.headers on a per request basis, + * Use the `headers` property, setting the desired header to `undefined`. For example: + * + * ```js + * var req = { + * method: 'POST', + * url: 'http://example.com', + * headers: { + * 'Content-Type': undefined + * }, + * data: { test: 'test' } + * } + * + * $http(req).then(function(){...}, function(){...}); + * ``` + * + * ## Transforming Requests and Responses + * + * Both requests and responses can be transformed using transformation functions: `transformRequest` + * and `transformResponse`. These properties can be a single function that returns + * the transformed value (`function(data, headersGetter, status)`) or an array of such transformation functions, + * which allows you to `push` or `unshift` a new transformation function into the transformation chain. + * + * ### Default Transformations + * + * The `$httpProvider` provider and `$http` service expose `defaults.transformRequest` and + * `defaults.transformResponse` properties. If a request does not provide its own transformations + * then these will be applied. + * + * You can augment or replace the default transformations by modifying these properties by adding to or + * replacing the array. + * + * Angular provides the following default transformations: + * + * Request transformations (`$httpProvider.defaults.transformRequest` and `$http.defaults.transformRequest`): + * + * - If the `data` property of the request configuration object contains an object, serialize it + * into JSON format. + * + * Response transformations (`$httpProvider.defaults.transformResponse` and `$http.defaults.transformResponse`): + * + * - If XSRF prefix is detected, strip it (see Security Considerations section below). + * - If JSON response is detected, deserialize it using a JSON parser. + * + * + * ### Overriding the Default Transformations Per Request + * + * If you wish override the request/response transformations only for a single request then provide + * `transformRequest` and/or `transformResponse` properties on the configuration object passed + * into `$http`. + * + * Note that if you provide these properties on the config object the default transformations will be + * overwritten. If you wish to augment the default transformations then you must include them in your + * local transformation array. + * + * The following code demonstrates adding a new response transformation to be run after the default response + * transformations have been run. + * + * ```js + * function appendTransform(defaults, transform) { + * + * // We can't guarantee that the default transformation is an array + * defaults = angular.isArray(defaults) ? defaults : [defaults]; + * + * // Append the new transformation to the defaults + * return defaults.concat(transform); + * } + * + * $http({ + * url: '...', + * method: 'GET', + * transformResponse: appendTransform($http.defaults.transformResponse, function(value) { + * return doTransform(value); + * }) + * }); + * ``` + * + * + * ## Caching + * + * To enable caching, set the request configuration `cache` property to `true` (to use default + * cache) or to a custom cache object (built with {@link ng.$cacheFactory `$cacheFactory`}). + * When the cache is enabled, `$http` stores the response from the server in the specified + * cache. The next time the same request is made, the response is served from the cache without + * sending a request to the server. + * + * Note that even if the response is served from cache, delivery of the data is asynchronous in + * the same way that real requests are. + * + * If there are multiple GET requests for the same URL that should be cached using the same + * cache, but the cache is not populated yet, only one request to the server will be made and + * the remaining requests will be fulfilled using the response from the first request. + * + * You can change the default cache to a new object (built with + * {@link ng.$cacheFactory `$cacheFactory`}) by updating the + * {@link ng.$http#defaults `$http.defaults.cache`} property. All requests who set + * their `cache` property to `true` will now use this cache object. + * + * If you set the default cache to `false` then only requests that specify their own custom + * cache object will be cached. + * + * ## Interceptors + * + * Before you start creating interceptors, be sure to understand the + * {@link ng.$q $q and deferred/promise APIs}. + * + * For purposes of global error handling, authentication, or any kind of synchronous or + * asynchronous pre-processing of request or postprocessing of responses, it is desirable to be + * able to intercept requests before they are handed to the server and + * responses before they are handed over to the application code that + * initiated these requests. The interceptors leverage the {@link ng.$q + * promise APIs} to fulfill this need for both synchronous and asynchronous pre-processing. + * + * The interceptors are service factories that are registered with the `$httpProvider` by + * adding them to the `$httpProvider.interceptors` array. The factory is called and + * injected with dependencies (if specified) and returns the interceptor. + * + * There are two kinds of interceptors (and two kinds of rejection interceptors): + * + * * `request`: interceptors get called with a http `config` object. The function is free to + * modify the `config` object or create a new one. The function needs to return the `config` + * object directly, or a promise containing the `config` or a new `config` object. + * * `requestError`: interceptor gets called when a previous interceptor threw an error or + * resolved with a rejection. + * * `response`: interceptors get called with http `response` object. The function is free to + * modify the `response` object or create a new one. The function needs to return the `response` + * object directly, or as a promise containing the `response` or a new `response` object. + * * `responseError`: interceptor gets called when a previous interceptor threw an error or + * resolved with a rejection. + * + * + * ```js + * // register the interceptor as a service + * $provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) { + * return { + * // optional method + * 'request': function(config) { + * // do something on success + * return config; + * }, + * + * // optional method + * 'requestError': function(rejection) { + * // do something on error + * if (canRecover(rejection)) { + * return responseOrNewPromise + * } + * return $q.reject(rejection); + * }, + * + * + * + * // optional method + * 'response': function(response) { + * // do something on success + * return response; + * }, + * + * // optional method + * 'responseError': function(rejection) { + * // do something on error + * if (canRecover(rejection)) { + * return responseOrNewPromise + * } + * return $q.reject(rejection); + * } + * }; + * }); + * + * $httpProvider.interceptors.push('myHttpInterceptor'); + * + * + * // alternatively, register the interceptor via an anonymous factory + * $httpProvider.interceptors.push(function($q, dependency1, dependency2) { + * return { + * 'request': function(config) { + * // same as above + * }, + * + * 'response': function(response) { + * // same as above + * } + * }; + * }); + * ``` + * + * ## Security Considerations + * + * When designing web applications, consider security threats from: + * + * - [JSON vulnerability](http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx) + * - [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) + * + * Both server and the client must cooperate in order to eliminate these threats. Angular comes + * pre-configured with strategies that address these issues, but for this to work backend server + * cooperation is required. + * + * ### JSON Vulnerability Protection + * + * A [JSON vulnerability](http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx) + * allows third party website to turn your JSON resource URL into + * [JSONP](http://en.wikipedia.org/wiki/JSONP) request under some conditions. To + * counter this your server can prefix all JSON requests with following string `")]}',\n"`. + * Angular will automatically strip the prefix before processing it as JSON. + * + * For example if your server needs to return: + * ```js + * ['one','two'] + * ``` + * + * which is vulnerable to attack, your server can return: + * ```js + * )]}', + * ['one','two'] + * ``` + * + * Angular will strip the prefix, before processing the JSON. + * + * + * ### Cross Site Request Forgery (XSRF) Protection + * + * [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) is a technique by which + * an unauthorized site can gain your user's private data. Angular provides a mechanism + * to counter XSRF. When performing XHR requests, the $http service reads a token from a cookie + * (by default, `XSRF-TOKEN`) and sets it as an HTTP header (`X-XSRF-TOKEN`). Since only + * JavaScript that runs on your domain could read the cookie, your server can be assured that + * the XHR came from JavaScript running on your domain. The header will not be set for + * cross-domain requests. + * + * To take advantage of this, your server needs to set a token in a JavaScript readable session + * cookie called `XSRF-TOKEN` on the first HTTP GET request. On subsequent XHR requests the + * server can verify that the cookie matches `X-XSRF-TOKEN` HTTP header, and therefore be sure + * that only JavaScript running on your domain could have sent the request. The token must be + * unique for each user and must be verifiable by the server (to prevent the JavaScript from + * making up its own tokens). We recommend that the token is a digest of your site's + * authentication cookie with a [salt](https://en.wikipedia.org/wiki/Salt_(cryptography)) + * for added security. + * + * The name of the headers can be specified using the xsrfHeaderName and xsrfCookieName + * properties of either $httpProvider.defaults at config-time, $http.defaults at run-time, + * or the per-request config object. + * + * In order to prevent collisions in environments where multiple Angular apps share the + * same domain or subdomain, we recommend that each application uses unique cookie name. + * + * @param {object} config Object describing the request to be made and how it should be + * processed. The object has following properties: + * + * - **method** – `{string}` – HTTP method (e.g. 'GET', 'POST', etc) + * - **url** – `{string}` – Absolute or relative URL of the resource that is being requested. + * - **params** – `{Object.}` – Map of strings or objects which will be serialized + * with the `paramSerializer` and appended as GET parameters. + * - **data** – `{string|Object}` – Data to be sent as the request message data. + * - **headers** – `{Object}` – Map of strings or functions which return strings representing + * HTTP headers to send to the server. If the return value of a function is null, the + * header will not be sent. Functions accept a config object as an argument. + * - **xsrfHeaderName** – `{string}` – Name of HTTP header to populate with the XSRF token. + * - **xsrfCookieName** – `{string}` – Name of cookie containing the XSRF token. + * - **transformRequest** – + * `{function(data, headersGetter)|Array.}` – + * transform function or an array of such functions. The transform function takes the http + * request body and headers and returns its transformed (typically serialized) version. + * See {@link ng.$http#overriding-the-default-transformations-per-request + * Overriding the Default Transformations} + * - **transformResponse** – + * `{function(data, headersGetter, status)|Array.}` – + * transform function or an array of such functions. The transform function takes the http + * response body, headers and status and returns its transformed (typically deserialized) version. + * See {@link ng.$http#overriding-the-default-transformations-per-request + * Overriding the Default TransformationjqLiks} + * - **paramSerializer** - `{string|function(Object):string}` - A function used to + * prepare the string representation of request parameters (specified as an object). + * If specified as string, it is interpreted as function registered with the + * {@link $injector $injector}, which means you can create your own serializer + * by registering it as a {@link auto.$provide#service service}. + * The default serializer is the {@link $httpParamSerializer $httpParamSerializer}; + * alternatively, you can use the {@link $httpParamSerializerJQLike $httpParamSerializerJQLike} + * - **cache** – `{boolean|Cache}` – If true, a default $http cache will be used to cache the + * GET request, otherwise if a cache instance built with + * {@link ng.$cacheFactory $cacheFactory}, this cache will be used for + * caching. + * - **timeout** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise} + * that should abort the request when resolved. + * - **withCredentials** - `{boolean}` - whether to set the `withCredentials` flag on the + * XHR object. See [requests with credentials](https://developer.mozilla.org/docs/Web/HTTP/Access_control_CORS#Requests_with_credentials) + * for more information. + * - **responseType** - `{string}` - see + * [XMLHttpRequest.responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype). + * + * @returns {HttpPromise} Returns a {@link ng.$q `Promise}` that will be resolved to a response object + * when the request succeeds or fails. + * + * + * @property {Array.} pendingRequests Array of config objects for currently pending + * requests. This is primarily meant to be used for debugging purposes. + * + * + * @example + + +
+ + +
+ + + +
http status code: {{status}}
+
http response data: {{data}}
+
+
+ + angular.module('httpExample', []) + .controller('FetchController', ['$scope', '$http', '$templateCache', + function($scope, $http, $templateCache) { + $scope.method = 'GET'; + $scope.url = 'http-hello.html'; + + $scope.fetch = function() { + $scope.code = null; + $scope.response = null; + + $http({method: $scope.method, url: $scope.url, cache: $templateCache}). + then(function(response) { + $scope.status = response.status; + $scope.data = response.data; + }, function(response) { + $scope.data = response.data || "Request failed"; + $scope.status = response.status; + }); + }; + + $scope.updateModel = function(method, url) { + $scope.method = method; + $scope.url = url; + }; + }]); + + + Hello, $http! + + + var status = element(by.binding('status')); + var data = element(by.binding('data')); + var fetchBtn = element(by.id('fetchbtn')); + var sampleGetBtn = element(by.id('samplegetbtn')); + var sampleJsonpBtn = element(by.id('samplejsonpbtn')); + var invalidJsonpBtn = element(by.id('invalidjsonpbtn')); + + it('should make an xhr GET request', function() { + sampleGetBtn.click(); + fetchBtn.click(); + expect(status.getText()).toMatch('200'); + expect(data.getText()).toMatch(/Hello, \$http!/); + }); + +// Commented out due to flakes. See https://github.com/angular/angular.js/issues/9185 +// it('should make a JSONP request to angularjs.org', function() { +// sampleJsonpBtn.click(); +// fetchBtn.click(); +// expect(status.getText()).toMatch('200'); +// expect(data.getText()).toMatch(/Super Hero!/); +// }); + + it('should make JSONP request to invalid URL and invoke the error handler', + function() { + invalidJsonpBtn.click(); + fetchBtn.click(); + expect(status.getText()).toMatch('0'); + expect(data.getText()).toMatch('Request failed'); + }); + +
+ */ + function $http(requestConfig) { + + if (!angular.isObject(requestConfig)) { + throw minErr('$http')('badreq', 'Http request configuration must be an object. Received: {0}', requestConfig); + } + + var config = extend({ + method: 'get', + transformRequest: defaults.transformRequest, + transformResponse: defaults.transformResponse, + paramSerializer: defaults.paramSerializer + }, requestConfig); + + config.headers = mergeHeaders(requestConfig); + config.method = uppercase(config.method); + config.paramSerializer = isString(config.paramSerializer) ? + $injector.get(config.paramSerializer) : config.paramSerializer; + + var serverRequest = function(config) { + var headers = config.headers; + var reqData = transformData(config.data, headersGetter(headers), undefined, config.transformRequest); + + // strip content-type if data is undefined + if (isUndefined(reqData)) { + forEach(headers, function(value, header) { + if (lowercase(header) === 'content-type') { + delete headers[header]; + } + }); + } + + if (isUndefined(config.withCredentials) && !isUndefined(defaults.withCredentials)) { + config.withCredentials = defaults.withCredentials; + } + + // send request + return sendReq(config, reqData).then(transformResponse, transformResponse); + }; + + var chain = [serverRequest, undefined]; + var promise = $q.when(config); + + // apply interceptors + forEach(reversedInterceptors, function(interceptor) { + if (interceptor.request || interceptor.requestError) { + chain.unshift(interceptor.request, interceptor.requestError); + } + if (interceptor.response || interceptor.responseError) { + chain.push(interceptor.response, interceptor.responseError); + } + }); + + while (chain.length) { + var thenFn = chain.shift(); + var rejectFn = chain.shift(); + + promise = promise.then(thenFn, rejectFn); + } + + if (useLegacyPromise) { + promise.success = function(fn) { + assertArgFn(fn, 'fn'); + + promise.then(function(response) { + fn(response.data, response.status, response.headers, config); + }); + return promise; + }; + + promise.error = function(fn) { + assertArgFn(fn, 'fn'); + + promise.then(null, function(response) { + fn(response.data, response.status, response.headers, config); + }); + return promise; + }; + } else { + promise.success = $httpMinErrLegacyFn('success'); + promise.error = $httpMinErrLegacyFn('error'); + } + + return promise; + + function transformResponse(response) { + // make a copy since the response must be cacheable + var resp = extend({}, response); + if (!response.data) { + resp.data = response.data; + } else { + resp.data = transformData(response.data, response.headers, response.status, config.transformResponse); + } + return (isSuccess(response.status)) + ? resp + : $q.reject(resp); + } + + function executeHeaderFns(headers, config) { + var headerContent, processedHeaders = {}; + + forEach(headers, function(headerFn, header) { + if (isFunction(headerFn)) { + headerContent = headerFn(config); + if (headerContent != null) { + processedHeaders[header] = headerContent; + } + } else { + processedHeaders[header] = headerFn; + } + }); + + return processedHeaders; + } + + function mergeHeaders(config) { + var defHeaders = defaults.headers, + reqHeaders = extend({}, config.headers), + defHeaderName, lowercaseDefHeaderName, reqHeaderName; + + defHeaders = extend({}, defHeaders.common, defHeaders[lowercase(config.method)]); + + // using for-in instead of forEach to avoid unecessary iteration after header has been found + defaultHeadersIteration: + for (defHeaderName in defHeaders) { + lowercaseDefHeaderName = lowercase(defHeaderName); + + for (reqHeaderName in reqHeaders) { + if (lowercase(reqHeaderName) === lowercaseDefHeaderName) { + continue defaultHeadersIteration; + } + } + + reqHeaders[defHeaderName] = defHeaders[defHeaderName]; + } + + // execute if header value is a function for merged headers + return executeHeaderFns(reqHeaders, shallowCopy(config)); + } + } + + $http.pendingRequests = []; + + /** + * @ngdoc method + * @name $http#get + * + * @description + * Shortcut method to perform `GET` request. + * + * @param {string} url Relative or absolute URL specifying the destination of the request + * @param {Object=} config Optional configuration object + * @returns {HttpPromise} Future object + */ + + /** + * @ngdoc method + * @name $http#delete + * + * @description + * Shortcut method to perform `DELETE` request. + * + * @param {string} url Relative or absolute URL specifying the destination of the request + * @param {Object=} config Optional configuration object + * @returns {HttpPromise} Future object + */ + + /** + * @ngdoc method + * @name $http#head + * + * @description + * Shortcut method to perform `HEAD` request. + * + * @param {string} url Relative or absolute URL specifying the destination of the request + * @param {Object=} config Optional configuration object + * @returns {HttpPromise} Future object + */ + + /** + * @ngdoc method + * @name $http#jsonp + * + * @description + * Shortcut method to perform `JSONP` request. + * + * @param {string} url Relative or absolute URL specifying the destination of the request. + * The name of the callback should be the string `JSON_CALLBACK`. + * @param {Object=} config Optional configuration object + * @returns {HttpPromise} Future object + */ + createShortMethods('get', 'delete', 'head', 'jsonp'); + + /** + * @ngdoc method + * @name $http#post + * + * @description + * Shortcut method to perform `POST` request. + * + * @param {string} url Relative or absolute URL specifying the destination of the request + * @param {*} data Request content + * @param {Object=} config Optional configuration object + * @returns {HttpPromise} Future object + */ + + /** + * @ngdoc method + * @name $http#put + * + * @description + * Shortcut method to perform `PUT` request. + * + * @param {string} url Relative or absolute URL specifying the destination of the request + * @param {*} data Request content + * @param {Object=} config Optional configuration object + * @returns {HttpPromise} Future object + */ + + /** + * @ngdoc method + * @name $http#patch + * + * @description + * Shortcut method to perform `PATCH` request. + * + * @param {string} url Relative or absolute URL specifying the destination of the request + * @param {*} data Request content + * @param {Object=} config Optional configuration object + * @returns {HttpPromise} Future object + */ + createShortMethodsWithData('post', 'put', 'patch'); + + /** + * @ngdoc property + * @name $http#defaults + * + * @description + * Runtime equivalent of the `$httpProvider.defaults` property. Allows configuration of + * default headers, withCredentials as well as request and response transformations. + * + * See "Setting HTTP Headers" and "Transforming Requests and Responses" sections above. + */ + $http.defaults = defaults; + + + return $http; + + + function createShortMethods(names) { + forEach(arguments, function(name) { + $http[name] = function(url, config) { + return $http(extend({}, config || {}, { + method: name, + url: url + })); + }; + }); + } + + + function createShortMethodsWithData(name) { + forEach(arguments, function(name) { + $http[name] = function(url, data, config) { + return $http(extend({}, config || {}, { + method: name, + url: url, + data: data + })); + }; + }); + } + + + /** + * Makes the request. + * + * !!! ACCESSES CLOSURE VARS: + * $httpBackend, defaults, $log, $rootScope, defaultCache, $http.pendingRequests + */ + function sendReq(config, reqData) { + var deferred = $q.defer(), + promise = deferred.promise, + cache, + cachedResp, + reqHeaders = config.headers, + url = buildUrl(config.url, config.paramSerializer(config.params)); + + $http.pendingRequests.push(config); + promise.then(removePendingReq, removePendingReq); + + + if ((config.cache || defaults.cache) && config.cache !== false && + (config.method === 'GET' || config.method === 'JSONP')) { + cache = isObject(config.cache) ? config.cache + : isObject(defaults.cache) ? defaults.cache + : defaultCache; + } + + if (cache) { + cachedResp = cache.get(url); + if (isDefined(cachedResp)) { + if (isPromiseLike(cachedResp)) { + // cached request has already been sent, but there is no response yet + cachedResp.then(resolvePromiseWithResult, resolvePromiseWithResult); + } else { + // serving from cache + if (isArray(cachedResp)) { + resolvePromise(cachedResp[1], cachedResp[0], shallowCopy(cachedResp[2]), cachedResp[3]); + } else { + resolvePromise(cachedResp, 200, {}, 'OK'); + } + } + } else { + // put the promise for the non-transformed response into cache as a placeholder + cache.put(url, promise); + } + } + + + // if we won't have the response in cache, set the xsrf headers and + // send the request to the backend + if (isUndefined(cachedResp)) { + var xsrfValue = urlIsSameOrigin(config.url) + ? $$cookieReader()[config.xsrfCookieName || defaults.xsrfCookieName] + : undefined; + if (xsrfValue) { + reqHeaders[(config.xsrfHeaderName || defaults.xsrfHeaderName)] = xsrfValue; + } + + $httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout, + config.withCredentials, config.responseType); + } + + return promise; + + + /** + * Callback registered to $httpBackend(): + * - caches the response if desired + * - resolves the raw $http promise + * - calls $apply + */ + function done(status, response, headersString, statusText) { + if (cache) { + if (isSuccess(status)) { + cache.put(url, [status, response, parseHeaders(headersString), statusText]); + } else { + // remove promise from the cache + cache.remove(url); + } + } + + function resolveHttpPromise() { + resolvePromise(response, status, headersString, statusText); + } + + if (useApplyAsync) { + $rootScope.$applyAsync(resolveHttpPromise); + } else { + resolveHttpPromise(); + if (!$rootScope.$$phase) $rootScope.$apply(); + } + } + + + /** + * Resolves the raw $http promise. + */ + function resolvePromise(response, status, headers, statusText) { + //status: HTTP response status code, 0, -1 (aborted by timeout / promise) + status = status >= -1 ? status : 0; + + (isSuccess(status) ? deferred.resolve : deferred.reject)({ + data: response, + status: status, + headers: headersGetter(headers), + config: config, + statusText: statusText + }); + } + + function resolvePromiseWithResult(result) { + resolvePromise(result.data, result.status, shallowCopy(result.headers()), result.statusText); + } + + function removePendingReq() { + var idx = $http.pendingRequests.indexOf(config); + if (idx !== -1) $http.pendingRequests.splice(idx, 1); + } + } + + + function buildUrl(url, serializedParams) { + if (serializedParams.length > 0) { + url += ((url.indexOf('?') == -1) ? '?' : '&') + serializedParams; + } + return url; + } + }]; +} + +function createXhr() { + return new window.XMLHttpRequest(); +} + +/** + * @ngdoc service + * @name $httpBackend + * @requires $window + * @requires $document + * + * @description + * HTTP backend used by the {@link ng.$http service} that delegates to + * XMLHttpRequest object or JSONP and deals with browser incompatibilities. + * + * You should never need to use this service directly, instead use the higher-level abstractions: + * {@link ng.$http $http} or {@link ngResource.$resource $resource}. + * + * During testing this implementation is swapped with {@link ngMock.$httpBackend mock + * $httpBackend} which can be trained with responses. + */ +function $HttpBackendProvider() { + this.$get = ['$browser', '$window', '$document', function($browser, $window, $document) { + return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]); + }]; +} + +function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) { + // TODO(vojta): fix the signature + return function(method, url, post, callback, headers, timeout, withCredentials, responseType) { + $browser.$$incOutstandingRequestCount(); + url = url || $browser.url(); + + if (lowercase(method) == 'jsonp') { + var callbackId = '_' + (callbacks.counter++).toString(36); + callbacks[callbackId] = function(data) { + callbacks[callbackId].data = data; + callbacks[callbackId].called = true; + }; + + var jsonpDone = jsonpReq(url.replace('JSON_CALLBACK', 'angular.callbacks.' + callbackId), + callbackId, function(status, text) { + completeRequest(callback, status, callbacks[callbackId].data, "", text); + callbacks[callbackId] = noop; + }); + } else { + + var xhr = createXhr(); + + xhr.open(method, url, true); + forEach(headers, function(value, key) { + if (isDefined(value)) { + xhr.setRequestHeader(key, value); + } + }); + + xhr.onload = function requestLoaded() { + var statusText = xhr.statusText || ''; + + // responseText is the old-school way of retrieving response (supported by IE9) + // response/responseType properties were introduced in XHR Level2 spec (supported by IE10) + var response = ('response' in xhr) ? xhr.response : xhr.responseText; + + // normalize IE9 bug (http://bugs.jquery.com/ticket/1450) + var status = xhr.status === 1223 ? 204 : xhr.status; + + // fix status code when it is 0 (0 status is undocumented). + // Occurs when accessing file resources or on Android 4.1 stock browser + // while retrieving files from application cache. + if (status === 0) { + status = response ? 200 : urlResolve(url).protocol == 'file' ? 404 : 0; + } + + completeRequest(callback, + status, + response, + xhr.getAllResponseHeaders(), + statusText); + }; + + var requestError = function() { + // The response is always empty + // See https://xhr.spec.whatwg.org/#request-error-steps and https://fetch.spec.whatwg.org/#concept-network-error + completeRequest(callback, -1, null, null, ''); + }; + + xhr.onerror = requestError; + xhr.onabort = requestError; + + if (withCredentials) { + xhr.withCredentials = true; + } + + if (responseType) { + try { + xhr.responseType = responseType; + } catch (e) { + // WebKit added support for the json responseType value on 09/03/2013 + // https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are + // known to throw when setting the value "json" as the response type. Other older + // browsers implementing the responseType + // + // The json response type can be ignored if not supported, because JSON payloads are + // parsed on the client-side regardless. + if (responseType !== 'json') { + throw e; + } + } + } + + xhr.send(isUndefined(post) ? null : post); + } + + if (timeout > 0) { + var timeoutId = $browserDefer(timeoutRequest, timeout); + } else if (isPromiseLike(timeout)) { + timeout.then(timeoutRequest); + } + + + function timeoutRequest() { + jsonpDone && jsonpDone(); + xhr && xhr.abort(); + } + + function completeRequest(callback, status, response, headersString, statusText) { + // cancel timeout and subsequent timeout promise resolution + if (isDefined(timeoutId)) { + $browserDefer.cancel(timeoutId); + } + jsonpDone = xhr = null; + + callback(status, response, headersString, statusText); + $browser.$$completeOutstandingRequest(noop); + } + }; + + function jsonpReq(url, callbackId, done) { + // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.: + // - fetches local scripts via XHR and evals them + // - adds and immediately removes script elements from the document + var script = rawDocument.createElement('script'), callback = null; + script.type = "text/javascript"; + script.src = url; + script.async = true; + + callback = function(event) { + removeEventListenerFn(script, "load", callback); + removeEventListenerFn(script, "error", callback); + rawDocument.body.removeChild(script); + script = null; + var status = -1; + var text = "unknown"; + + if (event) { + if (event.type === "load" && !callbacks[callbackId].called) { + event = { type: "error" }; + } + text = event.type; + status = event.type === "error" ? 404 : 200; + } + + if (done) { + done(status, text); + } + }; + + addEventListenerFn(script, "load", callback); + addEventListenerFn(script, "error", callback); + rawDocument.body.appendChild(script); + return callback; + } +} + +var $interpolateMinErr = angular.$interpolateMinErr = minErr('$interpolate'); +$interpolateMinErr.throwNoconcat = function(text) { + throw $interpolateMinErr('noconcat', + "Error while interpolating: {0}\nStrict Contextual Escaping disallows " + + "interpolations that concatenate multiple expressions when a trusted value is " + + "required. See http://docs.angularjs.org/api/ng.$sce", text); +}; + +$interpolateMinErr.interr = function(text, err) { + return $interpolateMinErr('interr', "Can't interpolate: {0}\n{1}", text, err.toString()); +}; + +/** + * @ngdoc provider + * @name $interpolateProvider + * + * @description + * + * Used for configuring the interpolation markup. Defaults to `{{` and `}}`. + * + * @example + + + +
+ //demo.label// +
+
+ + it('should interpolate binding with custom symbols', function() { + expect(element(by.binding('demo.label')).getText()).toBe('This binding is brought you by // interpolation symbols.'); + }); + +
+ */ +function $InterpolateProvider() { + var startSymbol = '{{'; + var endSymbol = '}}'; + + /** + * @ngdoc method + * @name $interpolateProvider#startSymbol + * @description + * Symbol to denote start of expression in the interpolated string. Defaults to `{{`. + * + * @param {string=} value new value to set the starting symbol to. + * @returns {string|self} Returns the symbol when used as getter and self if used as setter. + */ + this.startSymbol = function(value) { + if (value) { + startSymbol = value; + return this; + } else { + return startSymbol; + } + }; + + /** + * @ngdoc method + * @name $interpolateProvider#endSymbol + * @description + * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`. + * + * @param {string=} value new value to set the ending symbol to. + * @returns {string|self} Returns the symbol when used as getter and self if used as setter. + */ + this.endSymbol = function(value) { + if (value) { + endSymbol = value; + return this; + } else { + return endSymbol; + } + }; + + + this.$get = ['$parse', '$exceptionHandler', '$sce', function($parse, $exceptionHandler, $sce) { + var startSymbolLength = startSymbol.length, + endSymbolLength = endSymbol.length, + escapedStartRegexp = new RegExp(startSymbol.replace(/./g, escape), 'g'), + escapedEndRegexp = new RegExp(endSymbol.replace(/./g, escape), 'g'); + + function escape(ch) { + return '\\\\\\' + ch; + } + + function unescapeText(text) { + return text.replace(escapedStartRegexp, startSymbol). + replace(escapedEndRegexp, endSymbol); + } + + function stringify(value) { + if (value == null) { // null || undefined + return ''; + } + switch (typeof value) { + case 'string': + break; + case 'number': + value = '' + value; + break; + default: + value = toJson(value); + } + + return value; + } + + /** + * @ngdoc service + * @name $interpolate + * @kind function + * + * @requires $parse + * @requires $sce + * + * @description + * + * Compiles a string with markup into an interpolation function. This service is used by the + * HTML {@link ng.$compile $compile} service for data binding. See + * {@link ng.$interpolateProvider $interpolateProvider} for configuring the + * interpolation markup. + * + * + * ```js + * var $interpolate = ...; // injected + * var exp = $interpolate('Hello {{name | uppercase}}!'); + * expect(exp({name:'Angular'})).toEqual('Hello ANGULAR!'); + * ``` + * + * `$interpolate` takes an optional fourth argument, `allOrNothing`. If `allOrNothing` is + * `true`, the interpolation function will return `undefined` unless all embedded expressions + * evaluate to a value other than `undefined`. + * + * ```js + * var $interpolate = ...; // injected + * var context = {greeting: 'Hello', name: undefined }; + * + * // default "forgiving" mode + * var exp = $interpolate('{{greeting}} {{name}}!'); + * expect(exp(context)).toEqual('Hello !'); + * + * // "allOrNothing" mode + * exp = $interpolate('{{greeting}} {{name}}!', false, null, true); + * expect(exp(context)).toBeUndefined(); + * context.name = 'Angular'; + * expect(exp(context)).toEqual('Hello Angular!'); + * ``` + * + * `allOrNothing` is useful for interpolating URLs. `ngSrc` and `ngSrcset` use this behavior. + * + * ####Escaped Interpolation + * $interpolate provides a mechanism for escaping interpolation markers. Start and end markers + * can be escaped by preceding each of their characters with a REVERSE SOLIDUS U+005C (backslash). + * It will be rendered as a regular start/end marker, and will not be interpreted as an expression + * or binding. + * + * This enables web-servers to prevent script injection attacks and defacing attacks, to some + * degree, while also enabling code examples to work without relying on the + * {@link ng.directive:ngNonBindable ngNonBindable} directive. + * + * **For security purposes, it is strongly encouraged that web servers escape user-supplied data, + * replacing angle brackets (<, >) with &lt; and &gt; respectively, and replacing all + * interpolation start/end markers with their escaped counterparts.** + * + * Escaped interpolation markers are only replaced with the actual interpolation markers in rendered + * output when the $interpolate service processes the text. So, for HTML elements interpolated + * by {@link ng.$compile $compile}, or otherwise interpolated with the `mustHaveExpression` parameter + * set to `true`, the interpolated text must contain an unescaped interpolation expression. As such, + * this is typically useful only when user-data is used in rendering a template from the server, or + * when otherwise untrusted data is used by a directive. + * + * + * + *
+ *

{{apptitle}}: \{\{ username = "defaced value"; \}\} + *

+ *

{{username}} attempts to inject code which will deface the + * application, but fails to accomplish their task, because the server has correctly + * escaped the interpolation start/end markers with REVERSE SOLIDUS U+005C (backslash) + * characters.

+ *

Instead, the result of the attempted script injection is visible, and can be removed + * from the database by an administrator.

+ *
+ *
+ *
+ * + * @param {string} text The text with markup to interpolate. + * @param {boolean=} mustHaveExpression if set to true then the interpolation string must have + * embedded expression in order to return an interpolation function. Strings with no + * embedded expression will return null for the interpolation function. + * @param {string=} trustedContext when provided, the returned function passes the interpolated + * result through {@link ng.$sce#getTrusted $sce.getTrusted(interpolatedResult, + * trustedContext)} before returning it. Refer to the {@link ng.$sce $sce} service that + * provides Strict Contextual Escaping for details. + * @param {boolean=} allOrNothing if `true`, then the returned function returns undefined + * unless all embedded expressions evaluate to a value other than `undefined`. + * @returns {function(context)} an interpolation function which is used to compute the + * interpolated string. The function has these parameters: + * + * - `context`: evaluation context for all expressions embedded in the interpolated text + */ + function $interpolate(text, mustHaveExpression, trustedContext, allOrNothing) { + allOrNothing = !!allOrNothing; + var startIndex, + endIndex, + index = 0, + expressions = [], + parseFns = [], + textLength = text.length, + exp, + concat = [], + expressionPositions = []; + + while (index < textLength) { + if (((startIndex = text.indexOf(startSymbol, index)) != -1) && + ((endIndex = text.indexOf(endSymbol, startIndex + startSymbolLength)) != -1)) { + if (index !== startIndex) { + concat.push(unescapeText(text.substring(index, startIndex))); + } + exp = text.substring(startIndex + startSymbolLength, endIndex); + expressions.push(exp); + parseFns.push($parse(exp, parseStringifyInterceptor)); + index = endIndex + endSymbolLength; + expressionPositions.push(concat.length); + concat.push(''); + } else { + // we did not find an interpolation, so we have to add the remainder to the separators array + if (index !== textLength) { + concat.push(unescapeText(text.substring(index))); + } + break; + } + } + + // Concatenating expressions makes it hard to reason about whether some combination of + // concatenated values are unsafe to use and could easily lead to XSS. By requiring that a + // single expression be used for iframe[src], object[src], etc., we ensure that the value + // that's used is assigned or constructed by some JS code somewhere that is more testable or + // make it obvious that you bound the value to some user controlled value. This helps reduce + // the load when auditing for XSS issues. + if (trustedContext && concat.length > 1) { + $interpolateMinErr.throwNoconcat(text); + } + + if (!mustHaveExpression || expressions.length) { + var compute = function(values) { + for (var i = 0, ii = expressions.length; i < ii; i++) { + if (allOrNothing && isUndefined(values[i])) return; + concat[expressionPositions[i]] = values[i]; + } + return concat.join(''); + }; + + var getValue = function(value) { + return trustedContext ? + $sce.getTrusted(trustedContext, value) : + $sce.valueOf(value); + }; + + return extend(function interpolationFn(context) { + var i = 0; + var ii = expressions.length; + var values = new Array(ii); + + try { + for (; i < ii; i++) { + values[i] = parseFns[i](context); + } + + return compute(values); + } catch (err) { + $exceptionHandler($interpolateMinErr.interr(text, err)); + } + + }, { + // all of these properties are undocumented for now + exp: text, //just for compatibility with regular watchers created via $watch + expressions: expressions, + $$watchDelegate: function(scope, listener) { + var lastValue; + return scope.$watchGroup(parseFns, function interpolateFnWatcher(values, oldValues) { + var currValue = compute(values); + if (isFunction(listener)) { + listener.call(this, currValue, values !== oldValues ? lastValue : currValue, scope); + } + lastValue = currValue; + }); + } + }); + } + + function parseStringifyInterceptor(value) { + try { + value = getValue(value); + return allOrNothing && !isDefined(value) ? value : stringify(value); + } catch (err) { + $exceptionHandler($interpolateMinErr.interr(text, err)); + } + } + } + + + /** + * @ngdoc method + * @name $interpolate#startSymbol + * @description + * Symbol to denote the start of expression in the interpolated string. Defaults to `{{`. + * + * Use {@link ng.$interpolateProvider#startSymbol `$interpolateProvider.startSymbol`} to change + * the symbol. + * + * @returns {string} start symbol. + */ + $interpolate.startSymbol = function() { + return startSymbol; + }; + + + /** + * @ngdoc method + * @name $interpolate#endSymbol + * @description + * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`. + * + * Use {@link ng.$interpolateProvider#endSymbol `$interpolateProvider.endSymbol`} to change + * the symbol. + * + * @returns {string} end symbol. + */ + $interpolate.endSymbol = function() { + return endSymbol; + }; + + return $interpolate; + }]; +} + +function $IntervalProvider() { + this.$get = ['$rootScope', '$window', '$q', '$$q', + function($rootScope, $window, $q, $$q) { + var intervals = {}; + + + /** + * @ngdoc service + * @name $interval + * + * @description + * Angular's wrapper for `window.setInterval`. The `fn` function is executed every `delay` + * milliseconds. + * + * The return value of registering an interval function is a promise. This promise will be + * notified upon each tick of the interval, and will be resolved after `count` iterations, or + * run indefinitely if `count` is not defined. The value of the notification will be the + * number of iterations that have run. + * To cancel an interval, call `$interval.cancel(promise)`. + * + * In tests you can use {@link ngMock.$interval#flush `$interval.flush(millis)`} to + * move forward by `millis` milliseconds and trigger any functions scheduled to run in that + * time. + * + *
+ * **Note**: Intervals created by this service must be explicitly destroyed when you are finished + * with them. In particular they are not automatically destroyed when a controller's scope or a + * directive's element are destroyed. + * You should take this into consideration and make sure to always cancel the interval at the + * appropriate moment. See the example below for more details on how and when to do this. + *
+ * + * @param {function()} fn A function that should be called repeatedly. + * @param {number} delay Number of milliseconds between each function call. + * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat + * indefinitely. + * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise + * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. + * @param {...*=} Pass additional parameters to the executed function. + * @returns {promise} A promise which will be notified on each iteration. + * + * @example + * + * + * + * + *
+ *
+ *
+ * Current time is: + *
+ * Blood 1 : {{blood_1}} + * Blood 2 : {{blood_2}} + * + * + * + *
+ *
+ * + *
+ *
+ */ + function interval(fn, delay, count, invokeApply) { + var hasParams = arguments.length > 4, + args = hasParams ? sliceArgs(arguments, 4) : [], + setInterval = $window.setInterval, + clearInterval = $window.clearInterval, + iteration = 0, + skipApply = (isDefined(invokeApply) && !invokeApply), + deferred = (skipApply ? $$q : $q).defer(), + promise = deferred.promise; + + count = isDefined(count) ? count : 0; + + promise.then(null, null, (!hasParams) ? fn : function() { + fn.apply(null, args); + }); + + promise.$$intervalId = setInterval(function tick() { + deferred.notify(iteration++); + + if (count > 0 && iteration >= count) { + deferred.resolve(iteration); + clearInterval(promise.$$intervalId); + delete intervals[promise.$$intervalId]; + } + + if (!skipApply) $rootScope.$apply(); + + }, delay); + + intervals[promise.$$intervalId] = deferred; + + return promise; + } + + + /** + * @ngdoc method + * @name $interval#cancel + * + * @description + * Cancels a task associated with the `promise`. + * + * @param {Promise=} promise returned by the `$interval` function. + * @returns {boolean} Returns `true` if the task was successfully canceled. + */ + interval.cancel = function(promise) { + if (promise && promise.$$intervalId in intervals) { + intervals[promise.$$intervalId].reject('canceled'); + $window.clearInterval(promise.$$intervalId); + delete intervals[promise.$$intervalId]; + return true; + } + return false; + }; + + return interval; + }]; +} + +/** + * @ngdoc service + * @name $locale + * + * @description + * $locale service provides localization rules for various Angular components. As of right now the + * only public api is: + * + * * `id` – `{string}` – locale id formatted as `languageId-countryId` (e.g. `en-us`) + */ + +var PATH_MATCH = /^([^\?#]*)(\?([^#]*))?(#(.*))?$/, + DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp': 21}; +var $locationMinErr = minErr('$location'); + + +/** + * Encode path using encodeUriSegment, ignoring forward slashes + * + * @param {string} path Path to encode + * @returns {string} + */ +function encodePath(path) { + var segments = path.split('/'), + i = segments.length; + + while (i--) { + segments[i] = encodeUriSegment(segments[i]); + } + + return segments.join('/'); +} + +function parseAbsoluteUrl(absoluteUrl, locationObj) { + var parsedUrl = urlResolve(absoluteUrl); + + locationObj.$$protocol = parsedUrl.protocol; + locationObj.$$host = parsedUrl.hostname; + locationObj.$$port = toInt(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null; +} + + +function parseAppUrl(relativeUrl, locationObj) { + var prefixed = (relativeUrl.charAt(0) !== '/'); + if (prefixed) { + relativeUrl = '/' + relativeUrl; + } + var match = urlResolve(relativeUrl); + locationObj.$$path = decodeURIComponent(prefixed && match.pathname.charAt(0) === '/' ? + match.pathname.substring(1) : match.pathname); + locationObj.$$search = parseKeyValue(match.search); + locationObj.$$hash = decodeURIComponent(match.hash); + + // make sure path starts with '/'; + if (locationObj.$$path && locationObj.$$path.charAt(0) != '/') { + locationObj.$$path = '/' + locationObj.$$path; + } +} + + +/** + * + * @param {string} begin + * @param {string} whole + * @returns {string} returns text from whole after begin or undefined if it does not begin with + * expected string. + */ +function beginsWith(begin, whole) { + if (whole.indexOf(begin) === 0) { + return whole.substr(begin.length); + } +} + + +function stripHash(url) { + var index = url.indexOf('#'); + return index == -1 ? url : url.substr(0, index); +} + +function trimEmptyHash(url) { + return url.replace(/(#.+)|#$/, '$1'); +} + + +function stripFile(url) { + return url.substr(0, stripHash(url).lastIndexOf('/') + 1); +} + +/* return the server only (scheme://host:port) */ +function serverBase(url) { + return url.substring(0, url.indexOf('/', url.indexOf('//') + 2)); +} + + +/** + * LocationHtml5Url represents an url + * This object is exposed as $location service when HTML5 mode is enabled and supported + * + * @constructor + * @param {string} appBase application base URL + * @param {string} appBaseNoFile application base URL stripped of any filename + * @param {string} basePrefix url path prefix + */ +function LocationHtml5Url(appBase, appBaseNoFile, basePrefix) { + this.$$html5 = true; + basePrefix = basePrefix || ''; + parseAbsoluteUrl(appBase, this); + + + /** + * Parse given html5 (regular) url string into properties + * @param {string} url HTML5 url + * @private + */ + this.$$parse = function(url) { + var pathUrl = beginsWith(appBaseNoFile, url); + if (!isString(pathUrl)) { + throw $locationMinErr('ipthprfx', 'Invalid url "{0}", missing path prefix "{1}".', url, + appBaseNoFile); + } + + parseAppUrl(pathUrl, this); + + if (!this.$$path) { + this.$$path = '/'; + } + + this.$$compose(); + }; + + /** + * Compose url and update `absUrl` property + * @private + */ + this.$$compose = function() { + var search = toKeyValue(this.$$search), + hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; + + this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; + this.$$absUrl = appBaseNoFile + this.$$url.substr(1); // first char is always '/' + }; + + this.$$parseLinkUrl = function(url, relHref) { + if (relHref && relHref[0] === '#') { + // special case for links to hash fragments: + // keep the old url and only replace the hash fragment + this.hash(relHref.slice(1)); + return true; + } + var appUrl, prevAppUrl; + var rewrittenUrl; + + if (isDefined(appUrl = beginsWith(appBase, url))) { + prevAppUrl = appUrl; + if (isDefined(appUrl = beginsWith(basePrefix, appUrl))) { + rewrittenUrl = appBaseNoFile + (beginsWith('/', appUrl) || appUrl); + } else { + rewrittenUrl = appBase + prevAppUrl; + } + } else if (isDefined(appUrl = beginsWith(appBaseNoFile, url))) { + rewrittenUrl = appBaseNoFile + appUrl; + } else if (appBaseNoFile == url + '/') { + rewrittenUrl = appBaseNoFile; + } + if (rewrittenUrl) { + this.$$parse(rewrittenUrl); + } + return !!rewrittenUrl; + }; +} + + +/** + * LocationHashbangUrl represents url + * This object is exposed as $location service when developer doesn't opt into html5 mode. + * It also serves as the base class for html5 mode fallback on legacy browsers. + * + * @constructor + * @param {string} appBase application base URL + * @param {string} appBaseNoFile application base URL stripped of any filename + * @param {string} hashPrefix hashbang prefix + */ +function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) { + + parseAbsoluteUrl(appBase, this); + + + /** + * Parse given hashbang url into properties + * @param {string} url Hashbang url + * @private + */ + this.$$parse = function(url) { + var withoutBaseUrl = beginsWith(appBase, url) || beginsWith(appBaseNoFile, url); + var withoutHashUrl; + + if (!isUndefined(withoutBaseUrl) && withoutBaseUrl.charAt(0) === '#') { + + // The rest of the url starts with a hash so we have + // got either a hashbang path or a plain hash fragment + withoutHashUrl = beginsWith(hashPrefix, withoutBaseUrl); + if (isUndefined(withoutHashUrl)) { + // There was no hashbang prefix so we just have a hash fragment + withoutHashUrl = withoutBaseUrl; + } + + } else { + // There was no hashbang path nor hash fragment: + // If we are in HTML5 mode we use what is left as the path; + // Otherwise we ignore what is left + if (this.$$html5) { + withoutHashUrl = withoutBaseUrl; + } else { + withoutHashUrl = ''; + if (isUndefined(withoutBaseUrl)) { + appBase = url; + this.replace(); + } + } + } + + parseAppUrl(withoutHashUrl, this); + + this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase); + + this.$$compose(); + + /* + * In Windows, on an anchor node on documents loaded from + * the filesystem, the browser will return a pathname + * prefixed with the drive name ('/C:/path') when a + * pathname without a drive is set: + * * a.setAttribute('href', '/foo') + * * a.pathname === '/C:/foo' //true + * + * Inside of Angular, we're always using pathnames that + * do not include drive names for routing. + */ + function removeWindowsDriveName(path, url, base) { + /* + Matches paths for file protocol on windows, + such as /C:/foo/bar, and captures only /foo/bar. + */ + var windowsFilePathExp = /^\/[A-Z]:(\/.*)/; + + var firstPathSegmentMatch; + + //Get the relative path from the input URL. + if (url.indexOf(base) === 0) { + url = url.replace(base, ''); + } + + // The input URL intentionally contains a first path segment that ends with a colon. + if (windowsFilePathExp.exec(url)) { + return path; + } + + firstPathSegmentMatch = windowsFilePathExp.exec(path); + return firstPathSegmentMatch ? firstPathSegmentMatch[1] : path; + } + }; + + /** + * Compose hashbang url and update `absUrl` property + * @private + */ + this.$$compose = function() { + var search = toKeyValue(this.$$search), + hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; + + this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; + this.$$absUrl = appBase + (this.$$url ? hashPrefix + this.$$url : ''); + }; + + this.$$parseLinkUrl = function(url, relHref) { + if (stripHash(appBase) == stripHash(url)) { + this.$$parse(url); + return true; + } + return false; + }; +} + + +/** + * LocationHashbangUrl represents url + * This object is exposed as $location service when html5 history api is enabled but the browser + * does not support it. + * + * @constructor + * @param {string} appBase application base URL + * @param {string} appBaseNoFile application base URL stripped of any filename + * @param {string} hashPrefix hashbang prefix + */ +function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) { + this.$$html5 = true; + LocationHashbangUrl.apply(this, arguments); + + this.$$parseLinkUrl = function(url, relHref) { + if (relHref && relHref[0] === '#') { + // special case for links to hash fragments: + // keep the old url and only replace the hash fragment + this.hash(relHref.slice(1)); + return true; + } + + var rewrittenUrl; + var appUrl; + + if (appBase == stripHash(url)) { + rewrittenUrl = url; + } else if ((appUrl = beginsWith(appBaseNoFile, url))) { + rewrittenUrl = appBase + hashPrefix + appUrl; + } else if (appBaseNoFile === url + '/') { + rewrittenUrl = appBaseNoFile; + } + if (rewrittenUrl) { + this.$$parse(rewrittenUrl); + } + return !!rewrittenUrl; + }; + + this.$$compose = function() { + var search = toKeyValue(this.$$search), + hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; + + this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; + // include hashPrefix in $$absUrl when $$url is empty so IE9 does not reload page because of removal of '#' + this.$$absUrl = appBase + hashPrefix + this.$$url; + }; + +} + + +var locationPrototype = { + + /** + * Are we in html5 mode? + * @private + */ + $$html5: false, + + /** + * Has any change been replacing? + * @private + */ + $$replace: false, + + /** + * @ngdoc method + * @name $location#absUrl + * + * @description + * This method is getter only. + * + * Return full url representation with all segments encoded according to rules specified in + * [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). + * + * + * ```js + * // given url http://example.com/#/some/path?foo=bar&baz=xoxo + * var absUrl = $location.absUrl(); + * // => "http://example.com/#/some/path?foo=bar&baz=xoxo" + * ``` + * + * @return {string} full url + */ + absUrl: locationGetter('$$absUrl'), + + /** + * @ngdoc method + * @name $location#url + * + * @description + * This method is getter / setter. + * + * Return url (e.g. `/path?a=b#hash`) when called without any parameter. + * + * Change path, search and hash, when called with parameter and return `$location`. + * + * + * ```js + * // given url http://example.com/#/some/path?foo=bar&baz=xoxo + * var url = $location.url(); + * // => "/some/path?foo=bar&baz=xoxo" + * ``` + * + * @param {string=} url New url without base prefix (e.g. `/path?a=b#hash`) + * @return {string} url + */ + url: function(url) { + if (isUndefined(url)) { + return this.$$url; + } + + var match = PATH_MATCH.exec(url); + if (match[1] || url === '') this.path(decodeURIComponent(match[1])); + if (match[2] || match[1] || url === '') this.search(match[3] || ''); + this.hash(match[5] || ''); + + return this; + }, + + /** + * @ngdoc method + * @name $location#protocol + * + * @description + * This method is getter only. + * + * Return protocol of current url. + * + * + * ```js + * // given url http://example.com/#/some/path?foo=bar&baz=xoxo + * var protocol = $location.protocol(); + * // => "http" + * ``` + * + * @return {string} protocol of current url + */ + protocol: locationGetter('$$protocol'), + + /** + * @ngdoc method + * @name $location#host + * + * @description + * This method is getter only. + * + * Return host of current url. + * + * Note: compared to the non-angular version `location.host` which returns `hostname:port`, this returns the `hostname` portion only. + * + * + * ```js + * // given url http://example.com/#/some/path?foo=bar&baz=xoxo + * var host = $location.host(); + * // => "example.com" + * + * // given url http://user:password@example.com:8080/#/some/path?foo=bar&baz=xoxo + * host = $location.host(); + * // => "example.com" + * host = location.host; + * // => "example.com:8080" + * ``` + * + * @return {string} host of current url. + */ + host: locationGetter('$$host'), + + /** + * @ngdoc method + * @name $location#port + * + * @description + * This method is getter only. + * + * Return port of current url. + * + * + * ```js + * // given url http://example.com/#/some/path?foo=bar&baz=xoxo + * var port = $location.port(); + * // => 80 + * ``` + * + * @return {Number} port + */ + port: locationGetter('$$port'), + + /** + * @ngdoc method + * @name $location#path + * + * @description + * This method is getter / setter. + * + * Return path of current url when called without any parameter. + * + * Change path when called with parameter and return `$location`. + * + * Note: Path should always begin with forward slash (/), this method will add the forward slash + * if it is missing. + * + * + * ```js + * // given url http://example.com/#/some/path?foo=bar&baz=xoxo + * var path = $location.path(); + * // => "/some/path" + * ``` + * + * @param {(string|number)=} path New path + * @return {string} path + */ + path: locationGetterSetter('$$path', function(path) { + path = path !== null ? path.toString() : ''; + return path.charAt(0) == '/' ? path : '/' + path; + }), + + /** + * @ngdoc method + * @name $location#search + * + * @description + * This method is getter / setter. + * + * Return search part (as object) of current url when called without any parameter. + * + * Change search part when called with parameter and return `$location`. + * + * + * ```js + * // given url http://example.com/#/some/path?foo=bar&baz=xoxo + * var searchObject = $location.search(); + * // => {foo: 'bar', baz: 'xoxo'} + * + * // set foo to 'yipee' + * $location.search('foo', 'yipee'); + * // $location.search() => {foo: 'yipee', baz: 'xoxo'} + * ``` + * + * @param {string|Object.|Object.>} search New search params - string or + * hash object. + * + * When called with a single argument the method acts as a setter, setting the `search` component + * of `$location` to the specified value. + * + * If the argument is a hash object containing an array of values, these values will be encoded + * as duplicate search parameters in the url. + * + * @param {(string|Number|Array|boolean)=} paramValue If `search` is a string or number, then `paramValue` + * will override only a single search property. + * + * If `paramValue` is an array, it will override the property of the `search` component of + * `$location` specified via the first argument. + * + * If `paramValue` is `null`, the property specified via the first argument will be deleted. + * + * If `paramValue` is `true`, the property specified via the first argument will be added with no + * value nor trailing equal sign. + * + * @return {Object} If called with no arguments returns the parsed `search` object. If called with + * one or more arguments returns `$location` object itself. + */ + search: function(search, paramValue) { + switch (arguments.length) { + case 0: + return this.$$search; + case 1: + if (isString(search) || isNumber(search)) { + search = search.toString(); + this.$$search = parseKeyValue(search); + } else if (isObject(search)) { + search = copy(search, {}); + // remove object undefined or null properties + forEach(search, function(value, key) { + if (value == null) delete search[key]; + }); + + this.$$search = search; + } else { + throw $locationMinErr('isrcharg', + 'The first argument of the `$location#search()` call must be a string or an object.'); + } + break; + default: + if (isUndefined(paramValue) || paramValue === null) { + delete this.$$search[search]; + } else { + this.$$search[search] = paramValue; + } + } + + this.$$compose(); + return this; + }, + + /** + * @ngdoc method + * @name $location#hash + * + * @description + * This method is getter / setter. + * + * Return hash fragment when called without any parameter. + * + * Change hash fragment when called with parameter and return `$location`. + * + * + * ```js + * // given url http://example.com/#/some/path?foo=bar&baz=xoxo#hashValue + * var hash = $location.hash(); + * // => "hashValue" + * ``` + * + * @param {(string|number)=} hash New hash fragment + * @return {string} hash + */ + hash: locationGetterSetter('$$hash', function(hash) { + return hash !== null ? hash.toString() : ''; + }), + + /** + * @ngdoc method + * @name $location#replace + * + * @description + * If called, all changes to $location during current `$digest` will be replacing current history + * record, instead of adding new one. + */ + replace: function() { + this.$$replace = true; + return this; + } +}; + +forEach([LocationHashbangInHtml5Url, LocationHashbangUrl, LocationHtml5Url], function(Location) { + Location.prototype = Object.create(locationPrototype); + + /** + * @ngdoc method + * @name $location#state + * + * @description + * This method is getter / setter. + * + * Return the history state object when called without any parameter. + * + * Change the history state object when called with one parameter and return `$location`. + * The state object is later passed to `pushState` or `replaceState`. + * + * NOTE: This method is supported only in HTML5 mode and only in browsers supporting + * the HTML5 History API (i.e. methods `pushState` and `replaceState`). If you need to support + * older browsers (like IE9 or Android < 4.0), don't use this method. + * + * @param {object=} state State object for pushState or replaceState + * @return {object} state + */ + Location.prototype.state = function(state) { + if (!arguments.length) { + return this.$$state; + } + + if (Location !== LocationHtml5Url || !this.$$html5) { + throw $locationMinErr('nostate', 'History API state support is available only ' + + 'in HTML5 mode and only in browsers supporting HTML5 History API'); + } + // The user might modify `stateObject` after invoking `$location.state(stateObject)` + // but we're changing the $$state reference to $browser.state() during the $digest + // so the modification window is narrow. + this.$$state = isUndefined(state) ? null : state; + + return this; + }; +}); + + +function locationGetter(property) { + return function() { + return this[property]; + }; +} + + +function locationGetterSetter(property, preprocess) { + return function(value) { + if (isUndefined(value)) { + return this[property]; + } + + this[property] = preprocess(value); + this.$$compose(); + + return this; + }; +} + + +/** + * @ngdoc service + * @name $location + * + * @requires $rootElement + * + * @description + * The $location service parses the URL in the browser address bar (based on the + * [window.location](https://developer.mozilla.org/en/window.location)) and makes the URL + * available to your application. Changes to the URL in the address bar are reflected into + * $location service and changes to $location are reflected into the browser address bar. + * + * **The $location service:** + * + * - Exposes the current URL in the browser address bar, so you can + * - Watch and observe the URL. + * - Change the URL. + * - Synchronizes the URL with the browser when the user + * - Changes the address bar. + * - Clicks the back or forward button (or clicks a History link). + * - Clicks on a link. + * - Represents the URL object as a set of methods (protocol, host, port, path, search, hash). + * + * For more information see {@link guide/$location Developer Guide: Using $location} + */ + +/** + * @ngdoc provider + * @name $locationProvider + * @description + * Use the `$locationProvider` to configure how the application deep linking paths are stored. + */ +function $LocationProvider() { + var hashPrefix = '', + html5Mode = { + enabled: false, + requireBase: true, + rewriteLinks: true + }; + + /** + * @ngdoc method + * @name $locationProvider#hashPrefix + * @description + * @param {string=} prefix Prefix for hash part (containing path and search) + * @returns {*} current value if used as getter or itself (chaining) if used as setter + */ + this.hashPrefix = function(prefix) { + if (isDefined(prefix)) { + hashPrefix = prefix; + return this; + } else { + return hashPrefix; + } + }; + + /** + * @ngdoc method + * @name $locationProvider#html5Mode + * @description + * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value. + * If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported + * properties: + * - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to + * change urls where supported. Will fall back to hash-prefixed paths in browsers that do not + * support `pushState`. + * - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies + * whether or not a tag is required to be present. If `enabled` and `requireBase` are + * true, and a base tag is not present, an error will be thrown when `$location` is injected. + * See the {@link guide/$location $location guide for more information} + * - **rewriteLinks** - `{boolean}` - (default: `true`) When html5Mode is enabled, + * enables/disables url rewriting for relative links. + * + * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter + */ + this.html5Mode = function(mode) { + if (isBoolean(mode)) { + html5Mode.enabled = mode; + return this; + } else if (isObject(mode)) { + + if (isBoolean(mode.enabled)) { + html5Mode.enabled = mode.enabled; + } + + if (isBoolean(mode.requireBase)) { + html5Mode.requireBase = mode.requireBase; + } + + if (isBoolean(mode.rewriteLinks)) { + html5Mode.rewriteLinks = mode.rewriteLinks; + } + + return this; + } else { + return html5Mode; + } + }; + + /** + * @ngdoc event + * @name $location#$locationChangeStart + * @eventType broadcast on root scope + * @description + * Broadcasted before a URL will change. + * + * This change can be prevented by calling + * `preventDefault` method of the event. See {@link ng.$rootScope.Scope#$on} for more + * details about event object. Upon successful change + * {@link ng.$location#$locationChangeSuccess $locationChangeSuccess} is fired. + * + * The `newState` and `oldState` parameters may be defined only in HTML5 mode and when + * the browser supports the HTML5 History API. + * + * @param {Object} angularEvent Synthetic event object. + * @param {string} newUrl New URL + * @param {string=} oldUrl URL that was before it was changed. + * @param {string=} newState New history state object + * @param {string=} oldState History state object that was before it was changed. + */ + + /** + * @ngdoc event + * @name $location#$locationChangeSuccess + * @eventType broadcast on root scope + * @description + * Broadcasted after a URL was changed. + * + * The `newState` and `oldState` parameters may be defined only in HTML5 mode and when + * the browser supports the HTML5 History API. + * + * @param {Object} angularEvent Synthetic event object. + * @param {string} newUrl New URL + * @param {string=} oldUrl URL that was before it was changed. + * @param {string=} newState New history state object + * @param {string=} oldState History state object that was before it was changed. + */ + + this.$get = ['$rootScope', '$browser', '$sniffer', '$rootElement', '$window', + function($rootScope, $browser, $sniffer, $rootElement, $window) { + var $location, + LocationMode, + baseHref = $browser.baseHref(), // if base[href] is undefined, it defaults to '' + initialUrl = $browser.url(), + appBase; + + if (html5Mode.enabled) { + if (!baseHref && html5Mode.requireBase) { + throw $locationMinErr('nobase', + "$location in HTML5 mode requires a tag to be present!"); + } + appBase = serverBase(initialUrl) + (baseHref || '/'); + LocationMode = $sniffer.history ? LocationHtml5Url : LocationHashbangInHtml5Url; + } else { + appBase = stripHash(initialUrl); + LocationMode = LocationHashbangUrl; + } + var appBaseNoFile = stripFile(appBase); + + $location = new LocationMode(appBase, appBaseNoFile, '#' + hashPrefix); + $location.$$parseLinkUrl(initialUrl, initialUrl); + + $location.$$state = $browser.state(); + + var IGNORE_URI_REGEXP = /^\s*(javascript|mailto):/i; + + function setBrowserUrlWithFallback(url, replace, state) { + var oldUrl = $location.url(); + var oldState = $location.$$state; + try { + $browser.url(url, replace, state); + + // Make sure $location.state() returns referentially identical (not just deeply equal) + // state object; this makes possible quick checking if the state changed in the digest + // loop. Checking deep equality would be too expensive. + $location.$$state = $browser.state(); + } catch (e) { + // Restore old values if pushState fails + $location.url(oldUrl); + $location.$$state = oldState; + + throw e; + } + } + + $rootElement.on('click', function(event) { + // TODO(vojta): rewrite link when opening in new tab/window (in legacy browser) + // currently we open nice url link and redirect then + + if (!html5Mode.rewriteLinks || event.ctrlKey || event.metaKey || event.shiftKey || event.which == 2 || event.button == 2) return; + + var elm = jqLite(event.target); + + // traverse the DOM up to find first A tag + while (nodeName_(elm[0]) !== 'a') { + // ignore rewriting if no A tag (reached root element, or no parent - removed from document) + if (elm[0] === $rootElement[0] || !(elm = elm.parent())[0]) return; + } + + var absHref = elm.prop('href'); + // get the actual href attribute - see + // http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx + var relHref = elm.attr('href') || elm.attr('xlink:href'); + + if (isObject(absHref) && absHref.toString() === '[object SVGAnimatedString]') { + // SVGAnimatedString.animVal should be identical to SVGAnimatedString.baseVal, unless during + // an animation. + absHref = urlResolve(absHref.animVal).href; + } + + // Ignore when url is started with javascript: or mailto: + if (IGNORE_URI_REGEXP.test(absHref)) return; + + if (absHref && !elm.attr('target') && !event.isDefaultPrevented()) { + if ($location.$$parseLinkUrl(absHref, relHref)) { + // We do a preventDefault for all urls that are part of the angular application, + // in html5mode and also without, so that we are able to abort navigation without + // getting double entries in the location history. + event.preventDefault(); + // update location manually + if ($location.absUrl() != $browser.url()) { + $rootScope.$apply(); + // hack to work around FF6 bug 684208 when scenario runner clicks on links + $window.angular['ff-684208-preventDefault'] = true; + } + } + } + }); + + + // rewrite hashbang url <> html5 url + if (trimEmptyHash($location.absUrl()) != trimEmptyHash(initialUrl)) { + $browser.url($location.absUrl(), true); + } + + var initializing = true; + + // update $location when $browser url changes + $browser.onUrlChange(function(newUrl, newState) { + + if (isUndefined(beginsWith(appBaseNoFile, newUrl))) { + // If we are navigating outside of the app then force a reload + $window.location.href = newUrl; + return; + } + + $rootScope.$evalAsync(function() { + var oldUrl = $location.absUrl(); + var oldState = $location.$$state; + var defaultPrevented; + + $location.$$parse(newUrl); + $location.$$state = newState; + + defaultPrevented = $rootScope.$broadcast('$locationChangeStart', newUrl, oldUrl, + newState, oldState).defaultPrevented; + + // if the location was changed by a `$locationChangeStart` handler then stop + // processing this location change + if ($location.absUrl() !== newUrl) return; + + if (defaultPrevented) { + $location.$$parse(oldUrl); + $location.$$state = oldState; + setBrowserUrlWithFallback(oldUrl, false, oldState); + } else { + initializing = false; + afterLocationChange(oldUrl, oldState); + } + }); + if (!$rootScope.$$phase) $rootScope.$digest(); + }); + + // update browser + $rootScope.$watch(function $locationWatch() { + var oldUrl = trimEmptyHash($browser.url()); + var newUrl = trimEmptyHash($location.absUrl()); + var oldState = $browser.state(); + var currentReplace = $location.$$replace; + var urlOrStateChanged = oldUrl !== newUrl || + ($location.$$html5 && $sniffer.history && oldState !== $location.$$state); + + if (initializing || urlOrStateChanged) { + initializing = false; + + $rootScope.$evalAsync(function() { + var newUrl = $location.absUrl(); + var defaultPrevented = $rootScope.$broadcast('$locationChangeStart', newUrl, oldUrl, + $location.$$state, oldState).defaultPrevented; + + // if the location was changed by a `$locationChangeStart` handler then stop + // processing this location change + if ($location.absUrl() !== newUrl) return; + + if (defaultPrevented) { + $location.$$parse(oldUrl); + $location.$$state = oldState; + } else { + if (urlOrStateChanged) { + setBrowserUrlWithFallback(newUrl, currentReplace, + oldState === $location.$$state ? null : $location.$$state); + } + afterLocationChange(oldUrl, oldState); + } + }); + } + + $location.$$replace = false; + + // we don't need to return anything because $evalAsync will make the digest loop dirty when + // there is a change + }); + + return $location; + + function afterLocationChange(oldUrl, oldState) { + $rootScope.$broadcast('$locationChangeSuccess', $location.absUrl(), oldUrl, + $location.$$state, oldState); + } +}]; +} + +/** + * @ngdoc service + * @name $log + * @requires $window + * + * @description + * Simple service for logging. Default implementation safely writes the message + * into the browser's console (if present). + * + * The main purpose of this service is to simplify debugging and troubleshooting. + * + * The default is to log `debug` messages. You can use + * {@link ng.$logProvider ng.$logProvider#debugEnabled} to change this. + * + * @example + + + angular.module('logExample', []) + .controller('LogController', ['$scope', '$log', function($scope, $log) { + $scope.$log = $log; + $scope.message = 'Hello World!'; + }]); + + +
+

Reload this page with open console, enter text and hit the log button...

+ + + + + + +
+
+
+ */ + +/** + * @ngdoc provider + * @name $logProvider + * @description + * Use the `$logProvider` to configure how the application logs messages + */ +function $LogProvider() { + var debug = true, + self = this; + + /** + * @ngdoc method + * @name $logProvider#debugEnabled + * @description + * @param {boolean=} flag enable or disable debug level messages + * @returns {*} current value if used as getter or itself (chaining) if used as setter + */ + this.debugEnabled = function(flag) { + if (isDefined(flag)) { + debug = flag; + return this; + } else { + return debug; + } + }; + + this.$get = ['$window', function($window) { + return { + /** + * @ngdoc method + * @name $log#log + * + * @description + * Write a log message + */ + log: consoleLog('log'), + + /** + * @ngdoc method + * @name $log#info + * + * @description + * Write an information message + */ + info: consoleLog('info'), + + /** + * @ngdoc method + * @name $log#warn + * + * @description + * Write a warning message + */ + warn: consoleLog('warn'), + + /** + * @ngdoc method + * @name $log#error + * + * @description + * Write an error message + */ + error: consoleLog('error'), + + /** + * @ngdoc method + * @name $log#debug + * + * @description + * Write a debug message + */ + debug: (function() { + var fn = consoleLog('debug'); + + return function() { + if (debug) { + fn.apply(self, arguments); + } + }; + }()) + }; + + function formatError(arg) { + if (arg instanceof Error) { + if (arg.stack) { + arg = (arg.message && arg.stack.indexOf(arg.message) === -1) + ? 'Error: ' + arg.message + '\n' + arg.stack + : arg.stack; + } else if (arg.sourceURL) { + arg = arg.message + '\n' + arg.sourceURL + ':' + arg.line; + } + } + return arg; + } + + function consoleLog(type) { + var console = $window.console || {}, + logFn = console[type] || console.log || noop, + hasApply = false; + + // Note: reading logFn.apply throws an error in IE11 in IE8 document mode. + // The reason behind this is that console.log has type "object" in IE8... + try { + hasApply = !!logFn.apply; + } catch (e) {} + + if (hasApply) { + return function() { + var args = []; + forEach(arguments, function(arg) { + args.push(formatError(arg)); + }); + return logFn.apply(console, args); + }; + } + + // we are IE which either doesn't have window.console => this is noop and we do nothing, + // or we are IE where console.log doesn't have apply so we log at least first 2 args + return function(arg1, arg2) { + logFn(arg1, arg2 == null ? '' : arg2); + }; + } + }]; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Any commits to this file should be reviewed with security in mind. * + * Changes to this file can potentially create security vulnerabilities. * + * An approval from 2 Core members with history of modifying * + * this file is required. * + * * + * Does the change somehow allow for arbitrary javascript to be executed? * + * Or allows for someone to change the prototype of built-in objects? * + * Or gives undesired access to variables likes document or window? * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +var $parseMinErr = minErr('$parse'); + +// Sandboxing Angular Expressions +// ------------------------------ +// Angular expressions are generally considered safe because these expressions only have direct +// access to `$scope` and locals. However, one can obtain the ability to execute arbitrary JS code by +// obtaining a reference to native JS functions such as the Function constructor. +// +// As an example, consider the following Angular expression: +// +// {}.toString.constructor('alert("evil JS code")') +// +// This sandboxing technique is not perfect and doesn't aim to be. The goal is to prevent exploits +// against the expression language, but not to prevent exploits that were enabled by exposing +// sensitive JavaScript or browser APIs on Scope. Exposing such objects on a Scope is never a good +// practice and therefore we are not even trying to protect against interaction with an object +// explicitly exposed in this way. +// +// In general, it is not possible to access a Window object from an angular expression unless a +// window or some DOM object that has a reference to window is published onto a Scope. +// Similarly we prevent invocations of function known to be dangerous, as well as assignments to +// native objects. +// +// See https://docs.angularjs.org/guide/security + + +function ensureSafeMemberName(name, fullExpression) { + // From the JavaScript docs: + // Property names must be strings. This means that non-string objects cannot be used + // as keys in an object. Any non-string object, including a number, is typecasted + // into a string via the toString method. + // + // So, to ensure that we are checking the same `name` that JavaScript would use, + // we cast it to a string, if possible + name = (isObject(name) && name.toString) ? name.toString() : name; + + if (name === "__defineGetter__" || name === "__defineSetter__" + || name === "__lookupGetter__" || name === "__lookupSetter__" + || name === "__proto__") { + throw $parseMinErr('isecfld', + 'Attempting to access a disallowed field in Angular expressions! ' + + 'Expression: {0}', fullExpression); + } + return name; +} + +function ensureSafeObject(obj, fullExpression) { + // nifty check if obj is Function that is fast and works across iframes and other contexts + if (obj) { + if (obj.constructor === obj) { + throw $parseMinErr('isecfn', + 'Referencing Function in Angular expressions is disallowed! Expression: {0}', + fullExpression); + } else if (// isWindow(obj) + obj.window === obj) { + throw $parseMinErr('isecwindow', + 'Referencing the Window in Angular expressions is disallowed! Expression: {0}', + fullExpression); + } else if (// isElement(obj) + obj.children && (obj.nodeName || (obj.prop && obj.attr && obj.find))) { + throw $parseMinErr('isecdom', + 'Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}', + fullExpression); + } else if (// block Object so that we can't get hold of dangerous Object.* methods + obj === Object) { + throw $parseMinErr('isecobj', + 'Referencing Object in Angular expressions is disallowed! Expression: {0}', + fullExpression); + } + } + return obj; +} + +var CALL = Function.prototype.call; +var APPLY = Function.prototype.apply; +var BIND = Function.prototype.bind; + +function ensureSafeFunction(obj, fullExpression) { + if (obj) { + if (obj.constructor === obj) { + throw $parseMinErr('isecfn', + 'Referencing Function in Angular expressions is disallowed! Expression: {0}', + fullExpression); + } else if (obj === CALL || obj === APPLY || obj === BIND) { + throw $parseMinErr('isecff', + 'Referencing call, apply or bind in Angular expressions is disallowed! Expression: {0}', + fullExpression); + } + } +} + +var OPERATORS = createMap(); +forEach('+ - * / % === !== == != < > <= >= && || ! = |'.split(' '), function(operator) { OPERATORS[operator] = true; }); +var ESCAPE = {"n":"\n", "f":"\f", "r":"\r", "t":"\t", "v":"\v", "'":"'", '"':'"'}; + + +///////////////////////////////////////// + + +/** + * @constructor + */ +var Lexer = function(options) { + this.options = options; +}; + +Lexer.prototype = { + constructor: Lexer, + + lex: function(text) { + this.text = text; + this.index = 0; + this.tokens = []; + + while (this.index < this.text.length) { + var ch = this.text.charAt(this.index); + if (ch === '"' || ch === "'") { + this.readString(ch); + } else if (this.isNumber(ch) || ch === '.' && this.isNumber(this.peek())) { + this.readNumber(); + } else if (this.isIdent(ch)) { + this.readIdent(); + } else if (this.is(ch, '(){}[].,;:?')) { + this.tokens.push({index: this.index, text: ch}); + this.index++; + } else if (this.isWhitespace(ch)) { + this.index++; + } else { + var ch2 = ch + this.peek(); + var ch3 = ch2 + this.peek(2); + var op1 = OPERATORS[ch]; + var op2 = OPERATORS[ch2]; + var op3 = OPERATORS[ch3]; + if (op1 || op2 || op3) { + var token = op3 ? ch3 : (op2 ? ch2 : ch); + this.tokens.push({index: this.index, text: token, operator: true}); + this.index += token.length; + } else { + this.throwError('Unexpected next character ', this.index, this.index + 1); + } + } + } + return this.tokens; + }, + + is: function(ch, chars) { + return chars.indexOf(ch) !== -1; + }, + + peek: function(i) { + var num = i || 1; + return (this.index + num < this.text.length) ? this.text.charAt(this.index + num) : false; + }, + + isNumber: function(ch) { + return ('0' <= ch && ch <= '9') && typeof ch === "string"; + }, + + isWhitespace: function(ch) { + // IE treats non-breaking space as \u00A0 + return (ch === ' ' || ch === '\r' || ch === '\t' || + ch === '\n' || ch === '\v' || ch === '\u00A0'); + }, + + isIdent: function(ch) { + return ('a' <= ch && ch <= 'z' || + 'A' <= ch && ch <= 'Z' || + '_' === ch || ch === '$'); + }, + + isExpOperator: function(ch) { + return (ch === '-' || ch === '+' || this.isNumber(ch)); + }, + + throwError: function(error, start, end) { + end = end || this.index; + var colStr = (isDefined(start) + ? 's ' + start + '-' + this.index + ' [' + this.text.substring(start, end) + ']' + : ' ' + end); + throw $parseMinErr('lexerr', 'Lexer Error: {0} at column{1} in expression [{2}].', + error, colStr, this.text); + }, + + readNumber: function() { + var number = ''; + var start = this.index; + while (this.index < this.text.length) { + var ch = lowercase(this.text.charAt(this.index)); + if (ch == '.' || this.isNumber(ch)) { + number += ch; + } else { + var peekCh = this.peek(); + if (ch == 'e' && this.isExpOperator(peekCh)) { + number += ch; + } else if (this.isExpOperator(ch) && + peekCh && this.isNumber(peekCh) && + number.charAt(number.length - 1) == 'e') { + number += ch; + } else if (this.isExpOperator(ch) && + (!peekCh || !this.isNumber(peekCh)) && + number.charAt(number.length - 1) == 'e') { + this.throwError('Invalid exponent'); + } else { + break; + } + } + this.index++; + } + this.tokens.push({ + index: start, + text: number, + constant: true, + value: Number(number) + }); + }, + + readIdent: function() { + var start = this.index; + while (this.index < this.text.length) { + var ch = this.text.charAt(this.index); + if (!(this.isIdent(ch) || this.isNumber(ch))) { + break; + } + this.index++; + } + this.tokens.push({ + index: start, + text: this.text.slice(start, this.index), + identifier: true + }); + }, + + readString: function(quote) { + var start = this.index; + this.index++; + var string = ''; + var rawString = quote; + var escape = false; + while (this.index < this.text.length) { + var ch = this.text.charAt(this.index); + rawString += ch; + if (escape) { + if (ch === 'u') { + var hex = this.text.substring(this.index + 1, this.index + 5); + if (!hex.match(/[\da-f]{4}/i)) { + this.throwError('Invalid unicode escape [\\u' + hex + ']'); + } + this.index += 4; + string += String.fromCharCode(parseInt(hex, 16)); + } else { + var rep = ESCAPE[ch]; + string = string + (rep || ch); + } + escape = false; + } else if (ch === '\\') { + escape = true; + } else if (ch === quote) { + this.index++; + this.tokens.push({ + index: start, + text: rawString, + constant: true, + value: string + }); + return; + } else { + string += ch; + } + this.index++; + } + this.throwError('Unterminated quote', start); + } +}; + +var AST = function(lexer, options) { + this.lexer = lexer; + this.options = options; +}; + +AST.Program = 'Program'; +AST.ExpressionStatement = 'ExpressionStatement'; +AST.AssignmentExpression = 'AssignmentExpression'; +AST.ConditionalExpression = 'ConditionalExpression'; +AST.LogicalExpression = 'LogicalExpression'; +AST.BinaryExpression = 'BinaryExpression'; +AST.UnaryExpression = 'UnaryExpression'; +AST.CallExpression = 'CallExpression'; +AST.MemberExpression = 'MemberExpression'; +AST.Identifier = 'Identifier'; +AST.Literal = 'Literal'; +AST.ArrayExpression = 'ArrayExpression'; +AST.Property = 'Property'; +AST.ObjectExpression = 'ObjectExpression'; +AST.ThisExpression = 'ThisExpression'; + +// Internal use only +AST.NGValueParameter = 'NGValueParameter'; + +AST.prototype = { + ast: function(text) { + this.text = text; + this.tokens = this.lexer.lex(text); + + var value = this.program(); + + if (this.tokens.length !== 0) { + this.throwError('is an unexpected token', this.tokens[0]); + } + + return value; + }, + + program: function() { + var body = []; + while (true) { + if (this.tokens.length > 0 && !this.peek('}', ')', ';', ']')) + body.push(this.expressionStatement()); + if (!this.expect(';')) { + return { type: AST.Program, body: body}; + } + } + }, + + expressionStatement: function() { + return { type: AST.ExpressionStatement, expression: this.filterChain() }; + }, + + filterChain: function() { + var left = this.expression(); + var token; + while ((token = this.expect('|'))) { + left = this.filter(left); + } + return left; + }, + + expression: function() { + return this.assignment(); + }, + + assignment: function() { + var result = this.ternary(); + if (this.expect('=')) { + result = { type: AST.AssignmentExpression, left: result, right: this.assignment(), operator: '='}; + } + return result; + }, + + ternary: function() { + var test = this.logicalOR(); + var alternate; + var consequent; + if (this.expect('?')) { + alternate = this.expression(); + if (this.consume(':')) { + consequent = this.expression(); + return { type: AST.ConditionalExpression, test: test, alternate: alternate, consequent: consequent}; + } + } + return test; + }, + + logicalOR: function() { + var left = this.logicalAND(); + while (this.expect('||')) { + left = { type: AST.LogicalExpression, operator: '||', left: left, right: this.logicalAND() }; + } + return left; + }, + + logicalAND: function() { + var left = this.equality(); + while (this.expect('&&')) { + left = { type: AST.LogicalExpression, operator: '&&', left: left, right: this.equality()}; + } + return left; + }, + + equality: function() { + var left = this.relational(); + var token; + while ((token = this.expect('==','!=','===','!=='))) { + left = { type: AST.BinaryExpression, operator: token.text, left: left, right: this.relational() }; + } + return left; + }, + + relational: function() { + var left = this.additive(); + var token; + while ((token = this.expect('<', '>', '<=', '>='))) { + left = { type: AST.BinaryExpression, operator: token.text, left: left, right: this.additive() }; + } + return left; + }, + + additive: function() { + var left = this.multiplicative(); + var token; + while ((token = this.expect('+','-'))) { + left = { type: AST.BinaryExpression, operator: token.text, left: left, right: this.multiplicative() }; + } + return left; + }, + + multiplicative: function() { + var left = this.unary(); + var token; + while ((token = this.expect('*','/','%'))) { + left = { type: AST.BinaryExpression, operator: token.text, left: left, right: this.unary() }; + } + return left; + }, + + unary: function() { + var token; + if ((token = this.expect('+', '-', '!'))) { + return { type: AST.UnaryExpression, operator: token.text, prefix: true, argument: this.unary() }; + } else { + return this.primary(); + } + }, + + primary: function() { + var primary; + if (this.expect('(')) { + primary = this.filterChain(); + this.consume(')'); + } else if (this.expect('[')) { + primary = this.arrayDeclaration(); + } else if (this.expect('{')) { + primary = this.object(); + } else if (this.constants.hasOwnProperty(this.peek().text)) { + primary = copy(this.constants[this.consume().text]); + } else if (this.peek().identifier) { + primary = this.identifier(); + } else if (this.peek().constant) { + primary = this.constant(); + } else { + this.throwError('not a primary expression', this.peek()); + } + + var next; + while ((next = this.expect('(', '[', '.'))) { + if (next.text === '(') { + primary = {type: AST.CallExpression, callee: primary, arguments: this.parseArguments() }; + this.consume(')'); + } else if (next.text === '[') { + primary = { type: AST.MemberExpression, object: primary, property: this.expression(), computed: true }; + this.consume(']'); + } else if (next.text === '.') { + primary = { type: AST.MemberExpression, object: primary, property: this.identifier(), computed: false }; + } else { + this.throwError('IMPOSSIBLE'); + } + } + return primary; + }, + + filter: function(baseExpression) { + var args = [baseExpression]; + var result = {type: AST.CallExpression, callee: this.identifier(), arguments: args, filter: true}; + + while (this.expect(':')) { + args.push(this.expression()); + } + + return result; + }, + + parseArguments: function() { + var args = []; + if (this.peekToken().text !== ')') { + do { + args.push(this.expression()); + } while (this.expect(',')); + } + return args; + }, + + identifier: function() { + var token = this.consume(); + if (!token.identifier) { + this.throwError('is not a valid identifier', token); + } + return { type: AST.Identifier, name: token.text }; + }, + + constant: function() { + // TODO check that it is a constant + return { type: AST.Literal, value: this.consume().value }; + }, + + arrayDeclaration: function() { + var elements = []; + if (this.peekToken().text !== ']') { + do { + if (this.peek(']')) { + // Support trailing commas per ES5.1. + break; + } + elements.push(this.expression()); + } while (this.expect(',')); + } + this.consume(']'); + + return { type: AST.ArrayExpression, elements: elements }; + }, + + object: function() { + var properties = [], property; + if (this.peekToken().text !== '}') { + do { + if (this.peek('}')) { + // Support trailing commas per ES5.1. + break; + } + property = {type: AST.Property, kind: 'init'}; + if (this.peek().constant) { + property.key = this.constant(); + } else if (this.peek().identifier) { + property.key = this.identifier(); + } else { + this.throwError("invalid key", this.peek()); + } + this.consume(':'); + property.value = this.expression(); + properties.push(property); + } while (this.expect(',')); + } + this.consume('}'); + + return {type: AST.ObjectExpression, properties: properties }; + }, + + throwError: function(msg, token) { + throw $parseMinErr('syntax', + 'Syntax Error: Token \'{0}\' {1} at column {2} of the expression [{3}] starting at [{4}].', + token.text, msg, (token.index + 1), this.text, this.text.substring(token.index)); + }, + + consume: function(e1) { + if (this.tokens.length === 0) { + throw $parseMinErr('ueoe', 'Unexpected end of expression: {0}', this.text); + } + + var token = this.expect(e1); + if (!token) { + this.throwError('is unexpected, expecting [' + e1 + ']', this.peek()); + } + return token; + }, + + peekToken: function() { + if (this.tokens.length === 0) { + throw $parseMinErr('ueoe', 'Unexpected end of expression: {0}', this.text); + } + return this.tokens[0]; + }, + + peek: function(e1, e2, e3, e4) { + return this.peekAhead(0, e1, e2, e3, e4); + }, + + peekAhead: function(i, e1, e2, e3, e4) { + if (this.tokens.length > i) { + var token = this.tokens[i]; + var t = token.text; + if (t === e1 || t === e2 || t === e3 || t === e4 || + (!e1 && !e2 && !e3 && !e4)) { + return token; + } + } + return false; + }, + + expect: function(e1, e2, e3, e4) { + var token = this.peek(e1, e2, e3, e4); + if (token) { + this.tokens.shift(); + return token; + } + return false; + }, + + + /* `undefined` is not a constant, it is an identifier, + * but using it as an identifier is not supported + */ + constants: { + 'true': { type: AST.Literal, value: true }, + 'false': { type: AST.Literal, value: false }, + 'null': { type: AST.Literal, value: null }, + 'undefined': {type: AST.Literal, value: undefined }, + 'this': {type: AST.ThisExpression } + } +}; + +function ifDefined(v, d) { + return typeof v !== 'undefined' ? v : d; +} + +function plusFn(l, r) { + if (typeof l === 'undefined') return r; + if (typeof r === 'undefined') return l; + return l + r; +} + +function isStateless($filter, filterName) { + var fn = $filter(filterName); + return !fn.$stateful; +} + +function findConstantAndWatchExpressions(ast, $filter) { + var allConstants; + var argsToWatch; + switch (ast.type) { + case AST.Program: + allConstants = true; + forEach(ast.body, function(expr) { + findConstantAndWatchExpressions(expr.expression, $filter); + allConstants = allConstants && expr.expression.constant; + }); + ast.constant = allConstants; + break; + case AST.Literal: + ast.constant = true; + ast.toWatch = []; + break; + case AST.UnaryExpression: + findConstantAndWatchExpressions(ast.argument, $filter); + ast.constant = ast.argument.constant; + ast.toWatch = ast.argument.toWatch; + break; + case AST.BinaryExpression: + findConstantAndWatchExpressions(ast.left, $filter); + findConstantAndWatchExpressions(ast.right, $filter); + ast.constant = ast.left.constant && ast.right.constant; + ast.toWatch = ast.left.toWatch.concat(ast.right.toWatch); + break; + case AST.LogicalExpression: + findConstantAndWatchExpressions(ast.left, $filter); + findConstantAndWatchExpressions(ast.right, $filter); + ast.constant = ast.left.constant && ast.right.constant; + ast.toWatch = ast.constant ? [] : [ast]; + break; + case AST.ConditionalExpression: + findConstantAndWatchExpressions(ast.test, $filter); + findConstantAndWatchExpressions(ast.alternate, $filter); + findConstantAndWatchExpressions(ast.consequent, $filter); + ast.constant = ast.test.constant && ast.alternate.constant && ast.consequent.constant; + ast.toWatch = ast.constant ? [] : [ast]; + break; + case AST.Identifier: + ast.constant = false; + ast.toWatch = [ast]; + break; + case AST.MemberExpression: + findConstantAndWatchExpressions(ast.object, $filter); + if (ast.computed) { + findConstantAndWatchExpressions(ast.property, $filter); + } + ast.constant = ast.object.constant && (!ast.computed || ast.property.constant); + ast.toWatch = [ast]; + break; + case AST.CallExpression: + allConstants = ast.filter ? isStateless($filter, ast.callee.name) : false; + argsToWatch = []; + forEach(ast.arguments, function(expr) { + findConstantAndWatchExpressions(expr, $filter); + allConstants = allConstants && expr.constant; + if (!expr.constant) { + argsToWatch.push.apply(argsToWatch, expr.toWatch); + } + }); + ast.constant = allConstants; + ast.toWatch = ast.filter && isStateless($filter, ast.callee.name) ? argsToWatch : [ast]; + break; + case AST.AssignmentExpression: + findConstantAndWatchExpressions(ast.left, $filter); + findConstantAndWatchExpressions(ast.right, $filter); + ast.constant = ast.left.constant && ast.right.constant; + ast.toWatch = [ast]; + break; + case AST.ArrayExpression: + allConstants = true; + argsToWatch = []; + forEach(ast.elements, function(expr) { + findConstantAndWatchExpressions(expr, $filter); + allConstants = allConstants && expr.constant; + if (!expr.constant) { + argsToWatch.push.apply(argsToWatch, expr.toWatch); + } + }); + ast.constant = allConstants; + ast.toWatch = argsToWatch; + break; + case AST.ObjectExpression: + allConstants = true; + argsToWatch = []; + forEach(ast.properties, function(property) { + findConstantAndWatchExpressions(property.value, $filter); + allConstants = allConstants && property.value.constant; + if (!property.value.constant) { + argsToWatch.push.apply(argsToWatch, property.value.toWatch); + } + }); + ast.constant = allConstants; + ast.toWatch = argsToWatch; + break; + case AST.ThisExpression: + ast.constant = false; + ast.toWatch = []; + break; + } +} + +function getInputs(body) { + if (body.length != 1) return; + var lastExpression = body[0].expression; + var candidate = lastExpression.toWatch; + if (candidate.length !== 1) return candidate; + return candidate[0] !== lastExpression ? candidate : undefined; +} + +function isAssignable(ast) { + return ast.type === AST.Identifier || ast.type === AST.MemberExpression; +} + +function assignableAST(ast) { + if (ast.body.length === 1 && isAssignable(ast.body[0].expression)) { + return {type: AST.AssignmentExpression, left: ast.body[0].expression, right: {type: AST.NGValueParameter}, operator: '='}; + } +} + +function isLiteral(ast) { + return ast.body.length === 0 || + ast.body.length === 1 && ( + ast.body[0].expression.type === AST.Literal || + ast.body[0].expression.type === AST.ArrayExpression || + ast.body[0].expression.type === AST.ObjectExpression); +} + +function isConstant(ast) { + return ast.constant; +} + +function ASTCompiler(astBuilder, $filter) { + this.astBuilder = astBuilder; + this.$filter = $filter; +} + +ASTCompiler.prototype = { + compile: function(expression, expensiveChecks) { + var self = this; + var ast = this.astBuilder.ast(expression); + this.state = { + nextId: 0, + filters: {}, + expensiveChecks: expensiveChecks, + fn: {vars: [], body: [], own: {}}, + assign: {vars: [], body: [], own: {}}, + inputs: [] + }; + findConstantAndWatchExpressions(ast, self.$filter); + var extra = ''; + var assignable; + this.stage = 'assign'; + if ((assignable = assignableAST(ast))) { + this.state.computing = 'assign'; + var result = this.nextId(); + this.recurse(assignable, result); + this.return_(result); + extra = 'fn.assign=' + this.generateFunction('assign', 's,v,l'); + } + var toWatch = getInputs(ast.body); + self.stage = 'inputs'; + forEach(toWatch, function(watch, key) { + var fnKey = 'fn' + key; + self.state[fnKey] = {vars: [], body: [], own: {}}; + self.state.computing = fnKey; + var intoId = self.nextId(); + self.recurse(watch, intoId); + self.return_(intoId); + self.state.inputs.push(fnKey); + watch.watchId = key; + }); + this.state.computing = 'fn'; + this.stage = 'main'; + this.recurse(ast); + var fnString = + // The build and minification steps remove the string "use strict" from the code, but this is done using a regex. + // This is a workaround for this until we do a better job at only removing the prefix only when we should. + '"' + this.USE + ' ' + this.STRICT + '";\n' + + this.filterPrefix() + + 'var fn=' + this.generateFunction('fn', 's,l,a,i') + + extra + + this.watchFns() + + 'return fn;'; + + /* jshint -W054 */ + var fn = (new Function('$filter', + 'ensureSafeMemberName', + 'ensureSafeObject', + 'ensureSafeFunction', + 'ifDefined', + 'plus', + 'text', + fnString))( + this.$filter, + ensureSafeMemberName, + ensureSafeObject, + ensureSafeFunction, + ifDefined, + plusFn, + expression); + /* jshint +W054 */ + this.state = this.stage = undefined; + fn.literal = isLiteral(ast); + fn.constant = isConstant(ast); + return fn; + }, + + USE: 'use', + + STRICT: 'strict', + + watchFns: function() { + var result = []; + var fns = this.state.inputs; + var self = this; + forEach(fns, function(name) { + result.push('var ' + name + '=' + self.generateFunction(name, 's')); + }); + if (fns.length) { + result.push('fn.inputs=[' + fns.join(',') + '];'); + } + return result.join(''); + }, + + generateFunction: function(name, params) { + return 'function(' + params + '){' + + this.varsPrefix(name) + + this.body(name) + + '};'; + }, + + filterPrefix: function() { + var parts = []; + var self = this; + forEach(this.state.filters, function(id, filter) { + parts.push(id + '=$filter(' + self.escape(filter) + ')'); + }); + if (parts.length) return 'var ' + parts.join(',') + ';'; + return ''; + }, + + varsPrefix: function(section) { + return this.state[section].vars.length ? 'var ' + this.state[section].vars.join(',') + ';' : ''; + }, + + body: function(section) { + return this.state[section].body.join(''); + }, + + recurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) { + var left, right, self = this, args, expression; + recursionFn = recursionFn || noop; + if (!skipWatchIdCheck && isDefined(ast.watchId)) { + intoId = intoId || this.nextId(); + this.if_('i', + this.lazyAssign(intoId, this.computedMember('i', ast.watchId)), + this.lazyRecurse(ast, intoId, nameId, recursionFn, create, true) + ); + return; + } + switch (ast.type) { + case AST.Program: + forEach(ast.body, function(expression, pos) { + self.recurse(expression.expression, undefined, undefined, function(expr) { right = expr; }); + if (pos !== ast.body.length - 1) { + self.current().body.push(right, ';'); + } else { + self.return_(right); + } + }); + break; + case AST.Literal: + expression = this.escape(ast.value); + this.assign(intoId, expression); + recursionFn(expression); + break; + case AST.UnaryExpression: + this.recurse(ast.argument, undefined, undefined, function(expr) { right = expr; }); + expression = ast.operator + '(' + this.ifDefined(right, 0) + ')'; + this.assign(intoId, expression); + recursionFn(expression); + break; + case AST.BinaryExpression: + this.recurse(ast.left, undefined, undefined, function(expr) { left = expr; }); + this.recurse(ast.right, undefined, undefined, function(expr) { right = expr; }); + if (ast.operator === '+') { + expression = this.plus(left, right); + } else if (ast.operator === '-') { + expression = this.ifDefined(left, 0) + ast.operator + this.ifDefined(right, 0); + } else { + expression = '(' + left + ')' + ast.operator + '(' + right + ')'; + } + this.assign(intoId, expression); + recursionFn(expression); + break; + case AST.LogicalExpression: + intoId = intoId || this.nextId(); + self.recurse(ast.left, intoId); + self.if_(ast.operator === '&&' ? intoId : self.not(intoId), self.lazyRecurse(ast.right, intoId)); + recursionFn(intoId); + break; + case AST.ConditionalExpression: + intoId = intoId || this.nextId(); + self.recurse(ast.test, intoId); + self.if_(intoId, self.lazyRecurse(ast.alternate, intoId), self.lazyRecurse(ast.consequent, intoId)); + recursionFn(intoId); + break; + case AST.Identifier: + intoId = intoId || this.nextId(); + if (nameId) { + nameId.context = self.stage === 'inputs' ? 's' : this.assign(this.nextId(), this.getHasOwnProperty('l', ast.name) + '?l:s'); + nameId.computed = false; + nameId.name = ast.name; + } + ensureSafeMemberName(ast.name); + self.if_(self.stage === 'inputs' || self.not(self.getHasOwnProperty('l', ast.name)), + function() { + self.if_(self.stage === 'inputs' || 's', function() { + if (create && create !== 1) { + self.if_( + self.not(self.nonComputedMember('s', ast.name)), + self.lazyAssign(self.nonComputedMember('s', ast.name), '{}')); + } + self.assign(intoId, self.nonComputedMember('s', ast.name)); + }); + }, intoId && self.lazyAssign(intoId, self.nonComputedMember('l', ast.name)) + ); + if (self.state.expensiveChecks || isPossiblyDangerousMemberName(ast.name)) { + self.addEnsureSafeObject(intoId); + } + recursionFn(intoId); + break; + case AST.MemberExpression: + left = nameId && (nameId.context = this.nextId()) || this.nextId(); + intoId = intoId || this.nextId(); + self.recurse(ast.object, left, undefined, function() { + self.if_(self.notNull(left), function() { + if (ast.computed) { + right = self.nextId(); + self.recurse(ast.property, right); + self.addEnsureSafeMemberName(right); + if (create && create !== 1) { + self.if_(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), '{}')); + } + expression = self.ensureSafeObject(self.computedMember(left, right)); + self.assign(intoId, expression); + if (nameId) { + nameId.computed = true; + nameId.name = right; + } + } else { + ensureSafeMemberName(ast.property.name); + if (create && create !== 1) { + self.if_(self.not(self.nonComputedMember(left, ast.property.name)), self.lazyAssign(self.nonComputedMember(left, ast.property.name), '{}')); + } + expression = self.nonComputedMember(left, ast.property.name); + if (self.state.expensiveChecks || isPossiblyDangerousMemberName(ast.property.name)) { + expression = self.ensureSafeObject(expression); + } + self.assign(intoId, expression); + if (nameId) { + nameId.computed = false; + nameId.name = ast.property.name; + } + } + }, function() { + self.assign(intoId, 'undefined'); + }); + recursionFn(intoId); + }, !!create); + break; + case AST.CallExpression: + intoId = intoId || this.nextId(); + if (ast.filter) { + right = self.filter(ast.callee.name); + args = []; + forEach(ast.arguments, function(expr) { + var argument = self.nextId(); + self.recurse(expr, argument); + args.push(argument); + }); + expression = right + '(' + args.join(',') + ')'; + self.assign(intoId, expression); + recursionFn(intoId); + } else { + right = self.nextId(); + left = {}; + args = []; + self.recurse(ast.callee, right, left, function() { + self.if_(self.notNull(right), function() { + self.addEnsureSafeFunction(right); + forEach(ast.arguments, function(expr) { + self.recurse(expr, self.nextId(), undefined, function(argument) { + args.push(self.ensureSafeObject(argument)); + }); + }); + if (left.name) { + if (!self.state.expensiveChecks) { + self.addEnsureSafeObject(left.context); + } + expression = self.member(left.context, left.name, left.computed) + '(' + args.join(',') + ')'; + } else { + expression = right + '(' + args.join(',') + ')'; + } + expression = self.ensureSafeObject(expression); + self.assign(intoId, expression); + }, function() { + self.assign(intoId, 'undefined'); + }); + recursionFn(intoId); + }); + } + break; + case AST.AssignmentExpression: + right = this.nextId(); + left = {}; + if (!isAssignable(ast.left)) { + throw $parseMinErr('lval', 'Trying to assing a value to a non l-value'); + } + this.recurse(ast.left, undefined, left, function() { + self.if_(self.notNull(left.context), function() { + self.recurse(ast.right, right); + self.addEnsureSafeObject(self.member(left.context, left.name, left.computed)); + expression = self.member(left.context, left.name, left.computed) + ast.operator + right; + self.assign(intoId, expression); + recursionFn(intoId || expression); + }); + }, 1); + break; + case AST.ArrayExpression: + args = []; + forEach(ast.elements, function(expr) { + self.recurse(expr, self.nextId(), undefined, function(argument) { + args.push(argument); + }); + }); + expression = '[' + args.join(',') + ']'; + this.assign(intoId, expression); + recursionFn(expression); + break; + case AST.ObjectExpression: + args = []; + forEach(ast.properties, function(property) { + self.recurse(property.value, self.nextId(), undefined, function(expr) { + args.push(self.escape( + property.key.type === AST.Identifier ? property.key.name : + ('' + property.key.value)) + + ':' + expr); + }); + }); + expression = '{' + args.join(',') + '}'; + this.assign(intoId, expression); + recursionFn(expression); + break; + case AST.ThisExpression: + this.assign(intoId, 's'); + recursionFn('s'); + break; + case AST.NGValueParameter: + this.assign(intoId, 'v'); + recursionFn('v'); + break; + } + }, + + getHasOwnProperty: function(element, property) { + var key = element + '.' + property; + var own = this.current().own; + if (!own.hasOwnProperty(key)) { + own[key] = this.nextId(false, element + '&&(' + this.escape(property) + ' in ' + element + ')'); + } + return own[key]; + }, + + assign: function(id, value) { + if (!id) return; + this.current().body.push(id, '=', value, ';'); + return id; + }, + + filter: function(filterName) { + if (!this.state.filters.hasOwnProperty(filterName)) { + this.state.filters[filterName] = this.nextId(true); + } + return this.state.filters[filterName]; + }, + + ifDefined: function(id, defaultValue) { + return 'ifDefined(' + id + ',' + this.escape(defaultValue) + ')'; + }, + + plus: function(left, right) { + return 'plus(' + left + ',' + right + ')'; + }, + + return_: function(id) { + this.current().body.push('return ', id, ';'); + }, + + if_: function(test, alternate, consequent) { + if (test === true) { + alternate(); + } else { + var body = this.current().body; + body.push('if(', test, '){'); + alternate(); + body.push('}'); + if (consequent) { + body.push('else{'); + consequent(); + body.push('}'); + } + } + }, + + not: function(expression) { + return '!(' + expression + ')'; + }, + + notNull: function(expression) { + return expression + '!=null'; + }, + + nonComputedMember: function(left, right) { + return left + '.' + right; + }, + + computedMember: function(left, right) { + return left + '[' + right + ']'; + }, + + member: function(left, right, computed) { + if (computed) return this.computedMember(left, right); + return this.nonComputedMember(left, right); + }, + + addEnsureSafeObject: function(item) { + this.current().body.push(this.ensureSafeObject(item), ';'); + }, + + addEnsureSafeMemberName: function(item) { + this.current().body.push(this.ensureSafeMemberName(item), ';'); + }, + + addEnsureSafeFunction: function(item) { + this.current().body.push(this.ensureSafeFunction(item), ';'); + }, + + ensureSafeObject: function(item) { + return 'ensureSafeObject(' + item + ',text)'; + }, + + ensureSafeMemberName: function(item) { + return 'ensureSafeMemberName(' + item + ',text)'; + }, + + ensureSafeFunction: function(item) { + return 'ensureSafeFunction(' + item + ',text)'; + }, + + lazyRecurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) { + var self = this; + return function() { + self.recurse(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck); + }; + }, + + lazyAssign: function(id, value) { + var self = this; + return function() { + self.assign(id, value); + }; + }, + + stringEscapeRegex: /[^ a-zA-Z0-9]/g, + + stringEscapeFn: function(c) { + return '\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4); + }, + + escape: function(value) { + if (isString(value)) return "'" + value.replace(this.stringEscapeRegex, this.stringEscapeFn) + "'"; + if (isNumber(value)) return value.toString(); + if (value === true) return 'true'; + if (value === false) return 'false'; + if (value === null) return 'null'; + if (typeof value === 'undefined') return 'undefined'; + + throw $parseMinErr('esc', 'IMPOSSIBLE'); + }, + + nextId: function(skip, init) { + var id = 'v' + (this.state.nextId++); + if (!skip) { + this.current().vars.push(id + (init ? '=' + init : '')); + } + return id; + }, + + current: function() { + return this.state[this.state.computing]; + } +}; + + +function ASTInterpreter(astBuilder, $filter) { + this.astBuilder = astBuilder; + this.$filter = $filter; +} + +ASTInterpreter.prototype = { + compile: function(expression, expensiveChecks) { + var self = this; + var ast = this.astBuilder.ast(expression); + this.expression = expression; + this.expensiveChecks = expensiveChecks; + findConstantAndWatchExpressions(ast, self.$filter); + var assignable; + var assign; + if ((assignable = assignableAST(ast))) { + assign = this.recurse(assignable); + } + var toWatch = getInputs(ast.body); + var inputs; + if (toWatch) { + inputs = []; + forEach(toWatch, function(watch, key) { + var input = self.recurse(watch); + watch.input = input; + inputs.push(input); + watch.watchId = key; + }); + } + var expressions = []; + forEach(ast.body, function(expression) { + expressions.push(self.recurse(expression.expression)); + }); + var fn = ast.body.length === 0 ? function() {} : + ast.body.length === 1 ? expressions[0] : + function(scope, locals) { + var lastValue; + forEach(expressions, function(exp) { + lastValue = exp(scope, locals); + }); + return lastValue; + }; + if (assign) { + fn.assign = function(scope, value, locals) { + return assign(scope, locals, value); + }; + } + if (inputs) { + fn.inputs = inputs; + } + fn.literal = isLiteral(ast); + fn.constant = isConstant(ast); + return fn; + }, + + recurse: function(ast, context, create) { + var left, right, self = this, args, expression; + if (ast.input) { + return this.inputs(ast.input, ast.watchId); + } + switch (ast.type) { + case AST.Literal: + return this.value(ast.value, context); + case AST.UnaryExpression: + right = this.recurse(ast.argument); + return this['unary' + ast.operator](right, context); + case AST.BinaryExpression: + left = this.recurse(ast.left); + right = this.recurse(ast.right); + return this['binary' + ast.operator](left, right, context); + case AST.LogicalExpression: + left = this.recurse(ast.left); + right = this.recurse(ast.right); + return this['binary' + ast.operator](left, right, context); + case AST.ConditionalExpression: + return this['ternary?:']( + this.recurse(ast.test), + this.recurse(ast.alternate), + this.recurse(ast.consequent), + context + ); + case AST.Identifier: + ensureSafeMemberName(ast.name, self.expression); + return self.identifier(ast.name, + self.expensiveChecks || isPossiblyDangerousMemberName(ast.name), + context, create, self.expression); + case AST.MemberExpression: + left = this.recurse(ast.object, false, !!create); + if (!ast.computed) { + ensureSafeMemberName(ast.property.name, self.expression); + right = ast.property.name; + } + if (ast.computed) right = this.recurse(ast.property); + return ast.computed ? + this.computedMember(left, right, context, create, self.expression) : + this.nonComputedMember(left, right, self.expensiveChecks, context, create, self.expression); + case AST.CallExpression: + args = []; + forEach(ast.arguments, function(expr) { + args.push(self.recurse(expr)); + }); + if (ast.filter) right = this.$filter(ast.callee.name); + if (!ast.filter) right = this.recurse(ast.callee, true); + return ast.filter ? + function(scope, locals, assign, inputs) { + var values = []; + for (var i = 0; i < args.length; ++i) { + values.push(args[i](scope, locals, assign, inputs)); + } + var value = right.apply(undefined, values, inputs); + return context ? {context: undefined, name: undefined, value: value} : value; + } : + function(scope, locals, assign, inputs) { + var rhs = right(scope, locals, assign, inputs); + var value; + if (rhs.value != null) { + ensureSafeObject(rhs.context, self.expression); + ensureSafeFunction(rhs.value, self.expression); + var values = []; + for (var i = 0; i < args.length; ++i) { + values.push(ensureSafeObject(args[i](scope, locals, assign, inputs), self.expression)); + } + value = ensureSafeObject(rhs.value.apply(rhs.context, values), self.expression); + } + return context ? {value: value} : value; + }; + case AST.AssignmentExpression: + left = this.recurse(ast.left, true, 1); + right = this.recurse(ast.right); + return function(scope, locals, assign, inputs) { + var lhs = left(scope, locals, assign, inputs); + var rhs = right(scope, locals, assign, inputs); + ensureSafeObject(lhs.value, self.expression); + lhs.context[lhs.name] = rhs; + return context ? {value: rhs} : rhs; + }; + case AST.ArrayExpression: + args = []; + forEach(ast.elements, function(expr) { + args.push(self.recurse(expr)); + }); + return function(scope, locals, assign, inputs) { + var value = []; + for (var i = 0; i < args.length; ++i) { + value.push(args[i](scope, locals, assign, inputs)); + } + return context ? {value: value} : value; + }; + case AST.ObjectExpression: + args = []; + forEach(ast.properties, function(property) { + args.push({key: property.key.type === AST.Identifier ? + property.key.name : + ('' + property.key.value), + value: self.recurse(property.value) + }); + }); + return function(scope, locals, assign, inputs) { + var value = {}; + for (var i = 0; i < args.length; ++i) { + value[args[i].key] = args[i].value(scope, locals, assign, inputs); + } + return context ? {value: value} : value; + }; + case AST.ThisExpression: + return function(scope) { + return context ? {value: scope} : scope; + }; + case AST.NGValueParameter: + return function(scope, locals, assign, inputs) { + return context ? {value: assign} : assign; + }; + } + }, + + 'unary+': function(argument, context) { + return function(scope, locals, assign, inputs) { + var arg = argument(scope, locals, assign, inputs); + if (isDefined(arg)) { + arg = +arg; + } else { + arg = 0; + } + return context ? {value: arg} : arg; + }; + }, + 'unary-': function(argument, context) { + return function(scope, locals, assign, inputs) { + var arg = argument(scope, locals, assign, inputs); + if (isDefined(arg)) { + arg = -arg; + } else { + arg = 0; + } + return context ? {value: arg} : arg; + }; + }, + 'unary!': function(argument, context) { + return function(scope, locals, assign, inputs) { + var arg = !argument(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary+': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var lhs = left(scope, locals, assign, inputs); + var rhs = right(scope, locals, assign, inputs); + var arg = plusFn(lhs, rhs); + return context ? {value: arg} : arg; + }; + }, + 'binary-': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var lhs = left(scope, locals, assign, inputs); + var rhs = right(scope, locals, assign, inputs); + var arg = (isDefined(lhs) ? lhs : 0) - (isDefined(rhs) ? rhs : 0); + return context ? {value: arg} : arg; + }; + }, + 'binary*': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) * right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary/': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) / right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary%': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) % right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary===': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) === right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary!==': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) !== right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary==': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) == right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary!=': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) != right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary<': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) < right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary>': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) > right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary<=': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) <= right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary>=': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) >= right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary&&': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) && right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'binary||': function(left, right, context) { + return function(scope, locals, assign, inputs) { + var arg = left(scope, locals, assign, inputs) || right(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + 'ternary?:': function(test, alternate, consequent, context) { + return function(scope, locals, assign, inputs) { + var arg = test(scope, locals, assign, inputs) ? alternate(scope, locals, assign, inputs) : consequent(scope, locals, assign, inputs); + return context ? {value: arg} : arg; + }; + }, + value: function(value, context) { + return function() { return context ? {context: undefined, name: undefined, value: value} : value; }; + }, + identifier: function(name, expensiveChecks, context, create, expression) { + return function(scope, locals, assign, inputs) { + var base = locals && (name in locals) ? locals : scope; + if (create && create !== 1 && base && !(base[name])) { + base[name] = {}; + } + var value = base ? base[name] : undefined; + if (expensiveChecks) { + ensureSafeObject(value, expression); + } + if (context) { + return {context: base, name: name, value: value}; + } else { + return value; + } + }; + }, + computedMember: function(left, right, context, create, expression) { + return function(scope, locals, assign, inputs) { + var lhs = left(scope, locals, assign, inputs); + var rhs; + var value; + if (lhs != null) { + rhs = right(scope, locals, assign, inputs); + ensureSafeMemberName(rhs, expression); + if (create && create !== 1 && lhs && !(lhs[rhs])) { + lhs[rhs] = {}; + } + value = lhs[rhs]; + ensureSafeObject(value, expression); + } + if (context) { + return {context: lhs, name: rhs, value: value}; + } else { + return value; + } + }; + }, + nonComputedMember: function(left, right, expensiveChecks, context, create, expression) { + return function(scope, locals, assign, inputs) { + var lhs = left(scope, locals, assign, inputs); + if (create && create !== 1 && lhs && !(lhs[right])) { + lhs[right] = {}; + } + var value = lhs != null ? lhs[right] : undefined; + if (expensiveChecks || isPossiblyDangerousMemberName(right)) { + ensureSafeObject(value, expression); + } + if (context) { + return {context: lhs, name: right, value: value}; + } else { + return value; + } + }; + }, + inputs: function(input, watchId) { + return function(scope, value, locals, inputs) { + if (inputs) return inputs[watchId]; + return input(scope, value, locals); + }; + } +}; + +/** + * @constructor + */ +var Parser = function(lexer, $filter, options) { + this.lexer = lexer; + this.$filter = $filter; + this.options = options; + this.ast = new AST(this.lexer); + this.astCompiler = options.csp ? new ASTInterpreter(this.ast, $filter) : + new ASTCompiler(this.ast, $filter); +}; + +Parser.prototype = { + constructor: Parser, + + parse: function(text) { + return this.astCompiler.compile(text, this.options.expensiveChecks); + } +}; + +var getterFnCacheDefault = createMap(); +var getterFnCacheExpensive = createMap(); + +function isPossiblyDangerousMemberName(name) { + return name == 'constructor'; +} + +var objectValueOf = Object.prototype.valueOf; + +function getValueOf(value) { + return isFunction(value.valueOf) ? value.valueOf() : objectValueOf.call(value); +} + +/////////////////////////////////// + +/** + * @ngdoc service + * @name $parse + * @kind function + * + * @description + * + * Converts Angular {@link guide/expression expression} into a function. + * + * ```js + * var getter = $parse('user.name'); + * var setter = getter.assign; + * var context = {user:{name:'angular'}}; + * var locals = {user:{name:'local'}}; + * + * expect(getter(context)).toEqual('angular'); + * setter(context, 'newValue'); + * expect(context.user.name).toEqual('newValue'); + * expect(getter(context, locals)).toEqual('local'); + * ``` + * + * + * @param {string} expression String expression to compile. + * @returns {function(context, locals)} a function which represents the compiled expression: + * + * * `context` – `{object}` – an object against which any expressions embedded in the strings + * are evaluated against (typically a scope object). + * * `locals` – `{object=}` – local variables context object, useful for overriding values in + * `context`. + * + * The returned function also has the following properties: + * * `literal` – `{boolean}` – whether the expression's top-level node is a JavaScript + * literal. + * * `constant` – `{boolean}` – whether the expression is made entirely of JavaScript + * constant literals. + * * `assign` – `{?function(context, value)}` – if the expression is assignable, this will be + * set to a function to change its value on the given context. + * + */ + + +/** + * @ngdoc provider + * @name $parseProvider + * + * @description + * `$parseProvider` can be used for configuring the default behavior of the {@link ng.$parse $parse} + * service. + */ +function $ParseProvider() { + var cacheDefault = createMap(); + var cacheExpensive = createMap(); + + this.$get = ['$filter', function($filter) { + var noUnsafeEval = csp().noUnsafeEval; + var $parseOptions = { + csp: noUnsafeEval, + expensiveChecks: false + }, + $parseOptionsExpensive = { + csp: noUnsafeEval, + expensiveChecks: true + }; + + return function $parse(exp, interceptorFn, expensiveChecks) { + var parsedExpression, oneTime, cacheKey; + + switch (typeof exp) { + case 'string': + exp = exp.trim(); + cacheKey = exp; + + var cache = (expensiveChecks ? cacheExpensive : cacheDefault); + parsedExpression = cache[cacheKey]; + + if (!parsedExpression) { + if (exp.charAt(0) === ':' && exp.charAt(1) === ':') { + oneTime = true; + exp = exp.substring(2); + } + var parseOptions = expensiveChecks ? $parseOptionsExpensive : $parseOptions; + var lexer = new Lexer(parseOptions); + var parser = new Parser(lexer, $filter, parseOptions); + parsedExpression = parser.parse(exp); + if (parsedExpression.constant) { + parsedExpression.$$watchDelegate = constantWatchDelegate; + } else if (oneTime) { + parsedExpression.$$watchDelegate = parsedExpression.literal ? + oneTimeLiteralWatchDelegate : oneTimeWatchDelegate; + } else if (parsedExpression.inputs) { + parsedExpression.$$watchDelegate = inputsWatchDelegate; + } + cache[cacheKey] = parsedExpression; + } + return addInterceptor(parsedExpression, interceptorFn); + + case 'function': + return addInterceptor(exp, interceptorFn); + + default: + return noop; + } + }; + + function expressionInputDirtyCheck(newValue, oldValueOfValue) { + + if (newValue == null || oldValueOfValue == null) { // null/undefined + return newValue === oldValueOfValue; + } + + if (typeof newValue === 'object') { + + // attempt to convert the value to a primitive type + // TODO(docs): add a note to docs that by implementing valueOf even objects and arrays can + // be cheaply dirty-checked + newValue = getValueOf(newValue); + + if (typeof newValue === 'object') { + // objects/arrays are not supported - deep-watching them would be too expensive + return false; + } + + // fall-through to the primitive equality check + } + + //Primitive or NaN + return newValue === oldValueOfValue || (newValue !== newValue && oldValueOfValue !== oldValueOfValue); + } + + function inputsWatchDelegate(scope, listener, objectEquality, parsedExpression, prettyPrintExpression) { + var inputExpressions = parsedExpression.inputs; + var lastResult; + + if (inputExpressions.length === 1) { + var oldInputValueOf = expressionInputDirtyCheck; // init to something unique so that equals check fails + inputExpressions = inputExpressions[0]; + return scope.$watch(function expressionInputWatch(scope) { + var newInputValue = inputExpressions(scope); + if (!expressionInputDirtyCheck(newInputValue, oldInputValueOf)) { + lastResult = parsedExpression(scope, undefined, undefined, [newInputValue]); + oldInputValueOf = newInputValue && getValueOf(newInputValue); + } + return lastResult; + }, listener, objectEquality, prettyPrintExpression); + } + + var oldInputValueOfValues = []; + var oldInputValues = []; + for (var i = 0, ii = inputExpressions.length; i < ii; i++) { + oldInputValueOfValues[i] = expressionInputDirtyCheck; // init to something unique so that equals check fails + oldInputValues[i] = null; + } + + return scope.$watch(function expressionInputsWatch(scope) { + var changed = false; + + for (var i = 0, ii = inputExpressions.length; i < ii; i++) { + var newInputValue = inputExpressions[i](scope); + if (changed || (changed = !expressionInputDirtyCheck(newInputValue, oldInputValueOfValues[i]))) { + oldInputValues[i] = newInputValue; + oldInputValueOfValues[i] = newInputValue && getValueOf(newInputValue); + } + } + + if (changed) { + lastResult = parsedExpression(scope, undefined, undefined, oldInputValues); + } + + return lastResult; + }, listener, objectEquality, prettyPrintExpression); + } + + function oneTimeWatchDelegate(scope, listener, objectEquality, parsedExpression) { + var unwatch, lastValue; + return unwatch = scope.$watch(function oneTimeWatch(scope) { + return parsedExpression(scope); + }, function oneTimeListener(value, old, scope) { + lastValue = value; + if (isFunction(listener)) { + listener.apply(this, arguments); + } + if (isDefined(value)) { + scope.$$postDigest(function() { + if (isDefined(lastValue)) { + unwatch(); + } + }); + } + }, objectEquality); + } + + function oneTimeLiteralWatchDelegate(scope, listener, objectEquality, parsedExpression) { + var unwatch, lastValue; + return unwatch = scope.$watch(function oneTimeWatch(scope) { + return parsedExpression(scope); + }, function oneTimeListener(value, old, scope) { + lastValue = value; + if (isFunction(listener)) { + listener.call(this, value, old, scope); + } + if (isAllDefined(value)) { + scope.$$postDigest(function() { + if (isAllDefined(lastValue)) unwatch(); + }); + } + }, objectEquality); + + function isAllDefined(value) { + var allDefined = true; + forEach(value, function(val) { + if (!isDefined(val)) allDefined = false; + }); + return allDefined; + } + } + + function constantWatchDelegate(scope, listener, objectEquality, parsedExpression) { + var unwatch; + return unwatch = scope.$watch(function constantWatch(scope) { + return parsedExpression(scope); + }, function constantListener(value, old, scope) { + if (isFunction(listener)) { + listener.apply(this, arguments); + } + unwatch(); + }, objectEquality); + } + + function addInterceptor(parsedExpression, interceptorFn) { + if (!interceptorFn) return parsedExpression; + var watchDelegate = parsedExpression.$$watchDelegate; + + var regularWatch = + watchDelegate !== oneTimeLiteralWatchDelegate && + watchDelegate !== oneTimeWatchDelegate; + + var fn = regularWatch ? function regularInterceptedExpression(scope, locals, assign, inputs) { + var value = parsedExpression(scope, locals, assign, inputs); + return interceptorFn(value, scope, locals); + } : function oneTimeInterceptedExpression(scope, locals, assign, inputs) { + var value = parsedExpression(scope, locals, assign, inputs); + var result = interceptorFn(value, scope, locals); + // we only return the interceptor's result if the + // initial value is defined (for bind-once) + return isDefined(value) ? result : value; + }; + + // Propagate $$watchDelegates other then inputsWatchDelegate + if (parsedExpression.$$watchDelegate && + parsedExpression.$$watchDelegate !== inputsWatchDelegate) { + fn.$$watchDelegate = parsedExpression.$$watchDelegate; + } else if (!interceptorFn.$stateful) { + // If there is an interceptor, but no watchDelegate then treat the interceptor like + // we treat filters - it is assumed to be a pure function unless flagged with $stateful + fn.$$watchDelegate = inputsWatchDelegate; + fn.inputs = parsedExpression.inputs ? parsedExpression.inputs : [parsedExpression]; + } + + return fn; + } + }]; +} + +/** + * @ngdoc service + * @name $q + * @requires $rootScope + * + * @description + * A service that helps you run functions asynchronously, and use their return values (or exceptions) + * when they are done processing. + * + * This is an implementation of promises/deferred objects inspired by + * [Kris Kowal's Q](https://github.com/kriskowal/q). + * + * $q can be used in two fashions --- one which is more similar to Kris Kowal's Q or jQuery's Deferred + * implementations, and the other which resembles ES6 promises to some degree. + * + * # $q constructor + * + * The streamlined ES6 style promise is essentially just using $q as a constructor which takes a `resolver` + * function as the first argument. This is similar to the native Promise implementation from ES6 Harmony, + * see [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). + * + * While the constructor-style use is supported, not all of the supporting methods from ES6 Harmony promises are + * available yet. + * + * It can be used like so: + * + * ```js + * // for the purpose of this example let's assume that variables `$q` and `okToGreet` + * // are available in the current lexical scope (they could have been injected or passed in). + * + * function asyncGreet(name) { + * // perform some asynchronous operation, resolve or reject the promise when appropriate. + * return $q(function(resolve, reject) { + * setTimeout(function() { + * if (okToGreet(name)) { + * resolve('Hello, ' + name + '!'); + * } else { + * reject('Greeting ' + name + ' is not allowed.'); + * } + * }, 1000); + * }); + * } + * + * var promise = asyncGreet('Robin Hood'); + * promise.then(function(greeting) { + * alert('Success: ' + greeting); + * }, function(reason) { + * alert('Failed: ' + reason); + * }); + * ``` + * + * Note: progress/notify callbacks are not currently supported via the ES6-style interface. + * + * However, the more traditional CommonJS-style usage is still available, and documented below. + * + * [The CommonJS Promise proposal](http://wiki.commonjs.org/wiki/Promises) describes a promise as an + * interface for interacting with an object that represents the result of an action that is + * performed asynchronously, and may or may not be finished at any given point in time. + * + * From the perspective of dealing with error handling, deferred and promise APIs are to + * asynchronous programming what `try`, `catch` and `throw` keywords are to synchronous programming. + * + * ```js + * // for the purpose of this example let's assume that variables `$q` and `okToGreet` + * // are available in the current lexical scope (they could have been injected or passed in). + * + * function asyncGreet(name) { + * var deferred = $q.defer(); + * + * setTimeout(function() { + * deferred.notify('About to greet ' + name + '.'); + * + * if (okToGreet(name)) { + * deferred.resolve('Hello, ' + name + '!'); + * } else { + * deferred.reject('Greeting ' + name + ' is not allowed.'); + * } + * }, 1000); + * + * return deferred.promise; + * } + * + * var promise = asyncGreet('Robin Hood'); + * promise.then(function(greeting) { + * alert('Success: ' + greeting); + * }, function(reason) { + * alert('Failed: ' + reason); + * }, function(update) { + * alert('Got notification: ' + update); + * }); + * ``` + * + * At first it might not be obvious why this extra complexity is worth the trouble. The payoff + * comes in the way of guarantees that promise and deferred APIs make, see + * https://github.com/kriskowal/uncommonjs/blob/master/promises/specification.md. + * + * Additionally the promise api allows for composition that is very hard to do with the + * traditional callback ([CPS](http://en.wikipedia.org/wiki/Continuation-passing_style)) approach. + * For more on this please see the [Q documentation](https://github.com/kriskowal/q) especially the + * section on serial or parallel joining of promises. + * + * # The Deferred API + * + * A new instance of deferred is constructed by calling `$q.defer()`. + * + * The purpose of the deferred object is to expose the associated Promise instance as well as APIs + * that can be used for signaling the successful or unsuccessful completion, as well as the status + * of the task. + * + * **Methods** + * + * - `resolve(value)` – resolves the derived promise with the `value`. If the value is a rejection + * constructed via `$q.reject`, the promise will be rejected instead. + * - `reject(reason)` – rejects the derived promise with the `reason`. This is equivalent to + * resolving it with a rejection constructed via `$q.reject`. + * - `notify(value)` - provides updates on the status of the promise's execution. This may be called + * multiple times before the promise is either resolved or rejected. + * + * **Properties** + * + * - promise – `{Promise}` – promise object associated with this deferred. + * + * + * # The Promise API + * + * A new promise instance is created when a deferred instance is created and can be retrieved by + * calling `deferred.promise`. + * + * The purpose of the promise object is to allow for interested parties to get access to the result + * of the deferred task when it completes. + * + * **Methods** + * + * - `then(successCallback, errorCallback, notifyCallback)` – regardless of when the promise was or + * will be resolved or rejected, `then` calls one of the success or error callbacks asynchronously + * as soon as the result is available. The callbacks are called with a single argument: the result + * or rejection reason. Additionally, the notify callback may be called zero or more times to + * provide a progress indication, before the promise is resolved or rejected. + * + * This method *returns a new promise* which is resolved or rejected via the return value of the + * `successCallback`, `errorCallback` (unless that value is a promise, in which case it is resolved + * with the value which is resolved in that promise using + * [promise chaining](http://www.html5rocks.com/en/tutorials/es6/promises/#toc-promises-queues)). + * It also notifies via the return value of the `notifyCallback` method. The promise cannot be + * resolved or rejected from the notifyCallback method. + * + * - `catch(errorCallback)` – shorthand for `promise.then(null, errorCallback)` + * + * - `finally(callback, notifyCallback)` – allows you to observe either the fulfillment or rejection of a promise, + * but to do so without modifying the final value. This is useful to release resources or do some + * clean-up that needs to be done whether the promise was rejected or resolved. See the [full + * specification](https://github.com/kriskowal/q/wiki/API-Reference#promisefinallycallback) for + * more information. + * + * # Chaining promises + * + * Because calling the `then` method of a promise returns a new derived promise, it is easily + * possible to create a chain of promises: + * + * ```js + * promiseB = promiseA.then(function(result) { + * return result + 1; + * }); + * + * // promiseB will be resolved immediately after promiseA is resolved and its value + * // will be the result of promiseA incremented by 1 + * ``` + * + * It is possible to create chains of any length and since a promise can be resolved with another + * promise (which will defer its resolution further), it is possible to pause/defer resolution of + * the promises at any point in the chain. This makes it possible to implement powerful APIs like + * $http's response interceptors. + * + * + * # Differences between Kris Kowal's Q and $q + * + * There are two main differences: + * + * - $q is integrated with the {@link ng.$rootScope.Scope} Scope model observation + * mechanism in angular, which means faster propagation of resolution or rejection into your + * models and avoiding unnecessary browser repaints, which would result in flickering UI. + * - Q has many more features than $q, but that comes at a cost of bytes. $q is tiny, but contains + * all the important functionality needed for common async tasks. + * + * # Testing + * + * ```js + * it('should simulate promise', inject(function($q, $rootScope) { + * var deferred = $q.defer(); + * var promise = deferred.promise; + * var resolvedValue; + * + * promise.then(function(value) { resolvedValue = value; }); + * expect(resolvedValue).toBeUndefined(); + * + * // Simulate resolving of promise + * deferred.resolve(123); + * // Note that the 'then' function does not get called synchronously. + * // This is because we want the promise API to always be async, whether or not + * // it got called synchronously or asynchronously. + * expect(resolvedValue).toBeUndefined(); + * + * // Propagate promise resolution to 'then' functions using $apply(). + * $rootScope.$apply(); + * expect(resolvedValue).toEqual(123); + * })); + * ``` + * + * @param {function(function, function)} resolver Function which is responsible for resolving or + * rejecting the newly created promise. The first parameter is a function which resolves the + * promise, the second parameter is a function which rejects the promise. + * + * @returns {Promise} The newly created promise. + */ +function $QProvider() { + + this.$get = ['$rootScope', '$exceptionHandler', function($rootScope, $exceptionHandler) { + return qFactory(function(callback) { + $rootScope.$evalAsync(callback); + }, $exceptionHandler); + }]; +} + +function $$QProvider() { + this.$get = ['$browser', '$exceptionHandler', function($browser, $exceptionHandler) { + return qFactory(function(callback) { + $browser.defer(callback); + }, $exceptionHandler); + }]; +} + +/** + * Constructs a promise manager. + * + * @param {function(function)} nextTick Function for executing functions in the next turn. + * @param {function(...*)} exceptionHandler Function into which unexpected exceptions are passed for + * debugging purposes. + * @returns {object} Promise manager. + */ +function qFactory(nextTick, exceptionHandler) { + var $qMinErr = minErr('$q', TypeError); + function callOnce(self, resolveFn, rejectFn) { + var called = false; + function wrap(fn) { + return function(value) { + if (called) return; + called = true; + fn.call(self, value); + }; + } + + return [wrap(resolveFn), wrap(rejectFn)]; + } + + /** + * @ngdoc method + * @name ng.$q#defer + * @kind function + * + * @description + * Creates a `Deferred` object which represents a task which will finish in the future. + * + * @returns {Deferred} Returns a new instance of deferred. + */ + var defer = function() { + return new Deferred(); + }; + + function Promise() { + this.$$state = { status: 0 }; + } + + extend(Promise.prototype, { + then: function(onFulfilled, onRejected, progressBack) { + if (isUndefined(onFulfilled) && isUndefined(onRejected) && isUndefined(progressBack)) { + return this; + } + var result = new Deferred(); + + this.$$state.pending = this.$$state.pending || []; + this.$$state.pending.push([result, onFulfilled, onRejected, progressBack]); + if (this.$$state.status > 0) scheduleProcessQueue(this.$$state); + + return result.promise; + }, + + "catch": function(callback) { + return this.then(null, callback); + }, + + "finally": function(callback, progressBack) { + return this.then(function(value) { + return handleCallback(value, true, callback); + }, function(error) { + return handleCallback(error, false, callback); + }, progressBack); + } + }); + + //Faster, more basic than angular.bind http://jsperf.com/angular-bind-vs-custom-vs-native + function simpleBind(context, fn) { + return function(value) { + fn.call(context, value); + }; + } + + function processQueue(state) { + var fn, deferred, pending; + + pending = state.pending; + state.processScheduled = false; + state.pending = undefined; + for (var i = 0, ii = pending.length; i < ii; ++i) { + deferred = pending[i][0]; + fn = pending[i][state.status]; + try { + if (isFunction(fn)) { + deferred.resolve(fn(state.value)); + } else if (state.status === 1) { + deferred.resolve(state.value); + } else { + deferred.reject(state.value); + } + } catch (e) { + deferred.reject(e); + exceptionHandler(e); + } + } + } + + function scheduleProcessQueue(state) { + if (state.processScheduled || !state.pending) return; + state.processScheduled = true; + nextTick(function() { processQueue(state); }); + } + + function Deferred() { + this.promise = new Promise(); + //Necessary to support unbound execution :/ + this.resolve = simpleBind(this, this.resolve); + this.reject = simpleBind(this, this.reject); + this.notify = simpleBind(this, this.notify); + } + + extend(Deferred.prototype, { + resolve: function(val) { + if (this.promise.$$state.status) return; + if (val === this.promise) { + this.$$reject($qMinErr( + 'qcycle', + "Expected promise to be resolved with value other than itself '{0}'", + val)); + } else { + this.$$resolve(val); + } + + }, + + $$resolve: function(val) { + var then, fns; + + fns = callOnce(this, this.$$resolve, this.$$reject); + try { + if ((isObject(val) || isFunction(val))) then = val && val.then; + if (isFunction(then)) { + this.promise.$$state.status = -1; + then.call(val, fns[0], fns[1], this.notify); + } else { + this.promise.$$state.value = val; + this.promise.$$state.status = 1; + scheduleProcessQueue(this.promise.$$state); + } + } catch (e) { + fns[1](e); + exceptionHandler(e); + } + }, + + reject: function(reason) { + if (this.promise.$$state.status) return; + this.$$reject(reason); + }, + + $$reject: function(reason) { + this.promise.$$state.value = reason; + this.promise.$$state.status = 2; + scheduleProcessQueue(this.promise.$$state); + }, + + notify: function(progress) { + var callbacks = this.promise.$$state.pending; + + if ((this.promise.$$state.status <= 0) && callbacks && callbacks.length) { + nextTick(function() { + var callback, result; + for (var i = 0, ii = callbacks.length; i < ii; i++) { + result = callbacks[i][0]; + callback = callbacks[i][3]; + try { + result.notify(isFunction(callback) ? callback(progress) : progress); + } catch (e) { + exceptionHandler(e); + } + } + }); + } + } + }); + + /** + * @ngdoc method + * @name $q#reject + * @kind function + * + * @description + * Creates a promise that is resolved as rejected with the specified `reason`. This api should be + * used to forward rejection in a chain of promises. If you are dealing with the last promise in + * a promise chain, you don't need to worry about it. + * + * When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of + * `reject` as the `throw` keyword in JavaScript. This also means that if you "catch" an error via + * a promise error callback and you want to forward the error to the promise derived from the + * current promise, you have to "rethrow" the error by returning a rejection constructed via + * `reject`. + * + * ```js + * promiseB = promiseA.then(function(result) { + * // success: do something and resolve promiseB + * // with the old or a new result + * return result; + * }, function(reason) { + * // error: handle the error if possible and + * // resolve promiseB with newPromiseOrValue, + * // otherwise forward the rejection to promiseB + * if (canHandle(reason)) { + * // handle the error and recover + * return newPromiseOrValue; + * } + * return $q.reject(reason); + * }); + * ``` + * + * @param {*} reason Constant, message, exception or an object representing the rejection reason. + * @returns {Promise} Returns a promise that was already resolved as rejected with the `reason`. + */ + var reject = function(reason) { + var result = new Deferred(); + result.reject(reason); + return result.promise; + }; + + var makePromise = function makePromise(value, resolved) { + var result = new Deferred(); + if (resolved) { + result.resolve(value); + } else { + result.reject(value); + } + return result.promise; + }; + + var handleCallback = function handleCallback(value, isResolved, callback) { + var callbackOutput = null; + try { + if (isFunction(callback)) callbackOutput = callback(); + } catch (e) { + return makePromise(e, false); + } + if (isPromiseLike(callbackOutput)) { + return callbackOutput.then(function() { + return makePromise(value, isResolved); + }, function(error) { + return makePromise(error, false); + }); + } else { + return makePromise(value, isResolved); + } + }; + + /** + * @ngdoc method + * @name $q#when + * @kind function + * + * @description + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. + * This is useful when you are dealing with an object that might or might not be a promise, or if + * the promise comes from a source that can't be trusted. + * + * @param {*} value Value or a promise + * @param {Function=} successCallback + * @param {Function=} errorCallback + * @param {Function=} progressCallback + * @returns {Promise} Returns a promise of the passed value or promise + */ + + + var when = function(value, callback, errback, progressBack) { + var result = new Deferred(); + result.resolve(value); + return result.promise.then(callback, errback, progressBack); + }; + + /** + * @ngdoc method + * @name $q#resolve + * @kind function + * + * @description + * Alias of {@link ng.$q#when when} to maintain naming consistency with ES6. + * + * @param {*} value Value or a promise + * @param {Function=} successCallback + * @param {Function=} errorCallback + * @param {Function=} progressCallback + * @returns {Promise} Returns a promise of the passed value or promise + */ + var resolve = when; + + /** + * @ngdoc method + * @name $q#all + * @kind function + * + * @description + * Combines multiple promises into a single promise that is resolved when all of the input + * promises are resolved. + * + * @param {Array.|Object.} promises An array or hash of promises. + * @returns {Promise} Returns a single promise that will be resolved with an array/hash of values, + * each value corresponding to the promise at the same index/key in the `promises` array/hash. + * If any of the promises is resolved with a rejection, this resulting promise will be rejected + * with the same rejection value. + */ + + function all(promises) { + var deferred = new Deferred(), + counter = 0, + results = isArray(promises) ? [] : {}; + + forEach(promises, function(promise, key) { + counter++; + when(promise).then(function(value) { + if (results.hasOwnProperty(key)) return; + results[key] = value; + if (!(--counter)) deferred.resolve(results); + }, function(reason) { + if (results.hasOwnProperty(key)) return; + deferred.reject(reason); + }); + }); + + if (counter === 0) { + deferred.resolve(results); + } + + return deferred.promise; + } + + var $Q = function Q(resolver) { + if (!isFunction(resolver)) { + throw $qMinErr('norslvr', "Expected resolverFn, got '{0}'", resolver); + } + + if (!(this instanceof Q)) { + // More useful when $Q is the Promise itself. + return new Q(resolver); + } + + var deferred = new Deferred(); + + function resolveFn(value) { + deferred.resolve(value); + } + + function rejectFn(reason) { + deferred.reject(reason); + } + + resolver(resolveFn, rejectFn); + + return deferred.promise; + }; + + $Q.defer = defer; + $Q.reject = reject; + $Q.when = when; + $Q.resolve = resolve; + $Q.all = all; + + return $Q; +} + +function $$RAFProvider() { //rAF + this.$get = ['$window', '$timeout', function($window, $timeout) { + var requestAnimationFrame = $window.requestAnimationFrame || + $window.webkitRequestAnimationFrame; + + var cancelAnimationFrame = $window.cancelAnimationFrame || + $window.webkitCancelAnimationFrame || + $window.webkitCancelRequestAnimationFrame; + + var rafSupported = !!requestAnimationFrame; + var raf = rafSupported + ? function(fn) { + var id = requestAnimationFrame(fn); + return function() { + cancelAnimationFrame(id); + }; + } + : function(fn) { + var timer = $timeout(fn, 16.66, false); // 1000 / 60 = 16.666 + return function() { + $timeout.cancel(timer); + }; + }; + + raf.supported = rafSupported; + + return raf; + }]; +} + +/** + * DESIGN NOTES + * + * The design decisions behind the scope are heavily favored for speed and memory consumption. + * + * The typical use of scope is to watch the expressions, which most of the time return the same + * value as last time so we optimize the operation. + * + * Closures construction is expensive in terms of speed as well as memory: + * - No closures, instead use prototypical inheritance for API + * - Internal state needs to be stored on scope directly, which means that private state is + * exposed as $$____ properties + * + * Loop operations are optimized by using while(count--) { ... } + * - this means that in order to keep the same order of execution as addition we have to add + * items to the array at the beginning (unshift) instead of at the end (push) + * + * Child scopes are created and removed often + * - Using an array would be slow since inserts in middle are expensive so we use linked list + * + * There are few watches then a lot of observers. This is why you don't want the observer to be + * implemented in the same way as watch. Watch requires return of initialization function which + * are expensive to construct. + */ + + +/** + * @ngdoc provider + * @name $rootScopeProvider + * @description + * + * Provider for the $rootScope service. + */ + +/** + * @ngdoc method + * @name $rootScopeProvider#digestTtl + * @description + * + * Sets the number of `$digest` iterations the scope should attempt to execute before giving up and + * assuming that the model is unstable. + * + * The current default is 10 iterations. + * + * In complex applications it's possible that the dependencies between `$watch`s will result in + * several digest iterations. However if an application needs more than the default 10 digest + * iterations for its model to stabilize then you should investigate what is causing the model to + * continuously change during the digest. + * + * Increasing the TTL could have performance implications, so you should not change it without + * proper justification. + * + * @param {number} limit The number of digest iterations. + */ + + +/** + * @ngdoc service + * @name $rootScope + * @description + * + * Every application has a single root {@link ng.$rootScope.Scope scope}. + * All other scopes are descendant scopes of the root scope. Scopes provide separation + * between the model and the view, via a mechanism for watching the model for changes. + * They also provide an event emission/broadcast and subscription facility. See the + * {@link guide/scope developer guide on scopes}. + */ +function $RootScopeProvider() { + var TTL = 10; + var $rootScopeMinErr = minErr('$rootScope'); + var lastDirtyWatch = null; + var applyAsyncId = null; + + this.digestTtl = function(value) { + if (arguments.length) { + TTL = value; + } + return TTL; + }; + + function createChildScopeClass(parent) { + function ChildScope() { + this.$$watchers = this.$$nextSibling = + this.$$childHead = this.$$childTail = null; + this.$$listeners = {}; + this.$$listenerCount = {}; + this.$$watchersCount = 0; + this.$id = nextUid(); + this.$$ChildScope = null; + } + ChildScope.prototype = parent; + return ChildScope; + } + + this.$get = ['$injector', '$exceptionHandler', '$parse', '$browser', + function($injector, $exceptionHandler, $parse, $browser) { + + function destroyChildScope($event) { + $event.currentScope.$$destroyed = true; + } + + /** + * @ngdoc type + * @name $rootScope.Scope + * + * @description + * A root scope can be retrieved using the {@link ng.$rootScope $rootScope} key from the + * {@link auto.$injector $injector}. Child scopes are created using the + * {@link ng.$rootScope.Scope#$new $new()} method. (Most scopes are created automatically when + * compiled HTML template is executed.) See also the {@link guide/scope Scopes guide} for + * an in-depth introduction and usage examples. + * + * + * # Inheritance + * A scope can inherit from a parent scope, as in this example: + * ```js + var parent = $rootScope; + var child = parent.$new(); + + parent.salutation = "Hello"; + expect(child.salutation).toEqual('Hello'); + + child.salutation = "Welcome"; + expect(child.salutation).toEqual('Welcome'); + expect(parent.salutation).toEqual('Hello'); + * ``` + * + * When interacting with `Scope` in tests, additional helper methods are available on the + * instances of `Scope` type. See {@link ngMock.$rootScope.Scope ngMock Scope} for additional + * details. + * + * + * @param {Object.=} providers Map of service factory which need to be + * provided for the current scope. Defaults to {@link ng}. + * @param {Object.=} instanceCache Provides pre-instantiated services which should + * append/override services provided by `providers`. This is handy + * when unit-testing and having the need to override a default + * service. + * @returns {Object} Newly created scope. + * + */ + function Scope() { + this.$id = nextUid(); + this.$$phase = this.$parent = this.$$watchers = + this.$$nextSibling = this.$$prevSibling = + this.$$childHead = this.$$childTail = null; + this.$root = this; + this.$$destroyed = false; + this.$$listeners = {}; + this.$$listenerCount = {}; + this.$$watchersCount = 0; + this.$$isolateBindings = null; + } + + /** + * @ngdoc property + * @name $rootScope.Scope#$id + * + * @description + * Unique scope ID (monotonically increasing) useful for debugging. + */ + + /** + * @ngdoc property + * @name $rootScope.Scope#$parent + * + * @description + * Reference to the parent scope. + */ + + /** + * @ngdoc property + * @name $rootScope.Scope#$root + * + * @description + * Reference to the root scope. + */ + + Scope.prototype = { + constructor: Scope, + /** + * @ngdoc method + * @name $rootScope.Scope#$new + * @kind function + * + * @description + * Creates a new child {@link ng.$rootScope.Scope scope}. + * + * The parent scope will propagate the {@link ng.$rootScope.Scope#$digest $digest()} event. + * The scope can be removed from the scope hierarchy using {@link ng.$rootScope.Scope#$destroy $destroy()}. + * + * {@link ng.$rootScope.Scope#$destroy $destroy()} must be called on a scope when it is + * desired for the scope and its child scopes to be permanently detached from the parent and + * thus stop participating in model change detection and listener notification by invoking. + * + * @param {boolean} isolate If true, then the scope does not prototypically inherit from the + * parent scope. The scope is isolated, as it can not see parent scope properties. + * When creating widgets, it is useful for the widget to not accidentally read parent + * state. + * + * @param {Scope} [parent=this] The {@link ng.$rootScope.Scope `Scope`} that will be the `$parent` + * of the newly created scope. Defaults to `this` scope if not provided. + * This is used when creating a transclude scope to correctly place it + * in the scope hierarchy while maintaining the correct prototypical + * inheritance. + * + * @returns {Object} The newly created child scope. + * + */ + $new: function(isolate, parent) { + var child; + + parent = parent || this; + + if (isolate) { + child = new Scope(); + child.$root = this.$root; + } else { + // Only create a child scope class if somebody asks for one, + // but cache it to allow the VM to optimize lookups. + if (!this.$$ChildScope) { + this.$$ChildScope = createChildScopeClass(this); + } + child = new this.$$ChildScope(); + } + child.$parent = parent; + child.$$prevSibling = parent.$$childTail; + if (parent.$$childHead) { + parent.$$childTail.$$nextSibling = child; + parent.$$childTail = child; + } else { + parent.$$childHead = parent.$$childTail = child; + } + + // When the new scope is not isolated or we inherit from `this`, and + // the parent scope is destroyed, the property `$$destroyed` is inherited + // prototypically. In all other cases, this property needs to be set + // when the parent scope is destroyed. + // The listener needs to be added after the parent is set + if (isolate || parent != this) child.$on('$destroy', destroyChildScope); + + return child; + }, + + /** + * @ngdoc method + * @name $rootScope.Scope#$watch + * @kind function + * + * @description + * Registers a `listener` callback to be executed whenever the `watchExpression` changes. + * + * - The `watchExpression` is called on every call to {@link ng.$rootScope.Scope#$digest + * $digest()} and should return the value that will be watched. (`watchExpression` should not change + * its value when executed multiple times with the same input because it may be executed multiple + * times by {@link ng.$rootScope.Scope#$digest $digest()}. That is, `watchExpression` should be + * [idempotent](http://en.wikipedia.org/wiki/Idempotence). + * - The `listener` is called only when the value from the current `watchExpression` and the + * previous call to `watchExpression` are not equal (with the exception of the initial run, + * see below). Inequality is determined according to reference inequality, + * [strict comparison](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators) + * via the `!==` Javascript operator, unless `objectEquality == true` + * (see next point) + * - When `objectEquality == true`, inequality of the `watchExpression` is determined + * according to the {@link angular.equals} function. To save the value of the object for + * later comparison, the {@link angular.copy} function is used. This therefore means that + * watching complex objects will have adverse memory and performance implications. + * - The watch `listener` may change the model, which may trigger other `listener`s to fire. + * This is achieved by rerunning the watchers until no changes are detected. The rerun + * iteration limit is 10 to prevent an infinite loop deadlock. + * + * + * If you want to be notified whenever {@link ng.$rootScope.Scope#$digest $digest} is called, + * you can register a `watchExpression` function with no `listener`. (Be prepared for + * multiple calls to your `watchExpression` because it will execute multiple times in a + * single {@link ng.$rootScope.Scope#$digest $digest} cycle if a change is detected.) + * + * After a watcher is registered with the scope, the `listener` fn is called asynchronously + * (via {@link ng.$rootScope.Scope#$evalAsync $evalAsync}) to initialize the + * watcher. In rare cases, this is undesirable because the listener is called when the result + * of `watchExpression` didn't change. To detect this scenario within the `listener` fn, you + * can compare the `newVal` and `oldVal`. If these two values are identical (`===`) then the + * listener was called due to initialization. + * + * + * + * # Example + * ```js + // let's assume that scope was dependency injected as the $rootScope + var scope = $rootScope; + scope.name = 'misko'; + scope.counter = 0; + + expect(scope.counter).toEqual(0); + scope.$watch('name', function(newValue, oldValue) { + scope.counter = scope.counter + 1; + }); + expect(scope.counter).toEqual(0); + + scope.$digest(); + // the listener is always called during the first $digest loop after it was registered + expect(scope.counter).toEqual(1); + + scope.$digest(); + // but now it will not be called unless the value changes + expect(scope.counter).toEqual(1); + + scope.name = 'adam'; + scope.$digest(); + expect(scope.counter).toEqual(2); + + + + // Using a function as a watchExpression + var food; + scope.foodCounter = 0; + expect(scope.foodCounter).toEqual(0); + scope.$watch( + // This function returns the value being watched. It is called for each turn of the $digest loop + function() { return food; }, + // This is the change listener, called when the value returned from the above function changes + function(newValue, oldValue) { + if ( newValue !== oldValue ) { + // Only increment the counter if the value changed + scope.foodCounter = scope.foodCounter + 1; + } + } + ); + // No digest has been run so the counter will be zero + expect(scope.foodCounter).toEqual(0); + + // Run the digest but since food has not changed count will still be zero + scope.$digest(); + expect(scope.foodCounter).toEqual(0); + + // Update food and run digest. Now the counter will increment + food = 'cheeseburger'; + scope.$digest(); + expect(scope.foodCounter).toEqual(1); + + * ``` + * + * + * + * @param {(function()|string)} watchExpression Expression that is evaluated on each + * {@link ng.$rootScope.Scope#$digest $digest} cycle. A change in the return value triggers + * a call to the `listener`. + * + * - `string`: Evaluated as {@link guide/expression expression} + * - `function(scope)`: called with current `scope` as a parameter. + * @param {function(newVal, oldVal, scope)} listener Callback called whenever the value + * of `watchExpression` changes. + * + * - `newVal` contains the current value of the `watchExpression` + * - `oldVal` contains the previous value of the `watchExpression` + * - `scope` refers to the current scope + * @param {boolean=} objectEquality Compare for object equality using {@link angular.equals} instead of + * comparing for reference equality. + * @returns {function()} Returns a deregistration function for this listener. + */ + $watch: function(watchExp, listener, objectEquality, prettyPrintExpression) { + var get = $parse(watchExp); + + if (get.$$watchDelegate) { + return get.$$watchDelegate(this, listener, objectEquality, get, watchExp); + } + var scope = this, + array = scope.$$watchers, + watcher = { + fn: listener, + last: initWatchVal, + get: get, + exp: prettyPrintExpression || watchExp, + eq: !!objectEquality + }; + + lastDirtyWatch = null; + + if (!isFunction(listener)) { + watcher.fn = noop; + } + + if (!array) { + array = scope.$$watchers = []; + } + // we use unshift since we use a while loop in $digest for speed. + // the while loop reads in reverse order. + array.unshift(watcher); + incrementWatchersCount(this, 1); + + return function deregisterWatch() { + if (arrayRemove(array, watcher) >= 0) { + incrementWatchersCount(scope, -1); + } + lastDirtyWatch = null; + }; + }, + + /** + * @ngdoc method + * @name $rootScope.Scope#$watchGroup + * @kind function + * + * @description + * A variant of {@link ng.$rootScope.Scope#$watch $watch()} where it watches an array of `watchExpressions`. + * If any one expression in the collection changes the `listener` is executed. + * + * - The items in the `watchExpressions` array are observed via standard $watch operation and are examined on every + * call to $digest() to see if any items changes. + * - The `listener` is called whenever any expression in the `watchExpressions` array changes. + * + * @param {Array.} watchExpressions Array of expressions that will be individually + * watched using {@link ng.$rootScope.Scope#$watch $watch()} + * + * @param {function(newValues, oldValues, scope)} listener Callback called whenever the return value of any + * expression in `watchExpressions` changes + * The `newValues` array contains the current values of the `watchExpressions`, with the indexes matching + * those of `watchExpression` + * and the `oldValues` array contains the previous values of the `watchExpressions`, with the indexes matching + * those of `watchExpression` + * The `scope` refers to the current scope. + * @returns {function()} Returns a de-registration function for all listeners. + */ + $watchGroup: function(watchExpressions, listener) { + var oldValues = new Array(watchExpressions.length); + var newValues = new Array(watchExpressions.length); + var deregisterFns = []; + var self = this; + var changeReactionScheduled = false; + var firstRun = true; + + if (!watchExpressions.length) { + // No expressions means we call the listener ASAP + var shouldCall = true; + self.$evalAsync(function() { + if (shouldCall) listener(newValues, newValues, self); + }); + return function deregisterWatchGroup() { + shouldCall = false; + }; + } + + if (watchExpressions.length === 1) { + // Special case size of one + return this.$watch(watchExpressions[0], function watchGroupAction(value, oldValue, scope) { + newValues[0] = value; + oldValues[0] = oldValue; + listener(newValues, (value === oldValue) ? newValues : oldValues, scope); + }); + } + + forEach(watchExpressions, function(expr, i) { + var unwatchFn = self.$watch(expr, function watchGroupSubAction(value, oldValue) { + newValues[i] = value; + oldValues[i] = oldValue; + if (!changeReactionScheduled) { + changeReactionScheduled = true; + self.$evalAsync(watchGroupAction); + } + }); + deregisterFns.push(unwatchFn); + }); + + function watchGroupAction() { + changeReactionScheduled = false; + + if (firstRun) { + firstRun = false; + listener(newValues, newValues, self); + } else { + listener(newValues, oldValues, self); + } + } + + return function deregisterWatchGroup() { + while (deregisterFns.length) { + deregisterFns.shift()(); + } + }; + }, + + + /** + * @ngdoc method + * @name $rootScope.Scope#$watchCollection + * @kind function + * + * @description + * Shallow watches the properties of an object and fires whenever any of the properties change + * (for arrays, this implies watching the array items; for object maps, this implies watching + * the properties). If a change is detected, the `listener` callback is fired. + * + * - The `obj` collection is observed via standard $watch operation and is examined on every + * call to $digest() to see if any items have been added, removed, or moved. + * - The `listener` is called whenever anything within the `obj` has changed. Examples include + * adding, removing, and moving items belonging to an object or array. + * + * + * # Example + * ```js + $scope.names = ['igor', 'matias', 'misko', 'james']; + $scope.dataCount = 4; + + $scope.$watchCollection('names', function(newNames, oldNames) { + $scope.dataCount = newNames.length; + }); + + expect($scope.dataCount).toEqual(4); + $scope.$digest(); + + //still at 4 ... no changes + expect($scope.dataCount).toEqual(4); + + $scope.names.pop(); + $scope.$digest(); + + //now there's been a change + expect($scope.dataCount).toEqual(3); + * ``` + * + * + * @param {string|function(scope)} obj Evaluated as {@link guide/expression expression}. The + * expression value should evaluate to an object or an array which is observed on each + * {@link ng.$rootScope.Scope#$digest $digest} cycle. Any shallow change within the + * collection will trigger a call to the `listener`. + * + * @param {function(newCollection, oldCollection, scope)} listener a callback function called + * when a change is detected. + * - The `newCollection` object is the newly modified data obtained from the `obj` expression + * - The `oldCollection` object is a copy of the former collection data. + * Due to performance considerations, the`oldCollection` value is computed only if the + * `listener` function declares two or more arguments. + * - The `scope` argument refers to the current scope. + * + * @returns {function()} Returns a de-registration function for this listener. When the + * de-registration function is executed, the internal watch operation is terminated. + */ + $watchCollection: function(obj, listener) { + $watchCollectionInterceptor.$stateful = true; + + var self = this; + // the current value, updated on each dirty-check run + var newValue; + // a shallow copy of the newValue from the last dirty-check run, + // updated to match newValue during dirty-check run + var oldValue; + // a shallow copy of the newValue from when the last change happened + var veryOldValue; + // only track veryOldValue if the listener is asking for it + var trackVeryOldValue = (listener.length > 1); + var changeDetected = 0; + var changeDetector = $parse(obj, $watchCollectionInterceptor); + var internalArray = []; + var internalObject = {}; + var initRun = true; + var oldLength = 0; + + function $watchCollectionInterceptor(_value) { + newValue = _value; + var newLength, key, bothNaN, newItem, oldItem; + + // If the new value is undefined, then return undefined as the watch may be a one-time watch + if (isUndefined(newValue)) return; + + if (!isObject(newValue)) { // if primitive + if (oldValue !== newValue) { + oldValue = newValue; + changeDetected++; + } + } else if (isArrayLike(newValue)) { + if (oldValue !== internalArray) { + // we are transitioning from something which was not an array into array. + oldValue = internalArray; + oldLength = oldValue.length = 0; + changeDetected++; + } + + newLength = newValue.length; + + if (oldLength !== newLength) { + // if lengths do not match we need to trigger change notification + changeDetected++; + oldValue.length = oldLength = newLength; + } + // copy the items to oldValue and look for changes. + for (var i = 0; i < newLength; i++) { + oldItem = oldValue[i]; + newItem = newValue[i]; + + bothNaN = (oldItem !== oldItem) && (newItem !== newItem); + if (!bothNaN && (oldItem !== newItem)) { + changeDetected++; + oldValue[i] = newItem; + } + } + } else { + if (oldValue !== internalObject) { + // we are transitioning from something which was not an object into object. + oldValue = internalObject = {}; + oldLength = 0; + changeDetected++; + } + // copy the items to oldValue and look for changes. + newLength = 0; + for (key in newValue) { + if (hasOwnProperty.call(newValue, key)) { + newLength++; + newItem = newValue[key]; + oldItem = oldValue[key]; + + if (key in oldValue) { + bothNaN = (oldItem !== oldItem) && (newItem !== newItem); + if (!bothNaN && (oldItem !== newItem)) { + changeDetected++; + oldValue[key] = newItem; + } + } else { + oldLength++; + oldValue[key] = newItem; + changeDetected++; + } + } + } + if (oldLength > newLength) { + // we used to have more keys, need to find them and destroy them. + changeDetected++; + for (key in oldValue) { + if (!hasOwnProperty.call(newValue, key)) { + oldLength--; + delete oldValue[key]; + } + } + } + } + return changeDetected; + } + + function $watchCollectionAction() { + if (initRun) { + initRun = false; + listener(newValue, newValue, self); + } else { + listener(newValue, veryOldValue, self); + } + + // make a copy for the next time a collection is changed + if (trackVeryOldValue) { + if (!isObject(newValue)) { + //primitive + veryOldValue = newValue; + } else if (isArrayLike(newValue)) { + veryOldValue = new Array(newValue.length); + for (var i = 0; i < newValue.length; i++) { + veryOldValue[i] = newValue[i]; + } + } else { // if object + veryOldValue = {}; + for (var key in newValue) { + if (hasOwnProperty.call(newValue, key)) { + veryOldValue[key] = newValue[key]; + } + } + } + } + } + + return this.$watch(changeDetector, $watchCollectionAction); + }, + + /** + * @ngdoc method + * @name $rootScope.Scope#$digest + * @kind function + * + * @description + * Processes all of the {@link ng.$rootScope.Scope#$watch watchers} of the current scope and + * its children. Because a {@link ng.$rootScope.Scope#$watch watcher}'s listener can change + * the model, the `$digest()` keeps calling the {@link ng.$rootScope.Scope#$watch watchers} + * until no more listeners are firing. This means that it is possible to get into an infinite + * loop. This function will throw `'Maximum iteration limit exceeded.'` if the number of + * iterations exceeds 10. + * + * Usually, you don't call `$digest()` directly in + * {@link ng.directive:ngController controllers} or in + * {@link ng.$compileProvider#directive directives}. + * Instead, you should call {@link ng.$rootScope.Scope#$apply $apply()} (typically from within + * a {@link ng.$compileProvider#directive directive}), which will force a `$digest()`. + * + * If you want to be notified whenever `$digest()` is called, + * you can register a `watchExpression` function with + * {@link ng.$rootScope.Scope#$watch $watch()} with no `listener`. + * + * In unit tests, you may need to call `$digest()` to simulate the scope life cycle. + * + * # Example + * ```js + var scope = ...; + scope.name = 'misko'; + scope.counter = 0; + + expect(scope.counter).toEqual(0); + scope.$watch('name', function(newValue, oldValue) { + scope.counter = scope.counter + 1; + }); + expect(scope.counter).toEqual(0); + + scope.$digest(); + // the listener is always called during the first $digest loop after it was registered + expect(scope.counter).toEqual(1); + + scope.$digest(); + // but now it will not be called unless the value changes + expect(scope.counter).toEqual(1); + + scope.name = 'adam'; + scope.$digest(); + expect(scope.counter).toEqual(2); + * ``` + * + */ + $digest: function() { + var watch, value, last, + watchers, + length, + dirty, ttl = TTL, + next, current, target = this, + watchLog = [], + logIdx, logMsg, asyncTask; + + beginPhase('$digest'); + // Check for changes to browser url that happened in sync before the call to $digest + $browser.$$checkUrlChange(); + + if (this === $rootScope && applyAsyncId !== null) { + // If this is the root scope, and $applyAsync has scheduled a deferred $apply(), then + // cancel the scheduled $apply and flush the queue of expressions to be evaluated. + $browser.defer.cancel(applyAsyncId); + flushApplyAsync(); + } + + lastDirtyWatch = null; + + do { // "while dirty" loop + dirty = false; + current = target; + + while (asyncQueue.length) { + try { + asyncTask = asyncQueue.shift(); + asyncTask.scope.$eval(asyncTask.expression, asyncTask.locals); + } catch (e) { + $exceptionHandler(e); + } + lastDirtyWatch = null; + } + + traverseScopesLoop: + do { // "traverse the scopes" loop + if ((watchers = current.$$watchers)) { + // process our watches + length = watchers.length; + while (length--) { + try { + watch = watchers[length]; + // Most common watches are on primitives, in which case we can short + // circuit it with === operator, only when === fails do we use .equals + if (watch) { + if ((value = watch.get(current)) !== (last = watch.last) && + !(watch.eq + ? equals(value, last) + : (typeof value === 'number' && typeof last === 'number' + && isNaN(value) && isNaN(last)))) { + dirty = true; + lastDirtyWatch = watch; + watch.last = watch.eq ? copy(value, null) : value; + watch.fn(value, ((last === initWatchVal) ? value : last), current); + if (ttl < 5) { + logIdx = 4 - ttl; + if (!watchLog[logIdx]) watchLog[logIdx] = []; + watchLog[logIdx].push({ + msg: isFunction(watch.exp) ? 'fn: ' + (watch.exp.name || watch.exp.toString()) : watch.exp, + newVal: value, + oldVal: last + }); + } + } else if (watch === lastDirtyWatch) { + // If the most recently dirty watcher is now clean, short circuit since the remaining watchers + // have already been tested. + dirty = false; + break traverseScopesLoop; + } + } + } catch (e) { + $exceptionHandler(e); + } + } + } + + // Insanity Warning: scope depth-first traversal + // yes, this code is a bit crazy, but it works and we have tests to prove it! + // this piece should be kept in sync with the traversal in $broadcast + if (!(next = ((current.$$watchersCount && current.$$childHead) || + (current !== target && current.$$nextSibling)))) { + while (current !== target && !(next = current.$$nextSibling)) { + current = current.$parent; + } + } + } while ((current = next)); + + // `break traverseScopesLoop;` takes us to here + + if ((dirty || asyncQueue.length) && !(ttl--)) { + clearPhase(); + throw $rootScopeMinErr('infdig', + '{0} $digest() iterations reached. Aborting!\n' + + 'Watchers fired in the last 5 iterations: {1}', + TTL, watchLog); + } + + } while (dirty || asyncQueue.length); + + clearPhase(); + + while (postDigestQueue.length) { + try { + postDigestQueue.shift()(); + } catch (e) { + $exceptionHandler(e); + } + } + }, + + + /** + * @ngdoc event + * @name $rootScope.Scope#$destroy + * @eventType broadcast on scope being destroyed + * + * @description + * Broadcasted when a scope and its children are being destroyed. + * + * Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to + * clean up DOM bindings before an element is removed from the DOM. + */ + + /** + * @ngdoc method + * @name $rootScope.Scope#$destroy + * @kind function + * + * @description + * Removes the current scope (and all of its children) from the parent scope. Removal implies + * that calls to {@link ng.$rootScope.Scope#$digest $digest()} will no longer + * propagate to the current scope and its children. Removal also implies that the current + * scope is eligible for garbage collection. + * + * The `$destroy()` is usually used by directives such as + * {@link ng.directive:ngRepeat ngRepeat} for managing the + * unrolling of the loop. + * + * Just before a scope is destroyed, a `$destroy` event is broadcasted on this scope. + * Application code can register a `$destroy` event handler that will give it a chance to + * perform any necessary cleanup. + * + * Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to + * clean up DOM bindings before an element is removed from the DOM. + */ + $destroy: function() { + // We can't destroy a scope that has been already destroyed. + if (this.$$destroyed) return; + var parent = this.$parent; + + this.$broadcast('$destroy'); + this.$$destroyed = true; + + if (this === $rootScope) { + //Remove handlers attached to window when $rootScope is removed + $browser.$$applicationDestroyed(); + } + + incrementWatchersCount(this, -this.$$watchersCount); + for (var eventName in this.$$listenerCount) { + decrementListenerCount(this, this.$$listenerCount[eventName], eventName); + } + + // sever all the references to parent scopes (after this cleanup, the current scope should + // not be retained by any of our references and should be eligible for garbage collection) + if (parent && parent.$$childHead == this) parent.$$childHead = this.$$nextSibling; + if (parent && parent.$$childTail == this) parent.$$childTail = this.$$prevSibling; + if (this.$$prevSibling) this.$$prevSibling.$$nextSibling = this.$$nextSibling; + if (this.$$nextSibling) this.$$nextSibling.$$prevSibling = this.$$prevSibling; + + // Disable listeners, watchers and apply/digest methods + this.$destroy = this.$digest = this.$apply = this.$evalAsync = this.$applyAsync = noop; + this.$on = this.$watch = this.$watchGroup = function() { return noop; }; + this.$$listeners = {}; + + // All of the code below is bogus code that works around V8's memory leak via optimized code + // and inline caches. + // + // see: + // - https://code.google.com/p/v8/issues/detail?id=2073#c26 + // - https://github.com/angular/angular.js/issues/6794#issuecomment-38648909 + // - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451 + + this.$parent = this.$$nextSibling = this.$$prevSibling = this.$$childHead = + this.$$childTail = this.$root = this.$$watchers = null; + }, + + /** + * @ngdoc method + * @name $rootScope.Scope#$eval + * @kind function + * + * @description + * Executes the `expression` on the current scope and returns the result. Any exceptions in + * the expression are propagated (uncaught). This is useful when evaluating Angular + * expressions. + * + * # Example + * ```js + var scope = ng.$rootScope.Scope(); + scope.a = 1; + scope.b = 2; + + expect(scope.$eval('a+b')).toEqual(3); + expect(scope.$eval(function(scope){ return scope.a + scope.b; })).toEqual(3); + * ``` + * + * @param {(string|function())=} expression An angular expression to be executed. + * + * - `string`: execute using the rules as defined in {@link guide/expression expression}. + * - `function(scope)`: execute the function with the current `scope` parameter. + * + * @param {(object)=} locals Local variables object, useful for overriding values in scope. + * @returns {*} The result of evaluating the expression. + */ + $eval: function(expr, locals) { + return $parse(expr)(this, locals); + }, + + /** + * @ngdoc method + * @name $rootScope.Scope#$evalAsync + * @kind function + * + * @description + * Executes the expression on the current scope at a later point in time. + * + * The `$evalAsync` makes no guarantees as to when the `expression` will be executed, only + * that: + * + * - it will execute after the function that scheduled the evaluation (preferably before DOM + * rendering). + * - at least one {@link ng.$rootScope.Scope#$digest $digest cycle} will be performed after + * `expression` execution. + * + * Any exceptions from the execution of the expression are forwarded to the + * {@link ng.$exceptionHandler $exceptionHandler} service. + * + * __Note:__ if this function is called outside of a `$digest` cycle, a new `$digest` cycle + * will be scheduled. However, it is encouraged to always call code that changes the model + * from within an `$apply` call. That includes code evaluated via `$evalAsync`. + * + * @param {(string|function())=} expression An angular expression to be executed. + * + * - `string`: execute using the rules as defined in {@link guide/expression expression}. + * - `function(scope)`: execute the function with the current `scope` parameter. + * + * @param {(object)=} locals Local variables object, useful for overriding values in scope. + */ + $evalAsync: function(expr, locals) { + // if we are outside of an $digest loop and this is the first time we are scheduling async + // task also schedule async auto-flush + if (!$rootScope.$$phase && !asyncQueue.length) { + $browser.defer(function() { + if (asyncQueue.length) { + $rootScope.$digest(); + } + }); + } + + asyncQueue.push({scope: this, expression: expr, locals: locals}); + }, + + $$postDigest: function(fn) { + postDigestQueue.push(fn); + }, + + /** + * @ngdoc method + * @name $rootScope.Scope#$apply + * @kind function + * + * @description + * `$apply()` is used to execute an expression in angular from outside of the angular + * framework. (For example from browser DOM events, setTimeout, XHR or third party libraries). + * Because we are calling into the angular framework we need to perform proper scope life + * cycle of {@link ng.$exceptionHandler exception handling}, + * {@link ng.$rootScope.Scope#$digest executing watches}. + * + * ## Life cycle + * + * # Pseudo-Code of `$apply()` + * ```js + function $apply(expr) { + try { + return $eval(expr); + } catch (e) { + $exceptionHandler(e); + } finally { + $root.$digest(); + } + } + * ``` + * + * + * Scope's `$apply()` method transitions through the following stages: + * + * 1. The {@link guide/expression expression} is executed using the + * {@link ng.$rootScope.Scope#$eval $eval()} method. + * 2. Any exceptions from the execution of the expression are forwarded to the + * {@link ng.$exceptionHandler $exceptionHandler} service. + * 3. The {@link ng.$rootScope.Scope#$watch watch} listeners are fired immediately after the + * expression was executed using the {@link ng.$rootScope.Scope#$digest $digest()} method. + * + * + * @param {(string|function())=} exp An angular expression to be executed. + * + * - `string`: execute using the rules as defined in {@link guide/expression expression}. + * - `function(scope)`: execute the function with current `scope` parameter. + * + * @returns {*} The result of evaluating the expression. + */ + $apply: function(expr) { + try { + beginPhase('$apply'); + try { + return this.$eval(expr); + } finally { + clearPhase(); + } + } catch (e) { + $exceptionHandler(e); + } finally { + try { + $rootScope.$digest(); + } catch (e) { + $exceptionHandler(e); + throw e; + } + } + }, + + /** + * @ngdoc method + * @name $rootScope.Scope#$applyAsync + * @kind function + * + * @description + * Schedule the invocation of $apply to occur at a later time. The actual time difference + * varies across browsers, but is typically around ~10 milliseconds. + * + * This can be used to queue up multiple expressions which need to be evaluated in the same + * digest. + * + * @param {(string|function())=} exp An angular expression to be executed. + * + * - `string`: execute using the rules as defined in {@link guide/expression expression}. + * - `function(scope)`: execute the function with current `scope` parameter. + */ + $applyAsync: function(expr) { + var scope = this; + expr && applyAsyncQueue.push($applyAsyncExpression); + scheduleApplyAsync(); + + function $applyAsyncExpression() { + scope.$eval(expr); + } + }, + + /** + * @ngdoc method + * @name $rootScope.Scope#$on + * @kind function + * + * @description + * Listens on events of a given type. See {@link ng.$rootScope.Scope#$emit $emit} for + * discussion of event life cycle. + * + * The event listener function format is: `function(event, args...)`. The `event` object + * passed into the listener has the following attributes: + * + * - `targetScope` - `{Scope}`: the scope on which the event was `$emit`-ed or + * `$broadcast`-ed. + * - `currentScope` - `{Scope}`: the scope that is currently handling the event. Once the + * event propagates through the scope hierarchy, this property is set to null. + * - `name` - `{string}`: name of the event. + * - `stopPropagation` - `{function=}`: calling `stopPropagation` function will cancel + * further event propagation (available only for events that were `$emit`-ed). + * - `preventDefault` - `{function}`: calling `preventDefault` sets `defaultPrevented` flag + * to true. + * - `defaultPrevented` - `{boolean}`: true if `preventDefault` was called. + * + * @param {string} name Event name to listen on. + * @param {function(event, ...args)} listener Function to call when the event is emitted. + * @returns {function()} Returns a deregistration function for this listener. + */ + $on: function(name, listener) { + var namedListeners = this.$$listeners[name]; + if (!namedListeners) { + this.$$listeners[name] = namedListeners = []; + } + namedListeners.push(listener); + + var current = this; + do { + if (!current.$$listenerCount[name]) { + current.$$listenerCount[name] = 0; + } + current.$$listenerCount[name]++; + } while ((current = current.$parent)); + + var self = this; + return function() { + var indexOfListener = namedListeners.indexOf(listener); + if (indexOfListener !== -1) { + namedListeners[indexOfListener] = null; + decrementListenerCount(self, 1, name); + } + }; + }, + + + /** + * @ngdoc method + * @name $rootScope.Scope#$emit + * @kind function + * + * @description + * Dispatches an event `name` upwards through the scope hierarchy notifying the + * registered {@link ng.$rootScope.Scope#$on} listeners. + * + * The event life cycle starts at the scope on which `$emit` was called. All + * {@link ng.$rootScope.Scope#$on listeners} listening for `name` event on this scope get + * notified. Afterwards, the event traverses upwards toward the root scope and calls all + * registered listeners along the way. The event will stop propagating if one of the listeners + * cancels it. + * + * Any exception emitted from the {@link ng.$rootScope.Scope#$on listeners} will be passed + * onto the {@link ng.$exceptionHandler $exceptionHandler} service. + * + * @param {string} name Event name to emit. + * @param {...*} args Optional one or more arguments which will be passed onto the event listeners. + * @return {Object} Event object (see {@link ng.$rootScope.Scope#$on}). + */ + $emit: function(name, args) { + var empty = [], + namedListeners, + scope = this, + stopPropagation = false, + event = { + name: name, + targetScope: scope, + stopPropagation: function() {stopPropagation = true;}, + preventDefault: function() { + event.defaultPrevented = true; + }, + defaultPrevented: false + }, + listenerArgs = concat([event], arguments, 1), + i, length; + + do { + namedListeners = scope.$$listeners[name] || empty; + event.currentScope = scope; + for (i = 0, length = namedListeners.length; i < length; i++) { + + // if listeners were deregistered, defragment the array + if (!namedListeners[i]) { + namedListeners.splice(i, 1); + i--; + length--; + continue; + } + try { + //allow all listeners attached to the current scope to run + namedListeners[i].apply(null, listenerArgs); + } catch (e) { + $exceptionHandler(e); + } + } + //if any listener on the current scope stops propagation, prevent bubbling + if (stopPropagation) { + event.currentScope = null; + return event; + } + //traverse upwards + scope = scope.$parent; + } while (scope); + + event.currentScope = null; + + return event; + }, + + + /** + * @ngdoc method + * @name $rootScope.Scope#$broadcast + * @kind function + * + * @description + * Dispatches an event `name` downwards to all child scopes (and their children) notifying the + * registered {@link ng.$rootScope.Scope#$on} listeners. + * + * The event life cycle starts at the scope on which `$broadcast` was called. All + * {@link ng.$rootScope.Scope#$on listeners} listening for `name` event on this scope get + * notified. Afterwards, the event propagates to all direct and indirect scopes of the current + * scope and calls all registered listeners along the way. The event cannot be canceled. + * + * Any exception emitted from the {@link ng.$rootScope.Scope#$on listeners} will be passed + * onto the {@link ng.$exceptionHandler $exceptionHandler} service. + * + * @param {string} name Event name to broadcast. + * @param {...*} args Optional one or more arguments which will be passed onto the event listeners. + * @return {Object} Event object, see {@link ng.$rootScope.Scope#$on} + */ + $broadcast: function(name, args) { + var target = this, + current = target, + next = target, + event = { + name: name, + targetScope: target, + preventDefault: function() { + event.defaultPrevented = true; + }, + defaultPrevented: false + }; + + if (!target.$$listenerCount[name]) return event; + + var listenerArgs = concat([event], arguments, 1), + listeners, i, length; + + //down while you can, then up and next sibling or up and next sibling until back at root + while ((current = next)) { + event.currentScope = current; + listeners = current.$$listeners[name] || []; + for (i = 0, length = listeners.length; i < length; i++) { + // if listeners were deregistered, defragment the array + if (!listeners[i]) { + listeners.splice(i, 1); + i--; + length--; + continue; + } + + try { + listeners[i].apply(null, listenerArgs); + } catch (e) { + $exceptionHandler(e); + } + } + + // Insanity Warning: scope depth-first traversal + // yes, this code is a bit crazy, but it works and we have tests to prove it! + // this piece should be kept in sync with the traversal in $digest + // (though it differs due to having the extra check for $$listenerCount) + if (!(next = ((current.$$listenerCount[name] && current.$$childHead) || + (current !== target && current.$$nextSibling)))) { + while (current !== target && !(next = current.$$nextSibling)) { + current = current.$parent; + } + } + } + + event.currentScope = null; + return event; + } + }; + + var $rootScope = new Scope(); + + //The internal queues. Expose them on the $rootScope for debugging/testing purposes. + var asyncQueue = $rootScope.$$asyncQueue = []; + var postDigestQueue = $rootScope.$$postDigestQueue = []; + var applyAsyncQueue = $rootScope.$$applyAsyncQueue = []; + + return $rootScope; + + + function beginPhase(phase) { + if ($rootScope.$$phase) { + throw $rootScopeMinErr('inprog', '{0} already in progress', $rootScope.$$phase); + } + + $rootScope.$$phase = phase; + } + + function clearPhase() { + $rootScope.$$phase = null; + } + + function incrementWatchersCount(current, count) { + do { + current.$$watchersCount += count; + } while ((current = current.$parent)); + } + + function decrementListenerCount(current, count, name) { + do { + current.$$listenerCount[name] -= count; + + if (current.$$listenerCount[name] === 0) { + delete current.$$listenerCount[name]; + } + } while ((current = current.$parent)); + } + + /** + * function used as an initial value for watchers. + * because it's unique we can easily tell it apart from other values + */ + function initWatchVal() {} + + function flushApplyAsync() { + while (applyAsyncQueue.length) { + try { + applyAsyncQueue.shift()(); + } catch (e) { + $exceptionHandler(e); + } + } + applyAsyncId = null; + } + + function scheduleApplyAsync() { + if (applyAsyncId === null) { + applyAsyncId = $browser.defer(function() { + $rootScope.$apply(flushApplyAsync); + }); + } + } + }]; +} + +/** + * @description + * Private service to sanitize uris for links and images. Used by $compile and $sanitize. + */ +function $$SanitizeUriProvider() { + var aHrefSanitizationWhitelist = /^\s*(https?|ftp|mailto|tel|file):/, + imgSrcSanitizationWhitelist = /^\s*((https?|ftp|file|blob):|data:image\/)/; + + /** + * @description + * Retrieves or overrides the default regular expression that is used for whitelisting of safe + * urls during a[href] sanitization. + * + * The sanitization is a security measure aimed at prevent XSS attacks via html links. + * + * Any url about to be assigned to a[href] via data-binding is first normalized and turned into + * an absolute url. Afterwards, the url is matched against the `aHrefSanitizationWhitelist` + * regular expression. If a match is found, the original url is written into the dom. Otherwise, + * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM. + * + * @param {RegExp=} regexp New regexp to whitelist urls with. + * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for + * chaining otherwise. + */ + this.aHrefSanitizationWhitelist = function(regexp) { + if (isDefined(regexp)) { + aHrefSanitizationWhitelist = regexp; + return this; + } + return aHrefSanitizationWhitelist; + }; + + + /** + * @description + * Retrieves or overrides the default regular expression that is used for whitelisting of safe + * urls during img[src] sanitization. + * + * The sanitization is a security measure aimed at prevent XSS attacks via html links. + * + * Any url about to be assigned to img[src] via data-binding is first normalized and turned into + * an absolute url. Afterwards, the url is matched against the `imgSrcSanitizationWhitelist` + * regular expression. If a match is found, the original url is written into the dom. Otherwise, + * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM. + * + * @param {RegExp=} regexp New regexp to whitelist urls with. + * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for + * chaining otherwise. + */ + this.imgSrcSanitizationWhitelist = function(regexp) { + if (isDefined(regexp)) { + imgSrcSanitizationWhitelist = regexp; + return this; + } + return imgSrcSanitizationWhitelist; + }; + + this.$get = function() { + return function sanitizeUri(uri, isImage) { + var regex = isImage ? imgSrcSanitizationWhitelist : aHrefSanitizationWhitelist; + var normalizedVal; + normalizedVal = urlResolve(uri).href; + if (normalizedVal !== '' && !normalizedVal.match(regex)) { + return 'unsafe:' + normalizedVal; + } + return uri; + }; + }; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Any commits to this file should be reviewed with security in mind. * + * Changes to this file can potentially create security vulnerabilities. * + * An approval from 2 Core members with history of modifying * + * this file is required. * + * * + * Does the change somehow allow for arbitrary javascript to be executed? * + * Or allows for someone to change the prototype of built-in objects? * + * Or gives undesired access to variables likes document or window? * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +var $sceMinErr = minErr('$sce'); + +var SCE_CONTEXTS = { + HTML: 'html', + CSS: 'css', + URL: 'url', + // RESOURCE_URL is a subtype of URL used in contexts where a privileged resource is sourced from a + // url. (e.g. ng-include, script src, templateUrl) + RESOURCE_URL: 'resourceUrl', + JS: 'js' +}; + +// Helper functions follow. + +function adjustMatcher(matcher) { + if (matcher === 'self') { + return matcher; + } else if (isString(matcher)) { + // Strings match exactly except for 2 wildcards - '*' and '**'. + // '*' matches any character except those from the set ':/.?&'. + // '**' matches any character (like .* in a RegExp). + // More than 2 *'s raises an error as it's ill defined. + if (matcher.indexOf('***') > -1) { + throw $sceMinErr('iwcard', + 'Illegal sequence *** in string matcher. String: {0}', matcher); + } + matcher = escapeForRegexp(matcher). + replace('\\*\\*', '.*'). + replace('\\*', '[^:/.?&;]*'); + return new RegExp('^' + matcher + '$'); + } else if (isRegExp(matcher)) { + // The only other type of matcher allowed is a Regexp. + // Match entire URL / disallow partial matches. + // Flags are reset (i.e. no global, ignoreCase or multiline) + return new RegExp('^' + matcher.source + '$'); + } else { + throw $sceMinErr('imatcher', + 'Matchers may only be "self", string patterns or RegExp objects'); + } +} + + +function adjustMatchers(matchers) { + var adjustedMatchers = []; + if (isDefined(matchers)) { + forEach(matchers, function(matcher) { + adjustedMatchers.push(adjustMatcher(matcher)); + }); + } + return adjustedMatchers; +} + + +/** + * @ngdoc service + * @name $sceDelegate + * @kind function + * + * @description + * + * `$sceDelegate` is a service that is used by the `$sce` service to provide {@link ng.$sce Strict + * Contextual Escaping (SCE)} services to AngularJS. + * + * Typically, you would configure or override the {@link ng.$sceDelegate $sceDelegate} instead of + * the `$sce` service to customize the way Strict Contextual Escaping works in AngularJS. This is + * because, while the `$sce` provides numerous shorthand methods, etc., you really only need to + * override 3 core functions (`trustAs`, `getTrusted` and `valueOf`) to replace the way things + * work because `$sce` delegates to `$sceDelegate` for these operations. + * + * Refer {@link ng.$sceDelegateProvider $sceDelegateProvider} to configure this service. + * + * The default instance of `$sceDelegate` should work out of the box with little pain. While you + * can override it completely to change the behavior of `$sce`, the common case would + * involve configuring the {@link ng.$sceDelegateProvider $sceDelegateProvider} instead by setting + * your own whitelists and blacklists for trusting URLs used for loading AngularJS resources such as + * templates. Refer {@link ng.$sceDelegateProvider#resourceUrlWhitelist + * $sceDelegateProvider.resourceUrlWhitelist} and {@link + * ng.$sceDelegateProvider#resourceUrlBlacklist $sceDelegateProvider.resourceUrlBlacklist} + */ + +/** + * @ngdoc provider + * @name $sceDelegateProvider + * @description + * + * The `$sceDelegateProvider` provider allows developers to configure the {@link ng.$sceDelegate + * $sceDelegate} service. This allows one to get/set the whitelists and blacklists used to ensure + * that the URLs used for sourcing Angular templates are safe. Refer {@link + * ng.$sceDelegateProvider#resourceUrlWhitelist $sceDelegateProvider.resourceUrlWhitelist} and + * {@link ng.$sceDelegateProvider#resourceUrlBlacklist $sceDelegateProvider.resourceUrlBlacklist} + * + * For the general details about this service in Angular, read the main page for {@link ng.$sce + * Strict Contextual Escaping (SCE)}. + * + * **Example**: Consider the following case. + * + * - your app is hosted at url `http://myapp.example.com/` + * - but some of your templates are hosted on other domains you control such as + * `http://srv01.assets.example.com/`,  `http://srv02.assets.example.com/`, etc. + * - and you have an open redirect at `http://myapp.example.com/clickThru?...`. + * + * Here is what a secure configuration for this scenario might look like: + * + * ``` + * angular.module('myApp', []).config(function($sceDelegateProvider) { + * $sceDelegateProvider.resourceUrlWhitelist([ + * // Allow same origin resource loads. + * 'self', + * // Allow loading from our assets domain. Notice the difference between * and **. + * 'http://srv*.assets.example.com/**' + * ]); + * + * // The blacklist overrides the whitelist so the open redirect here is blocked. + * $sceDelegateProvider.resourceUrlBlacklist([ + * 'http://myapp.example.com/clickThru**' + * ]); + * }); + * ``` + */ + +function $SceDelegateProvider() { + this.SCE_CONTEXTS = SCE_CONTEXTS; + + // Resource URLs can also be trusted by policy. + var resourceUrlWhitelist = ['self'], + resourceUrlBlacklist = []; + + /** + * @ngdoc method + * @name $sceDelegateProvider#resourceUrlWhitelist + * @kind function + * + * @param {Array=} whitelist When provided, replaces the resourceUrlWhitelist with the value + * provided. This must be an array or null. A snapshot of this array is used so further + * changes to the array are ignored. + * + * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items + * allowed in this array. + * + * Note: **an empty whitelist array will block all URLs**! + * + * @return {Array} the currently set whitelist array. + * + * The **default value** when no whitelist has been explicitly set is `['self']` allowing only + * same origin resource requests. + * + * @description + * Sets/Gets the whitelist of trusted resource URLs. + */ + this.resourceUrlWhitelist = function(value) { + if (arguments.length) { + resourceUrlWhitelist = adjustMatchers(value); + } + return resourceUrlWhitelist; + }; + + /** + * @ngdoc method + * @name $sceDelegateProvider#resourceUrlBlacklist + * @kind function + * + * @param {Array=} blacklist When provided, replaces the resourceUrlBlacklist with the value + * provided. This must be an array or null. A snapshot of this array is used so further + * changes to the array are ignored. + * + * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items + * allowed in this array. + * + * The typical usage for the blacklist is to **block + * [open redirects](http://cwe.mitre.org/data/definitions/601.html)** served by your domain as + * these would otherwise be trusted but actually return content from the redirected domain. + * + * Finally, **the blacklist overrides the whitelist** and has the final say. + * + * @return {Array} the currently set blacklist array. + * + * The **default value** when no whitelist has been explicitly set is the empty array (i.e. there + * is no blacklist.) + * + * @description + * Sets/Gets the blacklist of trusted resource URLs. + */ + + this.resourceUrlBlacklist = function(value) { + if (arguments.length) { + resourceUrlBlacklist = adjustMatchers(value); + } + return resourceUrlBlacklist; + }; + + this.$get = ['$injector', function($injector) { + + var htmlSanitizer = function htmlSanitizer(html) { + throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.'); + }; + + if ($injector.has('$sanitize')) { + htmlSanitizer = $injector.get('$sanitize'); + } + + + function matchUrl(matcher, parsedUrl) { + if (matcher === 'self') { + return urlIsSameOrigin(parsedUrl); + } else { + // definitely a regex. See adjustMatchers() + return !!matcher.exec(parsedUrl.href); + } + } + + function isResourceUrlAllowedByPolicy(url) { + var parsedUrl = urlResolve(url.toString()); + var i, n, allowed = false; + // Ensure that at least one item from the whitelist allows this url. + for (i = 0, n = resourceUrlWhitelist.length; i < n; i++) { + if (matchUrl(resourceUrlWhitelist[i], parsedUrl)) { + allowed = true; + break; + } + } + if (allowed) { + // Ensure that no item from the blacklist blocked this url. + for (i = 0, n = resourceUrlBlacklist.length; i < n; i++) { + if (matchUrl(resourceUrlBlacklist[i], parsedUrl)) { + allowed = false; + break; + } + } + } + return allowed; + } + + function generateHolderType(Base) { + var holderType = function TrustedValueHolderType(trustedValue) { + this.$$unwrapTrustedValue = function() { + return trustedValue; + }; + }; + if (Base) { + holderType.prototype = new Base(); + } + holderType.prototype.valueOf = function sceValueOf() { + return this.$$unwrapTrustedValue(); + }; + holderType.prototype.toString = function sceToString() { + return this.$$unwrapTrustedValue().toString(); + }; + return holderType; + } + + var trustedValueHolderBase = generateHolderType(), + byType = {}; + + byType[SCE_CONTEXTS.HTML] = generateHolderType(trustedValueHolderBase); + byType[SCE_CONTEXTS.CSS] = generateHolderType(trustedValueHolderBase); + byType[SCE_CONTEXTS.URL] = generateHolderType(trustedValueHolderBase); + byType[SCE_CONTEXTS.JS] = generateHolderType(trustedValueHolderBase); + byType[SCE_CONTEXTS.RESOURCE_URL] = generateHolderType(byType[SCE_CONTEXTS.URL]); + + /** + * @ngdoc method + * @name $sceDelegate#trustAs + * + * @description + * Returns an object that is trusted by angular for use in specified strict + * contextual escaping contexts (such as ng-bind-html, ng-include, any src + * attribute interpolation, any dom event binding attribute interpolation + * such as for onclick, etc.) that uses the provided value. + * See {@link ng.$sce $sce} for enabling strict contextual escaping. + * + * @param {string} type The kind of context in which this value is safe for use. e.g. url, + * resourceUrl, html, js and css. + * @param {*} value The value that that should be considered trusted/safe. + * @returns {*} A value that can be used to stand in for the provided `value` in places + * where Angular expects a $sce.trustAs() return value. + */ + function trustAs(type, trustedValue) { + var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); + if (!Constructor) { + throw $sceMinErr('icontext', + 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}', + type, trustedValue); + } + if (trustedValue === null || isUndefined(trustedValue) || trustedValue === '') { + return trustedValue; + } + // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting + // mutable objects, we ensure here that the value passed in is actually a string. + if (typeof trustedValue !== 'string') { + throw $sceMinErr('itype', + 'Attempted to trust a non-string value in a content requiring a string: Context: {0}', + type); + } + return new Constructor(trustedValue); + } + + /** + * @ngdoc method + * @name $sceDelegate#valueOf + * + * @description + * If the passed parameter had been returned by a prior call to {@link ng.$sceDelegate#trustAs + * `$sceDelegate.trustAs`}, returns the value that had been passed to {@link + * ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}. + * + * If the passed parameter is not a value that had been returned by {@link + * ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}, returns it as-is. + * + * @param {*} value The result of a prior {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`} + * call or anything else. + * @returns {*} The `value` that was originally provided to {@link ng.$sceDelegate#trustAs + * `$sceDelegate.trustAs`} if `value` is the result of such a call. Otherwise, returns + * `value` unchanged. + */ + function valueOf(maybeTrusted) { + if (maybeTrusted instanceof trustedValueHolderBase) { + return maybeTrusted.$$unwrapTrustedValue(); + } else { + return maybeTrusted; + } + } + + /** + * @ngdoc method + * @name $sceDelegate#getTrusted + * + * @description + * Takes the result of a {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`} call and + * returns the originally supplied value if the queried context type is a supertype of the + * created type. If this condition isn't satisfied, throws an exception. + * + * @param {string} type The kind of context in which this value is to be used. + * @param {*} maybeTrusted The result of a prior {@link ng.$sceDelegate#trustAs + * `$sceDelegate.trustAs`} call. + * @returns {*} The value the was originally provided to {@link ng.$sceDelegate#trustAs + * `$sceDelegate.trustAs`} if valid in this context. Otherwise, throws an exception. + */ + function getTrusted(type, maybeTrusted) { + if (maybeTrusted === null || isUndefined(maybeTrusted) || maybeTrusted === '') { + return maybeTrusted; + } + var constructor = (byType.hasOwnProperty(type) ? byType[type] : null); + if (constructor && maybeTrusted instanceof constructor) { + return maybeTrusted.$$unwrapTrustedValue(); + } + // If we get here, then we may only take one of two actions. + // 1. sanitize the value for the requested type, or + // 2. throw an exception. + if (type === SCE_CONTEXTS.RESOURCE_URL) { + if (isResourceUrlAllowedByPolicy(maybeTrusted)) { + return maybeTrusted; + } else { + throw $sceMinErr('insecurl', + 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: {0}', + maybeTrusted.toString()); + } + } else if (type === SCE_CONTEXTS.HTML) { + return htmlSanitizer(maybeTrusted); + } + throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.'); + } + + return { trustAs: trustAs, + getTrusted: getTrusted, + valueOf: valueOf }; + }]; +} + + +/** + * @ngdoc provider + * @name $sceProvider + * @description + * + * The $sceProvider provider allows developers to configure the {@link ng.$sce $sce} service. + * - enable/disable Strict Contextual Escaping (SCE) in a module + * - override the default implementation with a custom delegate + * + * Read more about {@link ng.$sce Strict Contextual Escaping (SCE)}. + */ + +/* jshint maxlen: false*/ + +/** + * @ngdoc service + * @name $sce + * @kind function + * + * @description + * + * `$sce` is a service that provides Strict Contextual Escaping services to AngularJS. + * + * # Strict Contextual Escaping + * + * Strict Contextual Escaping (SCE) is a mode in which AngularJS requires bindings in certain + * contexts to result in a value that is marked as safe to use for that context. One example of + * such a context is binding arbitrary html controlled by the user via `ng-bind-html`. We refer + * to these contexts as privileged or SCE contexts. + * + * As of version 1.2, Angular ships with SCE enabled by default. + * + * Note: When enabled (the default), IE<11 in quirks mode is not supported. In this mode, IE<11 allow + * one to execute arbitrary javascript by the use of the expression() syntax. Refer + * to learn more about them. + * You can ensure your document is in standards mode and not quirks mode by adding `` + * to the top of your HTML document. + * + * SCE assists in writing code in way that (a) is secure by default and (b) makes auditing for + * security vulnerabilities such as XSS, clickjacking, etc. a lot easier. + * + * Here's an example of a binding in a privileged context: + * + * ``` + * + *
+ * ``` + * + * Notice that `ng-bind-html` is bound to `userHtml` controlled by the user. With SCE + * disabled, this application allows the user to render arbitrary HTML into the DIV. + * In a more realistic example, one may be rendering user comments, blog articles, etc. via + * bindings. (HTML is just one example of a context where rendering user controlled input creates + * security vulnerabilities.) + * + * For the case of HTML, you might use a library, either on the client side, or on the server side, + * to sanitize unsafe HTML before binding to the value and rendering it in the document. + * + * How would you ensure that every place that used these types of bindings was bound to a value that + * was sanitized by your library (or returned as safe for rendering by your server?) How can you + * ensure that you didn't accidentally delete the line that sanitized the value, or renamed some + * properties/fields and forgot to update the binding to the sanitized value? + * + * To be secure by default, you want to ensure that any such bindings are disallowed unless you can + * determine that something explicitly says it's safe to use a value for binding in that + * context. You can then audit your code (a simple grep would do) to ensure that this is only done + * for those values that you can easily tell are safe - because they were received from your server, + * sanitized by your library, etc. You can organize your codebase to help with this - perhaps + * allowing only the files in a specific directory to do this. Ensuring that the internal API + * exposed by that code doesn't markup arbitrary values as safe then becomes a more manageable task. + * + * In the case of AngularJS' SCE service, one uses {@link ng.$sce#trustAs $sce.trustAs} + * (and shorthand methods such as {@link ng.$sce#trustAsHtml $sce.trustAsHtml}, etc.) to + * obtain values that will be accepted by SCE / privileged contexts. + * + * + * ## How does it work? + * + * In privileged contexts, directives and code will bind to the result of {@link ng.$sce#getTrusted + * $sce.getTrusted(context, value)} rather than to the value directly. Directives use {@link + * ng.$sce#parseAs $sce.parseAs} rather than `$parse` to watch attribute bindings, which performs the + * {@link ng.$sce#getTrusted $sce.getTrusted} behind the scenes on non-constant literals. + * + * As an example, {@link ng.directive:ngBindHtml ngBindHtml} uses {@link + * ng.$sce#parseAsHtml $sce.parseAsHtml(binding expression)}. Here's the actual code (slightly + * simplified): + * + * ``` + * var ngBindHtmlDirective = ['$sce', function($sce) { + * return function(scope, element, attr) { + * scope.$watch($sce.parseAsHtml(attr.ngBindHtml), function(value) { + * element.html(value || ''); + * }); + * }; + * }]; + * ``` + * + * ## Impact on loading templates + * + * This applies both to the {@link ng.directive:ngInclude `ng-include`} directive as well as + * `templateUrl`'s specified by {@link guide/directive directives}. + * + * By default, Angular only loads templates from the same domain and protocol as the application + * document. This is done by calling {@link ng.$sce#getTrustedResourceUrl + * $sce.getTrustedResourceUrl} on the template URL. To load templates from other domains and/or + * protocols, you may either either {@link ng.$sceDelegateProvider#resourceUrlWhitelist whitelist + * them} or {@link ng.$sce#trustAsResourceUrl wrap it} into a trusted value. + * + * *Please note*: + * The browser's + * [Same Origin Policy](https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_XMLHttpRequest) + * and [Cross-Origin Resource Sharing (CORS)](http://www.w3.org/TR/cors/) + * policy apply in addition to this and may further restrict whether the template is successfully + * loaded. This means that without the right CORS policy, loading templates from a different domain + * won't work on all browsers. Also, loading templates from `file://` URL does not work on some + * browsers. + * + * ## This feels like too much overhead + * + * It's important to remember that SCE only applies to interpolation expressions. + * + * If your expressions are constant literals, they're automatically trusted and you don't need to + * call `$sce.trustAs` on them (remember to include the `ngSanitize` module) (e.g. + * `
`) just works. + * + * Additionally, `a[href]` and `img[src]` automatically sanitize their URLs and do not pass them + * through {@link ng.$sce#getTrusted $sce.getTrusted}. SCE doesn't play a role here. + * + * The included {@link ng.$sceDelegate $sceDelegate} comes with sane defaults to allow you to load + * templates in `ng-include` from your application's domain without having to even know about SCE. + * It blocks loading templates from other domains or loading templates over http from an https + * served document. You can change these by setting your own custom {@link + * ng.$sceDelegateProvider#resourceUrlWhitelist whitelists} and {@link + * ng.$sceDelegateProvider#resourceUrlBlacklist blacklists} for matching such URLs. + * + * This significantly reduces the overhead. It is far easier to pay the small overhead and have an + * application that's secure and can be audited to verify that with much more ease than bolting + * security onto an application later. + * + * + * ## What trusted context types are supported? + * + * | Context | Notes | + * |---------------------|----------------| + * | `$sce.HTML` | For HTML that's safe to source into the application. The {@link ng.directive:ngBindHtml ngBindHtml} directive uses this context for bindings. If an unsafe value is encountered and the {@link ngSanitize $sanitize} module is present this will sanitize the value instead of throwing an error. | + * | `$sce.CSS` | For CSS that's safe to source into the application. Currently unused. Feel free to use it in your own directives. | + * | `$sce.URL` | For URLs that are safe to follow as links. Currently unused (`
Note that `$sce.RESOURCE_URL` makes a stronger statement about the URL than `$sce.URL` does and therefore contexts requiring values trusted for `$sce.RESOURCE_URL` can be used anywhere that values trusted for `$sce.URL` are required. | + * | `$sce.JS` | For JavaScript that is safe to execute in your application's context. Currently unused. Feel free to use it in your own directives. | + * + * ## Format of items in {@link ng.$sceDelegateProvider#resourceUrlWhitelist resourceUrlWhitelist}/{@link ng.$sceDelegateProvider#resourceUrlBlacklist Blacklist}
+ * + * Each element in these arrays must be one of the following: + * + * - **'self'** + * - The special **string**, `'self'`, can be used to match against all URLs of the **same + * domain** as the application document using the **same protocol**. + * - **String** (except the special value `'self'`) + * - The string is matched against the full *normalized / absolute URL* of the resource + * being tested (substring matches are not good enough.) + * - There are exactly **two wildcard sequences** - `*` and `**`. All other characters + * match themselves. + * - `*`: matches zero or more occurrences of any character other than one of the following 6 + * characters: '`:`', '`/`', '`.`', '`?`', '`&`' and '`;`'. It's a useful wildcard for use + * in a whitelist. + * - `**`: matches zero or more occurrences of *any* character. As such, it's not + * appropriate for use in a scheme, domain, etc. as it would match too much. (e.g. + * http://**.example.com/ would match http://evil.com/?ignore=.example.com/ and that might + * not have been the intention.) Its usage at the very end of the path is ok. (e.g. + * http://foo.example.com/templates/**). + * - **RegExp** (*see caveat below*) + * - *Caveat*: While regular expressions are powerful and offer great flexibility, their syntax + * (and all the inevitable escaping) makes them *harder to maintain*. It's easy to + * accidentally introduce a bug when one updates a complex expression (imho, all regexes should + * have good test coverage). For instance, the use of `.` in the regex is correct only in a + * small number of cases. A `.` character in the regex used when matching the scheme or a + * subdomain could be matched against a `:` or literal `.` that was likely not intended. It + * is highly recommended to use the string patterns and only fall back to regular expressions + * as a last resort. + * - The regular expression must be an instance of RegExp (i.e. not a string.) It is + * matched against the **entire** *normalized / absolute URL* of the resource being tested + * (even when the RegExp did not have the `^` and `$` codes.) In addition, any flags + * present on the RegExp (such as multiline, global, ignoreCase) are ignored. + * - If you are generating your JavaScript from some other templating engine (not + * recommended, e.g. in issue [#4006](https://github.com/angular/angular.js/issues/4006)), + * remember to escape your regular expression (and be aware that you might need more than + * one level of escaping depending on your templating engine and the way you interpolated + * the value.) Do make use of your platform's escaping mechanism as it might be good + * enough before coding your own. E.g. Ruby has + * [Regexp.escape(str)](http://www.ruby-doc.org/core-2.0.0/Regexp.html#method-c-escape) + * and Python has [re.escape](http://docs.python.org/library/re.html#re.escape). + * Javascript lacks a similar built in function for escaping. Take a look at Google + * Closure library's [goog.string.regExpEscape(s)]( + * http://docs.closure-library.googlecode.com/git/closure_goog_string_string.js.source.html#line962). + * + * Refer {@link ng.$sceDelegateProvider $sceDelegateProvider} for an example. + * + * ## Show me an example using SCE. + * + * + * + *
+ *

+ * User comments
+ * By default, HTML that isn't explicitly trusted (e.g. Alice's comment) is sanitized when + * $sanitize is available. If $sanitize isn't available, this results in an error instead of an + * exploit. + *
+ *
+ * {{userComment.name}}: + * + *
+ *
+ *
+ *
+ *
+ * + * + * angular.module('mySceApp', ['ngSanitize']) + * .controller('AppController', ['$http', '$templateCache', '$sce', + * function($http, $templateCache, $sce) { + * var self = this; + * $http.get("test_data.json", {cache: $templateCache}).success(function(userComments) { + * self.userComments = userComments; + * }); + * self.explicitlyTrustedHtml = $sce.trustAsHtml( + * 'Hover over this text.'); + * }]); + * + * + * + * [ + * { "name": "Alice", + * "htmlComment": + * "Is anyone reading this?" + * }, + * { "name": "Bob", + * "htmlComment": "Yes! Am I the only other one?" + * } + * ] + * + * + * + * describe('SCE doc demo', function() { + * it('should sanitize untrusted values', function() { + * expect(element.all(by.css('.htmlComment')).first().getInnerHtml()) + * .toBe('Is anyone reading this?'); + * }); + * + * it('should NOT sanitize explicitly trusted values', function() { + * expect(element(by.id('explicitlyTrustedHtml')).getInnerHtml()).toBe( + * 'Hover over this text.'); + * }); + * }); + * + *
+ * + * + * + * ## Can I disable SCE completely? + * + * Yes, you can. However, this is strongly discouraged. SCE gives you a lot of security benefits + * for little coding overhead. It will be much harder to take an SCE disabled application and + * either secure it on your own or enable SCE at a later stage. It might make sense to disable SCE + * for cases where you have a lot of existing code that was written before SCE was introduced and + * you're migrating them a module at a time. + * + * That said, here's how you can completely disable SCE: + * + * ``` + * angular.module('myAppWithSceDisabledmyApp', []).config(function($sceProvider) { + * // Completely disable SCE. For demonstration purposes only! + * // Do not use in new projects. + * $sceProvider.enabled(false); + * }); + * ``` + * + */ +/* jshint maxlen: 100 */ + +function $SceProvider() { + var enabled = true; + + /** + * @ngdoc method + * @name $sceProvider#enabled + * @kind function + * + * @param {boolean=} value If provided, then enables/disables SCE. + * @return {boolean} true if SCE is enabled, false otherwise. + * + * @description + * Enables/disables SCE and returns the current value. + */ + this.enabled = function(value) { + if (arguments.length) { + enabled = !!value; + } + return enabled; + }; + + + /* Design notes on the default implementation for SCE. + * + * The API contract for the SCE delegate + * ------------------------------------- + * The SCE delegate object must provide the following 3 methods: + * + * - trustAs(contextEnum, value) + * This method is used to tell the SCE service that the provided value is OK to use in the + * contexts specified by contextEnum. It must return an object that will be accepted by + * getTrusted() for a compatible contextEnum and return this value. + * + * - valueOf(value) + * For values that were not produced by trustAs(), return them as is. For values that were + * produced by trustAs(), return the corresponding input value to trustAs. Basically, if + * trustAs is wrapping the given values into some type, this operation unwraps it when given + * such a value. + * + * - getTrusted(contextEnum, value) + * This function should return the a value that is safe to use in the context specified by + * contextEnum or throw and exception otherwise. + * + * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be + * opaque or wrapped in some holder object. That happens to be an implementation detail. For + * instance, an implementation could maintain a registry of all trusted objects by context. In + * such a case, trustAs() would return the same object that was passed in. getTrusted() would + * return the same object passed in if it was found in the registry under a compatible context or + * throw an exception otherwise. An implementation might only wrap values some of the time based + * on some criteria. getTrusted() might return a value and not throw an exception for special + * constants or objects even if not wrapped. All such implementations fulfill this contract. + * + * + * A note on the inheritance model for SCE contexts + * ------------------------------------------------ + * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types. This + * is purely an implementation details. + * + * The contract is simply this: + * + * getTrusted($sce.RESOURCE_URL, value) succeeding implies that getTrusted($sce.URL, value) + * will also succeed. + * + * Inheritance happens to capture this in a natural way. In some future, we + * may not use inheritance anymore. That is OK because no code outside of + * sce.js and sceSpecs.js would need to be aware of this detail. + */ + + this.$get = ['$parse', '$sceDelegate', function( + $parse, $sceDelegate) { + // Prereq: Ensure that we're not running in IE<11 quirks mode. In that mode, IE < 11 allow + // the "expression(javascript expression)" syntax which is insecure. + if (enabled && msie < 8) { + throw $sceMinErr('iequirks', + 'Strict Contextual Escaping does not support Internet Explorer version < 11 in quirks ' + + 'mode. You can fix this by adding the text to the top of your HTML ' + + 'document. See http://docs.angularjs.org/api/ng.$sce for more information.'); + } + + var sce = shallowCopy(SCE_CONTEXTS); + + /** + * @ngdoc method + * @name $sce#isEnabled + * @kind function + * + * @return {Boolean} true if SCE is enabled, false otherwise. If you want to set the value, you + * have to do it at module config time on {@link ng.$sceProvider $sceProvider}. + * + * @description + * Returns a boolean indicating if SCE is enabled. + */ + sce.isEnabled = function() { + return enabled; + }; + sce.trustAs = $sceDelegate.trustAs; + sce.getTrusted = $sceDelegate.getTrusted; + sce.valueOf = $sceDelegate.valueOf; + + if (!enabled) { + sce.trustAs = sce.getTrusted = function(type, value) { return value; }; + sce.valueOf = identity; + } + + /** + * @ngdoc method + * @name $sce#parseAs + * + * @description + * Converts Angular {@link guide/expression expression} into a function. This is like {@link + * ng.$parse $parse} and is identical when the expression is a literal constant. Otherwise, it + * wraps the expression in a call to {@link ng.$sce#getTrusted $sce.getTrusted(*type*, + * *result*)} + * + * @param {string} type The kind of SCE context in which this result will be used. + * @param {string} expression String expression to compile. + * @returns {function(context, locals)} a function which represents the compiled expression: + * + * * `context` – `{object}` – an object against which any expressions embedded in the strings + * are evaluated against (typically a scope object). + * * `locals` – `{object=}` – local variables context object, useful for overriding values in + * `context`. + */ + sce.parseAs = function sceParseAs(type, expr) { + var parsed = $parse(expr); + if (parsed.literal && parsed.constant) { + return parsed; + } else { + return $parse(expr, function(value) { + return sce.getTrusted(type, value); + }); + } + }; + + /** + * @ngdoc method + * @name $sce#trustAs + * + * @description + * Delegates to {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}. As such, + * returns an object that is trusted by angular for use in specified strict contextual + * escaping contexts (such as ng-bind-html, ng-include, any src attribute + * interpolation, any dom event binding attribute interpolation such as for onclick, etc.) + * that uses the provided value. See * {@link ng.$sce $sce} for enabling strict contextual + * escaping. + * + * @param {string} type The kind of context in which this value is safe for use. e.g. url, + * resourceUrl, html, js and css. + * @param {*} value The value that that should be considered trusted/safe. + * @returns {*} A value that can be used to stand in for the provided `value` in places + * where Angular expects a $sce.trustAs() return value. + */ + + /** + * @ngdoc method + * @name $sce#trustAsHtml + * + * @description + * Shorthand method. `$sce.trustAsHtml(value)` → + * {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.HTML, value)`} + * + * @param {*} value The value to trustAs. + * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedHtml + * $sce.getTrustedHtml(value)} to obtain the original value. (privileged directives + * only accept expressions that are either literal constants or are the + * return value of {@link ng.$sce#trustAs $sce.trustAs}.) + */ + + /** + * @ngdoc method + * @name $sce#trustAsUrl + * + * @description + * Shorthand method. `$sce.trustAsUrl(value)` → + * {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.URL, value)`} + * + * @param {*} value The value to trustAs. + * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedUrl + * $sce.getTrustedUrl(value)} to obtain the original value. (privileged directives + * only accept expressions that are either literal constants or are the + * return value of {@link ng.$sce#trustAs $sce.trustAs}.) + */ + + /** + * @ngdoc method + * @name $sce#trustAsResourceUrl + * + * @description + * Shorthand method. `$sce.trustAsResourceUrl(value)` → + * {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.RESOURCE_URL, value)`} + * + * @param {*} value The value to trustAs. + * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedResourceUrl + * $sce.getTrustedResourceUrl(value)} to obtain the original value. (privileged directives + * only accept expressions that are either literal constants or are the return + * value of {@link ng.$sce#trustAs $sce.trustAs}.) + */ + + /** + * @ngdoc method + * @name $sce#trustAsJs + * + * @description + * Shorthand method. `$sce.trustAsJs(value)` → + * {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.JS, value)`} + * + * @param {*} value The value to trustAs. + * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedJs + * $sce.getTrustedJs(value)} to obtain the original value. (privileged directives + * only accept expressions that are either literal constants or are the + * return value of {@link ng.$sce#trustAs $sce.trustAs}.) + */ + + /** + * @ngdoc method + * @name $sce#getTrusted + * + * @description + * Delegates to {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted`}. As such, + * takes the result of a {@link ng.$sce#trustAs `$sce.trustAs`}() call and returns the + * originally supplied value if the queried context type is a supertype of the created type. + * If this condition isn't satisfied, throws an exception. + * + * @param {string} type The kind of context in which this value is to be used. + * @param {*} maybeTrusted The result of a prior {@link ng.$sce#trustAs `$sce.trustAs`} + * call. + * @returns {*} The value the was originally provided to + * {@link ng.$sce#trustAs `$sce.trustAs`} if valid in this context. + * Otherwise, throws an exception. + */ + + /** + * @ngdoc method + * @name $sce#getTrustedHtml + * + * @description + * Shorthand method. `$sce.getTrustedHtml(value)` → + * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.HTML, value)`} + * + * @param {*} value The value to pass to `$sce.getTrusted`. + * @returns {*} The return value of `$sce.getTrusted($sce.HTML, value)` + */ + + /** + * @ngdoc method + * @name $sce#getTrustedCss + * + * @description + * Shorthand method. `$sce.getTrustedCss(value)` → + * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.CSS, value)`} + * + * @param {*} value The value to pass to `$sce.getTrusted`. + * @returns {*} The return value of `$sce.getTrusted($sce.CSS, value)` + */ + + /** + * @ngdoc method + * @name $sce#getTrustedUrl + * + * @description + * Shorthand method. `$sce.getTrustedUrl(value)` → + * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.URL, value)`} + * + * @param {*} value The value to pass to `$sce.getTrusted`. + * @returns {*} The return value of `$sce.getTrusted($sce.URL, value)` + */ + + /** + * @ngdoc method + * @name $sce#getTrustedResourceUrl + * + * @description + * Shorthand method. `$sce.getTrustedResourceUrl(value)` → + * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.RESOURCE_URL, value)`} + * + * @param {*} value The value to pass to `$sceDelegate.getTrusted`. + * @returns {*} The return value of `$sce.getTrusted($sce.RESOURCE_URL, value)` + */ + + /** + * @ngdoc method + * @name $sce#getTrustedJs + * + * @description + * Shorthand method. `$sce.getTrustedJs(value)` → + * {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.JS, value)`} + * + * @param {*} value The value to pass to `$sce.getTrusted`. + * @returns {*} The return value of `$sce.getTrusted($sce.JS, value)` + */ + + /** + * @ngdoc method + * @name $sce#parseAsHtml + * + * @description + * Shorthand method. `$sce.parseAsHtml(expression string)` → + * {@link ng.$sce#parseAs `$sce.parseAs($sce.HTML, value)`} + * + * @param {string} expression String expression to compile. + * @returns {function(context, locals)} a function which represents the compiled expression: + * + * * `context` – `{object}` – an object against which any expressions embedded in the strings + * are evaluated against (typically a scope object). + * * `locals` – `{object=}` – local variables context object, useful for overriding values in + * `context`. + */ + + /** + * @ngdoc method + * @name $sce#parseAsCss + * + * @description + * Shorthand method. `$sce.parseAsCss(value)` → + * {@link ng.$sce#parseAs `$sce.parseAs($sce.CSS, value)`} + * + * @param {string} expression String expression to compile. + * @returns {function(context, locals)} a function which represents the compiled expression: + * + * * `context` – `{object}` – an object against which any expressions embedded in the strings + * are evaluated against (typically a scope object). + * * `locals` – `{object=}` – local variables context object, useful for overriding values in + * `context`. + */ + + /** + * @ngdoc method + * @name $sce#parseAsUrl + * + * @description + * Shorthand method. `$sce.parseAsUrl(value)` → + * {@link ng.$sce#parseAs `$sce.parseAs($sce.URL, value)`} + * + * @param {string} expression String expression to compile. + * @returns {function(context, locals)} a function which represents the compiled expression: + * + * * `context` – `{object}` – an object against which any expressions embedded in the strings + * are evaluated against (typically a scope object). + * * `locals` – `{object=}` – local variables context object, useful for overriding values in + * `context`. + */ + + /** + * @ngdoc method + * @name $sce#parseAsResourceUrl + * + * @description + * Shorthand method. `$sce.parseAsResourceUrl(value)` → + * {@link ng.$sce#parseAs `$sce.parseAs($sce.RESOURCE_URL, value)`} + * + * @param {string} expression String expression to compile. + * @returns {function(context, locals)} a function which represents the compiled expression: + * + * * `context` – `{object}` – an object against which any expressions embedded in the strings + * are evaluated against (typically a scope object). + * * `locals` – `{object=}` – local variables context object, useful for overriding values in + * `context`. + */ + + /** + * @ngdoc method + * @name $sce#parseAsJs + * + * @description + * Shorthand method. `$sce.parseAsJs(value)` → + * {@link ng.$sce#parseAs `$sce.parseAs($sce.JS, value)`} + * + * @param {string} expression String expression to compile. + * @returns {function(context, locals)} a function which represents the compiled expression: + * + * * `context` – `{object}` – an object against which any expressions embedded in the strings + * are evaluated against (typically a scope object). + * * `locals` – `{object=}` – local variables context object, useful for overriding values in + * `context`. + */ + + // Shorthand delegations. + var parse = sce.parseAs, + getTrusted = sce.getTrusted, + trustAs = sce.trustAs; + + forEach(SCE_CONTEXTS, function(enumValue, name) { + var lName = lowercase(name); + sce[camelCase("parse_as_" + lName)] = function(expr) { + return parse(enumValue, expr); + }; + sce[camelCase("get_trusted_" + lName)] = function(value) { + return getTrusted(enumValue, value); + }; + sce[camelCase("trust_as_" + lName)] = function(value) { + return trustAs(enumValue, value); + }; + }); + + return sce; + }]; +} + +/** + * !!! This is an undocumented "private" service !!! + * + * @name $sniffer + * @requires $window + * @requires $document + * + * @property {boolean} history Does the browser support html5 history api ? + * @property {boolean} transitions Does the browser support CSS transition events ? + * @property {boolean} animations Does the browser support CSS animation events ? + * + * @description + * This is very simple implementation of testing browser's features. + */ +function $SnifferProvider() { + this.$get = ['$window', '$document', function($window, $document) { + var eventSupport = {}, + android = + toInt((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]), + boxee = /Boxee/i.test(($window.navigator || {}).userAgent), + document = $document[0] || {}, + vendorPrefix, + vendorRegex = /^(Moz|webkit|ms)(?=[A-Z])/, + bodyStyle = document.body && document.body.style, + transitions = false, + animations = false, + match; + + if (bodyStyle) { + for (var prop in bodyStyle) { + if (match = vendorRegex.exec(prop)) { + vendorPrefix = match[0]; + vendorPrefix = vendorPrefix.substr(0, 1).toUpperCase() + vendorPrefix.substr(1); + break; + } + } + + if (!vendorPrefix) { + vendorPrefix = ('WebkitOpacity' in bodyStyle) && 'webkit'; + } + + transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle)); + animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle)); + + if (android && (!transitions || !animations)) { + transitions = isString(bodyStyle.webkitTransition); + animations = isString(bodyStyle.webkitAnimation); + } + } + + + return { + // Android has history.pushState, but it does not update location correctly + // so let's not use the history API at all. + // http://code.google.com/p/android/issues/detail?id=17471 + // https://github.com/angular/angular.js/issues/904 + + // older webkit browser (533.9) on Boxee box has exactly the same problem as Android has + // so let's not use the history API also + // We are purposefully using `!(android < 4)` to cover the case when `android` is undefined + // jshint -W018 + history: !!($window.history && $window.history.pushState && !(android < 4) && !boxee), + // jshint +W018 + hasEvent: function(event) { + // IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have + // it. In particular the event is not fired when backspace or delete key are pressed or + // when cut operation is performed. + // IE10+ implements 'input' event but it erroneously fires under various situations, + // e.g. when placeholder changes, or a form is focused. + if (event === 'input' && msie <= 11) return false; + + if (isUndefined(eventSupport[event])) { + var divElm = document.createElement('div'); + eventSupport[event] = 'on' + event in divElm; + } + + return eventSupport[event]; + }, + csp: csp(), + vendorPrefix: vendorPrefix, + transitions: transitions, + animations: animations, + android: android + }; + }]; +} + +var $compileMinErr = minErr('$compile'); + +/** + * @ngdoc service + * @name $templateRequest + * + * @description + * The `$templateRequest` service runs security checks then downloads the provided template using + * `$http` and, upon success, stores the contents inside of `$templateCache`. If the HTTP request + * fails or the response data of the HTTP request is empty, a `$compile` error will be thrown (the + * exception can be thwarted by setting the 2nd parameter of the function to true). Note that the + * contents of `$templateCache` are trusted, so the call to `$sce.getTrustedUrl(tpl)` is omitted + * when `tpl` is of type string and `$templateCache` has the matching entry. + * + * @param {string|TrustedResourceUrl} tpl The HTTP request template URL + * @param {boolean=} ignoreRequestError Whether or not to ignore the exception when the request fails or the template is empty + * + * @return {Promise} a promise for the HTTP response data of the given URL. + * + * @property {number} totalPendingRequests total amount of pending template requests being downloaded. + */ +function $TemplateRequestProvider() { + this.$get = ['$templateCache', '$http', '$q', '$sce', function($templateCache, $http, $q, $sce) { + function handleRequestFn(tpl, ignoreRequestError) { + handleRequestFn.totalPendingRequests++; + + // We consider the template cache holds only trusted templates, so + // there's no need to go through whitelisting again for keys that already + // are included in there. This also makes Angular accept any script + // directive, no matter its name. However, we still need to unwrap trusted + // types. + if (!isString(tpl) || !$templateCache.get(tpl)) { + tpl = $sce.getTrustedResourceUrl(tpl); + } + + var transformResponse = $http.defaults && $http.defaults.transformResponse; + + if (isArray(transformResponse)) { + transformResponse = transformResponse.filter(function(transformer) { + return transformer !== defaultHttpResponseTransform; + }); + } else if (transformResponse === defaultHttpResponseTransform) { + transformResponse = null; + } + + var httpOptions = { + cache: $templateCache, + transformResponse: transformResponse + }; + + return $http.get(tpl, httpOptions) + ['finally'](function() { + handleRequestFn.totalPendingRequests--; + }) + .then(function(response) { + $templateCache.put(tpl, response.data); + return response.data; + }, handleError); + + function handleError(resp) { + if (!ignoreRequestError) { + throw $compileMinErr('tpload', 'Failed to load template: {0} (HTTP status: {1} {2})', + tpl, resp.status, resp.statusText); + } + return $q.reject(resp); + } + } + + handleRequestFn.totalPendingRequests = 0; + + return handleRequestFn; + }]; +} + +function $$TestabilityProvider() { + this.$get = ['$rootScope', '$browser', '$location', + function($rootScope, $browser, $location) { + + /** + * @name $testability + * + * @description + * The private $$testability service provides a collection of methods for use when debugging + * or by automated test and debugging tools. + */ + var testability = {}; + + /** + * @name $$testability#findBindings + * + * @description + * Returns an array of elements that are bound (via ng-bind or {{}}) + * to expressions matching the input. + * + * @param {Element} element The element root to search from. + * @param {string} expression The binding expression to match. + * @param {boolean} opt_exactMatch If true, only returns exact matches + * for the expression. Filters and whitespace are ignored. + */ + testability.findBindings = function(element, expression, opt_exactMatch) { + var bindings = element.getElementsByClassName('ng-binding'); + var matches = []; + forEach(bindings, function(binding) { + var dataBinding = angular.element(binding).data('$binding'); + if (dataBinding) { + forEach(dataBinding, function(bindingName) { + if (opt_exactMatch) { + var matcher = new RegExp('(^|\\s)' + escapeForRegexp(expression) + '(\\s|\\||$)'); + if (matcher.test(bindingName)) { + matches.push(binding); + } + } else { + if (bindingName.indexOf(expression) != -1) { + matches.push(binding); + } + } + }); + } + }); + return matches; + }; + + /** + * @name $$testability#findModels + * + * @description + * Returns an array of elements that are two-way found via ng-model to + * expressions matching the input. + * + * @param {Element} element The element root to search from. + * @param {string} expression The model expression to match. + * @param {boolean} opt_exactMatch If true, only returns exact matches + * for the expression. + */ + testability.findModels = function(element, expression, opt_exactMatch) { + var prefixes = ['ng-', 'data-ng-', 'ng\\:']; + for (var p = 0; p < prefixes.length; ++p) { + var attributeEquals = opt_exactMatch ? '=' : '*='; + var selector = '[' + prefixes[p] + 'model' + attributeEquals + '"' + expression + '"]'; + var elements = element.querySelectorAll(selector); + if (elements.length) { + return elements; + } + } + }; + + /** + * @name $$testability#getLocation + * + * @description + * Shortcut for getting the location in a browser agnostic way. Returns + * the path, search, and hash. (e.g. /path?a=b#hash) + */ + testability.getLocation = function() { + return $location.url(); + }; + + /** + * @name $$testability#setLocation + * + * @description + * Shortcut for navigating to a location without doing a full page reload. + * + * @param {string} url The location url (path, search and hash, + * e.g. /path?a=b#hash) to go to. + */ + testability.setLocation = function(url) { + if (url !== $location.url()) { + $location.url(url); + $rootScope.$digest(); + } + }; + + /** + * @name $$testability#whenStable + * + * @description + * Calls the callback when $timeout and $http requests are completed. + * + * @param {function} callback + */ + testability.whenStable = function(callback) { + $browser.notifyWhenNoOutstandingRequests(callback); + }; + + return testability; + }]; +} + +function $TimeoutProvider() { + this.$get = ['$rootScope', '$browser', '$q', '$$q', '$exceptionHandler', + function($rootScope, $browser, $q, $$q, $exceptionHandler) { + + var deferreds = {}; + + + /** + * @ngdoc service + * @name $timeout + * + * @description + * Angular's wrapper for `window.setTimeout`. The `fn` function is wrapped into a try/catch + * block and delegates any exceptions to + * {@link ng.$exceptionHandler $exceptionHandler} service. + * + * The return value of calling `$timeout` is a promise, which will be resolved when + * the delay has passed and the timeout function, if provided, is executed. + * + * To cancel a timeout request, call `$timeout.cancel(promise)`. + * + * In tests you can use {@link ngMock.$timeout `$timeout.flush()`} to + * synchronously flush the queue of deferred functions. + * + * If you only want a promise that will be resolved after some specified delay + * then you can call `$timeout` without the `fn` function. + * + * @param {function()=} fn A function, whose execution should be delayed. + * @param {number=} [delay=0] Delay in milliseconds. + * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise + * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. + * @param {...*=} Pass additional parameters to the executed function. + * @returns {Promise} Promise that will be resolved when the timeout is reached. The value this + * promise will be resolved with is the return value of the `fn` function. + * + */ + function timeout(fn, delay, invokeApply) { + if (!isFunction(fn)) { + invokeApply = delay; + delay = fn; + fn = noop; + } + + var args = sliceArgs(arguments, 3), + skipApply = (isDefined(invokeApply) && !invokeApply), + deferred = (skipApply ? $$q : $q).defer(), + promise = deferred.promise, + timeoutId; + + timeoutId = $browser.defer(function() { + try { + deferred.resolve(fn.apply(null, args)); + } catch (e) { + deferred.reject(e); + $exceptionHandler(e); + } + finally { + delete deferreds[promise.$$timeoutId]; + } + + if (!skipApply) $rootScope.$apply(); + }, delay); + + promise.$$timeoutId = timeoutId; + deferreds[timeoutId] = deferred; + + return promise; + } + + + /** + * @ngdoc method + * @name $timeout#cancel + * + * @description + * Cancels a task associated with the `promise`. As a result of this, the promise will be + * resolved with a rejection. + * + * @param {Promise=} promise Promise returned by the `$timeout` function. + * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully + * canceled. + */ + timeout.cancel = function(promise) { + if (promise && promise.$$timeoutId in deferreds) { + deferreds[promise.$$timeoutId].reject('canceled'); + delete deferreds[promise.$$timeoutId]; + return $browser.defer.cancel(promise.$$timeoutId); + } + return false; + }; + + return timeout; + }]; +} + +// NOTE: The usage of window and document instead of $window and $document here is +// deliberate. This service depends on the specific behavior of anchor nodes created by the +// browser (resolving and parsing URLs) that is unlikely to be provided by mock objects and +// cause us to break tests. In addition, when the browser resolves a URL for XHR, it +// doesn't know about mocked locations and resolves URLs to the real document - which is +// exactly the behavior needed here. There is little value is mocking these out for this +// service. +var urlParsingNode = document.createElement("a"); +var originUrl = urlResolve(window.location.href); + + +/** + * + * Implementation Notes for non-IE browsers + * ---------------------------------------- + * Assigning a URL to the href property of an anchor DOM node, even one attached to the DOM, + * results both in the normalizing and parsing of the URL. Normalizing means that a relative + * URL will be resolved into an absolute URL in the context of the application document. + * Parsing means that the anchor node's host, hostname, protocol, port, pathname and related + * properties are all populated to reflect the normalized URL. This approach has wide + * compatibility - Safari 1+, Mozilla 1+, Opera 7+,e etc. See + * http://www.aptana.com/reference/html/api/HTMLAnchorElement.html + * + * Implementation Notes for IE + * --------------------------- + * IE <= 10 normalizes the URL when assigned to the anchor node similar to the other + * browsers. However, the parsed components will not be set if the URL assigned did not specify + * them. (e.g. if you assign a.href = "foo", then a.protocol, a.host, etc. will be empty.) We + * work around that by performing the parsing in a 2nd step by taking a previously normalized + * URL (e.g. by assigning to a.href) and assigning it a.href again. This correctly populates the + * properties such as protocol, hostname, port, etc. + * + * References: + * http://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement + * http://www.aptana.com/reference/html/api/HTMLAnchorElement.html + * http://url.spec.whatwg.org/#urlutils + * https://github.com/angular/angular.js/pull/2902 + * http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ + * + * @kind function + * @param {string} url The URL to be parsed. + * @description Normalizes and parses a URL. + * @returns {object} Returns the normalized URL as a dictionary. + * + * | member name | Description | + * |---------------|----------------| + * | href | A normalized version of the provided URL if it was not an absolute URL | + * | protocol | The protocol including the trailing colon | + * | host | The host and port (if the port is non-default) of the normalizedUrl | + * | search | The search params, minus the question mark | + * | hash | The hash string, minus the hash symbol + * | hostname | The hostname + * | port | The port, without ":" + * | pathname | The pathname, beginning with "/" + * + */ +function urlResolve(url) { + var href = url; + + if (msie) { + // Normalize before parse. Refer Implementation Notes on why this is + // done in two steps on IE. + urlParsingNode.setAttribute("href", href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') + ? urlParsingNode.pathname + : '/' + urlParsingNode.pathname + }; +} + +/** + * Parse a request URL and determine whether this is a same-origin request as the application document. + * + * @param {string|object} requestUrl The url of the request as a string that will be resolved + * or a parsed URL object. + * @returns {boolean} Whether the request is for the same origin as the application document. + */ +function urlIsSameOrigin(requestUrl) { + var parsed = (isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl; + return (parsed.protocol === originUrl.protocol && + parsed.host === originUrl.host); +} + +/** + * @ngdoc service + * @name $window + * + * @description + * A reference to the browser's `window` object. While `window` + * is globally available in JavaScript, it causes testability problems, because + * it is a global variable. In angular we always refer to it through the + * `$window` service, so it may be overridden, removed or mocked for testing. + * + * Expressions, like the one defined for the `ngClick` directive in the example + * below, are evaluated with respect to the current scope. Therefore, there is + * no risk of inadvertently coding in a dependency on a global value in such an + * expression. + * + * @example + + + +
+ + +
+
+ + it('should display the greeting in the input box', function() { + element(by.model('greeting')).sendKeys('Hello, E2E Tests'); + // If we click the button it will block the test runner + // element(':button').click(); + }); + +
+ */ +function $WindowProvider() { + this.$get = valueFn(window); +} + +/** + * @name $$cookieReader + * @requires $document + * + * @description + * This is a private service for reading cookies used by $http and ngCookies + * + * @return {Object} a key/value map of the current cookies + */ +function $$CookieReader($document) { + var rawDocument = $document[0] || {}; + var lastCookies = {}; + var lastCookieString = ''; + + function safeDecodeURIComponent(str) { + try { + return decodeURIComponent(str); + } catch (e) { + return str; + } + } + + return function() { + var cookieArray, cookie, i, index, name; + var currentCookieString = rawDocument.cookie || ''; + + if (currentCookieString !== lastCookieString) { + lastCookieString = currentCookieString; + cookieArray = lastCookieString.split('; '); + lastCookies = {}; + + for (i = 0; i < cookieArray.length; i++) { + cookie = cookieArray[i]; + index = cookie.indexOf('='); + if (index > 0) { //ignore nameless cookies + name = safeDecodeURIComponent(cookie.substring(0, index)); + // the first value that is seen for a cookie is the most + // specific one. values for the same cookie name that + // follow are for less specific paths. + if (isUndefined(lastCookies[name])) { + lastCookies[name] = safeDecodeURIComponent(cookie.substring(index + 1)); + } + } + } + } + return lastCookies; + }; +} + +$$CookieReader.$inject = ['$document']; + +function $$CookieReaderProvider() { + this.$get = $$CookieReader; +} + +/* global currencyFilter: true, + dateFilter: true, + filterFilter: true, + jsonFilter: true, + limitToFilter: true, + lowercaseFilter: true, + numberFilter: true, + orderByFilter: true, + uppercaseFilter: true, + */ + +/** + * @ngdoc provider + * @name $filterProvider + * @description + * + * Filters are just functions which transform input to an output. However filters need to be + * Dependency Injected. To achieve this a filter definition consists of a factory function which is + * annotated with dependencies and is responsible for creating a filter function. + * + *
+ * **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`. + * Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace + * your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores + * (`myapp_subsection_filterx`). + *
+ * + * ```js + * // Filter registration + * function MyModule($provide, $filterProvider) { + * // create a service to demonstrate injection (not always needed) + * $provide.value('greet', function(name){ + * return 'Hello ' + name + '!'; + * }); + * + * // register a filter factory which uses the + * // greet service to demonstrate DI. + * $filterProvider.register('greet', function(greet){ + * // return the filter function which uses the greet service + * // to generate salutation + * return function(text) { + * // filters need to be forgiving so check input validity + * return text && greet(text) || text; + * }; + * }); + * } + * ``` + * + * The filter function is registered with the `$injector` under the filter name suffix with + * `Filter`. + * + * ```js + * it('should be the same instance', inject( + * function($filterProvider) { + * $filterProvider.register('reverse', function(){ + * return ...; + * }); + * }, + * function($filter, reverseFilter) { + * expect($filter('reverse')).toBe(reverseFilter); + * }); + * ``` + * + * + * For more information about how angular filters work, and how to create your own filters, see + * {@link guide/filter Filters} in the Angular Developer Guide. + */ + +/** + * @ngdoc service + * @name $filter + * @kind function + * @description + * Filters are used for formatting data displayed to the user. + * + * The general syntax in templates is as follows: + * + * {{ expression [| filter_name[:parameter_value] ... ] }} + * + * @param {String} name Name of the filter function to retrieve + * @return {Function} the filter function + * @example + + +
+

{{ originalText }}

+

{{ filteredText }}

+
+
+ + + angular.module('filterExample', []) + .controller('MainCtrl', function($scope, $filter) { + $scope.originalText = 'hello'; + $scope.filteredText = $filter('uppercase')($scope.originalText); + }); + +
+ */ +$FilterProvider.$inject = ['$provide']; +function $FilterProvider($provide) { + var suffix = 'Filter'; + + /** + * @ngdoc method + * @name $filterProvider#register + * @param {string|Object} name Name of the filter function, or an object map of filters where + * the keys are the filter names and the values are the filter factories. + * + *
+ * **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`. + * Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace + * your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores + * (`myapp_subsection_filterx`). + *
+ * @param {Function} factory If the first argument was a string, a factory function for the filter to be registered. + * @returns {Object} Registered filter instance, or if a map of filters was provided then a map + * of the registered filter instances. + */ + function register(name, factory) { + if (isObject(name)) { + var filters = {}; + forEach(name, function(filter, key) { + filters[key] = register(key, filter); + }); + return filters; + } else { + return $provide.factory(name + suffix, factory); + } + } + this.register = register; + + this.$get = ['$injector', function($injector) { + return function(name) { + return $injector.get(name + suffix); + }; + }]; + + //////////////////////////////////////// + + /* global + currencyFilter: false, + dateFilter: false, + filterFilter: false, + jsonFilter: false, + limitToFilter: false, + lowercaseFilter: false, + numberFilter: false, + orderByFilter: false, + uppercaseFilter: false, + */ + + register('currency', currencyFilter); + register('date', dateFilter); + register('filter', filterFilter); + register('json', jsonFilter); + register('limitTo', limitToFilter); + register('lowercase', lowercaseFilter); + register('number', numberFilter); + register('orderBy', orderByFilter); + register('uppercase', uppercaseFilter); +} + +/** + * @ngdoc filter + * @name filter + * @kind function + * + * @description + * Selects a subset of items from `array` and returns it as a new array. + * + * @param {Array} array The source array. + * @param {string|Object|function()} expression The predicate to be used for selecting items from + * `array`. + * + * Can be one of: + * + * - `string`: The string is used for matching against the contents of the `array`. All strings or + * objects with string properties in `array` that match this string will be returned. This also + * applies to nested object properties. + * The predicate can be negated by prefixing the string with `!`. + * + * - `Object`: A pattern object can be used to filter specific properties on objects contained + * by `array`. For example `{name:"M", phone:"1"}` predicate will return an array of items + * which have property `name` containing "M" and property `phone` containing "1". A special + * property name `$` can be used (as in `{$:"text"}`) to accept a match against any + * property of the object or its nested object properties. That's equivalent to the simple + * substring match with a `string` as described above. The predicate can be negated by prefixing + * the string with `!`. + * For example `{name: "!M"}` predicate will return an array of items which have property `name` + * not containing "M". + * + * Note that a named property will match properties on the same level only, while the special + * `$` property will match properties on the same level or deeper. E.g. an array item like + * `{name: {first: 'John', last: 'Doe'}}` will **not** be matched by `{name: 'John'}`, but + * **will** be matched by `{$: 'John'}`. + * + * - `function(value, index, array)`: A predicate function can be used to write arbitrary filters. + * The function is called for each element of the array, with the element, its index, and + * the entire array itself as arguments. + * + * The final result is an array of those elements that the predicate returned true for. + * + * @param {function(actual, expected)|true|undefined} comparator Comparator which is used in + * determining if the expected value (from the filter expression) and actual value (from + * the object in the array) should be considered a match. + * + * Can be one of: + * + * - `function(actual, expected)`: + * The function will be given the object value and the predicate value to compare and + * should return true if both values should be considered equal. + * + * - `true`: A shorthand for `function(actual, expected) { return angular.equals(actual, expected)}`. + * This is essentially strict comparison of expected and actual. + * + * - `false|undefined`: A short hand for a function which will look for a substring match in case + * insensitive way. + * + * Primitive values are converted to strings. Objects are not compared against primitives, + * unless they have a custom `toString` method (e.g. `Date` objects). + * + * @example + + +
+ + + + + + + + +
NamePhone
{{friend.name}}{{friend.phone}}
+
+
+
+
+
+ + + + + + +
NamePhone
{{friendObj.name}}{{friendObj.phone}}
+
+ + var expectFriendNames = function(expectedNames, key) { + element.all(by.repeater(key + ' in friends').column(key + '.name')).then(function(arr) { + arr.forEach(function(wd, i) { + expect(wd.getText()).toMatch(expectedNames[i]); + }); + }); + }; + + it('should search across all fields when filtering with a string', function() { + var searchText = element(by.model('searchText')); + searchText.clear(); + searchText.sendKeys('m'); + expectFriendNames(['Mary', 'Mike', 'Adam'], 'friend'); + + searchText.clear(); + searchText.sendKeys('76'); + expectFriendNames(['John', 'Julie'], 'friend'); + }); + + it('should search in specific fields when filtering with a predicate object', function() { + var searchAny = element(by.model('search.$')); + searchAny.clear(); + searchAny.sendKeys('i'); + expectFriendNames(['Mary', 'Mike', 'Julie', 'Juliette'], 'friendObj'); + }); + it('should use a equal comparison when comparator is true', function() { + var searchName = element(by.model('search.name')); + var strict = element(by.model('strict')); + searchName.clear(); + searchName.sendKeys('Julie'); + strict.click(); + expectFriendNames(['Julie'], 'friendObj'); + }); + +
+ */ +function filterFilter() { + return function(array, expression, comparator) { + if (!isArrayLike(array)) { + if (array == null) { + return array; + } else { + throw minErr('filter')('notarray', 'Expected array but received: {0}', array); + } + } + + var expressionType = getTypeForFilter(expression); + var predicateFn; + var matchAgainstAnyProp; + + switch (expressionType) { + case 'function': + predicateFn = expression; + break; + case 'boolean': + case 'null': + case 'number': + case 'string': + matchAgainstAnyProp = true; + //jshint -W086 + case 'object': + //jshint +W086 + predicateFn = createPredicateFn(expression, comparator, matchAgainstAnyProp); + break; + default: + return array; + } + + return Array.prototype.filter.call(array, predicateFn); + }; +} + +// Helper functions for `filterFilter` +function createPredicateFn(expression, comparator, matchAgainstAnyProp) { + var shouldMatchPrimitives = isObject(expression) && ('$' in expression); + var predicateFn; + + if (comparator === true) { + comparator = equals; + } else if (!isFunction(comparator)) { + comparator = function(actual, expected) { + if (isUndefined(actual)) { + // No substring matching against `undefined` + return false; + } + if ((actual === null) || (expected === null)) { + // No substring matching against `null`; only match against `null` + return actual === expected; + } + if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { + // Should not compare primitives against objects, unless they have custom `toString` method + return false; + } + + actual = lowercase('' + actual); + expected = lowercase('' + expected); + return actual.indexOf(expected) !== -1; + }; + } + + predicateFn = function(item) { + if (shouldMatchPrimitives && !isObject(item)) { + return deepCompare(item, expression.$, comparator, false); + } + return deepCompare(item, expression, comparator, matchAgainstAnyProp); + }; + + return predicateFn; +} + +function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) { + var actualType = getTypeForFilter(actual); + var expectedType = getTypeForFilter(expected); + + if ((expectedType === 'string') && (expected.charAt(0) === '!')) { + return !deepCompare(actual, expected.substring(1), comparator, matchAgainstAnyProp); + } else if (isArray(actual)) { + // In case `actual` is an array, consider it a match + // if ANY of it's items matches `expected` + return actual.some(function(item) { + return deepCompare(item, expected, comparator, matchAgainstAnyProp); + }); + } + + switch (actualType) { + case 'object': + var key; + if (matchAgainstAnyProp) { + for (key in actual) { + if ((key.charAt(0) !== '$') && deepCompare(actual[key], expected, comparator, true)) { + return true; + } + } + return dontMatchWholeObject ? false : deepCompare(actual, expected, comparator, false); + } else if (expectedType === 'object') { + for (key in expected) { + var expectedVal = expected[key]; + if (isFunction(expectedVal) || isUndefined(expectedVal)) { + continue; + } + + var matchAnyProperty = key === '$'; + var actualVal = matchAnyProperty ? actual : actual[key]; + if (!deepCompare(actualVal, expectedVal, comparator, matchAnyProperty, matchAnyProperty)) { + return false; + } + } + return true; + } else { + return comparator(actual, expected); + } + break; + case 'function': + return false; + default: + return comparator(actual, expected); + } +} + +// Used for easily differentiating between `null` and actual `object` +function getTypeForFilter(val) { + return (val === null) ? 'null' : typeof val; +} + +/** + * @ngdoc filter + * @name currency + * @kind function + * + * @description + * Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default + * symbol for current locale is used. + * + * @param {number} amount Input to filter. + * @param {string=} symbol Currency symbol or identifier to be displayed. + * @param {number=} fractionSize Number of decimal places to round the amount to, defaults to default max fraction size for current locale + * @returns {string} Formatted number. + * + * + * @example + + + +
+
+ default currency symbol ($): {{amount | currency}}
+ custom currency identifier (USD$): {{amount | currency:"USD$"}} + no fractions (0): {{amount | currency:"USD$":0}} +
+
+ + it('should init with 1234.56', function() { + expect(element(by.id('currency-default')).getText()).toBe('$1,234.56'); + expect(element(by.id('currency-custom')).getText()).toBe('USD$1,234.56'); + expect(element(by.id('currency-no-fractions')).getText()).toBe('USD$1,235'); + }); + it('should update', function() { + if (browser.params.browser == 'safari') { + // Safari does not understand the minus key. See + // https://github.com/angular/protractor/issues/481 + return; + } + element(by.model('amount')).clear(); + element(by.model('amount')).sendKeys('-1234'); + expect(element(by.id('currency-default')).getText()).toBe('-$1,234.00'); + expect(element(by.id('currency-custom')).getText()).toBe('-USD$1,234.00'); + expect(element(by.id('currency-no-fractions')).getText()).toBe('-USD$1,234'); + }); + +
+ */ +currencyFilter.$inject = ['$locale']; +function currencyFilter($locale) { + var formats = $locale.NUMBER_FORMATS; + return function(amount, currencySymbol, fractionSize) { + if (isUndefined(currencySymbol)) { + currencySymbol = formats.CURRENCY_SYM; + } + + if (isUndefined(fractionSize)) { + fractionSize = formats.PATTERNS[1].maxFrac; + } + + // if null or undefined pass it through + return (amount == null) + ? amount + : formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, fractionSize). + replace(/\u00A4/g, currencySymbol); + }; +} + +/** + * @ngdoc filter + * @name number + * @kind function + * + * @description + * Formats a number as text. + * + * If the input is null or undefined, it will just be returned. + * If the input is infinite (Infinity/-Infinity) the Infinity symbol '∞' is returned. + * If the input is not a number an empty string is returned. + * + * + * @param {number|string} number Number to format. + * @param {(number|string)=} fractionSize Number of decimal places to round the number to. + * If this is not provided then the fraction size is computed from the current locale's number + * formatting pattern. In the case of the default locale, it will be 3. + * @returns {string} Number rounded to decimalPlaces and places a “,” after each third digit. + * + * @example + + + +
+
+ Default formatting: {{val | number}}
+ No fractions: {{val | number:0}}
+ Negative number: {{-val | number:4}} +
+
+ + it('should format numbers', function() { + expect(element(by.id('number-default')).getText()).toBe('1,234.568'); + expect(element(by.binding('val | number:0')).getText()).toBe('1,235'); + expect(element(by.binding('-val | number:4')).getText()).toBe('-1,234.5679'); + }); + + it('should update', function() { + element(by.model('val')).clear(); + element(by.model('val')).sendKeys('3374.333'); + expect(element(by.id('number-default')).getText()).toBe('3,374.333'); + expect(element(by.binding('val | number:0')).getText()).toBe('3,374'); + expect(element(by.binding('-val | number:4')).getText()).toBe('-3,374.3330'); + }); + +
+ */ + + +numberFilter.$inject = ['$locale']; +function numberFilter($locale) { + var formats = $locale.NUMBER_FORMATS; + return function(number, fractionSize) { + + // if null or undefined pass it through + return (number == null) + ? number + : formatNumber(number, formats.PATTERNS[0], formats.GROUP_SEP, formats.DECIMAL_SEP, + fractionSize); + }; +} + +var DECIMAL_SEP = '.'; +function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) { + if (isObject(number)) return ''; + + var isNegative = number < 0; + number = Math.abs(number); + + var isInfinity = number === Infinity; + if (!isInfinity && !isFinite(number)) return ''; + + var numStr = number + '', + formatedText = '', + hasExponent = false, + parts = []; + + if (isInfinity) formatedText = '\u221e'; + + if (!isInfinity && numStr.indexOf('e') !== -1) { + var match = numStr.match(/([\d\.]+)e(-?)(\d+)/); + if (match && match[2] == '-' && match[3] > fractionSize + 1) { + number = 0; + } else { + formatedText = numStr; + hasExponent = true; + } + } + + if (!isInfinity && !hasExponent) { + var fractionLen = (numStr.split(DECIMAL_SEP)[1] || '').length; + + // determine fractionSize if it is not specified + if (isUndefined(fractionSize)) { + fractionSize = Math.min(Math.max(pattern.minFrac, fractionLen), pattern.maxFrac); + } + + // safely round numbers in JS without hitting imprecisions of floating-point arithmetics + // inspired by: + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round + number = +(Math.round(+(number.toString() + 'e' + fractionSize)).toString() + 'e' + -fractionSize); + + var fraction = ('' + number).split(DECIMAL_SEP); + var whole = fraction[0]; + fraction = fraction[1] || ''; + + var i, pos = 0, + lgroup = pattern.lgSize, + group = pattern.gSize; + + if (whole.length >= (lgroup + group)) { + pos = whole.length - lgroup; + for (i = 0; i < pos; i++) { + if ((pos - i) % group === 0 && i !== 0) { + formatedText += groupSep; + } + formatedText += whole.charAt(i); + } + } + + for (i = pos; i < whole.length; i++) { + if ((whole.length - i) % lgroup === 0 && i !== 0) { + formatedText += groupSep; + } + formatedText += whole.charAt(i); + } + + // format fraction part. + while (fraction.length < fractionSize) { + fraction += '0'; + } + + if (fractionSize && fractionSize !== "0") formatedText += decimalSep + fraction.substr(0, fractionSize); + } else { + if (fractionSize > 0 && number < 1) { + formatedText = number.toFixed(fractionSize); + number = parseFloat(formatedText); + } + } + + if (number === 0) { + isNegative = false; + } + + parts.push(isNegative ? pattern.negPre : pattern.posPre, + formatedText, + isNegative ? pattern.negSuf : pattern.posSuf); + return parts.join(''); +} + +function padNumber(num, digits, trim) { + var neg = ''; + if (num < 0) { + neg = '-'; + num = -num; + } + num = '' + num; + while (num.length < digits) num = '0' + num; + if (trim) { + num = num.substr(num.length - digits); + } + return neg + num; +} + + +function dateGetter(name, size, offset, trim) { + offset = offset || 0; + return function(date) { + var value = date['get' + name](); + if (offset > 0 || value > -offset) { + value += offset; + } + if (value === 0 && offset == -12) value = 12; + return padNumber(value, size, trim); + }; +} + +function dateStrGetter(name, shortForm) { + return function(date, formats) { + var value = date['get' + name](); + var get = uppercase(shortForm ? ('SHORT' + name) : name); + + return formats[get][value]; + }; +} + +function timeZoneGetter(date, formats, offset) { + var zone = -1 * offset; + var paddedZone = (zone >= 0) ? "+" : ""; + + paddedZone += padNumber(Math[zone > 0 ? 'floor' : 'ceil'](zone / 60), 2) + + padNumber(Math.abs(zone % 60), 2); + + return paddedZone; +} + +function getFirstThursdayOfYear(year) { + // 0 = index of January + var dayOfWeekOnFirst = (new Date(year, 0, 1)).getDay(); + // 4 = index of Thursday (+1 to account for 1st = 5) + // 11 = index of *next* Thursday (+1 account for 1st = 12) + return new Date(year, 0, ((dayOfWeekOnFirst <= 4) ? 5 : 12) - dayOfWeekOnFirst); +} + +function getThursdayThisWeek(datetime) { + return new Date(datetime.getFullYear(), datetime.getMonth(), + // 4 = index of Thursday + datetime.getDate() + (4 - datetime.getDay())); +} + +function weekGetter(size) { + return function(date) { + var firstThurs = getFirstThursdayOfYear(date.getFullYear()), + thisThurs = getThursdayThisWeek(date); + + var diff = +thisThurs - +firstThurs, + result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week + + return padNumber(result, size); + }; +} + +function ampmGetter(date, formats) { + return date.getHours() < 12 ? formats.AMPMS[0] : formats.AMPMS[1]; +} + +function eraGetter(date, formats) { + return date.getFullYear() <= 0 ? formats.ERAS[0] : formats.ERAS[1]; +} + +function longEraGetter(date, formats) { + return date.getFullYear() <= 0 ? formats.ERANAMES[0] : formats.ERANAMES[1]; +} + +var DATE_FORMATS = { + yyyy: dateGetter('FullYear', 4), + yy: dateGetter('FullYear', 2, 0, true), + y: dateGetter('FullYear', 1), + MMMM: dateStrGetter('Month'), + MMM: dateStrGetter('Month', true), + MM: dateGetter('Month', 2, 1), + M: dateGetter('Month', 1, 1), + dd: dateGetter('Date', 2), + d: dateGetter('Date', 1), + HH: dateGetter('Hours', 2), + H: dateGetter('Hours', 1), + hh: dateGetter('Hours', 2, -12), + h: dateGetter('Hours', 1, -12), + mm: dateGetter('Minutes', 2), + m: dateGetter('Minutes', 1), + ss: dateGetter('Seconds', 2), + s: dateGetter('Seconds', 1), + // while ISO 8601 requires fractions to be prefixed with `.` or `,` + // we can be just safely rely on using `sss` since we currently don't support single or two digit fractions + sss: dateGetter('Milliseconds', 3), + EEEE: dateStrGetter('Day'), + EEE: dateStrGetter('Day', true), + a: ampmGetter, + Z: timeZoneGetter, + ww: weekGetter(2), + w: weekGetter(1), + G: eraGetter, + GG: eraGetter, + GGG: eraGetter, + GGGG: longEraGetter +}; + +var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z|G+|w+))(.*)/, + NUMBER_STRING = /^\-?\d+$/; + +/** + * @ngdoc filter + * @name date + * @kind function + * + * @description + * Formats `date` to a string based on the requested `format`. + * + * `format` string can be composed of the following elements: + * + * * `'yyyy'`: 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010) + * * `'yy'`: 2 digit representation of year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10) + * * `'y'`: 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199) + * * `'MMMM'`: Month in year (January-December) + * * `'MMM'`: Month in year (Jan-Dec) + * * `'MM'`: Month in year, padded (01-12) + * * `'M'`: Month in year (1-12) + * * `'dd'`: Day in month, padded (01-31) + * * `'d'`: Day in month (1-31) + * * `'EEEE'`: Day in Week,(Sunday-Saturday) + * * `'EEE'`: Day in Week, (Sun-Sat) + * * `'HH'`: Hour in day, padded (00-23) + * * `'H'`: Hour in day (0-23) + * * `'hh'`: Hour in AM/PM, padded (01-12) + * * `'h'`: Hour in AM/PM, (1-12) + * * `'mm'`: Minute in hour, padded (00-59) + * * `'m'`: Minute in hour (0-59) + * * `'ss'`: Second in minute, padded (00-59) + * * `'s'`: Second in minute (0-59) + * * `'sss'`: Millisecond in second, padded (000-999) + * * `'a'`: AM/PM marker + * * `'Z'`: 4 digit (+sign) representation of the timezone offset (-1200-+1200) + * * `'ww'`: Week of year, padded (00-53). Week 01 is the week with the first Thursday of the year + * * `'w'`: Week of year (0-53). Week 1 is the week with the first Thursday of the year + * * `'G'`, `'GG'`, `'GGG'`: The abbreviated form of the era string (e.g. 'AD') + * * `'GGGG'`: The long form of the era string (e.g. 'Anno Domini') + * + * `format` string can also be one of the following predefined + * {@link guide/i18n localizable formats}: + * + * * `'medium'`: equivalent to `'MMM d, y h:mm:ss a'` for en_US locale + * (e.g. Sep 3, 2010 12:05:08 PM) + * * `'short'`: equivalent to `'M/d/yy h:mm a'` for en_US locale (e.g. 9/3/10 12:05 PM) + * * `'fullDate'`: equivalent to `'EEEE, MMMM d, y'` for en_US locale + * (e.g. Friday, September 3, 2010) + * * `'longDate'`: equivalent to `'MMMM d, y'` for en_US locale (e.g. September 3, 2010) + * * `'mediumDate'`: equivalent to `'MMM d, y'` for en_US locale (e.g. Sep 3, 2010) + * * `'shortDate'`: equivalent to `'M/d/yy'` for en_US locale (e.g. 9/3/10) + * * `'mediumTime'`: equivalent to `'h:mm:ss a'` for en_US locale (e.g. 12:05:08 PM) + * * `'shortTime'`: equivalent to `'h:mm a'` for en_US locale (e.g. 12:05 PM) + * + * `format` string can contain literal values. These need to be escaped by surrounding with single quotes (e.g. + * `"h 'in the morning'"`). In order to output a single quote, escape it - i.e., two single quotes in a sequence + * (e.g. `"h 'o''clock'"`). + * + * @param {(Date|number|string)} date Date to format either as Date object, milliseconds (string or + * number) or various ISO 8601 datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.sssZ and its + * shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ). If no timezone is + * specified in the string input, the time is considered to be in the local timezone. + * @param {string=} format Formatting rules (see Description). If not specified, + * `mediumDate` is used. + * @param {string=} timezone Timezone to be used for formatting. It understands UTC/GMT and the + * continental US time zone abbreviations, but for general use, use a time zone offset, for + * example, `'+0430'` (4 hours, 30 minutes east of the Greenwich meridian) + * If not specified, the timezone of the browser will be used. + * @returns {string} Formatted string or the input if input is not recognized as date/millis. + * + * @example + + + {{1288323623006 | date:'medium'}}: + {{1288323623006 | date:'medium'}}
+ {{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}: + {{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}
+ {{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}: + {{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}
+ {{1288323623006 | date:"MM/dd/yyyy 'at' h:mma"}}: + {{'1288323623006' | date:"MM/dd/yyyy 'at' h:mma"}}
+
+ + it('should format date', function() { + expect(element(by.binding("1288323623006 | date:'medium'")).getText()). + toMatch(/Oct 2\d, 2010 \d{1,2}:\d{2}:\d{2} (AM|PM)/); + expect(element(by.binding("1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'")).getText()). + toMatch(/2010\-10\-2\d \d{2}:\d{2}:\d{2} (\-|\+)?\d{4}/); + expect(element(by.binding("'1288323623006' | date:'MM/dd/yyyy @ h:mma'")).getText()). + toMatch(/10\/2\d\/2010 @ \d{1,2}:\d{2}(AM|PM)/); + expect(element(by.binding("'1288323623006' | date:\"MM/dd/yyyy 'at' h:mma\"")).getText()). + toMatch(/10\/2\d\/2010 at \d{1,2}:\d{2}(AM|PM)/); + }); + +
+ */ +dateFilter.$inject = ['$locale']; +function dateFilter($locale) { + + + var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; + // 1 2 3 4 5 6 7 8 9 10 11 + function jsonStringToDate(string) { + var match; + if (match = string.match(R_ISO8601_STR)) { + var date = new Date(0), + tzHour = 0, + tzMin = 0, + dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear, + timeSetter = match[8] ? date.setUTCHours : date.setHours; + + if (match[9]) { + tzHour = toInt(match[9] + match[10]); + tzMin = toInt(match[9] + match[11]); + } + dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3])); + var h = toInt(match[4] || 0) - tzHour; + var m = toInt(match[5] || 0) - tzMin; + var s = toInt(match[6] || 0); + var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000); + timeSetter.call(date, h, m, s, ms); + return date; + } + return string; + } + + + return function(date, format, timezone) { + var text = '', + parts = [], + fn, match; + + format = format || 'mediumDate'; + format = $locale.DATETIME_FORMATS[format] || format; + if (isString(date)) { + date = NUMBER_STRING.test(date) ? toInt(date) : jsonStringToDate(date); + } + + if (isNumber(date)) { + date = new Date(date); + } + + if (!isDate(date) || !isFinite(date.getTime())) { + return date; + } + + while (format) { + match = DATE_FORMATS_SPLIT.exec(format); + if (match) { + parts = concat(parts, match, 1); + format = parts.pop(); + } else { + parts.push(format); + format = null; + } + } + + var dateTimezoneOffset = date.getTimezoneOffset(); + if (timezone) { + dateTimezoneOffset = timezoneToOffset(timezone, date.getTimezoneOffset()); + date = convertTimezoneToLocal(date, timezone, true); + } + forEach(parts, function(value) { + fn = DATE_FORMATS[value]; + text += fn ? fn(date, $locale.DATETIME_FORMATS, dateTimezoneOffset) + : value.replace(/(^'|'$)/g, '').replace(/''/g, "'"); + }); + + return text; + }; +} + + +/** + * @ngdoc filter + * @name json + * @kind function + * + * @description + * Allows you to convert a JavaScript object into JSON string. + * + * This filter is mostly useful for debugging. When using the double curly {{value}} notation + * the binding is automatically converted to JSON. + * + * @param {*} object Any JavaScript object (including arrays and primitive types) to filter. + * @param {number=} spacing The number of spaces to use per indentation, defaults to 2. + * @returns {string} JSON string. + * + * + * @example + + +
{{ {'name':'value'} | json }}
+
{{ {'name':'value'} | json:4 }}
+
+ + it('should jsonify filtered objects', function() { + expect(element(by.id('default-spacing')).getText()).toMatch(/\{\n "name": ?"value"\n}/); + expect(element(by.id('custom-spacing')).getText()).toMatch(/\{\n "name": ?"value"\n}/); + }); + +
+ * + */ +function jsonFilter() { + return function(object, spacing) { + if (isUndefined(spacing)) { + spacing = 2; + } + return toJson(object, spacing); + }; +} + + +/** + * @ngdoc filter + * @name lowercase + * @kind function + * @description + * Converts string to lowercase. + * @see angular.lowercase + */ +var lowercaseFilter = valueFn(lowercase); + + +/** + * @ngdoc filter + * @name uppercase + * @kind function + * @description + * Converts string to uppercase. + * @see angular.uppercase + */ +var uppercaseFilter = valueFn(uppercase); + +/** + * @ngdoc filter + * @name limitTo + * @kind function + * + * @description + * Creates a new array or string containing only a specified number of elements. The elements + * are taken from either the beginning or the end of the source array, string or number, as specified by + * the value and sign (positive or negative) of `limit`. If a number is used as input, it is + * converted to a string. + * + * @param {Array|string|number} input Source array, string or number to be limited. + * @param {string|number} limit The length of the returned array or string. If the `limit` number + * is positive, `limit` number of items from the beginning of the source array/string are copied. + * If the number is negative, `limit` number of items from the end of the source array/string + * are copied. The `limit` will be trimmed if it exceeds `array.length`. If `limit` is undefined, + * the input will be returned unchanged. + * @param {(string|number)=} begin Index at which to begin limitation. As a negative index, `begin` + * indicates an offset from the end of `input`. Defaults to `0`. + * @returns {Array|string} A new sub-array or substring of length `limit` or less if input array + * had less than `limit` elements. + * + * @example + + + +
+ +

Output numbers: {{ numbers | limitTo:numLimit }}

+ +

Output letters: {{ letters | limitTo:letterLimit }}

+ +

Output long number: {{ longNumber | limitTo:longNumberLimit }}

+
+
+ + var numLimitInput = element(by.model('numLimit')); + var letterLimitInput = element(by.model('letterLimit')); + var longNumberLimitInput = element(by.model('longNumberLimit')); + var limitedNumbers = element(by.binding('numbers | limitTo:numLimit')); + var limitedLetters = element(by.binding('letters | limitTo:letterLimit')); + var limitedLongNumber = element(by.binding('longNumber | limitTo:longNumberLimit')); + + it('should limit the number array to first three items', function() { + expect(numLimitInput.getAttribute('value')).toBe('3'); + expect(letterLimitInput.getAttribute('value')).toBe('3'); + expect(longNumberLimitInput.getAttribute('value')).toBe('3'); + expect(limitedNumbers.getText()).toEqual('Output numbers: [1,2,3]'); + expect(limitedLetters.getText()).toEqual('Output letters: abc'); + expect(limitedLongNumber.getText()).toEqual('Output long number: 234'); + }); + + // There is a bug in safari and protractor that doesn't like the minus key + // it('should update the output when -3 is entered', function() { + // numLimitInput.clear(); + // numLimitInput.sendKeys('-3'); + // letterLimitInput.clear(); + // letterLimitInput.sendKeys('-3'); + // longNumberLimitInput.clear(); + // longNumberLimitInput.sendKeys('-3'); + // expect(limitedNumbers.getText()).toEqual('Output numbers: [7,8,9]'); + // expect(limitedLetters.getText()).toEqual('Output letters: ghi'); + // expect(limitedLongNumber.getText()).toEqual('Output long number: 342'); + // }); + + it('should not exceed the maximum size of input array', function() { + numLimitInput.clear(); + numLimitInput.sendKeys('100'); + letterLimitInput.clear(); + letterLimitInput.sendKeys('100'); + longNumberLimitInput.clear(); + longNumberLimitInput.sendKeys('100'); + expect(limitedNumbers.getText()).toEqual('Output numbers: [1,2,3,4,5,6,7,8,9]'); + expect(limitedLetters.getText()).toEqual('Output letters: abcdefghi'); + expect(limitedLongNumber.getText()).toEqual('Output long number: 2345432342'); + }); + +
+*/ +function limitToFilter() { + return function(input, limit, begin) { + if (Math.abs(Number(limit)) === Infinity) { + limit = Number(limit); + } else { + limit = toInt(limit); + } + if (isNaN(limit)) return input; + + if (isNumber(input)) input = input.toString(); + if (!isArray(input) && !isString(input)) return input; + + begin = (!begin || isNaN(begin)) ? 0 : toInt(begin); + begin = (begin < 0 && begin >= -input.length) ? input.length + begin : begin; + + if (limit >= 0) { + return input.slice(begin, begin + limit); + } else { + if (begin === 0) { + return input.slice(limit, input.length); + } else { + return input.slice(Math.max(0, begin + limit), begin); + } + } + }; +} + +/** + * @ngdoc filter + * @name orderBy + * @kind function + * + * @description + * Orders a specified `array` by the `expression` predicate. It is ordered alphabetically + * for strings and numerically for numbers. Note: if you notice numbers are not being sorted + * as expected, make sure they are actually being saved as numbers and not strings. + * + * @param {Array} array The array to sort. + * @param {function(*)|string|Array.<(function(*)|string)>=} expression A predicate to be + * used by the comparator to determine the order of elements. + * + * Can be one of: + * + * - `function`: Getter function. The result of this function will be sorted using the + * `<`, `===`, `>` operator. + * - `string`: An Angular expression. The result of this expression is used to compare elements + * (for example `name` to sort by a property called `name` or `name.substr(0, 3)` to sort by + * 3 first characters of a property called `name`). The result of a constant expression + * is interpreted as a property name to be used in comparisons (for example `"special name"` + * to sort object by the value of their `special name` property). An expression can be + * optionally prefixed with `+` or `-` to control ascending or descending sort order + * (for example, `+name` or `-name`). If no property is provided, (e.g. `'+'`) then the array + * element itself is used to compare where sorting. + * - `Array`: An array of function or string predicates. The first predicate in the array + * is used for sorting, but when two items are equivalent, the next predicate is used. + * + * If the predicate is missing or empty then it defaults to `'+'`. + * + * @param {boolean=} reverse Reverse the order of the array. + * @returns {Array} Sorted copy of the source array. + * + * + * @example + * The example below demonstrates a simple ngRepeat, where the data is sorted + * by age in descending order (predicate is set to `'-age'`). + * `reverse` is not set, which means it defaults to `false`. + + + +
+ + + + + + + + + + + +
NamePhone NumberAge
{{friend.name}}{{friend.phone}}{{friend.age}}
+
+
+
+ * + * The predicate and reverse parameters can be controlled dynamically through scope properties, + * as shown in the next example. + * @example + + + + +
+
Sorting predicate = {{predicate}}; reverse = {{reverse}}
+
+ [ unsorted ] + + + + + + + + + + + +
+ Name + + + Phone Number + + + Age + +
{{friend.name}}{{friend.phone}}{{friend.age}}
+
+
+
+ * + * It's also possible to call the orderBy filter manually, by injecting `$filter`, retrieving the + * filter routine with `$filter('orderBy')`, and calling the returned filter routine with the + * desired parameters. + * + * Example: + * + * @example + + +
+ + + + + + + + + + + +
Name + (^)Phone NumberAge
{{friend.name}}{{friend.phone}}{{friend.age}}
+
+
+ + + angular.module('orderByExample', []) + .controller('ExampleController', ['$scope', '$filter', function($scope, $filter) { + var orderBy = $filter('orderBy'); + $scope.friends = [ + { name: 'John', phone: '555-1212', age: 10 }, + { name: 'Mary', phone: '555-9876', age: 19 }, + { name: 'Mike', phone: '555-4321', age: 21 }, + { name: 'Adam', phone: '555-5678', age: 35 }, + { name: 'Julie', phone: '555-8765', age: 29 } + ]; + $scope.order = function(predicate, reverse) { + $scope.friends = orderBy($scope.friends, predicate, reverse); + }; + $scope.order('-age',false); + }]); + +
+ */ +orderByFilter.$inject = ['$parse']; +function orderByFilter($parse) { + return function(array, sortPredicate, reverseOrder) { + + if (!(isArrayLike(array))) return array; + + if (!isArray(sortPredicate)) { sortPredicate = [sortPredicate]; } + if (sortPredicate.length === 0) { sortPredicate = ['+']; } + + var predicates = processPredicates(sortPredicate, reverseOrder); + // Add a predicate at the end that evaluates to the element index. This makes the + // sort stable as it works as a tie-breaker when all the input predicates cannot + // distinguish between two elements. + predicates.push({ get: function() { return {}; }, descending: reverseOrder ? -1 : 1}); + + // The next three lines are a version of a Swartzian Transform idiom from Perl + // (sometimes called the Decorate-Sort-Undecorate idiom) + // See https://en.wikipedia.org/wiki/Schwartzian_transform + var compareValues = Array.prototype.map.call(array, getComparisonObject); + compareValues.sort(doComparison); + array = compareValues.map(function(item) { return item.value; }); + + return array; + + function getComparisonObject(value, index) { + return { + value: value, + predicateValues: predicates.map(function(predicate) { + return getPredicateValue(predicate.get(value), index); + }) + }; + } + + function doComparison(v1, v2) { + var result = 0; + for (var index=0, length = predicates.length; index < length; ++index) { + result = compare(v1.predicateValues[index], v2.predicateValues[index]) * predicates[index].descending; + if (result) break; + } + return result; + } + }; + + function processPredicates(sortPredicate, reverseOrder) { + reverseOrder = reverseOrder ? -1 : 1; + return sortPredicate.map(function(predicate) { + var descending = 1, get = identity; + + if (isFunction(predicate)) { + get = predicate; + } else if (isString(predicate)) { + if ((predicate.charAt(0) == '+' || predicate.charAt(0) == '-')) { + descending = predicate.charAt(0) == '-' ? -1 : 1; + predicate = predicate.substring(1); + } + if (predicate !== '') { + get = $parse(predicate); + if (get.constant) { + var key = get(); + get = function(value) { return value[key]; }; + } + } + } + return { get: get, descending: descending * reverseOrder }; + }); + } + + function isPrimitive(value) { + switch (typeof value) { + case 'number': /* falls through */ + case 'boolean': /* falls through */ + case 'string': + return true; + default: + return false; + } + } + + function objectValue(value, index) { + // If `valueOf` is a valid function use that + if (typeof value.valueOf === 'function') { + value = value.valueOf(); + if (isPrimitive(value)) return value; + } + // If `toString` is a valid function and not the one from `Object.prototype` use that + if (hasCustomToString(value)) { + value = value.toString(); + if (isPrimitive(value)) return value; + } + // We have a basic object so we use the position of the object in the collection + return index; + } + + function getPredicateValue(value, index) { + var type = typeof value; + if (value === null) { + type = 'string'; + value = 'null'; + } else if (type === 'string') { + value = value.toLowerCase(); + } else if (type === 'object') { + value = objectValue(value, index); + } + return { value: value, type: type }; + } + + function compare(v1, v2) { + var result = 0; + if (v1.type === v2.type) { + if (v1.value !== v2.value) { + result = v1.value < v2.value ? -1 : 1; + } + } else { + result = v1.type < v2.type ? -1 : 1; + } + return result; + } +} + +function ngDirective(directive) { + if (isFunction(directive)) { + directive = { + link: directive + }; + } + directive.restrict = directive.restrict || 'AC'; + return valueFn(directive); +} + +/** + * @ngdoc directive + * @name a + * @restrict E + * + * @description + * Modifies the default behavior of the html A tag so that the default action is prevented when + * the href attribute is empty. + * + * This change permits the easy creation of action links with the `ngClick` directive + * without changing the location or causing page reloads, e.g.: + * `Add Item` + */ +var htmlAnchorDirective = valueFn({ + restrict: 'E', + compile: function(element, attr) { + if (!attr.href && !attr.xlinkHref) { + return function(scope, element) { + // If the linked element is not an anchor tag anymore, do nothing + if (element[0].nodeName.toLowerCase() !== 'a') return; + + // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute. + var href = toString.call(element.prop('href')) === '[object SVGAnimatedString]' ? + 'xlink:href' : 'href'; + element.on('click', function(event) { + // if we have no href url, then don't navigate anywhere. + if (!element.attr(href)) { + event.preventDefault(); + } + }); + }; + } + } +}); + +/** + * @ngdoc directive + * @name ngHref + * @restrict A + * @priority 99 + * + * @description + * Using Angular markup like `{{hash}}` in an href attribute will + * make the link go to the wrong URL if the user clicks it before + * Angular has a chance to replace the `{{hash}}` markup with its + * value. Until Angular replaces the markup the link will be broken + * and will most likely return a 404 error. The `ngHref` directive + * solves this problem. + * + * The wrong way to write it: + * ```html + * link1 + * ``` + * + * The correct way to write it: + * ```html + * link1 + * ``` + * + * @element A + * @param {template} ngHref any string which can contain `{{}}` markup. + * + * @example + * This example shows various combinations of `href`, `ng-href` and `ng-click` attributes + * in links and their different behaviors: + + +
+ link 1 (link, don't reload)
+ link 2 (link, don't reload)
+ link 3 (link, reload!)
+ anchor (link, don't reload)
+ anchor (no link)
+ link (link, change location) +
+ + it('should execute ng-click but not reload when href without value', function() { + element(by.id('link-1')).click(); + expect(element(by.model('value')).getAttribute('value')).toEqual('1'); + expect(element(by.id('link-1')).getAttribute('href')).toBe(''); + }); + + it('should execute ng-click but not reload when href empty string', function() { + element(by.id('link-2')).click(); + expect(element(by.model('value')).getAttribute('value')).toEqual('2'); + expect(element(by.id('link-2')).getAttribute('href')).toBe(''); + }); + + it('should execute ng-click and change url when ng-href specified', function() { + expect(element(by.id('link-3')).getAttribute('href')).toMatch(/\/123$/); + + element(by.id('link-3')).click(); + + // At this point, we navigate away from an Angular page, so we need + // to use browser.driver to get the base webdriver. + + browser.wait(function() { + return browser.driver.getCurrentUrl().then(function(url) { + return url.match(/\/123$/); + }); + }, 5000, 'page should navigate to /123'); + }); + + it('should execute ng-click but not reload when href empty string and name specified', function() { + element(by.id('link-4')).click(); + expect(element(by.model('value')).getAttribute('value')).toEqual('4'); + expect(element(by.id('link-4')).getAttribute('href')).toBe(''); + }); + + it('should execute ng-click but not reload when no href but name specified', function() { + element(by.id('link-5')).click(); + expect(element(by.model('value')).getAttribute('value')).toEqual('5'); + expect(element(by.id('link-5')).getAttribute('href')).toBe(null); + }); + + it('should only change url when only ng-href', function() { + element(by.model('value')).clear(); + element(by.model('value')).sendKeys('6'); + expect(element(by.id('link-6')).getAttribute('href')).toMatch(/\/6$/); + + element(by.id('link-6')).click(); + + // At this point, we navigate away from an Angular page, so we need + // to use browser.driver to get the base webdriver. + browser.wait(function() { + return browser.driver.getCurrentUrl().then(function(url) { + return url.match(/\/6$/); + }); + }, 5000, 'page should navigate to /6'); + }); + +
+ */ + +/** + * @ngdoc directive + * @name ngSrc + * @restrict A + * @priority 99 + * + * @description + * Using Angular markup like `{{hash}}` in a `src` attribute doesn't + * work right: The browser will fetch from the URL with the literal + * text `{{hash}}` until Angular replaces the expression inside + * `{{hash}}`. The `ngSrc` directive solves this problem. + * + * The buggy way to write it: + * ```html + * Description + * ``` + * + * The correct way to write it: + * ```html + * Description + * ``` + * + * @element IMG + * @param {template} ngSrc any string which can contain `{{}}` markup. + */ + +/** + * @ngdoc directive + * @name ngSrcset + * @restrict A + * @priority 99 + * + * @description + * Using Angular markup like `{{hash}}` in a `srcset` attribute doesn't + * work right: The browser will fetch from the URL with the literal + * text `{{hash}}` until Angular replaces the expression inside + * `{{hash}}`. The `ngSrcset` directive solves this problem. + * + * The buggy way to write it: + * ```html + * Description + * ``` + * + * The correct way to write it: + * ```html + * Description + * ``` + * + * @element IMG + * @param {template} ngSrcset any string which can contain `{{}}` markup. + */ + +/** + * @ngdoc directive + * @name ngDisabled + * @restrict A + * @priority 100 + * + * @description + * + * This directive sets the `disabled` attribute on the element if the + * {@link guide/expression expression} inside `ngDisabled` evaluates to truthy. + * + * A special directive is necessary because we cannot use interpolation inside the `disabled` + * attribute. The following example would make the button enabled on Chrome/Firefox + * but not on older IEs: + * + * ```html + * + *
+ * + *
+ * ``` + * + * This is because the HTML specification does not require browsers to preserve the values of + * boolean attributes such as `disabled` (Their presence means true and their absence means false.) + * If we put an Angular interpolation expression into such an attribute then the + * binding information would be lost when the browser removes the attribute. + * + * @example + + +
+ +
+ + it('should toggle button', function() { + expect(element(by.css('button')).getAttribute('disabled')).toBeFalsy(); + element(by.model('checked')).click(); + expect(element(by.css('button')).getAttribute('disabled')).toBeTruthy(); + }); + +
+ * + * @element INPUT + * @param {expression} ngDisabled If the {@link guide/expression expression} is truthy, + * then the `disabled` attribute will be set on the element + */ + + +/** + * @ngdoc directive + * @name ngChecked + * @restrict A + * @priority 100 + * + * @description + * Sets the `checked` attribute on the element, if the expression inside `ngChecked` is truthy. + * + * Note that this directive should not be used together with {@link ngModel `ngModel`}, + * as this can lead to unexpected behavior. + * + * ### Why do we need `ngChecked`? + * + * The HTML specification does not require browsers to preserve the values of boolean attributes + * such as checked. (Their presence means true and their absence means false.) + * If we put an Angular interpolation expression into such an attribute then the + * binding information would be lost when the browser removes the attribute. + * The `ngChecked` directive solves this problem for the `checked` attribute. + * This complementary directive is not removed by the browser and so provides + * a permanent reliable place to store the binding information. + * @example + + +
+ +
+ + it('should check both checkBoxes', function() { + expect(element(by.id('checkSlave')).getAttribute('checked')).toBeFalsy(); + element(by.model('master')).click(); + expect(element(by.id('checkSlave')).getAttribute('checked')).toBeTruthy(); + }); + +
+ * + * @element INPUT + * @param {expression} ngChecked If the {@link guide/expression expression} is truthy, + * then the `checked` attribute will be set on the element + */ + + +/** + * @ngdoc directive + * @name ngReadonly + * @restrict A + * @priority 100 + * + * @description + * The HTML specification does not require browsers to preserve the values of boolean attributes + * such as readonly. (Their presence means true and their absence means false.) + * If we put an Angular interpolation expression into such an attribute then the + * binding information would be lost when the browser removes the attribute. + * The `ngReadonly` directive solves this problem for the `readonly` attribute. + * This complementary directive is not removed by the browser and so provides + * a permanent reliable place to store the binding information. + * @example + + +
+ +
+ + it('should toggle readonly attr', function() { + expect(element(by.css('[type="text"]')).getAttribute('readonly')).toBeFalsy(); + element(by.model('checked')).click(); + expect(element(by.css('[type="text"]')).getAttribute('readonly')).toBeTruthy(); + }); + +
+ * + * @element INPUT + * @param {expression} ngReadonly If the {@link guide/expression expression} is truthy, + * then special attribute "readonly" will be set on the element + */ + + +/** + * @ngdoc directive + * @name ngSelected + * @restrict A + * @priority 100 + * + * @description + * The HTML specification does not require browsers to preserve the values of boolean attributes + * such as selected. (Their presence means true and their absence means false.) + * If we put an Angular interpolation expression into such an attribute then the + * binding information would be lost when the browser removes the attribute. + * The `ngSelected` directive solves this problem for the `selected` attribute. + * This complementary directive is not removed by the browser and so provides + * a permanent reliable place to store the binding information. + * + * @example + + +
+ +
+ + it('should select Greetings!', function() { + expect(element(by.id('greet')).getAttribute('selected')).toBeFalsy(); + element(by.model('selected')).click(); + expect(element(by.id('greet')).getAttribute('selected')).toBeTruthy(); + }); + +
+ * + * @element OPTION + * @param {expression} ngSelected If the {@link guide/expression expression} is truthy, + * then special attribute "selected" will be set on the element + */ + +/** + * @ngdoc directive + * @name ngOpen + * @restrict A + * @priority 100 + * + * @description + * The HTML specification does not require browsers to preserve the values of boolean attributes + * such as open. (Their presence means true and their absence means false.) + * If we put an Angular interpolation expression into such an attribute then the + * binding information would be lost when the browser removes the attribute. + * The `ngOpen` directive solves this problem for the `open` attribute. + * This complementary directive is not removed by the browser and so provides + * a permanent reliable place to store the binding information. + * @example + + +
+
+ Show/Hide me +
+
+ + it('should toggle open', function() { + expect(element(by.id('details')).getAttribute('open')).toBeFalsy(); + element(by.model('open')).click(); + expect(element(by.id('details')).getAttribute('open')).toBeTruthy(); + }); + +
+ * + * @element DETAILS + * @param {expression} ngOpen If the {@link guide/expression expression} is truthy, + * then special attribute "open" will be set on the element + */ + +var ngAttributeAliasDirectives = {}; + +// boolean attrs are evaluated +forEach(BOOLEAN_ATTR, function(propName, attrName) { + // binding to multiple is not supported + if (propName == "multiple") return; + + function defaultLinkFn(scope, element, attr) { + scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) { + attr.$set(attrName, !!value); + }); + } + + var normalized = directiveNormalize('ng-' + attrName); + var linkFn = defaultLinkFn; + + if (propName === 'checked') { + linkFn = function(scope, element, attr) { + // ensuring ngChecked doesn't interfere with ngModel when both are set on the same input + if (attr.ngModel !== attr[normalized]) { + defaultLinkFn(scope, element, attr); + } + }; + } + + ngAttributeAliasDirectives[normalized] = function() { + return { + restrict: 'A', + priority: 100, + link: linkFn + }; + }; +}); + +// aliased input attrs are evaluated +forEach(ALIASED_ATTR, function(htmlAttr, ngAttr) { + ngAttributeAliasDirectives[ngAttr] = function() { + return { + priority: 100, + link: function(scope, element, attr) { + //special case ngPattern when a literal regular expression value + //is used as the expression (this way we don't have to watch anything). + if (ngAttr === "ngPattern" && attr.ngPattern.charAt(0) == "/") { + var match = attr.ngPattern.match(REGEX_STRING_REGEXP); + if (match) { + attr.$set("ngPattern", new RegExp(match[1], match[2])); + return; + } + } + + scope.$watch(attr[ngAttr], function ngAttrAliasWatchAction(value) { + attr.$set(ngAttr, value); + }); + } + }; + }; +}); + +// ng-src, ng-srcset, ng-href are interpolated +forEach(['src', 'srcset', 'href'], function(attrName) { + var normalized = directiveNormalize('ng-' + attrName); + ngAttributeAliasDirectives[normalized] = function() { + return { + priority: 99, // it needs to run after the attributes are interpolated + link: function(scope, element, attr) { + var propName = attrName, + name = attrName; + + if (attrName === 'href' && + toString.call(element.prop('href')) === '[object SVGAnimatedString]') { + name = 'xlinkHref'; + attr.$attr[name] = 'xlink:href'; + propName = null; + } + + attr.$observe(normalized, function(value) { + if (!value) { + if (attrName === 'href') { + attr.$set(name, null); + } + return; + } + + attr.$set(name, value); + + // on IE, if "ng:src" directive declaration is used and "src" attribute doesn't exist + // then calling element.setAttribute('src', 'foo') doesn't do anything, so we need + // to set the property as well to achieve the desired effect. + // we use attr[attrName] value since $set can sanitize the url. + if (msie && propName) element.prop(propName, attr[name]); + }); + } + }; + }; +}); + +/* global -nullFormCtrl, -SUBMITTED_CLASS, addSetValidityMethod: true + */ +var nullFormCtrl = { + $addControl: noop, + $$renameControl: nullFormRenameControl, + $removeControl: noop, + $setValidity: noop, + $setDirty: noop, + $setPristine: noop, + $setSubmitted: noop +}, +SUBMITTED_CLASS = 'ng-submitted'; + +function nullFormRenameControl(control, name) { + control.$name = name; +} + +/** + * @ngdoc type + * @name form.FormController + * + * @property {boolean} $pristine True if user has not interacted with the form yet. + * @property {boolean} $dirty True if user has already interacted with the form. + * @property {boolean} $valid True if all of the containing forms and controls are valid. + * @property {boolean} $invalid True if at least one containing control or form is invalid. + * @property {boolean} $pending True if at least one containing control or form is pending. + * @property {boolean} $submitted True if user has submitted the form even if its invalid. + * + * @property {Object} $error Is an object hash, containing references to controls or + * forms with failing validators, where: + * + * - keys are validation tokens (error names), + * - values are arrays of controls or forms that have a failing validator for given error name. + * + * Built-in validation tokens: + * + * - `email` + * - `max` + * - `maxlength` + * - `min` + * - `minlength` + * - `number` + * - `pattern` + * - `required` + * - `url` + * - `date` + * - `datetimelocal` + * - `time` + * - `week` + * - `month` + * + * @description + * `FormController` keeps track of all its controls and nested forms as well as the state of them, + * such as being valid/invalid or dirty/pristine. + * + * Each {@link ng.directive:form form} directive creates an instance + * of `FormController`. + * + */ +//asks for $scope to fool the BC controller module +FormController.$inject = ['$element', '$attrs', '$scope', '$animate', '$interpolate']; +function FormController(element, attrs, $scope, $animate, $interpolate) { + var form = this, + controls = []; + + // init state + form.$error = {}; + form.$$success = {}; + form.$pending = undefined; + form.$name = $interpolate(attrs.name || attrs.ngForm || '')($scope); + form.$dirty = false; + form.$pristine = true; + form.$valid = true; + form.$invalid = false; + form.$submitted = false; + form.$$parentForm = nullFormCtrl; + + /** + * @ngdoc method + * @name form.FormController#$rollbackViewValue + * + * @description + * Rollback all form controls pending updates to the `$modelValue`. + * + * Updates may be pending by a debounced event or because the input is waiting for a some future + * event defined in `ng-model-options`. This method is typically needed by the reset button of + * a form that uses `ng-model-options` to pend updates. + */ + form.$rollbackViewValue = function() { + forEach(controls, function(control) { + control.$rollbackViewValue(); + }); + }; + + /** + * @ngdoc method + * @name form.FormController#$commitViewValue + * + * @description + * Commit all form controls pending updates to the `$modelValue`. + * + * Updates may be pending by a debounced event or because the input is waiting for a some future + * event defined in `ng-model-options`. This method is rarely needed as `NgModelController` + * usually handles calling this in response to input events. + */ + form.$commitViewValue = function() { + forEach(controls, function(control) { + control.$commitViewValue(); + }); + }; + + /** + * @ngdoc method + * @name form.FormController#$addControl + * @param {object} control control object, either a {@link form.FormController} or an + * {@link ngModel.NgModelController} + * + * @description + * Register a control with the form. Input elements using ngModelController do this automatically + * when they are linked. + * + * Note that the current state of the control will not be reflected on the new parent form. This + * is not an issue with normal use, as freshly compiled and linked controls are in a `$pristine` + * state. + * + * However, if the method is used programmatically, for example by adding dynamically created controls, + * or controls that have been previously removed without destroying their corresponding DOM element, + * it's the developers responsiblity to make sure the current state propagates to the parent form. + * + * For example, if an input control is added that is already `$dirty` and has `$error` properties, + * calling `$setDirty()` and `$validate()` afterwards will propagate the state to the parent form. + */ + form.$addControl = function(control) { + // Breaking change - before, inputs whose name was "hasOwnProperty" were quietly ignored + // and not added to the scope. Now we throw an error. + assertNotHasOwnProperty(control.$name, 'input'); + controls.push(control); + + if (control.$name) { + form[control.$name] = control; + } + + control.$$parentForm = form; + }; + + // Private API: rename a form control + form.$$renameControl = function(control, newName) { + var oldName = control.$name; + + if (form[oldName] === control) { + delete form[oldName]; + } + form[newName] = control; + control.$name = newName; + }; + + /** + * @ngdoc method + * @name form.FormController#$removeControl + * @param {object} control control object, either a {@link form.FormController} or an + * {@link ngModel.NgModelController} + * + * @description + * Deregister a control from the form. + * + * Input elements using ngModelController do this automatically when they are destroyed. + * + * Note that only the removed control's validation state (`$errors`etc.) will be removed from the + * form. `$dirty`, `$submitted` states will not be changed, because the expected behavior can be + * different from case to case. For example, removing the only `$dirty` control from a form may or + * may not mean that the form is still `$dirty`. + */ + form.$removeControl = function(control) { + if (control.$name && form[control.$name] === control) { + delete form[control.$name]; + } + forEach(form.$pending, function(value, name) { + form.$setValidity(name, null, control); + }); + forEach(form.$error, function(value, name) { + form.$setValidity(name, null, control); + }); + forEach(form.$$success, function(value, name) { + form.$setValidity(name, null, control); + }); + + arrayRemove(controls, control); + control.$$parentForm = nullFormCtrl; + }; + + + /** + * @ngdoc method + * @name form.FormController#$setValidity + * + * @description + * Sets the validity of a form control. + * + * This method will also propagate to parent forms. + */ + addSetValidityMethod({ + ctrl: this, + $element: element, + set: function(object, property, controller) { + var list = object[property]; + if (!list) { + object[property] = [controller]; + } else { + var index = list.indexOf(controller); + if (index === -1) { + list.push(controller); + } + } + }, + unset: function(object, property, controller) { + var list = object[property]; + if (!list) { + return; + } + arrayRemove(list, controller); + if (list.length === 0) { + delete object[property]; + } + }, + $animate: $animate + }); + + /** + * @ngdoc method + * @name form.FormController#$setDirty + * + * @description + * Sets the form to a dirty state. + * + * This method can be called to add the 'ng-dirty' class and set the form to a dirty + * state (ng-dirty class). This method will also propagate to parent forms. + */ + form.$setDirty = function() { + $animate.removeClass(element, PRISTINE_CLASS); + $animate.addClass(element, DIRTY_CLASS); + form.$dirty = true; + form.$pristine = false; + form.$$parentForm.$setDirty(); + }; + + /** + * @ngdoc method + * @name form.FormController#$setPristine + * + * @description + * Sets the form to its pristine state. + * + * This method can be called to remove the 'ng-dirty' class and set the form to its pristine + * state (ng-pristine class). This method will also propagate to all the controls contained + * in this form. + * + * Setting a form back to a pristine state is often useful when we want to 'reuse' a form after + * saving or resetting it. + */ + form.$setPristine = function() { + $animate.setClass(element, PRISTINE_CLASS, DIRTY_CLASS + ' ' + SUBMITTED_CLASS); + form.$dirty = false; + form.$pristine = true; + form.$submitted = false; + forEach(controls, function(control) { + control.$setPristine(); + }); + }; + + /** + * @ngdoc method + * @name form.FormController#$setUntouched + * + * @description + * Sets the form to its untouched state. + * + * This method can be called to remove the 'ng-touched' class and set the form controls to their + * untouched state (ng-untouched class). + * + * Setting a form controls back to their untouched state is often useful when setting the form + * back to its pristine state. + */ + form.$setUntouched = function() { + forEach(controls, function(control) { + control.$setUntouched(); + }); + }; + + /** + * @ngdoc method + * @name form.FormController#$setSubmitted + * + * @description + * Sets the form to its submitted state. + */ + form.$setSubmitted = function() { + $animate.addClass(element, SUBMITTED_CLASS); + form.$submitted = true; + form.$$parentForm.$setSubmitted(); + }; +} + +/** + * @ngdoc directive + * @name ngForm + * @restrict EAC + * + * @description + * Nestable alias of {@link ng.directive:form `form`} directive. HTML + * does not allow nesting of form elements. It is useful to nest forms, for example if the validity of a + * sub-group of controls needs to be determined. + * + * Note: the purpose of `ngForm` is to group controls, + * but not to be a replacement for the `
` tag with all of its capabilities + * (e.g. posting to the server, ...). + * + * @param {string=} ngForm|name Name of the form. If specified, the form controller will be published into + * related scope, under this name. + * + */ + + /** + * @ngdoc directive + * @name form + * @restrict E + * + * @description + * Directive that instantiates + * {@link form.FormController FormController}. + * + * If the `name` attribute is specified, the form controller is published onto the current scope under + * this name. + * + * # Alias: {@link ng.directive:ngForm `ngForm`} + * + * In Angular, forms can be nested. This means that the outer form is valid when all of the child + * forms are valid as well. However, browsers do not allow nesting of `` elements, so + * Angular provides the {@link ng.directive:ngForm `ngForm`} directive which behaves identically to + * `` but can be nested. This allows you to have nested forms, which is very useful when + * using Angular validation directives in forms that are dynamically generated using the + * {@link ng.directive:ngRepeat `ngRepeat`} directive. Since you cannot dynamically generate the `name` + * attribute of input elements using interpolation, you have to wrap each set of repeated inputs in an + * `ngForm` directive and nest these in an outer `form` element. + * + * + * # CSS classes + * - `ng-valid` is set if the form is valid. + * - `ng-invalid` is set if the form is invalid. + * - `ng-pending` is set if the form is pending. + * - `ng-pristine` is set if the form is pristine. + * - `ng-dirty` is set if the form is dirty. + * - `ng-submitted` is set if the form was submitted. + * + * Keep in mind that ngAnimate can detect each of these classes when added and removed. + * + * + * # Submitting a form and preventing the default action + * + * Since the role of forms in client-side Angular applications is different than in classical + * roundtrip apps, it is desirable for the browser not to translate the form submission into a full + * page reload that sends the data to the server. Instead some javascript logic should be triggered + * to handle the form submission in an application-specific way. + * + * For this reason, Angular prevents the default action (form submission to the server) unless the + * `` element has an `action` attribute specified. + * + * You can use one of the following two ways to specify what javascript method should be called when + * a form is submitted: + * + * - {@link ng.directive:ngSubmit ngSubmit} directive on the form element + * - {@link ng.directive:ngClick ngClick} directive on the first + * button or input field of type submit (input[type=submit]) + * + * To prevent double execution of the handler, use only one of the {@link ng.directive:ngSubmit ngSubmit} + * or {@link ng.directive:ngClick ngClick} directives. + * This is because of the following form submission rules in the HTML specification: + * + * - If a form has only one input field then hitting enter in this field triggers form submit + * (`ngSubmit`) + * - if a form has 2+ input fields and no buttons or input[type=submit] then hitting enter + * doesn't trigger submit + * - if a form has one or more input fields and one or more buttons or input[type=submit] then + * hitting enter in any of the input fields will trigger the click handler on the *first* button or + * input[type=submit] (`ngClick`) *and* a submit handler on the enclosing form (`ngSubmit`) + * + * Any pending `ngModelOptions` changes will take place immediately when an enclosing form is + * submitted. Note that `ngClick` events will occur before the model is updated. Use `ngSubmit` + * to have access to the updated model. + * + * ## Animation Hooks + * + * Animations in ngForm are triggered when any of the associated CSS classes are added and removed. + * These classes are: `.ng-pristine`, `.ng-dirty`, `.ng-invalid` and `.ng-valid` as well as any + * other validations that are performed within the form. Animations in ngForm are similar to how + * they work in ngClass and animations can be hooked into using CSS transitions, keyframes as well + * as JS animations. + * + * The following example shows a simple way to utilize CSS transitions to style a form element + * that has been rendered as invalid after it has been validated: + * + *
+ * //be sure to include ngAnimate as a module to hook into more
+ * //advanced animations
+ * .my-form {
+ *   transition:0.5s linear all;
+ *   background: white;
+ * }
+ * .my-form.ng-invalid {
+ *   background: red;
+ *   color:white;
+ * }
+ * 
+ * + * @example + + + + + + userType: + Required!
+ userType = {{userType}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+ +
+ + it('should initialize to model', function() { + var userType = element(by.binding('userType')); + var valid = element(by.binding('myForm.input.$valid')); + + expect(userType.getText()).toContain('guest'); + expect(valid.getText()).toContain('true'); + }); + + it('should be invalid if empty', function() { + var userType = element(by.binding('userType')); + var valid = element(by.binding('myForm.input.$valid')); + var userInput = element(by.model('userType')); + + userInput.clear(); + userInput.sendKeys(''); + + expect(userType.getText()).toEqual('userType ='); + expect(valid.getText()).toContain('false'); + }); + +
+ * + * @param {string=} name Name of the form. If specified, the form controller will be published into + * related scope, under this name. + */ +var formDirectiveFactory = function(isNgForm) { + return ['$timeout', '$parse', function($timeout, $parse) { + var formDirective = { + name: 'form', + restrict: isNgForm ? 'EAC' : 'E', + require: ['form', '^^?form'], //first is the form's own ctrl, second is an optional parent form + controller: FormController, + compile: function ngFormCompile(formElement, attr) { + // Setup initial state of the control + formElement.addClass(PRISTINE_CLASS).addClass(VALID_CLASS); + + var nameAttr = attr.name ? 'name' : (isNgForm && attr.ngForm ? 'ngForm' : false); + + return { + pre: function ngFormPreLink(scope, formElement, attr, ctrls) { + var controller = ctrls[0]; + + // if `action` attr is not present on the form, prevent the default action (submission) + if (!('action' in attr)) { + // we can't use jq events because if a form is destroyed during submission the default + // action is not prevented. see #1238 + // + // IE 9 is not affected because it doesn't fire a submit event and try to do a full + // page reload if the form was destroyed by submission of the form via a click handler + // on a button in the form. Looks like an IE9 specific bug. + var handleFormSubmission = function(event) { + scope.$apply(function() { + controller.$commitViewValue(); + controller.$setSubmitted(); + }); + + event.preventDefault(); + }; + + addEventListenerFn(formElement[0], 'submit', handleFormSubmission); + + // unregister the preventDefault listener so that we don't not leak memory but in a + // way that will achieve the prevention of the default action. + formElement.on('$destroy', function() { + $timeout(function() { + removeEventListenerFn(formElement[0], 'submit', handleFormSubmission); + }, 0, false); + }); + } + + var parentFormCtrl = ctrls[1] || controller.$$parentForm; + parentFormCtrl.$addControl(controller); + + var setter = nameAttr ? getSetter(controller.$name) : noop; + + if (nameAttr) { + setter(scope, controller); + attr.$observe(nameAttr, function(newValue) { + if (controller.$name === newValue) return; + setter(scope, undefined); + controller.$$parentForm.$$renameControl(controller, newValue); + setter = getSetter(controller.$name); + setter(scope, controller); + }); + } + formElement.on('$destroy', function() { + controller.$$parentForm.$removeControl(controller); + setter(scope, undefined); + extend(controller, nullFormCtrl); //stop propagating child destruction handlers upwards + }); + } + }; + } + }; + + return formDirective; + + function getSetter(expression) { + if (expression === '') { + //create an assignable expression, so forms with an empty name can be renamed later + return $parse('this[""]').assign; + } + return $parse(expression).assign || noop; + } + }]; +}; + +var formDirective = formDirectiveFactory(); +var ngFormDirective = formDirectiveFactory(true); + +/* global VALID_CLASS: false, + INVALID_CLASS: false, + PRISTINE_CLASS: false, + DIRTY_CLASS: false, + UNTOUCHED_CLASS: false, + TOUCHED_CLASS: false, + ngModelMinErr: false, +*/ + +// Regex code is obtained from SO: https://stackoverflow.com/questions/3143070/javascript-regex-iso-datetime#answer-3143231 +var ISO_DATE_REGEXP = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/; +var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/; +var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i; +var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))([eE][+-]?\d+)?\s*$/; +var DATE_REGEXP = /^(\d{4})-(\d{2})-(\d{2})$/; +var DATETIMELOCAL_REGEXP = /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/; +var WEEK_REGEXP = /^(\d{4})-W(\d\d)$/; +var MONTH_REGEXP = /^(\d{4})-(\d\d)$/; +var TIME_REGEXP = /^(\d\d):(\d\d)(?::(\d\d)(\.\d{1,3})?)?$/; + +var inputType = { + + /** + * @ngdoc input + * @name input[text] + * + * @description + * Standard HTML text input with angular data binding, inherited by most of the `input` elements. + * + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} required Adds `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than + * minlength. + * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than + * maxlength. Setting the attribute to a negative or non-numeric value, allows view values of + * any length. + * @param {string=} pattern Similar to `ngPattern` except that the attribute value is the actual string + * that contains the regular expression body that will be converted to a regular expression + * as in the ngPattern directive. + * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel value does not match + * a RegExp found by evaluating the Angular expression given in the attribute value. + * If the expression evaluates to a RegExp object, then this is used directly. + * If the expression evaluates to a string, then it will be converted to a RegExp + * after wrapping it in `^` and `$` characters. For instance, `"abc"` will be converted to + * `new RegExp('^abc$')`.
+ * **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to + * start at the index of the last search's match, thus not taking the whole input value into + * account. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input. + * This parameter is ignored for input[type=password] controls, which will never trim the + * input. + * + * @example + + + +
+ +
+ + Required! + + Single word only! +
+ text = {{example.text}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+
+
+ + var text = element(by.binding('example.text')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('example.text')); + + it('should initialize to model', function() { + expect(text.getText()).toContain('guest'); + expect(valid.getText()).toContain('true'); + }); + + it('should be invalid if empty', function() { + input.clear(); + input.sendKeys(''); + + expect(text.getText()).toEqual('text ='); + expect(valid.getText()).toContain('false'); + }); + + it('should be invalid if multi word', function() { + input.clear(); + input.sendKeys('hello world'); + + expect(valid.getText()).toContain('false'); + }); + +
+ */ + 'text': textInputType, + + /** + * @ngdoc input + * @name input[date] + * + * @description + * Input with date validation and transformation. In browsers that do not yet support + * the HTML5 date input, a text element will be used. In that case, text must be entered in a valid ISO-8601 + * date format (yyyy-MM-dd), for example: `2009-01-06`. Since many + * modern browsers do not yet support this input type, it is important to provide cues to users on the + * expected input format via a placeholder or label. + * + * The model must always be a Date object, otherwise Angular will throw an error. + * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string. + * + * The timezone to be used to read/write the `Date` instance in the model can be defined using + * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser. + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a + * valid ISO date string (yyyy-MM-dd). You can also use interpolation inside this attribute + * (e.g. `min="{{minDate | date:'yyyy-MM-dd'}}"`). Note that `min` will also add native HTML5 + * constraint validation. + * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be + * a valid ISO date string (yyyy-MM-dd). You can also use interpolation inside this attribute + * (e.g. `max="{{maxDate | date:'yyyy-MM-dd'}}"`). Note that `max` will also add native HTML5 + * constraint validation. + * @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO date string + * the `ngMin` expression evaluates to. Note that it does not set the `min` attribute. + * @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO date string + * the `ngMax` expression evaluates to. Note that it does not set the `max` attribute. + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * + * @example + + + +
+ + +
+ + Required! + + Not a valid date! +
+ value = {{example.value | date: "yyyy-MM-dd"}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+
+
+ + var value = element(by.binding('example.value | date: "yyyy-MM-dd"')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('example.value')); + + // currently protractor/webdriver does not support + // sending keys to all known HTML5 input controls + // for various browsers (see https://github.com/angular/protractor/issues/562). + function setInput(val) { + // set the value of the element and force validation. + var scr = "var ipt = document.getElementById('exampleInput'); " + + "ipt.value = '" + val + "';" + + "angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });"; + browser.executeScript(scr); + } + + it('should initialize to model', function() { + expect(value.getText()).toContain('2013-10-22'); + expect(valid.getText()).toContain('myForm.input.$valid = true'); + }); + + it('should be invalid if empty', function() { + setInput(''); + expect(value.getText()).toEqual('value ='); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + + it('should be invalid if over max', function() { + setInput('2015-01-01'); + expect(value.getText()).toContain(''); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + +
+ */ + 'date': createDateInputType('date', DATE_REGEXP, + createDateParser(DATE_REGEXP, ['yyyy', 'MM', 'dd']), + 'yyyy-MM-dd'), + + /** + * @ngdoc input + * @name input[datetime-local] + * + * @description + * Input with datetime validation and transformation. In browsers that do not yet support + * the HTML5 date input, a text element will be used. In that case, the text must be entered in a valid ISO-8601 + * local datetime format (yyyy-MM-ddTHH:mm:ss), for example: `2010-12-28T14:57:00`. + * + * The model must always be a Date object, otherwise Angular will throw an error. + * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string. + * + * The timezone to be used to read/write the `Date` instance in the model can be defined using + * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser. + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. + * This must be a valid ISO datetime format (yyyy-MM-ddTHH:mm:ss). You can also use interpolation + * inside this attribute (e.g. `min="{{minDatetimeLocal | date:'yyyy-MM-ddTHH:mm:ss'}}"`). + * Note that `min` will also add native HTML5 constraint validation. + * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. + * This must be a valid ISO datetime format (yyyy-MM-ddTHH:mm:ss). You can also use interpolation + * inside this attribute (e.g. `max="{{maxDatetimeLocal | date:'yyyy-MM-ddTHH:mm:ss'}}"`). + * Note that `max` will also add native HTML5 constraint validation. + * @param {(date|string)=} ngMin Sets the `min` validation error key to the Date / ISO datetime string + * the `ngMin` expression evaluates to. Note that it does not set the `min` attribute. + * @param {(date|string)=} ngMax Sets the `max` validation error key to the Date / ISO datetime string + * the `ngMax` expression evaluates to. Note that it does not set the `max` attribute. + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * + * @example + + + +
+ + +
+ + Required! + + Not a valid date! +
+ value = {{example.value | date: "yyyy-MM-ddTHH:mm:ss"}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+
+
+ + var value = element(by.binding('example.value | date: "yyyy-MM-ddTHH:mm:ss"')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('example.value')); + + // currently protractor/webdriver does not support + // sending keys to all known HTML5 input controls + // for various browsers (https://github.com/angular/protractor/issues/562). + function setInput(val) { + // set the value of the element and force validation. + var scr = "var ipt = document.getElementById('exampleInput'); " + + "ipt.value = '" + val + "';" + + "angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });"; + browser.executeScript(scr); + } + + it('should initialize to model', function() { + expect(value.getText()).toContain('2010-12-28T14:57:00'); + expect(valid.getText()).toContain('myForm.input.$valid = true'); + }); + + it('should be invalid if empty', function() { + setInput(''); + expect(value.getText()).toEqual('value ='); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + + it('should be invalid if over max', function() { + setInput('2015-01-01T23:59:00'); + expect(value.getText()).toContain(''); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + +
+ */ + 'datetime-local': createDateInputType('datetimelocal', DATETIMELOCAL_REGEXP, + createDateParser(DATETIMELOCAL_REGEXP, ['yyyy', 'MM', 'dd', 'HH', 'mm', 'ss', 'sss']), + 'yyyy-MM-ddTHH:mm:ss.sss'), + + /** + * @ngdoc input + * @name input[time] + * + * @description + * Input with time validation and transformation. In browsers that do not yet support + * the HTML5 date input, a text element will be used. In that case, the text must be entered in a valid ISO-8601 + * local time format (HH:mm:ss), for example: `14:57:00`. Model must be a Date object. This binding will always output a + * Date object to the model of January 1, 1970, or local date `new Date(1970, 0, 1, HH, mm, ss)`. + * + * The model must always be a Date object, otherwise Angular will throw an error. + * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string. + * + * The timezone to be used to read/write the `Date` instance in the model can be defined using + * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser. + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. + * This must be a valid ISO time format (HH:mm:ss). You can also use interpolation inside this + * attribute (e.g. `min="{{minTime | date:'HH:mm:ss'}}"`). Note that `min` will also add + * native HTML5 constraint validation. + * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. + * This must be a valid ISO time format (HH:mm:ss). You can also use interpolation inside this + * attribute (e.g. `max="{{maxTime | date:'HH:mm:ss'}}"`). Note that `max` will also add + * native HTML5 constraint validation. + * @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO time string the + * `ngMin` expression evaluates to. Note that it does not set the `min` attribute. + * @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO time string the + * `ngMax` expression evaluates to. Note that it does not set the `max` attribute. + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * + * @example + + + +
+ + +
+ + Required! + + Not a valid date! +
+ value = {{example.value | date: "HH:mm:ss"}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+
+
+ + var value = element(by.binding('example.value | date: "HH:mm:ss"')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('example.value')); + + // currently protractor/webdriver does not support + // sending keys to all known HTML5 input controls + // for various browsers (https://github.com/angular/protractor/issues/562). + function setInput(val) { + // set the value of the element and force validation. + var scr = "var ipt = document.getElementById('exampleInput'); " + + "ipt.value = '" + val + "';" + + "angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });"; + browser.executeScript(scr); + } + + it('should initialize to model', function() { + expect(value.getText()).toContain('14:57:00'); + expect(valid.getText()).toContain('myForm.input.$valid = true'); + }); + + it('should be invalid if empty', function() { + setInput(''); + expect(value.getText()).toEqual('value ='); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + + it('should be invalid if over max', function() { + setInput('23:59:00'); + expect(value.getText()).toContain(''); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + +
+ */ + 'time': createDateInputType('time', TIME_REGEXP, + createDateParser(TIME_REGEXP, ['HH', 'mm', 'ss', 'sss']), + 'HH:mm:ss.sss'), + + /** + * @ngdoc input + * @name input[week] + * + * @description + * Input with week-of-the-year validation and transformation to Date. In browsers that do not yet support + * the HTML5 week input, a text element will be used. In that case, the text must be entered in a valid ISO-8601 + * week format (yyyy-W##), for example: `2013-W02`. + * + * The model must always be a Date object, otherwise Angular will throw an error. + * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string. + * + * The timezone to be used to read/write the `Date` instance in the model can be defined using + * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser. + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. + * This must be a valid ISO week format (yyyy-W##). You can also use interpolation inside this + * attribute (e.g. `min="{{minWeek | date:'yyyy-Www'}}"`). Note that `min` will also add + * native HTML5 constraint validation. + * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. + * This must be a valid ISO week format (yyyy-W##). You can also use interpolation inside this + * attribute (e.g. `max="{{maxWeek | date:'yyyy-Www'}}"`). Note that `max` will also add + * native HTML5 constraint validation. + * @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO week string + * the `ngMin` expression evaluates to. Note that it does not set the `min` attribute. + * @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO week string + * the `ngMax` expression evaluates to. Note that it does not set the `max` attribute. + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * + * @example + + + +
+ +
+ + Required! + + Not a valid date! +
+ value = {{example.value | date: "yyyy-Www"}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+
+
+ + var value = element(by.binding('example.value | date: "yyyy-Www"')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('example.value')); + + // currently protractor/webdriver does not support + // sending keys to all known HTML5 input controls + // for various browsers (https://github.com/angular/protractor/issues/562). + function setInput(val) { + // set the value of the element and force validation. + var scr = "var ipt = document.getElementById('exampleInput'); " + + "ipt.value = '" + val + "';" + + "angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });"; + browser.executeScript(scr); + } + + it('should initialize to model', function() { + expect(value.getText()).toContain('2013-W01'); + expect(valid.getText()).toContain('myForm.input.$valid = true'); + }); + + it('should be invalid if empty', function() { + setInput(''); + expect(value.getText()).toEqual('value ='); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + + it('should be invalid if over max', function() { + setInput('2015-W01'); + expect(value.getText()).toContain(''); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + +
+ */ + 'week': createDateInputType('week', WEEK_REGEXP, weekParser, 'yyyy-Www'), + + /** + * @ngdoc input + * @name input[month] + * + * @description + * Input with month validation and transformation. In browsers that do not yet support + * the HTML5 month input, a text element will be used. In that case, the text must be entered in a valid ISO-8601 + * month format (yyyy-MM), for example: `2009-01`. + * + * The model must always be a Date object, otherwise Angular will throw an error. + * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string. + * If the model is not set to the first of the month, the next view to model update will set it + * to the first of the month. + * + * The timezone to be used to read/write the `Date` instance in the model can be defined using + * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser. + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. + * This must be a valid ISO month format (yyyy-MM). You can also use interpolation inside this + * attribute (e.g. `min="{{minMonth | date:'yyyy-MM'}}"`). Note that `min` will also add + * native HTML5 constraint validation. + * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. + * This must be a valid ISO month format (yyyy-MM). You can also use interpolation inside this + * attribute (e.g. `max="{{maxMonth | date:'yyyy-MM'}}"`). Note that `max` will also add + * native HTML5 constraint validation. + * @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO week string + * the `ngMin` expression evaluates to. Note that it does not set the `min` attribute. + * @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO week string + * the `ngMax` expression evaluates to. Note that it does not set the `max` attribute. + + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * + * @example + + + +
+ + +
+ + Required! + + Not a valid month! +
+ value = {{example.value | date: "yyyy-MM"}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+
+
+ + var value = element(by.binding('example.value | date: "yyyy-MM"')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('example.value')); + + // currently protractor/webdriver does not support + // sending keys to all known HTML5 input controls + // for various browsers (https://github.com/angular/protractor/issues/562). + function setInput(val) { + // set the value of the element and force validation. + var scr = "var ipt = document.getElementById('exampleInput'); " + + "ipt.value = '" + val + "';" + + "angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });"; + browser.executeScript(scr); + } + + it('should initialize to model', function() { + expect(value.getText()).toContain('2013-10'); + expect(valid.getText()).toContain('myForm.input.$valid = true'); + }); + + it('should be invalid if empty', function() { + setInput(''); + expect(value.getText()).toEqual('value ='); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + + it('should be invalid if over max', function() { + setInput('2015-01'); + expect(value.getText()).toContain(''); + expect(valid.getText()).toContain('myForm.input.$valid = false'); + }); + +
+ */ + 'month': createDateInputType('month', MONTH_REGEXP, + createDateParser(MONTH_REGEXP, ['yyyy', 'MM']), + 'yyyy-MM'), + + /** + * @ngdoc input + * @name input[number] + * + * @description + * Text input with number validation and transformation. Sets the `number` validation + * error if not a valid number. + * + *
+ * The model must always be of type `number` otherwise Angular will throw an error. + * Be aware that a string containing a number is not enough. See the {@link ngModel:numfmt} + * error docs for more information and an example of how to convert your model if necessary. + *
+ * + * ## Issues with HTML5 constraint validation + * + * In browsers that follow the + * [HTML5 specification](https://html.spec.whatwg.org/multipage/forms.html#number-state-%28type=number%29), + * `input[number]` does not work as expected with {@link ngModelOptions `ngModelOptions.allowInvalid`}. + * If a non-number is entered in the input, the browser will report the value as an empty string, + * which means the view / model values in `ngModel` and subsequently the scope value + * will also be an empty string. + * + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. + * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than + * minlength. + * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than + * maxlength. Setting the attribute to a negative or non-numeric value, allows view values of + * any length. + * @param {string=} pattern Similar to `ngPattern` except that the attribute value is the actual string + * that contains the regular expression body that will be converted to a regular expression + * as in the ngPattern directive. + * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel value does not match + * a RegExp found by evaluating the Angular expression given in the attribute value. + * If the expression evaluates to a RegExp object, then this is used directly. + * If the expression evaluates to a string, then it will be converted to a RegExp + * after wrapping it in `^` and `$` characters. For instance, `"abc"` will be converted to + * `new RegExp('^abc$')`.
+ * **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to + * start at the index of the last search's match, thus not taking the whole input value into + * account. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * + * @example + + + +
+ +
+ + Required! + + Not valid number! +
+ value = {{example.value}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+
+
+ + var value = element(by.binding('example.value')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('example.value')); + + it('should initialize to model', function() { + expect(value.getText()).toContain('12'); + expect(valid.getText()).toContain('true'); + }); + + it('should be invalid if empty', function() { + input.clear(); + input.sendKeys(''); + expect(value.getText()).toEqual('value ='); + expect(valid.getText()).toContain('false'); + }); + + it('should be invalid if over max', function() { + input.clear(); + input.sendKeys('123'); + expect(value.getText()).toEqual('value ='); + expect(valid.getText()).toContain('false'); + }); + +
+ */ + 'number': numberInputType, + + + /** + * @ngdoc input + * @name input[url] + * + * @description + * Text input with URL validation. Sets the `url` validation error key if the content is not a + * valid URL. + * + *
+ * **Note:** `input[url]` uses a regex to validate urls that is derived from the regex + * used in Chromium. If you need stricter validation, you can use `ng-pattern` or modify + * the built-in validators (see the {@link guide/forms Forms guide}) + *
+ * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than + * minlength. + * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than + * maxlength. Setting the attribute to a negative or non-numeric value, allows view values of + * any length. + * @param {string=} pattern Similar to `ngPattern` except that the attribute value is the actual string + * that contains the regular expression body that will be converted to a regular expression + * as in the ngPattern directive. + * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel value does not match + * a RegExp found by evaluating the Angular expression given in the attribute value. + * If the expression evaluates to a RegExp object, then this is used directly. + * If the expression evaluates to a string, then it will be converted to a RegExp + * after wrapping it in `^` and `$` characters. For instance, `"abc"` will be converted to + * `new RegExp('^abc$')`.
+ * **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to + * start at the index of the last search's match, thus not taking the whole input value into + * account. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * + * @example + + + +
+
+ + var text = element(by.binding('url.text')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('url.text')); + + it('should initialize to model', function() { + expect(text.getText()).toContain('http://google.com'); + expect(valid.getText()).toContain('true'); + }); + + it('should be invalid if empty', function() { + input.clear(); + input.sendKeys(''); + + expect(text.getText()).toEqual('text ='); + expect(valid.getText()).toContain('false'); + }); + + it('should be invalid if not url', function() { + input.clear(); + input.sendKeys('box'); + + expect(valid.getText()).toContain('false'); + }); + +
+ */ + 'url': urlInputType, + + + /** + * @ngdoc input + * @name input[email] + * + * @description + * Text input with email validation. Sets the `email` validation error key if not a valid email + * address. + * + *
+ * **Note:** `input[email]` uses a regex to validate email addresses that is derived from the regex + * used in Chromium. If you need stricter validation (e.g. requiring a top-level domain), you can + * use `ng-pattern` or modify the built-in validators (see the {@link guide/forms Forms guide}) + *
+ * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than + * minlength. + * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than + * maxlength. Setting the attribute to a negative or non-numeric value, allows view values of + * any length. + * @param {string=} pattern Similar to `ngPattern` except that the attribute value is the actual string + * that contains the regular expression body that will be converted to a regular expression + * as in the ngPattern directive. + * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel value does not match + * a RegExp found by evaluating the Angular expression given in the attribute value. + * If the expression evaluates to a RegExp object, then this is used directly. + * If the expression evaluates to a string, then it will be converted to a RegExp + * after wrapping it in `^` and `$` characters. For instance, `"abc"` will be converted to + * `new RegExp('^abc$')`.
+ * **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to + * start at the index of the last search's match, thus not taking the whole input value into + * account. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * + * @example + + + +
+ +
+ + Required! + + Not valid email! +
+ text = {{email.text}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+ myForm.$error.email = {{!!myForm.$error.email}}
+
+
+ + var text = element(by.binding('email.text')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('email.text')); + + it('should initialize to model', function() { + expect(text.getText()).toContain('me@example.com'); + expect(valid.getText()).toContain('true'); + }); + + it('should be invalid if empty', function() { + input.clear(); + input.sendKeys(''); + expect(text.getText()).toEqual('text ='); + expect(valid.getText()).toContain('false'); + }); + + it('should be invalid if not email', function() { + input.clear(); + input.sendKeys('xxx'); + + expect(valid.getText()).toContain('false'); + }); + +
+ */ + 'email': emailInputType, + + + /** + * @ngdoc input + * @name input[radio] + * + * @description + * HTML radio button. + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string} value The value to which the `ngModel` expression should be set when selected. + * Note that `value` only supports `string` values, i.e. the scope model needs to be a string, + * too. Use `ngValue` if you need complex models (`number`, `object`, ...). + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * @param {string} ngValue Angular expression to which `ngModel` will be be set when the radio + * is selected. Should be used instead of the `value` attribute if you need + * a non-string `ngModel` (`boolean`, `array`, ...). + * + * @example + + + +
+
+
+
+ color = {{color.name | json}}
+
+ Note that `ng-value="specialValue"` sets radio item's value to be the value of `$scope.specialValue`. +
+ + it('should change state', function() { + var color = element(by.binding('color.name')); + + expect(color.getText()).toContain('blue'); + + element.all(by.model('color.name')).get(0).click(); + + expect(color.getText()).toContain('red'); + }); + +
+ */ + 'radio': radioInputType, + + + /** + * @ngdoc input + * @name input[checkbox] + * + * @description + * HTML checkbox. + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {expression=} ngTrueValue The value to which the expression should be set when selected. + * @param {expression=} ngFalseValue The value to which the expression should be set when not selected. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * + * @example + + + +
+
+
+ value1 = {{checkboxModel.value1}}
+ value2 = {{checkboxModel.value2}}
+
+
+ + it('should change state', function() { + var value1 = element(by.binding('checkboxModel.value1')); + var value2 = element(by.binding('checkboxModel.value2')); + + expect(value1.getText()).toContain('true'); + expect(value2.getText()).toContain('YES'); + + element(by.model('checkboxModel.value1')).click(); + element(by.model('checkboxModel.value2')).click(); + + expect(value1.getText()).toContain('false'); + expect(value2.getText()).toContain('NO'); + }); + +
+ */ + 'checkbox': checkboxInputType, + + 'hidden': noop, + 'button': noop, + 'submit': noop, + 'reset': noop, + 'file': noop +}; + +function stringBasedInputType(ctrl) { + ctrl.$formatters.push(function(value) { + return ctrl.$isEmpty(value) ? value : value.toString(); + }); +} + +function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { + baseInputType(scope, element, attr, ctrl, $sniffer, $browser); + stringBasedInputType(ctrl); +} + +function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) { + var type = lowercase(element[0].type); + + // In composition mode, users are still inputing intermediate text buffer, + // hold the listener until composition is done. + // More about composition events: https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent + if (!$sniffer.android) { + var composing = false; + + element.on('compositionstart', function(data) { + composing = true; + }); + + element.on('compositionend', function() { + composing = false; + listener(); + }); + } + + var listener = function(ev) { + if (timeout) { + $browser.defer.cancel(timeout); + timeout = null; + } + if (composing) return; + var value = element.val(), + event = ev && ev.type; + + // By default we will trim the value + // If the attribute ng-trim exists we will avoid trimming + // If input type is 'password', the value is never trimmed + if (type !== 'password' && (!attr.ngTrim || attr.ngTrim !== 'false')) { + value = trim(value); + } + + // If a control is suffering from bad input (due to native validators), browsers discard its + // value, so it may be necessary to revalidate (by calling $setViewValue again) even if the + // control's value is the same empty value twice in a row. + if (ctrl.$viewValue !== value || (value === '' && ctrl.$$hasNativeValidators)) { + ctrl.$setViewValue(value, event); + } + }; + + // if the browser does support "input" event, we are fine - except on IE9 which doesn't fire the + // input event on backspace, delete or cut + if ($sniffer.hasEvent('input')) { + element.on('input', listener); + } else { + var timeout; + + var deferListener = function(ev, input, origValue) { + if (!timeout) { + timeout = $browser.defer(function() { + timeout = null; + if (!input || input.value !== origValue) { + listener(ev); + } + }); + } + }; + + element.on('keydown', function(event) { + var key = event.keyCode; + + // ignore + // command modifiers arrows + if (key === 91 || (15 < key && key < 19) || (37 <= key && key <= 40)) return; + + deferListener(event, this, this.value); + }); + + // if user modifies input value using context menu in IE, we need "paste" and "cut" events to catch it + if ($sniffer.hasEvent('paste')) { + element.on('paste cut', deferListener); + } + } + + // if user paste into input using mouse on older browser + // or form autocomplete on newer browser, we need "change" event to catch it + element.on('change', listener); + + ctrl.$render = function() { + // Workaround for Firefox validation #12102. + var value = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue; + if (element.val() !== value) { + element.val(value); + } + }; +} + +function weekParser(isoWeek, existingDate) { + if (isDate(isoWeek)) { + return isoWeek; + } + + if (isString(isoWeek)) { + WEEK_REGEXP.lastIndex = 0; + var parts = WEEK_REGEXP.exec(isoWeek); + if (parts) { + var year = +parts[1], + week = +parts[2], + hours = 0, + minutes = 0, + seconds = 0, + milliseconds = 0, + firstThurs = getFirstThursdayOfYear(year), + addDays = (week - 1) * 7; + + if (existingDate) { + hours = existingDate.getHours(); + minutes = existingDate.getMinutes(); + seconds = existingDate.getSeconds(); + milliseconds = existingDate.getMilliseconds(); + } + + return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds); + } + } + + return NaN; +} + +function createDateParser(regexp, mapping) { + return function(iso, date) { + var parts, map; + + if (isDate(iso)) { + return iso; + } + + if (isString(iso)) { + // When a date is JSON'ified to wraps itself inside of an extra + // set of double quotes. This makes the date parsing code unable + // to match the date string and parse it as a date. + if (iso.charAt(0) == '"' && iso.charAt(iso.length - 1) == '"') { + iso = iso.substring(1, iso.length - 1); + } + if (ISO_DATE_REGEXP.test(iso)) { + return new Date(iso); + } + regexp.lastIndex = 0; + parts = regexp.exec(iso); + + if (parts) { + parts.shift(); + if (date) { + map = { + yyyy: date.getFullYear(), + MM: date.getMonth() + 1, + dd: date.getDate(), + HH: date.getHours(), + mm: date.getMinutes(), + ss: date.getSeconds(), + sss: date.getMilliseconds() / 1000 + }; + } else { + map = { yyyy: 1970, MM: 1, dd: 1, HH: 0, mm: 0, ss: 0, sss: 0 }; + } + + forEach(parts, function(part, index) { + if (index < mapping.length) { + map[mapping[index]] = +part; + } + }); + return new Date(map.yyyy, map.MM - 1, map.dd, map.HH, map.mm, map.ss || 0, map.sss * 1000 || 0); + } + } + + return NaN; + }; +} + +function createDateInputType(type, regexp, parseDate, format) { + return function dynamicDateInputType(scope, element, attr, ctrl, $sniffer, $browser, $filter) { + badInputChecker(scope, element, attr, ctrl); + baseInputType(scope, element, attr, ctrl, $sniffer, $browser); + var timezone = ctrl && ctrl.$options && ctrl.$options.timezone; + var previousDate; + + ctrl.$$parserName = type; + ctrl.$parsers.push(function(value) { + if (ctrl.$isEmpty(value)) return null; + if (regexp.test(value)) { + // Note: We cannot read ctrl.$modelValue, as there might be a different + // parser/formatter in the processing chain so that the model + // contains some different data format! + var parsedDate = parseDate(value, previousDate); + if (timezone) { + parsedDate = convertTimezoneToLocal(parsedDate, timezone); + } + return parsedDate; + } + return undefined; + }); + + ctrl.$formatters.push(function(value) { + if (value && !isDate(value)) { + throw ngModelMinErr('datefmt', 'Expected `{0}` to be a date', value); + } + if (isValidDate(value)) { + previousDate = value; + if (previousDate && timezone) { + previousDate = convertTimezoneToLocal(previousDate, timezone, true); + } + return $filter('date')(value, format, timezone); + } else { + previousDate = null; + return ''; + } + }); + + if (isDefined(attr.min) || attr.ngMin) { + var minVal; + ctrl.$validators.min = function(value) { + return !isValidDate(value) || isUndefined(minVal) || parseDate(value) >= minVal; + }; + attr.$observe('min', function(val) { + minVal = parseObservedDateValue(val); + ctrl.$validate(); + }); + } + + if (isDefined(attr.max) || attr.ngMax) { + var maxVal; + ctrl.$validators.max = function(value) { + return !isValidDate(value) || isUndefined(maxVal) || parseDate(value) <= maxVal; + }; + attr.$observe('max', function(val) { + maxVal = parseObservedDateValue(val); + ctrl.$validate(); + }); + } + + function isValidDate(value) { + // Invalid Date: getTime() returns NaN + return value && !(value.getTime && value.getTime() !== value.getTime()); + } + + function parseObservedDateValue(val) { + return isDefined(val) && !isDate(val) ? parseDate(val) || undefined : val; + } + }; +} + +function badInputChecker(scope, element, attr, ctrl) { + var node = element[0]; + var nativeValidation = ctrl.$$hasNativeValidators = isObject(node.validity); + if (nativeValidation) { + ctrl.$parsers.push(function(value) { + var validity = element.prop(VALIDITY_STATE_PROPERTY) || {}; + // Detect bug in FF35 for input[email] (https://bugzilla.mozilla.org/show_bug.cgi?id=1064430): + // - also sets validity.badInput (should only be validity.typeMismatch). + // - see http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#e-mail-state-(type=email) + // - can ignore this case as we can still read out the erroneous email... + return validity.badInput && !validity.typeMismatch ? undefined : value; + }); + } +} + +function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) { + badInputChecker(scope, element, attr, ctrl); + baseInputType(scope, element, attr, ctrl, $sniffer, $browser); + + ctrl.$$parserName = 'number'; + ctrl.$parsers.push(function(value) { + if (ctrl.$isEmpty(value)) return null; + if (NUMBER_REGEXP.test(value)) return parseFloat(value); + return undefined; + }); + + ctrl.$formatters.push(function(value) { + if (!ctrl.$isEmpty(value)) { + if (!isNumber(value)) { + throw ngModelMinErr('numfmt', 'Expected `{0}` to be a number', value); + } + value = value.toString(); + } + return value; + }); + + if (isDefined(attr.min) || attr.ngMin) { + var minVal; + ctrl.$validators.min = function(value) { + return ctrl.$isEmpty(value) || isUndefined(minVal) || value >= minVal; + }; + + attr.$observe('min', function(val) { + if (isDefined(val) && !isNumber(val)) { + val = parseFloat(val, 10); + } + minVal = isNumber(val) && !isNaN(val) ? val : undefined; + // TODO(matsko): implement validateLater to reduce number of validations + ctrl.$validate(); + }); + } + + if (isDefined(attr.max) || attr.ngMax) { + var maxVal; + ctrl.$validators.max = function(value) { + return ctrl.$isEmpty(value) || isUndefined(maxVal) || value <= maxVal; + }; + + attr.$observe('max', function(val) { + if (isDefined(val) && !isNumber(val)) { + val = parseFloat(val, 10); + } + maxVal = isNumber(val) && !isNaN(val) ? val : undefined; + // TODO(matsko): implement validateLater to reduce number of validations + ctrl.$validate(); + }); + } +} + +function urlInputType(scope, element, attr, ctrl, $sniffer, $browser) { + // Note: no badInputChecker here by purpose as `url` is only a validation + // in browsers, i.e. we can always read out input.value even if it is not valid! + baseInputType(scope, element, attr, ctrl, $sniffer, $browser); + stringBasedInputType(ctrl); + + ctrl.$$parserName = 'url'; + ctrl.$validators.url = function(modelValue, viewValue) { + var value = modelValue || viewValue; + return ctrl.$isEmpty(value) || URL_REGEXP.test(value); + }; +} + +function emailInputType(scope, element, attr, ctrl, $sniffer, $browser) { + // Note: no badInputChecker here by purpose as `url` is only a validation + // in browsers, i.e. we can always read out input.value even if it is not valid! + baseInputType(scope, element, attr, ctrl, $sniffer, $browser); + stringBasedInputType(ctrl); + + ctrl.$$parserName = 'email'; + ctrl.$validators.email = function(modelValue, viewValue) { + var value = modelValue || viewValue; + return ctrl.$isEmpty(value) || EMAIL_REGEXP.test(value); + }; +} + +function radioInputType(scope, element, attr, ctrl) { + // make the name unique, if not defined + if (isUndefined(attr.name)) { + element.attr('name', nextUid()); + } + + var listener = function(ev) { + if (element[0].checked) { + ctrl.$setViewValue(attr.value, ev && ev.type); + } + }; + + element.on('click', listener); + + ctrl.$render = function() { + var value = attr.value; + element[0].checked = (value == ctrl.$viewValue); + }; + + attr.$observe('value', ctrl.$render); +} + +function parseConstantExpr($parse, context, name, expression, fallback) { + var parseFn; + if (isDefined(expression)) { + parseFn = $parse(expression); + if (!parseFn.constant) { + throw ngModelMinErr('constexpr', 'Expected constant expression for `{0}`, but saw ' + + '`{1}`.', name, expression); + } + return parseFn(context); + } + return fallback; +} + +function checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filter, $parse) { + var trueValue = parseConstantExpr($parse, scope, 'ngTrueValue', attr.ngTrueValue, true); + var falseValue = parseConstantExpr($parse, scope, 'ngFalseValue', attr.ngFalseValue, false); + + var listener = function(ev) { + ctrl.$setViewValue(element[0].checked, ev && ev.type); + }; + + element.on('click', listener); + + ctrl.$render = function() { + element[0].checked = ctrl.$viewValue; + }; + + // Override the standard `$isEmpty` because the $viewValue of an empty checkbox is always set to `false` + // This is because of the parser below, which compares the `$modelValue` with `trueValue` to convert + // it to a boolean. + ctrl.$isEmpty = function(value) { + return value === false; + }; + + ctrl.$formatters.push(function(value) { + return equals(value, trueValue); + }); + + ctrl.$parsers.push(function(value) { + return value ? trueValue : falseValue; + }); +} + + +/** + * @ngdoc directive + * @name textarea + * @restrict E + * + * @description + * HTML textarea element control with angular data-binding. The data-binding and validation + * properties of this element are exactly the same as those of the + * {@link ng.directive:input input element}. + * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to + * the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of + * `required` when you want to data-bind to the `required` attribute. + * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than + * minlength. + * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than + * maxlength. Setting the attribute to a negative or non-numeric value, allows view values of any + * length. + * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel value does not match + * a RegExp found by evaluating the Angular expression given in the attribute value. + * If the expression evaluates to a RegExp object, then this is used directly. + * If the expression evaluates to a string, then it will be converted to a RegExp + * after wrapping it in `^` and `$` characters. For instance, `"abc"` will be converted to + * `new RegExp('^abc$')`.
+ * **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to + * start at the index of the last search's match, thus not taking the whole input value into + * account. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input. + */ + + +/** + * @ngdoc directive + * @name input + * @restrict E + * + * @description + * HTML input element control. When used together with {@link ngModel `ngModel`}, it provides data-binding, + * input state control, and validation. + * Input control follows HTML5 input types and polyfills the HTML5 validation behavior for older browsers. + * + *
+ * **Note:** Not every feature offered is available for all input types. + * Specifically, data binding and event handling via `ng-model` is unsupported for `input[file]`. + *
+ * + * @param {string} ngModel Assignable angular expression to data-bind to. + * @param {string=} name Property name of the form under which the control is published. + * @param {string=} required Sets `required` validation error key if the value is not entered. + * @param {boolean=} ngRequired Sets `required` attribute if set to true + * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than + * minlength. + * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than + * maxlength. Setting the attribute to a negative or non-numeric value, allows view values of any + * length. + * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel value does not match + * a RegExp found by evaluating the Angular expression given in the attribute value. + * If the expression evaluates to a RegExp object, then this is used directly. + * If the expression evaluates to a string, then it will be converted to a RegExp + * after wrapping it in `^` and `$` characters. For instance, `"abc"` will be converted to + * `new RegExp('^abc$')`.
+ * **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to + * start at the index of the last search's match, thus not taking the whole input value into + * account. + * @param {string=} ngChange Angular expression to be executed when input changes due to user + * interaction with the input element. + * @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input. + * This parameter is ignored for input[type=password] controls, which will never trim the + * input. + * + * @example + + + +
+
+ +
+ + Required! +
+ +
+ + Too short! + + Too long! +
+
+
+ user = {{user}}
+ myForm.userName.$valid = {{myForm.userName.$valid}}
+ myForm.userName.$error = {{myForm.userName.$error}}
+ myForm.lastName.$valid = {{myForm.lastName.$valid}}
+ myForm.lastName.$error = {{myForm.lastName.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+ myForm.$error.minlength = {{!!myForm.$error.minlength}}
+ myForm.$error.maxlength = {{!!myForm.$error.maxlength}}
+
+
+ + var user = element(by.exactBinding('user')); + var userNameValid = element(by.binding('myForm.userName.$valid')); + var lastNameValid = element(by.binding('myForm.lastName.$valid')); + var lastNameError = element(by.binding('myForm.lastName.$error')); + var formValid = element(by.binding('myForm.$valid')); + var userNameInput = element(by.model('user.name')); + var userLastInput = element(by.model('user.last')); + + it('should initialize to model', function() { + expect(user.getText()).toContain('{"name":"guest","last":"visitor"}'); + expect(userNameValid.getText()).toContain('true'); + expect(formValid.getText()).toContain('true'); + }); + + it('should be invalid if empty when required', function() { + userNameInput.clear(); + userNameInput.sendKeys(''); + + expect(user.getText()).toContain('{"last":"visitor"}'); + expect(userNameValid.getText()).toContain('false'); + expect(formValid.getText()).toContain('false'); + }); + + it('should be valid if empty when min length is set', function() { + userLastInput.clear(); + userLastInput.sendKeys(''); + + expect(user.getText()).toContain('{"name":"guest","last":""}'); + expect(lastNameValid.getText()).toContain('true'); + expect(formValid.getText()).toContain('true'); + }); + + it('should be invalid if less than required min length', function() { + userLastInput.clear(); + userLastInput.sendKeys('xx'); + + expect(user.getText()).toContain('{"name":"guest"}'); + expect(lastNameValid.getText()).toContain('false'); + expect(lastNameError.getText()).toContain('minlength'); + expect(formValid.getText()).toContain('false'); + }); + + it('should be invalid if longer than max length', function() { + userLastInput.clear(); + userLastInput.sendKeys('some ridiculously long name'); + + expect(user.getText()).toContain('{"name":"guest"}'); + expect(lastNameValid.getText()).toContain('false'); + expect(lastNameError.getText()).toContain('maxlength'); + expect(formValid.getText()).toContain('false'); + }); + +
+ */ +var inputDirective = ['$browser', '$sniffer', '$filter', '$parse', + function($browser, $sniffer, $filter, $parse) { + return { + restrict: 'E', + require: ['?ngModel'], + link: { + pre: function(scope, element, attr, ctrls) { + if (ctrls[0]) { + (inputType[lowercase(attr.type)] || inputType.text)(scope, element, attr, ctrls[0], $sniffer, + $browser, $filter, $parse); + } + } + } + }; +}]; + + + +var CONSTANT_VALUE_REGEXP = /^(true|false|\d+)$/; +/** + * @ngdoc directive + * @name ngValue + * + * @description + * Binds the given expression to the value of `