fix
This commit is contained in:
7
book/node_modules/tiny-lr/.babelrc
generated
vendored
Normal file
7
book/node_modules/tiny-lr/.babelrc
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"presets": ["es2015"],
|
||||
|
||||
"plugins": [
|
||||
"add-module-exports"
|
||||
]
|
||||
}
|
2
book/node_modules/tiny-lr/.eslintignore
generated
vendored
Normal file
2
book/node_modules/tiny-lr/.eslintignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
src*
|
||||
*node_modules
|
18
book/node_modules/tiny-lr/.eslintrc
generated
vendored
Normal file
18
book/node_modules/tiny-lr/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"env": {
|
||||
"es6": true,
|
||||
"mocha": true
|
||||
},
|
||||
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
|
||||
"extends": "standard",
|
||||
|
||||
"rules": {
|
||||
"semi": ["error", "always"],
|
||||
"no-multi-spaces": ["error", { "exceptions": { "VariableDeclarator": true, "ImportDeclaration": true } }],
|
||||
"promise/param-names": 0
|
||||
}
|
||||
}
|
3
book/node_modules/tiny-lr/.idea/dictionaries/jhhawker.xml
generated
vendored
Normal file
3
book/node_modules/tiny-lr/.idea/dictionaries/jhhawker.xml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="jhhawker" />
|
||||
</component>
|
6
book/node_modules/tiny-lr/.idea/encodings.xml
generated
vendored
Normal file
6
book/node_modules/tiny-lr/.idea/encodings.xml
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
7
book/node_modules/tiny-lr/.idea/inspectionProfiles/Project_Default.xml
generated
vendored
Normal file
7
book/node_modules/tiny-lr/.idea/inspectionProfiles/Project_Default.xml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
<inspection_tool class="Jscs" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
7
book/node_modules/tiny-lr/.idea/inspectionProfiles/profiles_settings.xml
generated
vendored
Normal file
7
book/node_modules/tiny-lr/.idea/inspectionProfiles/profiles_settings.xml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
7
book/node_modules/tiny-lr/.idea/jsLibraryMappings.xml
generated
vendored
Normal file
7
book/node_modules/tiny-lr/.idea/jsLibraryMappings.xml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<includedPredefinedLibrary name="ECMAScript 6" />
|
||||
<includedPredefinedLibrary name="Node.js Core" />
|
||||
</component>
|
||||
</project>
|
20
book/node_modules/tiny-lr/.idea/misc.xml
generated
vendored
Normal file
20
book/node_modules/tiny-lr/.idea/misc.xml
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="JsBowerSettings">
|
||||
<exe-path />
|
||||
<config-path />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
</project>
|
8
book/node_modules/tiny-lr/.idea/modules.xml
generated
vendored
Normal file
8
book/node_modules/tiny-lr/.idea/modules.xml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/tiny-lr.iml" filepath="$PROJECT_DIR$/.idea/tiny-lr.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
12
book/node_modules/tiny-lr/.idea/tiny-lr.iml
generated
vendored
Normal file
12
book/node_modules/tiny-lr/.idea/tiny-lr.iml
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
book/node_modules/tiny-lr/.idea/vcs.xml
generated
vendored
Normal file
6
book/node_modules/tiny-lr/.idea/vcs.xml
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
300
book/node_modules/tiny-lr/.idea/workspace.xml
generated
vendored
Normal file
300
book/node_modules/tiny-lr/.idea/workspace.xml
generated
vendored
Normal file
@@ -0,0 +1,300 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="ceaafdf0-f5cb-4dca-a919-6bfe6e1f5913" name="Default" comment="" />
|
||||
<ignored path="tiny-lr.iws" />
|
||||
<ignored path=".idea/workspace.xml" />
|
||||
<ignored path="$PROJECT_DIR$/.tmp/" />
|
||||
<ignored path="$PROJECT_DIR$/temp/" />
|
||||
<ignored path="$PROJECT_DIR$/tmp/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="CreatePatchCommitExecutor">
|
||||
<option name="PATCH_PATH" value="" />
|
||||
</component>
|
||||
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
|
||||
<component name="FavoritesManager">
|
||||
<favorites_list name="tiny-lr" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="package.json" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/package.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="120">
|
||||
<caret line="8" column="14" selection-start-line="8" selection-start-column="14" selection-end-line="8" selection-end-column="14" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="UPDATE_TYPE" value="REBASE" />
|
||||
<option name="ROOT_SYNC" value="DONT_SYNC" />
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="npm-version-amaze" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="FORCE_PUSH_ALLOWED" value="true" />
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/package.json" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER">
|
||||
<package-json value="$PROJECT_DIR$/package.json" />
|
||||
</component>
|
||||
<component name="JsGulpfileManager">
|
||||
<detection-done>true</detection-done>
|
||||
<sorting>DEFINITION_ORDER</sorting>
|
||||
</component>
|
||||
<component name="NodeModulesDirectoryManager">
|
||||
<handled-path value="$PROJECT_DIR$/node_modules" />
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="y" value="23" />
|
||||
<option name="width" value="1440" />
|
||||
<option name="height" value="873" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="false" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||
<flattenPackages />
|
||||
<showMembers />
|
||||
<showModules />
|
||||
<showLibraryContents />
|
||||
<hideEmptyPackages />
|
||||
<abbreviatePackageNames />
|
||||
<autoscrollToSource />
|
||||
<autoscrollFromSource />
|
||||
<sortByType />
|
||||
<manualOrder />
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="tiny-lr" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="tiny-lr" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
||||
</PATH_ELEMENT>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="tiny-lr" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scratches" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="settings.editor.selected.configurable" value="fileTemplates" />
|
||||
<property name="JavaScriptPreferStrict" value="false" />
|
||||
<property name="JavaScriptWeakerCompletionTypeGuess" value="true" />
|
||||
<property name="js.eslint.nodeInterpreter" value="/usr/local/bin/node" />
|
||||
<property name="js.eslint.eslintPackage" value="/usr/local/lib/node_modules/eslint" />
|
||||
<property name="js-jscs-nodeInterpreter" value="/usr/local/bin/node" />
|
||||
<property name="settings.editor.splitter.proportion" value="0.2" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="javascript.nodejs.core.library.configured.version" value="4.2.3" />
|
||||
<property name="nodejs_interpreter_path" value="/usr/local/bin/node" />
|
||||
<property name="HbShouldOpenHtmlAsHb" value="" />
|
||||
<property name="GO_FMT" value="false" />
|
||||
</component>
|
||||
<component name="RestoreUpdateTree" date="Moments ago" ActionInfo="_Update">
|
||||
<UpdatedFiles>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Updated from server" />
|
||||
<option name="myStatusName" value="Changed on server" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="CHANGED_ON_SERVER" />
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Updated" />
|
||||
<option name="myStatusName" value="Changed" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="UPDATED" />
|
||||
<PATH vcs="Git" revision="">$PROJECT_DIR$/package.json</PATH>
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Created" />
|
||||
<option name="myStatusName" value="Created" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="CREATED" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Deleted" />
|
||||
<option name="myStatusName" value="Deleted" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="true" />
|
||||
<option name="myId" value="REMOVED_FROM_REPOSITORY" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Restored" />
|
||||
<option name="myStatusName" value="Will be restored" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="RESTORED" />
|
||||
</FILE-GROUP>
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Modified" />
|
||||
<option name="myStatusName" value="Modified" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="MODIFIED" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Skipped" />
|
||||
<option name="myStatusName" value="Skipped" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="SKIPPED" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Merged with conflicts" />
|
||||
<option name="myStatusName" value="Will be merged with conflicts" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="MERGED_WITH_CONFLICTS" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Merged with tree conflicts" />
|
||||
<option name="myStatusName" value="Merged with tree conflicts" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="MERGED_WITH_TREE_CONFLICT" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Merged with property conflicts" />
|
||||
<option name="myStatusName" value="Will be merged with property conflicts" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="MERGED_WITH_PROPERTY_CONFLICT" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Merged" />
|
||||
<option name="myStatusName" value="Will be merged" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="MERGED" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Not in repository" />
|
||||
<option name="myStatusName" value="Not in repository" />
|
||||
<option name="mySupportsDeletion" value="true" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="UNKNOWN" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Locally added" />
|
||||
<option name="myStatusName" value="Locally added" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="LOCALLY_ADDED" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Locally removed" />
|
||||
<option name="myStatusName" value="Locally removed" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="LOCALLY_REMOVED" />
|
||||
</FILE-GROUP>
|
||||
<FILE-GROUP>
|
||||
<option name="myUpdateName" value="Switched" />
|
||||
<option name="myStatusName" value="Switched" />
|
||||
<option name="mySupportsDeletion" value="false" />
|
||||
<option name="myCanBeAbsent" value="false" />
|
||||
<option name="myId" value="SWITCHED" />
|
||||
</FILE-GROUP>
|
||||
</UpdatedFiles>
|
||||
</component>
|
||||
<component name="ShelveChangesManager" show_recycled="false">
|
||||
<option name="remove_strategy" value="false" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="23" width="1440" height="873" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24947146" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32980132" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="Vcs.Log.UiProperties">
|
||||
<option name="RECENTLY_FILTERED_USER_GROUPS">
|
||||
<collection />
|
||||
</option>
|
||||
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
|
||||
<collection />
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Make `npm version patch` do all the work <3 @rwjblue @nathanhammond" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Make `npm version patch` do all the work <3 @rwjblue @nathanhammond" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager />
|
||||
<watches-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/package.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="120">
|
||||
<caret line="8" column="14" selection-start-line="8" selection-start-column="14" selection-end-line="8" selection-end-column="14" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
8
book/node_modules/tiny-lr/.travis.yml
generated
vendored
Normal file
8
book/node_modules/tiny-lr/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- '6'
|
||||
# - '5'
|
||||
# - '4'
|
||||
# - '0.12'
|
||||
# - '0.10'
|
22
book/node_modules/tiny-lr/LICENSE-MIT
generated
vendored
Normal file
22
book/node_modules/tiny-lr/LICENSE-MIT
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012-2016 Mickael Daniel
|
||||
|
||||
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.
|
30
book/node_modules/tiny-lr/appveyor.yml
generated
vendored
Normal file
30
book/node_modules/tiny-lr/appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# appveyor file
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
# branches to build
|
||||
branches:
|
||||
# whitelist
|
||||
only:
|
||||
- master
|
||||
|
||||
# build version format
|
||||
version: "{build}"
|
||||
|
||||
# what combinations to test
|
||||
environment:
|
||||
matrix:
|
||||
- nodejs_version: 5
|
||||
- nodejs_version: 4
|
||||
- nodejs_version: 0.12
|
||||
|
||||
# Get the latest stable version of Node 0.STABLE.latest
|
||||
install:
|
||||
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
|
||||
- npm install
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- node --version
|
||||
- npm --version
|
||||
- cmd: npm test
|
35
book/node_modules/tiny-lr/examples/express/app.js
generated
vendored
Normal file
35
book/node_modules/tiny-lr/examples/express/app.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
const path = require('path');
|
||||
const express = require('express');
|
||||
const tinylr = require('../..');
|
||||
const debug = require('debug')('tinylr:server');
|
||||
const gaze = require('gaze');
|
||||
|
||||
process.env.DEBUG = process.env.DEBUG || 'tinylr*';
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
function logger (fmt) {
|
||||
fmt = fmt || '%s - %s';
|
||||
|
||||
return function logger (req, res, next) {
|
||||
debug(fmt, req.method, req.url);
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
(function watch (em) {
|
||||
em = em || new (require('events').EventEmitter)();
|
||||
|
||||
gaze(path.join(__dirname, 'styles/site.css'), function () {
|
||||
this.on('changed', function (filepath) {
|
||||
tinylr.changed(filepath);
|
||||
});
|
||||
});
|
||||
|
||||
return watch;
|
||||
})();
|
||||
|
||||
app
|
||||
.use(logger())
|
||||
.use('/', express.static(path.join(__dirname)))
|
||||
.use(tinylr.middleware({ app: app }));
|
38
book/node_modules/tiny-lr/examples/express/index.html
generated
vendored
Normal file
38
book/node_modules/tiny-lr/examples/express/index.html
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WD Tests</title>
|
||||
<link rel="stylesheet" href="styles/site.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="test-lr">
|
||||
Testing livereload thing
|
||||
|
||||
<a href="#" class="fun">fun</a>
|
||||
</div>
|
||||
|
||||
<script>document.write('<script src="http://'
|
||||
+ location.host
|
||||
+ '/livereload.js?snipver=1"></'
|
||||
+ 'script>')</script>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
|
||||
window.onload = function() {
|
||||
var fun = document.querySelector('.fun');
|
||||
var lr = document.querySelector('.test-lr');
|
||||
fun.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
var d3 = /d3/.test(lr.className) ? '' : 'd3';
|
||||
lr.className = 'test-lr ' + d3;
|
||||
});
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
10
book/node_modules/tiny-lr/examples/express/package.json
generated
vendored
Normal file
10
book/node_modules/tiny-lr/examples/express/package.json
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "express-lr-sample",
|
||||
"version": "0.0.0",
|
||||
"description": "ERROR: No README.md file found!",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "DEBUG='tinylr tinylr:*' node server.js"
|
||||
}
|
||||
}
|
12
book/node_modules/tiny-lr/examples/express/server.js
generated
vendored
Normal file
12
book/node_modules/tiny-lr/examples/express/server.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
const port = process.env.LR_PORT || process.env.PORT || 35729;
|
||||
|
||||
process.env.DEBUG = process.env.DEBUG || 'tinylr*';
|
||||
const debug = require('debug')('tinylr:server');
|
||||
|
||||
const app = require('./app');
|
||||
|
||||
debug('Starting server');
|
||||
app.listen(port, function (err) {
|
||||
if (err) throw err;
|
||||
debug('listening on %d', port);
|
||||
});
|
15
book/node_modules/tiny-lr/examples/express/styles/site.css
generated
vendored
Normal file
15
book/node_modules/tiny-lr/examples/express/styles/site.css
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
body {
|
||||
padding: 50px;
|
||||
font-family: sans-serif;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.test-lr {
|
||||
padding: 4em;
|
||||
color: #444;
|
||||
/* color: red; */
|
||||
font-weight: bolder;
|
||||
|
||||
border: #ccc;
|
||||
background-color: #dedede;
|
||||
}
|
94
book/node_modules/tiny-lr/lib/client.js
generated
vendored
Normal file
94
book/node_modules/tiny-lr/lib/client.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
import events from 'events';
|
||||
import WebSocket from 'faye-websocket';
|
||||
import objectAssign from 'object-assign';
|
||||
|
||||
const debug = require('debug')('tinylr:client');
|
||||
|
||||
let idCounter = 0;
|
||||
|
||||
export default class Client extends events.EventEmitter {
|
||||
|
||||
constructor (req, socket, head, options = {}) {
|
||||
super();
|
||||
this.options = options;
|
||||
this.ws = new WebSocket(req, socket, head);
|
||||
this.ws.onmessage = this.message.bind(this);
|
||||
this.ws.onclose = this.close.bind(this);
|
||||
this.id = this.uniqueId('ws');
|
||||
}
|
||||
|
||||
message (event) {
|
||||
let data = this.data(event);
|
||||
if (this[data.command]) return this[data.command](data);
|
||||
}
|
||||
|
||||
close (event) {
|
||||
if (this.ws) {
|
||||
this.ws.close();
|
||||
this.ws = null;
|
||||
}
|
||||
|
||||
this.emit('end', event);
|
||||
}
|
||||
|
||||
// Commands
|
||||
hello () {
|
||||
this.send({
|
||||
command: 'hello',
|
||||
protocols: [
|
||||
'http://livereload.com/protocols/official-7'
|
||||
],
|
||||
serverName: 'tiny-lr'
|
||||
});
|
||||
}
|
||||
|
||||
info (data) {
|
||||
if (data) {
|
||||
debug('Info', data);
|
||||
this.emit('info', objectAssign({}, data, { id: this.id }));
|
||||
this.plugins = data.plugins;
|
||||
this.url = data.url;
|
||||
}
|
||||
|
||||
return objectAssign({}, data || {}, { id: this.id, url: this.url });
|
||||
}
|
||||
|
||||
// Server commands
|
||||
reload (files) {
|
||||
files.forEach(function (file) {
|
||||
this.send({
|
||||
command: 'reload',
|
||||
path: file,
|
||||
liveCSS: this.options.liveCSS !== false,
|
||||
reloadMissingCSS: this.options.reloadMissingCSS !== false,
|
||||
liveImg: this.options.liveImg !== false
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
|
||||
alert (message) {
|
||||
this.send({
|
||||
command: 'alert',
|
||||
message: message
|
||||
});
|
||||
}
|
||||
|
||||
// Utilities
|
||||
data (event) {
|
||||
let data = {};
|
||||
try {
|
||||
data = JSON.parse(event.data);
|
||||
} catch (e) {}
|
||||
return data;
|
||||
}
|
||||
|
||||
send (data) {
|
||||
if (!this.ws) return;
|
||||
this.ws.send(JSON.stringify(data));
|
||||
}
|
||||
|
||||
uniqueId (prefix) {
|
||||
let id = idCounter++;
|
||||
return prefix ? prefix + id : id;
|
||||
}
|
||||
}
|
46
book/node_modules/tiny-lr/lib/index.js
generated
vendored
Normal file
46
book/node_modules/tiny-lr/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import Server from './server';
|
||||
import Client from './client';
|
||||
|
||||
const debug = require('debug')('tinylr');
|
||||
|
||||
// Need to keep track of LR servers when notifying
|
||||
const servers = [];
|
||||
|
||||
export default tinylr;
|
||||
|
||||
// Expose Server / Client objects
|
||||
tinylr.Server = Server;
|
||||
tinylr.Client = Client;
|
||||
|
||||
// and the middleware helpers
|
||||
tinylr.middleware = middleware;
|
||||
tinylr.changed = changed;
|
||||
|
||||
// Main entry point
|
||||
function tinylr (opts) {
|
||||
const srv = new Server(opts);
|
||||
servers.push(srv);
|
||||
return srv;
|
||||
}
|
||||
|
||||
// A facade to Server#handle
|
||||
function middleware (opts) {
|
||||
const srv = new Server(opts);
|
||||
servers.push(srv);
|
||||
return function tinylr (req, res, next) {
|
||||
srv.handler(req, res, next);
|
||||
};
|
||||
}
|
||||
|
||||
// Changed helper, helps with notifying the server of a file change
|
||||
function changed (done) {
|
||||
const files = [].slice.call(arguments);
|
||||
if (typeof files[files.length - 1] === 'function') done = files.pop();
|
||||
done = typeof done === 'function' ? done : () => {};
|
||||
debug('Notifying %d servers - Files: ', servers.length, files);
|
||||
servers.forEach(srv => {
|
||||
const params = { params: { files: files } };
|
||||
srv && srv.changed(params);
|
||||
});
|
||||
done();
|
||||
}
|
322
book/node_modules/tiny-lr/lib/server.js
generated
vendored
Normal file
322
book/node_modules/tiny-lr/lib/server.js
generated
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
import fs from 'fs';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import events from 'events';
|
||||
import {parse} from 'url';
|
||||
import Client from './client';
|
||||
import config from '../package.json';
|
||||
import anybody from 'body/any';
|
||||
import qs from 'qs';
|
||||
|
||||
const debug = require('debug')('tinylr:server');
|
||||
|
||||
const CONTENT_TYPE = 'content-type';
|
||||
const FORM_TYPE = 'application/x-www-form-urlencoded';
|
||||
|
||||
function buildRootPath (prefix = '/') {
|
||||
let rootUrl = prefix;
|
||||
|
||||
// Add trailing slash
|
||||
if (prefix[prefix.length - 1] !== '/') {
|
||||
rootUrl = `${rootUrl}/`;
|
||||
}
|
||||
|
||||
// Add leading slash
|
||||
if (prefix[0] !== '/') {
|
||||
rootUrl = `/${rootUrl}`;
|
||||
}
|
||||
|
||||
return rootUrl;
|
||||
}
|
||||
|
||||
class Server extends events.EventEmitter {
|
||||
constructor (options = {}) {
|
||||
super();
|
||||
|
||||
this.options = options;
|
||||
|
||||
options.livereload = options.livereload || require.resolve('livereload-js/dist/livereload.js');
|
||||
|
||||
// todo: change falsy check to allow 0 for random port
|
||||
options.port = parseInt(options.port || 35729, 10);
|
||||
|
||||
if (options.errorListener) {
|
||||
this.errorListener = options.errorListener;
|
||||
}
|
||||
|
||||
this.rootPath = buildRootPath(options.prefix);
|
||||
|
||||
this.clients = {};
|
||||
this.configure(options.app);
|
||||
this.routes(options.app);
|
||||
}
|
||||
|
||||
routes () {
|
||||
if (!this.options.dashboard) {
|
||||
this.on(`GET ${this.rootPath}`, this.index.bind(this));
|
||||
}
|
||||
|
||||
this.on(`GET ${this.rootPath}changed`, this.changed.bind(this));
|
||||
this.on(`POST ${this.rootPath}changed`, this.changed.bind(this));
|
||||
this.on(`POST ${this.rootPath}alert`, this.alert.bind(this));
|
||||
this.on(`GET ${this.rootPath}livereload.js`, this.livereload.bind(this));
|
||||
this.on(`GET ${this.rootPath}kill`, this.close.bind(this));
|
||||
}
|
||||
|
||||
configure (app) {
|
||||
debug('Configuring %s', app ? 'connect / express application' : 'HTTP server');
|
||||
|
||||
let handler = this.options.handler || this.handler;
|
||||
|
||||
if (!app) {
|
||||
if ((this.options.key && this.options.cert) || this.options.pfx) {
|
||||
this.server = https.createServer(this.options, handler.bind(this));
|
||||
} else {
|
||||
this.server = http.createServer(handler.bind(this));
|
||||
}
|
||||
|
||||
this.server.on('upgrade', this.websocketify.bind(this));
|
||||
this.server.on('error', this.error.bind(this));
|
||||
return this;
|
||||
}
|
||||
|
||||
this.app = app;
|
||||
this.app.listen = (port, done) => {
|
||||
done = done || function () {};
|
||||
if (port !== this.options.port) {
|
||||
debug('Warn: LiveReload port is not standard (%d). You are listening on %d', this.options.port, port);
|
||||
debug('You\'ll need to rely on the LiveReload snippet');
|
||||
debug('> http://feedback.livereload.com/knowledgebase/articles/86180-how-do-i-add-the-script-tag-manually-');
|
||||
}
|
||||
|
||||
let srv = this.server = http.createServer(app);
|
||||
srv.on('upgrade', this.websocketify.bind(this));
|
||||
srv.on('error', this.error.bind(this));
|
||||
srv.on('close', this.close.bind(this));
|
||||
return srv.listen(port, done);
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
handler (req, res, next) {
|
||||
let middleware = typeof next === 'function';
|
||||
debug('LiveReload handler %s (middleware: %s)', req.url, middleware ? 'on' : 'off');
|
||||
|
||||
next = next || this.defaultHandler.bind(this, res);
|
||||
req.headers[CONTENT_TYPE] = req.headers[CONTENT_TYPE] || FORM_TYPE;
|
||||
return anybody(req, res, (err, body) => {
|
||||
if (err) return next(err);
|
||||
req.body = body;
|
||||
|
||||
if (!req.query) {
|
||||
req.query = req.url.indexOf('?') !== -1
|
||||
? qs.parse(parse(req.url).query)
|
||||
: {};
|
||||
}
|
||||
|
||||
return this.handle(req, res, next);
|
||||
});
|
||||
}
|
||||
|
||||
index (req, res) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.write(JSON.stringify({
|
||||
tinylr: 'Welcome',
|
||||
version: config.version
|
||||
}));
|
||||
|
||||
res.end();
|
||||
}
|
||||
|
||||
handle (req, res, next) {
|
||||
let url = parse(req.url);
|
||||
debug('Request:', req.method, url.href);
|
||||
let middleware = typeof next === 'function';
|
||||
|
||||
// do the routing
|
||||
let route = req.method + ' ' + url.pathname;
|
||||
let respond = this.emit(route, req, res);
|
||||
if (respond) return;
|
||||
|
||||
if (middleware) return next();
|
||||
|
||||
// Only apply content-type on non middleware setup #70
|
||||
return this.notFound(res);
|
||||
}
|
||||
|
||||
defaultHandler (res, err) {
|
||||
if (!err) return this.notFound(res);
|
||||
|
||||
this.error(err);
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
res.statusCode = 500;
|
||||
res.end('Error: ' + err.stack);
|
||||
}
|
||||
|
||||
notFound (res) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.writeHead(404);
|
||||
res.write(JSON.stringify({
|
||||
error: 'not_found',
|
||||
reason: 'no such route'
|
||||
}));
|
||||
res.end();
|
||||
}
|
||||
|
||||
websocketify (req, socket, head) {
|
||||
let client = new Client(req, socket, head, this.options);
|
||||
this.clients[client.id] = client;
|
||||
|
||||
// handle socket error to prevent possible app crash, such as ECONNRESET
|
||||
socket.on('error', (e) => {
|
||||
// ignore frequent ECONNRESET error (seems inevitable when refresh)
|
||||
if (e.code === 'ECONNRESET') return;
|
||||
this.error(e);
|
||||
});
|
||||
|
||||
client.once('info', (data) => {
|
||||
debug('Create client %s (url: %s)', data.id, data.url);
|
||||
this.emit('MSG /create', data.id, data.url);
|
||||
});
|
||||
|
||||
client.once('end', () => {
|
||||
debug('Destroy client %s (url: %s)', client.id, client.url);
|
||||
this.emit('MSG /destroy', client.id, client.url);
|
||||
delete this.clients[client.id];
|
||||
});
|
||||
}
|
||||
|
||||
listen (port, host, fn) {
|
||||
port = port || this.options.port;
|
||||
|
||||
// Last used port for error display
|
||||
this.port = port;
|
||||
|
||||
if (typeof host === 'function') {
|
||||
fn = host;
|
||||
host = undefined;
|
||||
}
|
||||
|
||||
this.server.listen(port, host, fn);
|
||||
}
|
||||
|
||||
close (req, res) {
|
||||
Object.keys(this.clients).forEach(function (id) {
|
||||
this.clients[id].close();
|
||||
}, this);
|
||||
|
||||
if (this.server._handle) this.server.close(this.emit.bind(this, 'close'));
|
||||
|
||||
if (res) res.end();
|
||||
}
|
||||
|
||||
error (e) {
|
||||
if (this.errorListener) {
|
||||
this.errorListener(e);
|
||||
return;
|
||||
}
|
||||
|
||||
console.error();
|
||||
if (typeof e === 'undefined') {
|
||||
console.error('... Uhoh. Got error %s ...', e);
|
||||
} else {
|
||||
console.error('... Uhoh. Got error %s ...', e.message);
|
||||
console.error(e.stack);
|
||||
|
||||
if (e.code !== 'EADDRINUSE') return;
|
||||
console.error();
|
||||
console.error('You already have a server listening on %s', this.port);
|
||||
console.error('You should stop it and try again.');
|
||||
console.error();
|
||||
}
|
||||
}
|
||||
|
||||
// Routes
|
||||
|
||||
livereload (req, res) {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
fs.createReadStream(this.options.livereload).pipe(res);
|
||||
}
|
||||
|
||||
changed (req, res) {
|
||||
let files = this.param('files', req);
|
||||
|
||||
debug('Changed event (Files: %s)', files.join(' '));
|
||||
let clients = this.notifyClients(files);
|
||||
|
||||
if (!res) return;
|
||||
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.write(JSON.stringify({
|
||||
clients: clients,
|
||||
files: files
|
||||
}));
|
||||
|
||||
res.end();
|
||||
}
|
||||
|
||||
alert (req, res) {
|
||||
let message = this.param('message', req);
|
||||
|
||||
debug('Alert event (Message: %s)', message);
|
||||
let clients = this.alertClients(message);
|
||||
|
||||
if (!res) return;
|
||||
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.write(JSON.stringify({
|
||||
clients: clients,
|
||||
message: message
|
||||
}));
|
||||
|
||||
res.end();
|
||||
}
|
||||
|
||||
notifyClients (files) {
|
||||
let clients = Object.keys(this.clients).map(function (id) {
|
||||
let client = this.clients[id];
|
||||
debug('Reloading client %s (url: %s)', client.id, client.url);
|
||||
client.reload(files);
|
||||
return {
|
||||
id: client.id,
|
||||
url: client.url
|
||||
};
|
||||
}, this);
|
||||
|
||||
return clients;
|
||||
};
|
||||
|
||||
alertClients (message) {
|
||||
let clients = Object.keys(this.clients).map(function (id) {
|
||||
let client = this.clients[id];
|
||||
debug('Alert client %s (url: %s)', client.id, client.url);
|
||||
client.alert(message);
|
||||
return {
|
||||
id: client.id,
|
||||
url: client.url
|
||||
};
|
||||
}, this);
|
||||
|
||||
return clients;
|
||||
}
|
||||
|
||||
// Lookup param from body / params / query.
|
||||
param (name, req) {
|
||||
let param;
|
||||
if (req.body && req.body[name]) param = req.body[name];
|
||||
else if (req.params && req.params[name]) param = req.params[name];
|
||||
else if (req.query && req.query[name]) param = req.query[name];
|
||||
|
||||
// normalize files array
|
||||
if (name === 'files') {
|
||||
param = Array.isArray(param) ? param
|
||||
: typeof param === 'string' ? param.split(/[\s,]/)
|
||||
: [];
|
||||
}
|
||||
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
export default Server;
|
395
book/node_modules/tiny-lr/node_modules/debug/CHANGELOG.md
generated
vendored
Normal file
395
book/node_modules/tiny-lr/node_modules/debug/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,395 @@
|
||||
|
||||
3.1.0 / 2017-09-26
|
||||
==================
|
||||
|
||||
* Add `DEBUG_HIDE_DATE` env var (#486)
|
||||
* Remove ReDoS regexp in %o formatter (#504)
|
||||
* Remove "component" from package.json
|
||||
* Remove `component.json`
|
||||
* Ignore package-lock.json
|
||||
* Examples: fix colors printout
|
||||
* Fix: browser detection
|
||||
* Fix: spelling mistake (#496, @EdwardBetts)
|
||||
|
||||
3.0.1 / 2017-08-24
|
||||
==================
|
||||
|
||||
* Fix: Disable colors in Edge and Internet Explorer (#489)
|
||||
|
||||
3.0.0 / 2017-08-08
|
||||
==================
|
||||
|
||||
* Breaking: Remove DEBUG_FD (#406)
|
||||
* Breaking: Use `Date#toISOString()` instead to `Date#toUTCString()` when output is not a TTY (#418)
|
||||
* Breaking: Make millisecond timer namespace specific and allow 'always enabled' output (#408)
|
||||
* Addition: document `enabled` flag (#465)
|
||||
* Addition: add 256 colors mode (#481)
|
||||
* Addition: `enabled()` updates existing debug instances, add `destroy()` function (#440)
|
||||
* Update: component: update "ms" to v2.0.0
|
||||
* Update: separate the Node and Browser tests in Travis-CI
|
||||
* Update: refactor Readme, fixed documentation, added "Namespace Colors" section, redid screenshots
|
||||
* Update: separate Node.js and web browser examples for organization
|
||||
* Update: update "browserify" to v14.4.0
|
||||
* Fix: fix Readme typo (#473)
|
||||
|
||||
2.6.9 / 2017-09-22
|
||||
==================
|
||||
|
||||
* remove ReDoS regexp in %o formatter (#504)
|
||||
|
||||
2.6.8 / 2017-05-18
|
||||
==================
|
||||
|
||||
* Fix: Check for undefined on browser globals (#462, @marbemac)
|
||||
|
||||
2.6.7 / 2017-05-16
|
||||
==================
|
||||
|
||||
* Fix: Update ms to 2.0.0 to fix regular expression denial of service vulnerability (#458, @hubdotcom)
|
||||
* Fix: Inline extend function in node implementation (#452, @dougwilson)
|
||||
* Docs: Fix typo (#455, @msasad)
|
||||
|
||||
2.6.5 / 2017-04-27
|
||||
==================
|
||||
|
||||
* Fix: null reference check on window.documentElement.style.WebkitAppearance (#447, @thebigredgeek)
|
||||
* Misc: clean up browser reference checks (#447, @thebigredgeek)
|
||||
* Misc: add npm-debug.log to .gitignore (@thebigredgeek)
|
||||
|
||||
|
||||
2.6.4 / 2017-04-20
|
||||
==================
|
||||
|
||||
* Fix: bug that would occur if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo)
|
||||
* Chore: ignore bower.json in npm installations. (#437, @joaovieira)
|
||||
* Misc: update "ms" to v0.7.3 (@tootallnate)
|
||||
|
||||
2.6.3 / 2017-03-13
|
||||
==================
|
||||
|
||||
* Fix: Electron reference to `process.env.DEBUG` (#431, @paulcbetts)
|
||||
* Docs: Changelog fix (@thebigredgeek)
|
||||
|
||||
2.6.2 / 2017-03-10
|
||||
==================
|
||||
|
||||
* Fix: DEBUG_MAX_ARRAY_LENGTH (#420, @slavaGanzin)
|
||||
* Docs: Add backers and sponsors from Open Collective (#422, @piamancini)
|
||||
* Docs: Add Slackin invite badge (@tootallnate)
|
||||
|
||||
2.6.1 / 2017-02-10
|
||||
==================
|
||||
|
||||
* Fix: Module's `export default` syntax fix for IE8 `Expected identifier` error
|
||||
* Fix: Whitelist DEBUG_FD for values 1 and 2 only (#415, @pi0)
|
||||
* Fix: IE8 "Expected identifier" error (#414, @vgoma)
|
||||
* Fix: Namespaces would not disable once enabled (#409, @musikov)
|
||||
|
||||
2.6.0 / 2016-12-28
|
||||
==================
|
||||
|
||||
* Fix: added better null pointer checks for browser useColors (@thebigredgeek)
|
||||
* Improvement: removed explicit `window.debug` export (#404, @tootallnate)
|
||||
* Improvement: deprecated `DEBUG_FD` environment variable (#405, @tootallnate)
|
||||
|
||||
2.5.2 / 2016-12-25
|
||||
==================
|
||||
|
||||
* Fix: reference error on window within webworkers (#393, @KlausTrainer)
|
||||
* Docs: fixed README typo (#391, @lurch)
|
||||
* Docs: added notice about v3 api discussion (@thebigredgeek)
|
||||
|
||||
2.5.1 / 2016-12-20
|
||||
==================
|
||||
|
||||
* Fix: babel-core compatibility
|
||||
|
||||
2.5.0 / 2016-12-20
|
||||
==================
|
||||
|
||||
* Fix: wrong reference in bower file (@thebigredgeek)
|
||||
* Fix: webworker compatibility (@thebigredgeek)
|
||||
* Fix: output formatting issue (#388, @kribblo)
|
||||
* Fix: babel-loader compatibility (#383, @escwald)
|
||||
* Misc: removed built asset from repo and publications (@thebigredgeek)
|
||||
* Misc: moved source files to /src (#378, @yamikuronue)
|
||||
* Test: added karma integration and replaced babel with browserify for browser tests (#378, @yamikuronue)
|
||||
* Test: coveralls integration (#378, @yamikuronue)
|
||||
* Docs: simplified language in the opening paragraph (#373, @yamikuronue)
|
||||
|
||||
2.4.5 / 2016-12-17
|
||||
==================
|
||||
|
||||
* Fix: `navigator` undefined in Rhino (#376, @jochenberger)
|
||||
* Fix: custom log function (#379, @hsiliev)
|
||||
* Improvement: bit of cleanup + linting fixes (@thebigredgeek)
|
||||
* Improvement: rm non-maintainted `dist/` dir (#375, @freewil)
|
||||
* Docs: simplified language in the opening paragraph. (#373, @yamikuronue)
|
||||
|
||||
2.4.4 / 2016-12-14
|
||||
==================
|
||||
|
||||
* Fix: work around debug being loaded in preload scripts for electron (#368, @paulcbetts)
|
||||
|
||||
2.4.3 / 2016-12-14
|
||||
==================
|
||||
|
||||
* Fix: navigation.userAgent error for react native (#364, @escwald)
|
||||
|
||||
2.4.2 / 2016-12-14
|
||||
==================
|
||||
|
||||
* Fix: browser colors (#367, @tootallnate)
|
||||
* Misc: travis ci integration (@thebigredgeek)
|
||||
* Misc: added linting and testing boilerplate with sanity check (@thebigredgeek)
|
||||
|
||||
2.4.1 / 2016-12-13
|
||||
==================
|
||||
|
||||
* Fix: typo that broke the package (#356)
|
||||
|
||||
2.4.0 / 2016-12-13
|
||||
==================
|
||||
|
||||
* Fix: bower.json references unbuilt src entry point (#342, @justmatt)
|
||||
* Fix: revert "handle regex special characters" (@tootallnate)
|
||||
* Feature: configurable util.inspect()`options for NodeJS (#327, @tootallnate)
|
||||
* Feature: %O`(big O) pretty-prints objects (#322, @tootallnate)
|
||||
* Improvement: allow colors in workers (#335, @botverse)
|
||||
* Improvement: use same color for same namespace. (#338, @lchenay)
|
||||
|
||||
2.3.3 / 2016-11-09
|
||||
==================
|
||||
|
||||
* Fix: Catch `JSON.stringify()` errors (#195, Jovan Alleyne)
|
||||
* Fix: Returning `localStorage` saved values (#331, Levi Thomason)
|
||||
* Improvement: Don't create an empty object when no `process` (Nathan Rajlich)
|
||||
|
||||
2.3.2 / 2016-11-09
|
||||
==================
|
||||
|
||||
* Fix: be super-safe in index.js as well (@TooTallNate)
|
||||
* Fix: should check whether process exists (Tom Newby)
|
||||
|
||||
2.3.1 / 2016-11-09
|
||||
==================
|
||||
|
||||
* Fix: Added electron compatibility (#324, @paulcbetts)
|
||||
* Improvement: Added performance optimizations (@tootallnate)
|
||||
* Readme: Corrected PowerShell environment variable example (#252, @gimre)
|
||||
* Misc: Removed yarn lock file from source control (#321, @fengmk2)
|
||||
|
||||
2.3.0 / 2016-11-07
|
||||
==================
|
||||
|
||||
* Fix: Consistent placement of ms diff at end of output (#215, @gorangajic)
|
||||
* Fix: Escaping of regex special characters in namespace strings (#250, @zacronos)
|
||||
* Fix: Fixed bug causing crash on react-native (#282, @vkarpov15)
|
||||
* Feature: Enabled ES6+ compatible import via default export (#212 @bucaran)
|
||||
* Feature: Added %O formatter to reflect Chrome's console.log capability (#279, @oncletom)
|
||||
* Package: Update "ms" to 0.7.2 (#315, @DevSide)
|
||||
* Package: removed superfluous version property from bower.json (#207 @kkirsche)
|
||||
* Readme: fix USE_COLORS to DEBUG_COLORS
|
||||
* Readme: Doc fixes for format string sugar (#269, @mlucool)
|
||||
* Readme: Updated docs for DEBUG_FD and DEBUG_COLORS environment variables (#232, @mattlyons0)
|
||||
* Readme: doc fixes for PowerShell (#271 #243, @exoticknight @unreadable)
|
||||
* Readme: better docs for browser support (#224, @matthewmueller)
|
||||
* Tooling: Added yarn integration for development (#317, @thebigredgeek)
|
||||
* Misc: Renamed History.md to CHANGELOG.md (@thebigredgeek)
|
||||
* Misc: Added license file (#226 #274, @CantemoInternal @sdaitzman)
|
||||
* Misc: Updated contributors (@thebigredgeek)
|
||||
|
||||
2.2.0 / 2015-05-09
|
||||
==================
|
||||
|
||||
* package: update "ms" to v0.7.1 (#202, @dougwilson)
|
||||
* README: add logging to file example (#193, @DanielOchoa)
|
||||
* README: fixed a typo (#191, @amir-s)
|
||||
* browser: expose `storage` (#190, @stephenmathieson)
|
||||
* Makefile: add a `distclean` target (#189, @stephenmathieson)
|
||||
|
||||
2.1.3 / 2015-03-13
|
||||
==================
|
||||
|
||||
* Updated stdout/stderr example (#186)
|
||||
* Updated example/stdout.js to match debug current behaviour
|
||||
* Renamed example/stderr.js to stdout.js
|
||||
* Update Readme.md (#184)
|
||||
* replace high intensity foreground color for bold (#182, #183)
|
||||
|
||||
2.1.2 / 2015-03-01
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* update "ms" to v0.7.0
|
||||
* package: update "browserify" to v9.0.3
|
||||
* component: fix "ms.js" repo location
|
||||
* changed bower package name
|
||||
* updated documentation about using debug in a browser
|
||||
* fix: security error on safari (#167, #168, @yields)
|
||||
|
||||
2.1.1 / 2014-12-29
|
||||
==================
|
||||
|
||||
* browser: use `typeof` to check for `console` existence
|
||||
* browser: check for `console.log` truthiness (fix IE 8/9)
|
||||
* browser: add support for Chrome apps
|
||||
* Readme: added Windows usage remarks
|
||||
* Add `bower.json` to properly support bower install
|
||||
|
||||
2.1.0 / 2014-10-15
|
||||
==================
|
||||
|
||||
* node: implement `DEBUG_FD` env variable support
|
||||
* package: update "browserify" to v6.1.0
|
||||
* package: add "license" field to package.json (#135, @panuhorsmalahti)
|
||||
|
||||
2.0.0 / 2014-09-01
|
||||
==================
|
||||
|
||||
* package: update "browserify" to v5.11.0
|
||||
* node: use stderr rather than stdout for logging (#29, @stephenmathieson)
|
||||
|
||||
1.0.4 / 2014-07-15
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* example: remove `console.info()` log usage
|
||||
* example: add "Content-Type" UTF-8 header to browser example
|
||||
* browser: place %c marker after the space character
|
||||
* browser: reset the "content" color via `color: inherit`
|
||||
* browser: add colors support for Firefox >= v31
|
||||
* debug: prefer an instance `log()` function over the global one (#119)
|
||||
* Readme: update documentation about styled console logs for FF v31 (#116, @wryk)
|
||||
|
||||
1.0.3 / 2014-07-09
|
||||
==================
|
||||
|
||||
* Add support for multiple wildcards in namespaces (#122, @seegno)
|
||||
* browser: fix lint
|
||||
|
||||
1.0.2 / 2014-06-10
|
||||
==================
|
||||
|
||||
* browser: update color palette (#113, @gscottolson)
|
||||
* common: make console logging function configurable (#108, @timoxley)
|
||||
* node: fix %o colors on old node <= 0.8.x
|
||||
* Makefile: find node path using shell/which (#109, @timoxley)
|
||||
|
||||
1.0.1 / 2014-06-06
|
||||
==================
|
||||
|
||||
* browser: use `removeItem()` to clear localStorage
|
||||
* browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777)
|
||||
* package: add "contributors" section
|
||||
* node: fix comment typo
|
||||
* README: list authors
|
||||
|
||||
1.0.0 / 2014-06-04
|
||||
==================
|
||||
|
||||
* make ms diff be global, not be scope
|
||||
* debug: ignore empty strings in enable()
|
||||
* node: make DEBUG_COLORS able to disable coloring
|
||||
* *: export the `colors` array
|
||||
* npmignore: don't publish the `dist` dir
|
||||
* Makefile: refactor to use browserify
|
||||
* package: add "browserify" as a dev dependency
|
||||
* Readme: add Web Inspector Colors section
|
||||
* node: reset terminal color for the debug content
|
||||
* node: map "%o" to `util.inspect()`
|
||||
* browser: map "%j" to `JSON.stringify()`
|
||||
* debug: add custom "formatters"
|
||||
* debug: use "ms" module for humanizing the diff
|
||||
* Readme: add "bash" syntax highlighting
|
||||
* browser: add Firebug color support
|
||||
* browser: add colors for WebKit browsers
|
||||
* node: apply log to `console`
|
||||
* rewrite: abstract common logic for Node & browsers
|
||||
* add .jshintrc file
|
||||
|
||||
0.8.1 / 2014-04-14
|
||||
==================
|
||||
|
||||
* package: re-add the "component" section
|
||||
|
||||
0.8.0 / 2014-03-30
|
||||
==================
|
||||
|
||||
* add `enable()` method for nodejs. Closes #27
|
||||
* change from stderr to stdout
|
||||
* remove unnecessary index.js file
|
||||
|
||||
0.7.4 / 2013-11-13
|
||||
==================
|
||||
|
||||
* remove "browserify" key from package.json (fixes something in browserify)
|
||||
|
||||
0.7.3 / 2013-10-30
|
||||
==================
|
||||
|
||||
* fix: catch localStorage security error when cookies are blocked (Chrome)
|
||||
* add debug(err) support. Closes #46
|
||||
* add .browser prop to package.json. Closes #42
|
||||
|
||||
0.7.2 / 2013-02-06
|
||||
==================
|
||||
|
||||
* fix package.json
|
||||
* fix: Mobile Safari (private mode) is broken with debug
|
||||
* fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
|
||||
|
||||
0.7.1 / 2013-02-05
|
||||
==================
|
||||
|
||||
* add repository URL to package.json
|
||||
* add DEBUG_COLORED to force colored output
|
||||
* add browserify support
|
||||
* fix component. Closes #24
|
||||
|
||||
0.7.0 / 2012-05-04
|
||||
==================
|
||||
|
||||
* Added .component to package.json
|
||||
* Added debug.component.js build
|
||||
|
||||
0.6.0 / 2012-03-16
|
||||
==================
|
||||
|
||||
* Added support for "-" prefix in DEBUG [Vinay Pulim]
|
||||
* Added `.enabled` flag to the node version [TooTallNate]
|
||||
|
||||
0.5.0 / 2012-02-02
|
||||
==================
|
||||
|
||||
* Added: humanize diffs. Closes #8
|
||||
* Added `debug.disable()` to the CS variant
|
||||
* Removed padding. Closes #10
|
||||
* Fixed: persist client-side variant again. Closes #9
|
||||
|
||||
0.4.0 / 2012-02-01
|
||||
==================
|
||||
|
||||
* Added browser variant support for older browsers [TooTallNate]
|
||||
* Added `debug.enable('project:*')` to browser variant [TooTallNate]
|
||||
* Added padding to diff (moved it to the right)
|
||||
|
||||
0.3.0 / 2012-01-26
|
||||
==================
|
||||
|
||||
* Added millisecond diff when isatty, otherwise UTC string
|
||||
|
||||
0.2.0 / 2012-01-22
|
||||
==================
|
||||
|
||||
* Added wildcard support
|
||||
|
||||
0.1.0 / 2011-12-02
|
||||
==================
|
||||
|
||||
* Added: remove colors unless stderr isatty [TooTallNate]
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
19
book/node_modules/tiny-lr/node_modules/debug/LICENSE
generated
vendored
Normal file
19
book/node_modules/tiny-lr/node_modules/debug/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
||||
|
437
book/node_modules/tiny-lr/node_modules/debug/README.md
generated
vendored
Normal file
437
book/node_modules/tiny-lr/node_modules/debug/README.md
generated
vendored
Normal file
@@ -0,0 +1,437 @@
|
||||
# debug
|
||||
[](https://travis-ci.org/visionmedia/debug) [](https://coveralls.io/github/visionmedia/debug?branch=master) [](https://visionmedia-community-slackin.now.sh/) [](#backers)
|
||||
[](#sponsors)
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
A tiny JavaScript debugging utility modelled after Node.js core's debugging
|
||||
technique. Works in Node.js and web browsers.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install debug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
|
||||
|
||||
Example [_app.js_](./examples/node/app.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug')('http')
|
||||
, http = require('http')
|
||||
, name = 'My App';
|
||||
|
||||
// fake app
|
||||
|
||||
debug('booting %o', name);
|
||||
|
||||
http.createServer(function(req, res){
|
||||
debug(req.method + ' ' + req.url);
|
||||
res.end('hello\n');
|
||||
}).listen(3000, function(){
|
||||
debug('listening');
|
||||
});
|
||||
|
||||
// fake worker of some kind
|
||||
|
||||
require('./worker');
|
||||
```
|
||||
|
||||
Example [_worker.js_](./examples/node/worker.js):
|
||||
|
||||
```js
|
||||
var a = require('debug')('worker:a')
|
||||
, b = require('debug')('worker:b');
|
||||
|
||||
function work() {
|
||||
a('doing lots of uninteresting work');
|
||||
setTimeout(work, Math.random() * 1000);
|
||||
}
|
||||
|
||||
work();
|
||||
|
||||
function workb() {
|
||||
b('doing some work');
|
||||
setTimeout(workb, Math.random() * 2000);
|
||||
}
|
||||
|
||||
workb();
|
||||
```
|
||||
|
||||
The `DEBUG` environment variable is then used to enable these based on space or
|
||||
comma-delimited names.
|
||||
|
||||
Here are some examples:
|
||||
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
|
||||
|
||||
#### Windows command prompt notes
|
||||
|
||||
##### CMD
|
||||
|
||||
On Windows the environment variable is set using the `set` command.
|
||||
|
||||
```cmd
|
||||
set DEBUG=*,-not_this
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
set DEBUG=* & node app.js
|
||||
```
|
||||
|
||||
##### PowerShell (VS Code default)
|
||||
|
||||
PowerShell uses different syntax to set environment variables.
|
||||
|
||||
```cmd
|
||||
$env:DEBUG = "*,-not_this"
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
$env:DEBUG='app';node app.js
|
||||
```
|
||||
|
||||
Then, run the program to be debugged as usual.
|
||||
|
||||
npm script example:
|
||||
```js
|
||||
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",
|
||||
```
|
||||
|
||||
## Namespace Colors
|
||||
|
||||
Every debug instance has a color generated for it based on its namespace name.
|
||||
This helps when visually parsing the debug output to identify which debug instance
|
||||
a debug line belongs to.
|
||||
|
||||
#### Node.js
|
||||
|
||||
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
|
||||
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
|
||||
otherwise debug will only use a small handful of basic colors.
|
||||
|
||||
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
|
||||
|
||||
#### Web Browser
|
||||
|
||||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||
option. These are WebKit web inspectors, Firefox ([since version
|
||||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||
and the Firebug plugin for Firefox (any version).
|
||||
|
||||
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
|
||||
|
||||
|
||||
## Millisecond diff
|
||||
|
||||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
|
||||
|
||||
|
||||
## Conventions
|
||||
|
||||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
|
||||
|
||||
## Wildcards
|
||||
|
||||
The `*` character may be used as a wildcard. Suppose for example your library has
|
||||
debuggers named "connect:bodyParser", "connect:compress", "connect:session",
|
||||
instead of listing all three with
|
||||
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
|
||||
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||
|
||||
You can also exclude specific debuggers by prefixing them with a "-" character.
|
||||
For example, `DEBUG=*,-connect:*` would include all debuggers except those
|
||||
starting with "connect:".
|
||||
|
||||
## Environment Variables
|
||||
|
||||
When running through Node.js, you can set a few environment variables that will
|
||||
change the behavior of the debug logging:
|
||||
|
||||
| Name | Purpose |
|
||||
|-----------|-------------------------------------------------|
|
||||
| `DEBUG` | Enables/disables specific debugging namespaces. |
|
||||
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
|
||||
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
|
||||
| `DEBUG_DEPTH` | Object inspection depth. |
|
||||
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
|
||||
|
||||
|
||||
__Note:__ The environment variables beginning with `DEBUG_` end up being
|
||||
converted into an Options object that gets used with `%o`/`%O` formatters.
|
||||
See the Node.js documentation for
|
||||
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
|
||||
for the complete list.
|
||||
|
||||
## Formatters
|
||||
|
||||
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
|
||||
Below are the officially supported formatters:
|
||||
|
||||
| Formatter | Representation |
|
||||
|-----------|----------------|
|
||||
| `%O` | Pretty-print an Object on multiple lines. |
|
||||
| `%o` | Pretty-print an Object all on a single line. |
|
||||
| `%s` | String. |
|
||||
| `%d` | Number (both integer and float). |
|
||||
| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
|
||||
| `%%` | Single percent sign ('%'). This does not consume an argument. |
|
||||
|
||||
|
||||
### Custom formatters
|
||||
|
||||
You can add custom formatters by extending the `debug.formatters` object.
|
||||
For example, if you wanted to add support for rendering a Buffer as hex with
|
||||
`%h`, you could do something like:
|
||||
|
||||
```js
|
||||
const createDebug = require('debug')
|
||||
createDebug.formatters.h = (v) => {
|
||||
return v.toString('hex')
|
||||
}
|
||||
|
||||
// …elsewhere
|
||||
const debug = createDebug('foo')
|
||||
debug('this is hex: %h', new Buffer('hello world'))
|
||||
// foo this is hex: 68656c6c6f20776f726c6421 +0ms
|
||||
```
|
||||
|
||||
|
||||
## Browser Support
|
||||
|
||||
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
|
||||
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
|
||||
if you don't want to build it yourself.
|
||||
|
||||
Debug's enable state is currently persisted by `localStorage`.
|
||||
Consider the situation shown below where you have `worker:a` and `worker:b`,
|
||||
and wish to debug both. You can enable this using `localStorage.debug`:
|
||||
|
||||
```js
|
||||
localStorage.debug = 'worker:*'
|
||||
```
|
||||
|
||||
And then refresh the page.
|
||||
|
||||
```js
|
||||
a = debug('worker:a');
|
||||
b = debug('worker:b');
|
||||
|
||||
setInterval(function(){
|
||||
a('doing some work');
|
||||
}, 1000);
|
||||
|
||||
setInterval(function(){
|
||||
b('doing some work');
|
||||
}, 1200);
|
||||
```
|
||||
|
||||
|
||||
## Output streams
|
||||
|
||||
By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
|
||||
|
||||
Example [_stdout.js_](./examples/node/stdout.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug');
|
||||
var error = debug('app:error');
|
||||
|
||||
// by default stderr is used
|
||||
error('goes to stderr!');
|
||||
|
||||
var log = debug('app:log');
|
||||
// set this namespace to log via console.log
|
||||
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||
log('goes to stdout');
|
||||
error('still goes to stderr!');
|
||||
|
||||
// set all output to go via console.info
|
||||
// overrides all per-namespace log settings
|
||||
debug.log = console.info.bind(console);
|
||||
error('now goes to stdout via console.info');
|
||||
log('still goes to stdout, but via console.info now');
|
||||
```
|
||||
|
||||
## Extend
|
||||
You can simply extend debugger
|
||||
```js
|
||||
const log = require('debug')('auth');
|
||||
|
||||
//creates new debug instance with extended namespace
|
||||
const logSign = log.extend('sign');
|
||||
const logLogin = log.extend('login');
|
||||
|
||||
log('hello'); // auth hello
|
||||
logSign('hello'); //auth:sign hello
|
||||
logLogin('hello'); //auth:login hello
|
||||
```
|
||||
|
||||
## Set dynamically
|
||||
|
||||
You can also enable debug dynamically by calling the `enable()` method :
|
||||
|
||||
```js
|
||||
let debug = require('debug');
|
||||
|
||||
console.log(1, debug.enabled('test'));
|
||||
|
||||
debug.enable('test');
|
||||
console.log(2, debug.enabled('test'));
|
||||
|
||||
debug.disable();
|
||||
console.log(3, debug.enabled('test'));
|
||||
|
||||
```
|
||||
|
||||
print :
|
||||
```
|
||||
1 false
|
||||
2 true
|
||||
3 false
|
||||
```
|
||||
|
||||
Usage :
|
||||
`enable(namespaces)`
|
||||
`namespaces` can include modes separated by a colon and wildcards.
|
||||
|
||||
Note that calling `enable()` completely overrides previously set DEBUG variable :
|
||||
|
||||
```
|
||||
$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
|
||||
=> false
|
||||
```
|
||||
|
||||
## Checking whether a debug target is enabled
|
||||
|
||||
After you've created a debug instance, you can determine whether or not it is
|
||||
enabled by checking the `enabled` property:
|
||||
|
||||
```javascript
|
||||
const debug = require('debug')('http');
|
||||
|
||||
if (debug.enabled) {
|
||||
// do stuff...
|
||||
}
|
||||
```
|
||||
|
||||
You can also manually toggle this property to force the debug instance to be
|
||||
enabled or disabled.
|
||||
|
||||
|
||||
## Authors
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
- Andrew Rhyne
|
||||
|
||||
## Backers
|
||||
|
||||
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
|
||||
|
||||
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
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.
|
1
book/node_modules/tiny-lr/node_modules/debug/node.js
generated
vendored
Normal file
1
book/node_modules/tiny-lr/node_modules/debug/node.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./src/node');
|
51
book/node_modules/tiny-lr/node_modules/debug/package.json
generated
vendored
Normal file
51
book/node_modules/tiny-lr/node_modules/debug/package.json
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "debug",
|
||||
"version": "3.2.7",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/visionmedia/debug.git"
|
||||
},
|
||||
"description": "small debugging utility",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"files": [
|
||||
"src",
|
||||
"node.js",
|
||||
"dist/debug.js",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
||||
"contributors": [
|
||||
"Nathan Rajlich <nathan@tootallnate.net> (http://n8.io)",
|
||||
"Andrew Rhyne <rhyneandrew@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.0.0",
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/preset-env": "^7.0.0",
|
||||
"browserify": "14.4.0",
|
||||
"chai": "^3.5.0",
|
||||
"concurrently": "^3.1.0",
|
||||
"coveralls": "^3.0.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"karma": "^3.0.0",
|
||||
"karma-chai": "^0.1.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-phantomjs-launcher": "^1.0.2",
|
||||
"mocha": "^5.2.0",
|
||||
"mocha-lcov-reporter": "^1.2.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"xo": "^0.23.0"
|
||||
},
|
||||
"main": "./src/index.js",
|
||||
"browser": "./src/browser.js",
|
||||
"unpkg": "./dist/debug.js"
|
||||
}
|
180
book/node_modules/tiny-lr/node_modules/debug/src/browser.js
generated
vendored
Normal file
180
book/node_modules/tiny-lr/node_modules/debug/src/browser.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
"use strict";
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*/
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = localstorage();
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
|
||||
function useColors() {
|
||||
// NB: In an Electron preload script, document will be defined but not fully
|
||||
// initialized. Since we know we're in Chrome, we'll just detect this case
|
||||
// explicitly
|
||||
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
||||
return true;
|
||||
} // Internet Explorer and Edge do not support colors.
|
||||
|
||||
|
||||
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||||
return false;
|
||||
} // Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
|
||||
|
||||
return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
||||
typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
||||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
||||
}
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function formatArgs(args) {
|
||||
args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
|
||||
|
||||
if (!this.useColors) {
|
||||
return;
|
||||
}
|
||||
|
||||
var c = 'color: ' + this.color;
|
||||
args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
|
||||
var index = 0;
|
||||
var lastC = 0;
|
||||
args[0].replace(/%[a-zA-Z%]/g, function (match) {
|
||||
if (match === '%%') {
|
||||
return;
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
if (match === '%c') {
|
||||
// We only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
args.splice(lastC, 0, c);
|
||||
}
|
||||
/**
|
||||
* Invokes `console.log()` when available.
|
||||
* No-op when `console.log` is not a "function".
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function log() {
|
||||
var _console;
|
||||
|
||||
// This hackery is required for IE8/9, where
|
||||
// the `console.log` function doesn't have 'apply'
|
||||
return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
|
||||
}
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (namespaces) {
|
||||
exports.storage.setItem('debug', namespaces);
|
||||
} else {
|
||||
exports.storage.removeItem('debug');
|
||||
}
|
||||
} catch (error) {// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function load() {
|
||||
var r;
|
||||
|
||||
try {
|
||||
r = exports.storage.getItem('debug');
|
||||
} catch (error) {} // Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||||
|
||||
|
||||
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
||||
r = process.env.DEBUG;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
/**
|
||||
* Localstorage attempts to return the localstorage.
|
||||
*
|
||||
* This is necessary because safari throws
|
||||
* when a user disables cookies/localstorage
|
||||
* and you attempt to access it.
|
||||
*
|
||||
* @return {LocalStorage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function localstorage() {
|
||||
try {
|
||||
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||||
// The Browser also has localStorage in the global context.
|
||||
return localStorage;
|
||||
} catch (error) {// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
var formatters = module.exports.formatters;
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
formatters.j = function (v) {
|
||||
try {
|
||||
return JSON.stringify(v);
|
||||
} catch (error) {
|
||||
return '[UnexpectedJSONParseError]: ' + error.message;
|
||||
}
|
||||
};
|
||||
|
249
book/node_modules/tiny-lr/node_modules/debug/src/common.js
generated
vendored
Normal file
249
book/node_modules/tiny-lr/node_modules/debug/src/common.js
generated
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* This is the common logic for both the Node.js and web browser
|
||||
* implementations of `debug()`.
|
||||
*/
|
||||
function setup(env) {
|
||||
createDebug.debug = createDebug;
|
||||
createDebug.default = createDebug;
|
||||
createDebug.coerce = coerce;
|
||||
createDebug.disable = disable;
|
||||
createDebug.enable = enable;
|
||||
createDebug.enabled = enabled;
|
||||
createDebug.humanize = require('ms');
|
||||
Object.keys(env).forEach(function (key) {
|
||||
createDebug[key] = env[key];
|
||||
});
|
||||
/**
|
||||
* Active `debug` instances.
|
||||
*/
|
||||
|
||||
createDebug.instances = [];
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
/**
|
||||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||
*
|
||||
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
||||
*/
|
||||
|
||||
createDebug.formatters = {};
|
||||
/**
|
||||
* Selects a color for a debug namespace
|
||||
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
||||
* @return {Number|String} An ANSI color code for the given namespace
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function selectColor(namespace) {
|
||||
var hash = 0;
|
||||
|
||||
for (var i = 0; i < namespace.length; i++) {
|
||||
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
|
||||
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||||
}
|
||||
|
||||
createDebug.selectColor = selectColor;
|
||||
/**
|
||||
* Create a debugger with the given `namespace`.
|
||||
*
|
||||
* @param {String} namespace
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function createDebug(namespace) {
|
||||
var prevTime;
|
||||
|
||||
function debug() {
|
||||
// Disabled?
|
||||
if (!debug.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var self = debug; // Set `diff` timestamp
|
||||
|
||||
var curr = Number(new Date());
|
||||
var ms = curr - (prevTime || curr);
|
||||
self.diff = ms;
|
||||
self.prev = prevTime;
|
||||
self.curr = curr;
|
||||
prevTime = curr;
|
||||
args[0] = createDebug.coerce(args[0]);
|
||||
|
||||
if (typeof args[0] !== 'string') {
|
||||
// Anything else let's inspect with %O
|
||||
args.unshift('%O');
|
||||
} // Apply any `formatters` transformations
|
||||
|
||||
|
||||
var index = 0;
|
||||
args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
|
||||
// If we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') {
|
||||
return match;
|
||||
}
|
||||
|
||||
index++;
|
||||
var formatter = createDebug.formatters[format];
|
||||
|
||||
if (typeof formatter === 'function') {
|
||||
var val = args[index];
|
||||
match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
|
||||
|
||||
args.splice(index, 1);
|
||||
index--;
|
||||
}
|
||||
|
||||
return match;
|
||||
}); // Apply env-specific formatting (colors, etc.)
|
||||
|
||||
createDebug.formatArgs.call(self, args);
|
||||
var logFn = self.log || createDebug.log;
|
||||
logFn.apply(self, args);
|
||||
}
|
||||
|
||||
debug.namespace = namespace;
|
||||
debug.enabled = createDebug.enabled(namespace);
|
||||
debug.useColors = createDebug.useColors();
|
||||
debug.color = selectColor(namespace);
|
||||
debug.destroy = destroy;
|
||||
debug.extend = extend; // Debug.formatArgs = formatArgs;
|
||||
// debug.rawLog = rawLog;
|
||||
// env-specific initialization logic for debug instances
|
||||
|
||||
if (typeof createDebug.init === 'function') {
|
||||
createDebug.init(debug);
|
||||
}
|
||||
|
||||
createDebug.instances.push(debug);
|
||||
return debug;
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
var index = createDebug.instances.indexOf(this);
|
||||
|
||||
if (index !== -1) {
|
||||
createDebug.instances.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function extend(namespace, delimiter) {
|
||||
return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||
}
|
||||
/**
|
||||
* Enables a debug mode by namespaces. This can include modes
|
||||
* separated by a colon and wildcards.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function enable(namespaces) {
|
||||
createDebug.save(namespaces);
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
var i;
|
||||
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||
var len = split.length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!split[i]) {
|
||||
// ignore empty strings
|
||||
continue;
|
||||
}
|
||||
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
|
||||
if (namespaces[0] === '-') {
|
||||
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||
} else {
|
||||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < createDebug.instances.length; i++) {
|
||||
var instance = createDebug.instances[i];
|
||||
instance.enabled = createDebug.enabled(instance.namespace);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function disable() {
|
||||
createDebug.enable('');
|
||||
}
|
||||
/**
|
||||
* Returns true if the given mode name is enabled, false otherwise.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function enabled(name) {
|
||||
if (name[name.length - 1] === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var i;
|
||||
var len;
|
||||
|
||||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||
if (createDebug.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||
if (createDebug.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
* @param {Mixed} val
|
||||
* @return {Mixed}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function coerce(val) {
|
||||
if (val instanceof Error) {
|
||||
return val.stack || val.message;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
createDebug.enable(createDebug.load());
|
||||
return createDebug;
|
||||
}
|
||||
|
||||
module.exports = setup;
|
||||
|
12
book/node_modules/tiny-lr/node_modules/debug/src/index.js
generated
vendored
Normal file
12
book/node_modules/tiny-lr/node_modules/debug/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Detect Electron renderer / nwjs process, which is node, but we should
|
||||
* treat as a browser.
|
||||
*/
|
||||
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
||||
module.exports = require('./browser.js');
|
||||
} else {
|
||||
module.exports = require('./node.js');
|
||||
}
|
||||
|
177
book/node_modules/tiny-lr/node_modules/debug/src/node.js
generated
vendored
Normal file
177
book/node_modules/tiny-lr/node_modules/debug/src/node.js
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var tty = require('tty');
|
||||
|
||||
var util = require('util');
|
||||
/**
|
||||
* This is the Node.js implementation of `debug()`.
|
||||
*/
|
||||
|
||||
|
||||
exports.init = init;
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||
|
||||
try {
|
||||
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
var supportsColor = require('supports-color');
|
||||
|
||||
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
||||
exports.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221];
|
||||
}
|
||||
} catch (error) {} // Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
||||
|
||||
/**
|
||||
* Build up the default `inspectOpts` object from the environment variables.
|
||||
*
|
||||
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
||||
*/
|
||||
|
||||
|
||||
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
|
||||
return /^debug_/i.test(key);
|
||||
}).reduce(function (obj, key) {
|
||||
// Camel-case
|
||||
var prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, function (_, k) {
|
||||
return k.toUpperCase();
|
||||
}); // Coerce string value into JS value
|
||||
|
||||
var val = process.env[key];
|
||||
|
||||
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
||||
val = true;
|
||||
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
||||
val = false;
|
||||
} else if (val === 'null') {
|
||||
val = null;
|
||||
} else {
|
||||
val = Number(val);
|
||||
}
|
||||
|
||||
obj[prop] = val;
|
||||
return obj;
|
||||
}, {});
|
||||
/**
|
||||
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
||||
}
|
||||
/**
|
||||
* Adds ANSI color escape codes if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
|
||||
function formatArgs(args) {
|
||||
var name = this.namespace,
|
||||
useColors = this.useColors;
|
||||
|
||||
if (useColors) {
|
||||
var c = this.color;
|
||||
var colorCode = "\x1B[3" + (c < 8 ? c : '8;5;' + c);
|
||||
var prefix = " ".concat(colorCode, ";1m").concat(name, " \x1B[0m");
|
||||
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
||||
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + "\x1B[0m");
|
||||
} else {
|
||||
args[0] = getDate() + name + ' ' + args[0];
|
||||
}
|
||||
}
|
||||
|
||||
function getDate() {
|
||||
if (exports.inspectOpts.hideDate) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return new Date().toISOString() + ' ';
|
||||
}
|
||||
/**
|
||||
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
||||
*/
|
||||
|
||||
|
||||
function log() {
|
||||
return process.stderr.write(util.format.apply(util, arguments) + '\n');
|
||||
}
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function save(namespaces) {
|
||||
if (namespaces) {
|
||||
process.env.DEBUG = namespaces;
|
||||
} else {
|
||||
// If you set a process.env field to null or undefined, it gets cast to the
|
||||
// string 'null' or 'undefined'. Just delete instead.
|
||||
delete process.env.DEBUG;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
|
||||
function load() {
|
||||
return process.env.DEBUG;
|
||||
}
|
||||
/**
|
||||
* Init logic for `debug` instances.
|
||||
*
|
||||
* Create a new `inspectOpts` object in case `useColors` is set
|
||||
* differently for a particular `debug` instance.
|
||||
*/
|
||||
|
||||
|
||||
function init(debug) {
|
||||
debug.inspectOpts = {};
|
||||
var keys = Object.keys(exports.inspectOpts);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
var formatters = module.exports.formatters;
|
||||
/**
|
||||
* Map %o to `util.inspect()`, all on a single line.
|
||||
*/
|
||||
|
||||
formatters.o = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts)
|
||||
.split('\n')
|
||||
.map(function (str) { return str.trim(); })
|
||||
.join(' ');
|
||||
};
|
||||
/**
|
||||
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
||||
*/
|
||||
|
||||
|
||||
formatters.O = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts);
|
||||
};
|
||||
|
76
book/node_modules/tiny-lr/package.json
generated
vendored
Normal file
76
book/node_modules/tiny-lr/package.json
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "tiny-lr",
|
||||
"version": "1.1.1",
|
||||
"description": "Tiny LiveReload server, background-friendly",
|
||||
"main": "./src",
|
||||
"scripts": {
|
||||
"prepublish:": "npm run babel",
|
||||
"preversion": "npm test",
|
||||
"postversion": "git push origin master --follow-tags && npm publish",
|
||||
"test": "npm run eslint && npm run mocha",
|
||||
"eslint": "eslint . --debug",
|
||||
"babel": "babel lib/ -d src && babel test/ -d src_test/",
|
||||
"mocha": "npm run babel && mocha --reporter spec src_test/",
|
||||
"test-debug": "DEBUG=tinylr:* mocha --reporter list",
|
||||
"test-debug-all": "DEBUG=* mocha --reporter list",
|
||||
"post-change": "sh scripts/post-change",
|
||||
"get-change": "curl http://localhost:35729/changed?files=site.css",
|
||||
"watch": "npm-watch"
|
||||
},
|
||||
"watch": {
|
||||
"babel": "{lib,test}/**/*.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"body": "^5.1.0",
|
||||
"debug": "^3.1.0",
|
||||
"faye-websocket": "~0.10.0",
|
||||
"livereload-js": "^2.3.0",
|
||||
"object-assign": "^4.1.0",
|
||||
"qs": "^6.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.9.0",
|
||||
"babel-plugin-add-module-exports": "^0.2.1",
|
||||
"babel-plugin-transform-regenerator": "^6.9.0",
|
||||
"babel-preset-es2015": "^6.9.0",
|
||||
"eslint": "^2.11.1",
|
||||
"eslint-config-standard": "^5.3.1",
|
||||
"eslint-plugin-promise": "^1.1.0",
|
||||
"eslint-plugin-standard": "^1.3.2",
|
||||
"express": "^4.1.1",
|
||||
"gaze": "^1.1.2",
|
||||
"mocha": "^2.3.3",
|
||||
"npm-watch": "^0.1.6",
|
||||
"standard-version": "^2.2.1",
|
||||
"supertest": "^1.2.0"
|
||||
},
|
||||
"author": "mklabs",
|
||||
"homepage": "https://github.com/mklabs/tiny-lr",
|
||||
"bugs": "https://github.com/mklabs/tiny-lr/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mklabs/tiny-lr.git"
|
||||
},
|
||||
"config": {
|
||||
"test_port": "9001"
|
||||
},
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Kyle Robinson Young",
|
||||
"url": "https://github.com/shama"
|
||||
},
|
||||
{
|
||||
"name": "Jordan Hawker",
|
||||
"url": "https://github.com/elwayman02"
|
||||
},
|
||||
{
|
||||
"name": "Hemanth.hm",
|
||||
"url": "https://github.com/hemanth"
|
||||
},
|
||||
{
|
||||
"name": "Mickael Daniel",
|
||||
"url": "https://github.com/mklabs"
|
||||
}
|
||||
]
|
||||
}
|
326
book/node_modules/tiny-lr/readme.md
generated
vendored
Normal file
326
book/node_modules/tiny-lr/readme.md
generated
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
# tiny-lr [](https://travis-ci.org/mklabs/tiny-lr)
|
||||
|
||||
This script manages a tiny [LiveReload](http://livereload.com/) server
|
||||
implementation.
|
||||
|
||||
[](https://nodei.co/npm/tiny-lr/)
|
||||
|
||||
It exposes an HTTP server and express middleware, with a very basic REST
|
||||
API to notify the server of a particular change.
|
||||
|
||||
It doesn't have any watch ability, this must be done at the build process or
|
||||
application level.
|
||||
|
||||
Instead, it exposes a very simple API to notify the server that some
|
||||
changes have been made, then broadcasted to every connected livereload client.
|
||||
|
||||
# notify of a single change
|
||||
curl http://localhost:35729/changed?files=style.css
|
||||
|
||||
# notify using a longer path
|
||||
curl http://localhost:35729/changed?files=js/app.js
|
||||
|
||||
# notify of multiple changes, comma or space delimited
|
||||
curl http://localhost:35729/changed?files=index.html,style.css,docs/docco.css
|
||||
|
||||
Or you can bulk the information into a POST request, with the body as a JSON array of files.
|
||||
|
||||
curl -X POST http://localhost:35729/changed -d '{ "files": ["style.css", "app.js"] }'
|
||||
|
||||
# from a JSON file
|
||||
node -pe 'JSON.stringify({ files: ["some.css", "files.css"] })' > files.json
|
||||
curl -X POST -d @files.json http://localhost:35729
|
||||
|
||||
As for the livereload client, you need to install the browser extension:
|
||||
http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-
|
||||
(**note**: you need to listen on port 35729 to be able to use it with your
|
||||
browser extension)
|
||||
|
||||
or add the livereload script tag manually:
|
||||
http://feedback.livereload.com/knowledgebase/articles/86180-how-do-i-add-the-script-tag-manually-
|
||||
(and here you can choose whichever port you want)
|
||||
|
||||
## Integration
|
||||
|
||||
The best way to integrate the runner into your workflow is to add it as a `reload`
|
||||
step within your build tool.
|
||||
|
||||
```js
|
||||
var tinylr = require('tiny-lr');
|
||||
|
||||
// standard LiveReload port
|
||||
var port = 35729;
|
||||
|
||||
// tinylr(opts) => new tinylr.Server(opts);
|
||||
tinylr().listen(port, function() {
|
||||
console.log('... Listening on %s ...', port);
|
||||
})
|
||||
```
|
||||
|
||||
You can define your own route and listen for a specific request:
|
||||
|
||||
```js
|
||||
var server = tinylr();
|
||||
|
||||
server.on('GET /myplace', function(req, res) {
|
||||
res.write('Mine');
|
||||
res.end();
|
||||
})
|
||||
```
|
||||
|
||||
And stop the server manually:
|
||||
|
||||
```js
|
||||
server.close();
|
||||
```
|
||||
|
||||
This will close any websocket connection established and emit a close event.
|
||||
|
||||
### Middleware
|
||||
|
||||
To use as a connect / express middleware, tiny-lr needs query /
|
||||
bodyParser middlewares prior in the stack (to handle POST requests)
|
||||
|
||||
Any handled requests ends at the tinylr level, not found and errors are
|
||||
nexted to the rest of the stack.
|
||||
|
||||
```js
|
||||
var port = process.env.LR_PORT || process.env.PORT || 35729;
|
||||
|
||||
var path = require('path');
|
||||
var express = require('express');
|
||||
var tinylr = require('tiny-lr');
|
||||
var body = require('body-parser');
|
||||
|
||||
var app = express();
|
||||
|
||||
// This binds both express app and tinylr on the same port
|
||||
|
||||
app
|
||||
.use(body())
|
||||
.use(tinylr.middleware({ app: app }))
|
||||
.use(express.static(path.resolve('./')))
|
||||
.listen(port, function() {
|
||||
console.log('listening on %d', port);
|
||||
});
|
||||
```
|
||||
|
||||
The port you listen on is important, and tinylr should **always** listen on
|
||||
the LiveReload standard one: `35729`. Otherwise, you won't be able to rely
|
||||
on the browser extensions, though you can still use the manual snippet
|
||||
approach.
|
||||
|
||||
You can also start two different servers, one on your app port, the
|
||||
other listening on the LiveReload port.
|
||||
|
||||
### Using grunt
|
||||
|
||||
Head over to [https://github.com/gruntjs/grunt-contrib-watch](https://github.com/gruntjs/grunt-contrib-watch#live-reloading)
|
||||
|
||||
### Using make
|
||||
|
||||
See the [make-livereload](https://github.com/mklabs/make-livereload) repo.
|
||||
This repository defines a bin wrapper you can use and install with:
|
||||
|
||||
npm install make-livereload -g
|
||||
|
||||
It bundles the same bin wrapper previously used in the tiny-lr repo.
|
||||
|
||||
Usage: tiny-lr [options]
|
||||
|
||||
Options:
|
||||
|
||||
-h, --help output usage information
|
||||
-V, --version output the version number
|
||||
port -p
|
||||
pid Path to the generated PID file (default: ./tiny-lr.pid)
|
||||
|
||||
### Using gulp
|
||||
|
||||
See the [gulp-livereload](https://github.com/vohof/gulp-livereload) repo.
|
||||
|
||||
## Options
|
||||
|
||||
- `livereload` - Path to the client side lib (defaults to `path.join(__dirname, '../node_modules/livereload-js/dist/livereload.js')`)
|
||||
- `port` - Livereload port (defaults to `35729`)
|
||||
- `errorListener` - A callback to invoke when an error occurs (otherwise, fallbacks to standard error output)
|
||||
- `handler` - A function to use as the main request handler (`function(req,
|
||||
res)`). When not defined, the default handler takes place.
|
||||
- `app` - An express or other middleware based HTTP server
|
||||
- `key` - Option to pass in to create an https server
|
||||
- `cert` - Option to pass in to create an https server
|
||||
- `pfx` - Can also be used to create an https server instead of `key` & `cert`
|
||||
- `liveCSS` - LiveReload option to enable live CSS reloading (defaults to true)
|
||||
- `liveImg` - LiveReload option to enable live images reloading (defaults to true)
|
||||
- `prefix` - Option to add prefix to all HTTP server routes
|
||||
- `dashboard` - A boolean to prevent tiny-lr from configuring a default
|
||||
"home" route. Only used with the CLI (default: false)
|
||||
|
||||
## Tests
|
||||
|
||||
npm test
|
||||
|
||||
---
|
||||
|
||||
|
||||
# TOC
|
||||
|
||||
- [GET /](#tiny-lr-get-)
|
||||
- [GET /changed](#tiny-lr-get-changed)
|
||||
- [POST /changed](#tiny-lr-post-changed)
|
||||
- [GET /livereload.js](#tiny-lr-get-livereloadjs)
|
||||
- [GET /kill](#tiny-lr-get-kill)
|
||||
|
||||
|
||||
```js
|
||||
var url = parse(this.request.url);
|
||||
var server = this.app;
|
||||
|
||||
var ws = this.ws = new WebSocket('ws://' + url.host + '/livereload');
|
||||
|
||||
ws.onopen = function(event) {
|
||||
var hello = {
|
||||
command: 'hello',
|
||||
protocols: ['http://livereload.com/protocols/official-7']
|
||||
};
|
||||
|
||||
ws.send(JSON.stringify(hello));
|
||||
};
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
assert.deepEqual(event.data, JSON.stringify({
|
||||
command: 'hello',
|
||||
protocols: ['http://livereload.com/protocols/official-7'],
|
||||
serverName: 'tiny-lr'
|
||||
}));
|
||||
|
||||
assert.ok(Object.keys(server.clients).length);
|
||||
done();
|
||||
};
|
||||
```
|
||||
|
||||
properly cleans up established connection on exit.
|
||||
|
||||
```js
|
||||
var ws = this.ws;
|
||||
|
||||
ws.onclose = done.bind(null, null);
|
||||
|
||||
request(this.server)
|
||||
.get('/kill')
|
||||
.expect(200, function() {
|
||||
console.log('server shutdown');
|
||||
});
|
||||
```
|
||||
|
||||
<a name="tiny-lr" />
|
||||
# tiny-lr
|
||||
<a name="tiny-lr-get-" />
|
||||
## GET /
|
||||
respond with nothing, but respond.
|
||||
|
||||
```js
|
||||
request(this.server)
|
||||
.get('/')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('{"tinylr":"Welcome","version":"0.0.1"}')
|
||||
.expect(200, done);
|
||||
```
|
||||
|
||||
unknown route respond with proper 404 and error message.
|
||||
|
||||
```js
|
||||
request(this.server)
|
||||
.get('/whatev')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('{"error":"not_found","reason":"no such route"}')
|
||||
.expect(404, done);
|
||||
```
|
||||
|
||||
<a name="tiny-lr-get-changed" />
|
||||
## GET /changed
|
||||
with no clients, no files.
|
||||
|
||||
```js
|
||||
request(this.server)
|
||||
.get('/changed')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(/"clients":\[\]/)
|
||||
.expect(/"files":\[\]/)
|
||||
.expect(200, done);
|
||||
```
|
||||
|
||||
with no clients, some files.
|
||||
|
||||
```js
|
||||
request(this.server)
|
||||
.get('/changed?files=gonna.css,test.css,it.css')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('{"clients":[],"files":["gonna.css","test.css","it.css"]}')
|
||||
.expect(200, done);
|
||||
```
|
||||
|
||||
<a name="tiny-lr-post-changed" />
|
||||
## POST /changed
|
||||
with no clients, no files.
|
||||
|
||||
```js
|
||||
request(this.server)
|
||||
.post('/changed')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(/"clients":\[\]/)
|
||||
.expect(/"files":\[\]/)
|
||||
.expect(200, done);
|
||||
```
|
||||
|
||||
with no clients, some files.
|
||||
|
||||
```js
|
||||
var data = { clients: [], files: ['cat.css', 'sed.css', 'ack.js'] };
|
||||
|
||||
request(this.server)
|
||||
.post('/changed')
|
||||
.send({ files: data.files })
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(JSON.stringify(data))
|
||||
.expect(200, done);
|
||||
```
|
||||
|
||||
<a name="tiny-lr-get-livereloadjs" />
|
||||
## GET /livereload.js
|
||||
respond with livereload script.
|
||||
|
||||
```js
|
||||
request(this.server)
|
||||
.get('/livereload.js')
|
||||
.expect(/LiveReload/)
|
||||
.expect(200, done);
|
||||
```
|
||||
|
||||
<a name="tiny-lr-get-kill" />
|
||||
## GET /kill
|
||||
shutdown the server.
|
||||
|
||||
```js
|
||||
var server = this.server;
|
||||
request(server)
|
||||
.get('/kill')
|
||||
.expect(200, function(err) {
|
||||
if(err) return done(err);
|
||||
assert.ok(!server._handle);
|
||||
done();
|
||||
});
|
||||
```
|
||||
|
||||
## Thanks!
|
||||
|
||||
- Tiny-lr is a [LiveReload](http://livereload.com/) implementation. They
|
||||
really made frontend editing better for a lot of us. They have a
|
||||
[LiveReload App on the Mac App Store](https://itunes.apple.com/us/app/livereload/id482898991)
|
||||
you might want to check out.
|
||||
|
||||
- To all [contributors](https://github.com/mklabs/tiny-lr/graphs/contributors)
|
||||
|
||||
- [@FGRibreau](https://github.com/FGRibreau) / [pid.js
|
||||
gist](https://gist.github.com/1846952)) for the background friendly
|
||||
bin wrapper, used in [make-livereload](https://github.com/mklabs/make-livereload)
|
9
book/node_modules/tiny-lr/scripts/post-change
generated
vendored
Normal file
9
book/node_modules/tiny-lr/scripts/post-change
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
echo curl -X POST http://localhost:35729/changed \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{ \"files\": true }"
|
||||
|
||||
echo
|
||||
|
||||
curl -X POST http://localhost:35729/changed \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{ \"files\": true }"
|
145
book/node_modules/tiny-lr/src/client.js
generated
vendored
Normal file
145
book/node_modules/tiny-lr/src/client.js
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _events = require('events');
|
||||
|
||||
var _events2 = _interopRequireDefault(_events);
|
||||
|
||||
var _fayeWebsocket = require('faye-websocket');
|
||||
|
||||
var _fayeWebsocket2 = _interopRequireDefault(_fayeWebsocket);
|
||||
|
||||
var _objectAssign = require('object-assign');
|
||||
|
||||
var _objectAssign2 = _interopRequireDefault(_objectAssign);
|
||||
|
||||
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"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var debug = require('debug')('tinylr:client');
|
||||
|
||||
var idCounter = 0;
|
||||
|
||||
var Client = function (_events$EventEmitter) {
|
||||
_inherits(Client, _events$EventEmitter);
|
||||
|
||||
function Client(req, socket, head) {
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
|
||||
_classCallCheck(this, Client);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (Client.__proto__ || Object.getPrototypeOf(Client)).call(this));
|
||||
|
||||
_this.options = options;
|
||||
_this.ws = new _fayeWebsocket2.default(req, socket, head);
|
||||
_this.ws.onmessage = _this.message.bind(_this);
|
||||
_this.ws.onclose = _this.close.bind(_this);
|
||||
_this.id = _this.uniqueId('ws');
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Client, [{
|
||||
key: 'message',
|
||||
value: function message(event) {
|
||||
var data = this.data(event);
|
||||
if (this[data.command]) return this[data.command](data);
|
||||
}
|
||||
}, {
|
||||
key: 'close',
|
||||
value: function close(event) {
|
||||
if (this.ws) {
|
||||
this.ws.close();
|
||||
this.ws = null;
|
||||
}
|
||||
|
||||
this.emit('end', event);
|
||||
}
|
||||
|
||||
// Commands
|
||||
|
||||
}, {
|
||||
key: 'hello',
|
||||
value: function hello() {
|
||||
this.send({
|
||||
command: 'hello',
|
||||
protocols: ['http://livereload.com/protocols/official-7'],
|
||||
serverName: 'tiny-lr'
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'info',
|
||||
value: function info(data) {
|
||||
if (data) {
|
||||
debug('Info', data);
|
||||
this.emit('info', (0, _objectAssign2.default)({}, data, { id: this.id }));
|
||||
this.plugins = data.plugins;
|
||||
this.url = data.url;
|
||||
}
|
||||
|
||||
return (0, _objectAssign2.default)({}, data || {}, { id: this.id, url: this.url });
|
||||
}
|
||||
|
||||
// Server commands
|
||||
|
||||
}, {
|
||||
key: 'reload',
|
||||
value: function reload(files) {
|
||||
files.forEach(function (file) {
|
||||
this.send({
|
||||
command: 'reload',
|
||||
path: file,
|
||||
liveCSS: this.options.liveCSS !== false,
|
||||
reloadMissingCSS: this.options.reloadMissingCSS !== false,
|
||||
liveImg: this.options.liveImg !== false
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
}, {
|
||||
key: 'alert',
|
||||
value: function alert(message) {
|
||||
this.send({
|
||||
command: 'alert',
|
||||
message: message
|
||||
});
|
||||
}
|
||||
|
||||
// Utilities
|
||||
|
||||
}, {
|
||||
key: 'data',
|
||||
value: function data(event) {
|
||||
var data = {};
|
||||
try {
|
||||
data = JSON.parse(event.data);
|
||||
} catch (e) {}
|
||||
return data;
|
||||
}
|
||||
}, {
|
||||
key: 'send',
|
||||
value: function send(data) {
|
||||
if (!this.ws) return;
|
||||
this.ws.send(JSON.stringify(data));
|
||||
}
|
||||
}, {
|
||||
key: 'uniqueId',
|
||||
value: function uniqueId(prefix) {
|
||||
var id = idCounter++;
|
||||
return prefix ? prefix + id : id;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Client;
|
||||
}(_events2.default.EventEmitter);
|
||||
|
||||
exports.default = Client;
|
||||
module.exports = exports['default'];
|
61
book/node_modules/tiny-lr/src/index.js
generated
vendored
Normal file
61
book/node_modules/tiny-lr/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _server = require('./server');
|
||||
|
||||
var _server2 = _interopRequireDefault(_server);
|
||||
|
||||
var _client = require('./client');
|
||||
|
||||
var _client2 = _interopRequireDefault(_client);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var debug = require('debug')('tinylr');
|
||||
|
||||
// Need to keep track of LR servers when notifying
|
||||
var servers = [];
|
||||
|
||||
exports.default = tinylr;
|
||||
|
||||
// Expose Server / Client objects
|
||||
|
||||
tinylr.Server = _server2.default;
|
||||
tinylr.Client = _client2.default;
|
||||
|
||||
// and the middleware helpers
|
||||
tinylr.middleware = middleware;
|
||||
tinylr.changed = changed;
|
||||
|
||||
// Main entry point
|
||||
function tinylr(opts) {
|
||||
var srv = new _server2.default(opts);
|
||||
servers.push(srv);
|
||||
return srv;
|
||||
}
|
||||
|
||||
// A facade to Server#handle
|
||||
function middleware(opts) {
|
||||
var srv = new _server2.default(opts);
|
||||
servers.push(srv);
|
||||
return function tinylr(req, res, next) {
|
||||
srv.handler(req, res, next);
|
||||
};
|
||||
}
|
||||
|
||||
// Changed helper, helps with notifying the server of a file change
|
||||
function changed(done) {
|
||||
var files = [].slice.call(arguments);
|
||||
if (typeof files[files.length - 1] === 'function') done = files.pop();
|
||||
done = typeof done === 'function' ? done : function () {};
|
||||
debug('Notifying %d servers - Files: ', servers.length, files);
|
||||
servers.forEach(function (srv) {
|
||||
var params = { params: { files: files } };
|
||||
srv && srv.changed(params);
|
||||
});
|
||||
done();
|
||||
}
|
||||
module.exports = exports['default'];
|
396
book/node_modules/tiny-lr/src/server.js
generated
vendored
Normal file
396
book/node_modules/tiny-lr/src/server.js
generated
vendored
Normal file
@@ -0,0 +1,396 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _fs = require('fs');
|
||||
|
||||
var _fs2 = _interopRequireDefault(_fs);
|
||||
|
||||
var _http = require('http');
|
||||
|
||||
var _http2 = _interopRequireDefault(_http);
|
||||
|
||||
var _https = require('https');
|
||||
|
||||
var _https2 = _interopRequireDefault(_https);
|
||||
|
||||
var _events = require('events');
|
||||
|
||||
var _events2 = _interopRequireDefault(_events);
|
||||
|
||||
var _url = require('url');
|
||||
|
||||
var _client = require('./client');
|
||||
|
||||
var _client2 = _interopRequireDefault(_client);
|
||||
|
||||
var _package = require('../package.json');
|
||||
|
||||
var _package2 = _interopRequireDefault(_package);
|
||||
|
||||
var _any = require('body/any');
|
||||
|
||||
var _any2 = _interopRequireDefault(_any);
|
||||
|
||||
var _qs = require('qs');
|
||||
|
||||
var _qs2 = _interopRequireDefault(_qs);
|
||||
|
||||
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"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var debug = require('debug')('tinylr:server');
|
||||
|
||||
var CONTENT_TYPE = 'content-type';
|
||||
var FORM_TYPE = 'application/x-www-form-urlencoded';
|
||||
|
||||
function buildRootPath() {
|
||||
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
|
||||
|
||||
var rootUrl = prefix;
|
||||
|
||||
// Add trailing slash
|
||||
if (prefix[prefix.length - 1] !== '/') {
|
||||
rootUrl = rootUrl + '/';
|
||||
}
|
||||
|
||||
// Add leading slash
|
||||
if (prefix[0] !== '/') {
|
||||
rootUrl = '/' + rootUrl;
|
||||
}
|
||||
|
||||
return rootUrl;
|
||||
}
|
||||
|
||||
var Server = function (_events$EventEmitter) {
|
||||
_inherits(Server, _events$EventEmitter);
|
||||
|
||||
function Server() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
_classCallCheck(this, Server);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (Server.__proto__ || Object.getPrototypeOf(Server)).call(this));
|
||||
|
||||
_this.options = options;
|
||||
|
||||
options.livereload = options.livereload || require.resolve('livereload-js/dist/livereload.js');
|
||||
|
||||
// todo: change falsy check to allow 0 for random port
|
||||
options.port = parseInt(options.port || 35729, 10);
|
||||
|
||||
if (options.errorListener) {
|
||||
_this.errorListener = options.errorListener;
|
||||
}
|
||||
|
||||
_this.rootPath = buildRootPath(options.prefix);
|
||||
|
||||
_this.clients = {};
|
||||
_this.configure(options.app);
|
||||
_this.routes(options.app);
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Server, [{
|
||||
key: 'routes',
|
||||
value: function routes() {
|
||||
if (!this.options.dashboard) {
|
||||
this.on('GET ' + this.rootPath, this.index.bind(this));
|
||||
}
|
||||
|
||||
this.on('GET ' + this.rootPath + 'changed', this.changed.bind(this));
|
||||
this.on('POST ' + this.rootPath + 'changed', this.changed.bind(this));
|
||||
this.on('POST ' + this.rootPath + 'alert', this.alert.bind(this));
|
||||
this.on('GET ' + this.rootPath + 'livereload.js', this.livereload.bind(this));
|
||||
this.on('GET ' + this.rootPath + 'kill', this.close.bind(this));
|
||||
}
|
||||
}, {
|
||||
key: 'configure',
|
||||
value: function configure(app) {
|
||||
var _this2 = this;
|
||||
|
||||
debug('Configuring %s', app ? 'connect / express application' : 'HTTP server');
|
||||
|
||||
var handler = this.options.handler || this.handler;
|
||||
|
||||
if (!app) {
|
||||
if (this.options.key && this.options.cert || this.options.pfx) {
|
||||
this.server = _https2.default.createServer(this.options, handler.bind(this));
|
||||
} else {
|
||||
this.server = _http2.default.createServer(handler.bind(this));
|
||||
}
|
||||
|
||||
this.server.on('upgrade', this.websocketify.bind(this));
|
||||
this.server.on('error', this.error.bind(this));
|
||||
return this;
|
||||
}
|
||||
|
||||
this.app = app;
|
||||
this.app.listen = function (port, done) {
|
||||
done = done || function () {};
|
||||
if (port !== _this2.options.port) {
|
||||
debug('Warn: LiveReload port is not standard (%d). You are listening on %d', _this2.options.port, port);
|
||||
debug('You\'ll need to rely on the LiveReload snippet');
|
||||
debug('> http://feedback.livereload.com/knowledgebase/articles/86180-how-do-i-add-the-script-tag-manually-');
|
||||
}
|
||||
|
||||
var srv = _this2.server = _http2.default.createServer(app);
|
||||
srv.on('upgrade', _this2.websocketify.bind(_this2));
|
||||
srv.on('error', _this2.error.bind(_this2));
|
||||
srv.on('close', _this2.close.bind(_this2));
|
||||
return srv.listen(port, done);
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: 'handler',
|
||||
value: function handler(req, res, next) {
|
||||
var _this3 = this;
|
||||
|
||||
var middleware = typeof next === 'function';
|
||||
debug('LiveReload handler %s (middleware: %s)', req.url, middleware ? 'on' : 'off');
|
||||
|
||||
next = next || this.defaultHandler.bind(this, res);
|
||||
req.headers[CONTENT_TYPE] = req.headers[CONTENT_TYPE] || FORM_TYPE;
|
||||
return (0, _any2.default)(req, res, function (err, body) {
|
||||
if (err) return next(err);
|
||||
req.body = body;
|
||||
|
||||
if (!req.query) {
|
||||
req.query = req.url.indexOf('?') !== -1 ? _qs2.default.parse((0, _url.parse)(req.url).query) : {};
|
||||
}
|
||||
|
||||
return _this3.handle(req, res, next);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'index',
|
||||
value: function index(req, res) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.write(JSON.stringify({
|
||||
tinylr: 'Welcome',
|
||||
version: _package2.default.version
|
||||
}));
|
||||
|
||||
res.end();
|
||||
}
|
||||
}, {
|
||||
key: 'handle',
|
||||
value: function handle(req, res, next) {
|
||||
var url = (0, _url.parse)(req.url);
|
||||
debug('Request:', req.method, url.href);
|
||||
var middleware = typeof next === 'function';
|
||||
|
||||
// do the routing
|
||||
var route = req.method + ' ' + url.pathname;
|
||||
var respond = this.emit(route, req, res);
|
||||
if (respond) return;
|
||||
|
||||
if (middleware) return next();
|
||||
|
||||
// Only apply content-type on non middleware setup #70
|
||||
return this.notFound(res);
|
||||
}
|
||||
}, {
|
||||
key: 'defaultHandler',
|
||||
value: function defaultHandler(res, err) {
|
||||
if (!err) return this.notFound(res);
|
||||
|
||||
this.error(err);
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
res.statusCode = 500;
|
||||
res.end('Error: ' + err.stack);
|
||||
}
|
||||
}, {
|
||||
key: 'notFound',
|
||||
value: function notFound(res) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.writeHead(404);
|
||||
res.write(JSON.stringify({
|
||||
error: 'not_found',
|
||||
reason: 'no such route'
|
||||
}));
|
||||
res.end();
|
||||
}
|
||||
}, {
|
||||
key: 'websocketify',
|
||||
value: function websocketify(req, socket, head) {
|
||||
var _this4 = this;
|
||||
|
||||
var client = new _client2.default(req, socket, head, this.options);
|
||||
this.clients[client.id] = client;
|
||||
|
||||
// handle socket error to prevent possible app crash, such as ECONNRESET
|
||||
socket.on('error', function (e) {
|
||||
// ignore frequent ECONNRESET error (seems inevitable when refresh)
|
||||
if (e.code === 'ECONNRESET') return;
|
||||
_this4.error(e);
|
||||
});
|
||||
|
||||
client.once('info', function (data) {
|
||||
debug('Create client %s (url: %s)', data.id, data.url);
|
||||
_this4.emit('MSG /create', data.id, data.url);
|
||||
});
|
||||
|
||||
client.once('end', function () {
|
||||
debug('Destroy client %s (url: %s)', client.id, client.url);
|
||||
_this4.emit('MSG /destroy', client.id, client.url);
|
||||
delete _this4.clients[client.id];
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'listen',
|
||||
value: function listen(port, host, fn) {
|
||||
port = port || this.options.port;
|
||||
|
||||
// Last used port for error display
|
||||
this.port = port;
|
||||
|
||||
if (typeof host === 'function') {
|
||||
fn = host;
|
||||
host = undefined;
|
||||
}
|
||||
|
||||
this.server.listen(port, host, fn);
|
||||
}
|
||||
}, {
|
||||
key: 'close',
|
||||
value: function close(req, res) {
|
||||
Object.keys(this.clients).forEach(function (id) {
|
||||
this.clients[id].close();
|
||||
}, this);
|
||||
|
||||
if (this.server._handle) this.server.close(this.emit.bind(this, 'close'));
|
||||
|
||||
if (res) res.end();
|
||||
}
|
||||
}, {
|
||||
key: 'error',
|
||||
value: function error(e) {
|
||||
if (this.errorListener) {
|
||||
this.errorListener(e);
|
||||
return;
|
||||
}
|
||||
|
||||
console.error();
|
||||
if (typeof e === 'undefined') {
|
||||
console.error('... Uhoh. Got error %s ...', e);
|
||||
} else {
|
||||
console.error('... Uhoh. Got error %s ...', e.message);
|
||||
console.error(e.stack);
|
||||
|
||||
if (e.code !== 'EADDRINUSE') return;
|
||||
console.error();
|
||||
console.error('You already have a server listening on %s', this.port);
|
||||
console.error('You should stop it and try again.');
|
||||
console.error();
|
||||
}
|
||||
}
|
||||
|
||||
// Routes
|
||||
|
||||
}, {
|
||||
key: 'livereload',
|
||||
value: function livereload(req, res) {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
_fs2.default.createReadStream(this.options.livereload).pipe(res);
|
||||
}
|
||||
}, {
|
||||
key: 'changed',
|
||||
value: function changed(req, res) {
|
||||
var files = this.param('files', req);
|
||||
|
||||
debug('Changed event (Files: %s)', files.join(' '));
|
||||
var clients = this.notifyClients(files);
|
||||
|
||||
if (!res) return;
|
||||
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.write(JSON.stringify({
|
||||
clients: clients,
|
||||
files: files
|
||||
}));
|
||||
|
||||
res.end();
|
||||
}
|
||||
}, {
|
||||
key: 'alert',
|
||||
value: function alert(req, res) {
|
||||
var message = this.param('message', req);
|
||||
|
||||
debug('Alert event (Message: %s)', message);
|
||||
var clients = this.alertClients(message);
|
||||
|
||||
if (!res) return;
|
||||
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.write(JSON.stringify({
|
||||
clients: clients,
|
||||
message: message
|
||||
}));
|
||||
|
||||
res.end();
|
||||
}
|
||||
}, {
|
||||
key: 'notifyClients',
|
||||
value: function notifyClients(files) {
|
||||
var clients = Object.keys(this.clients).map(function (id) {
|
||||
var client = this.clients[id];
|
||||
debug('Reloading client %s (url: %s)', client.id, client.url);
|
||||
client.reload(files);
|
||||
return {
|
||||
id: client.id,
|
||||
url: client.url
|
||||
};
|
||||
}, this);
|
||||
|
||||
return clients;
|
||||
}
|
||||
}, {
|
||||
key: 'alertClients',
|
||||
value: function alertClients(message) {
|
||||
var clients = Object.keys(this.clients).map(function (id) {
|
||||
var client = this.clients[id];
|
||||
debug('Alert client %s (url: %s)', client.id, client.url);
|
||||
client.alert(message);
|
||||
return {
|
||||
id: client.id,
|
||||
url: client.url
|
||||
};
|
||||
}, this);
|
||||
|
||||
return clients;
|
||||
}
|
||||
|
||||
// Lookup param from body / params / query.
|
||||
|
||||
}, {
|
||||
key: 'param',
|
||||
value: function param(name, req) {
|
||||
var param = void 0;
|
||||
if (req.body && req.body[name]) param = req.body[name];else if (req.params && req.params[name]) param = req.params[name];else if (req.query && req.query[name]) param = req.query[name];
|
||||
|
||||
// normalize files array
|
||||
if (name === 'files') {
|
||||
param = Array.isArray(param) ? param : typeof param === 'string' ? param.split(/[\s,]/) : [];
|
||||
}
|
||||
|
||||
return param;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Server;
|
||||
}(_events2.default.EventEmitter);
|
||||
|
||||
exports.default = Server;
|
||||
module.exports = exports['default'];
|
57
book/node_modules/tiny-lr/src_test/client.js
generated
vendored
Normal file
57
book/node_modules/tiny-lr/src_test/client.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
var _supertest = require('supertest');
|
||||
|
||||
var _supertest2 = _interopRequireDefault(_supertest);
|
||||
|
||||
var _assert = require('assert');
|
||||
|
||||
var _assert2 = _interopRequireDefault(_assert);
|
||||
|
||||
var _url = require('url');
|
||||
|
||||
var _listen = require('./helpers/listen');
|
||||
|
||||
var _listen2 = _interopRequireDefault(_listen);
|
||||
|
||||
var _fayeWebsocket = require('faye-websocket');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
describe('tiny-lr', function () {
|
||||
before((0, _listen2.default)());
|
||||
it('accepts ws clients', function (done) {
|
||||
var url = (0, _url.parse)(this.request.url);
|
||||
var server = this.app;
|
||||
|
||||
var ws = this.ws = new _fayeWebsocket.Client('ws://' + url.host + '/livereload');
|
||||
|
||||
ws.onopen = function (event) {
|
||||
var hello = {
|
||||
command: 'hello',
|
||||
protocols: ['http://livereload.com/protocols/official-7']
|
||||
};
|
||||
|
||||
ws.send(JSON.stringify(hello));
|
||||
};
|
||||
|
||||
ws.onmessage = function (event) {
|
||||
_assert2.default.deepEqual(event.data, JSON.stringify({
|
||||
command: 'hello',
|
||||
protocols: ['http://livereload.com/protocols/official-7'],
|
||||
serverName: 'tiny-lr'
|
||||
}));
|
||||
|
||||
_assert2.default.ok(Object.keys(server.clients).length);
|
||||
done();
|
||||
};
|
||||
});
|
||||
|
||||
it('properly cleans up established connection on exit', function (done) {
|
||||
var ws = this.ws;
|
||||
|
||||
ws.onclose = done.bind(null, null);
|
||||
|
||||
(0, _supertest2.default)(this.server).get('/kill').expect(200, function () {});
|
||||
});
|
||||
});
|
31
book/node_modules/tiny-lr/src_test/helpers/listen.js
generated
vendored
Normal file
31
book/node_modules/tiny-lr/src_test/helpers/listen.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = listen;
|
||||
|
||||
var _ = require('../..');
|
||||
|
||||
var _supertest = require('supertest');
|
||||
|
||||
var _supertest2 = _interopRequireDefault(_supertest);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function listen(opts) {
|
||||
opts = opts || {};
|
||||
|
||||
return function _listen(done) {
|
||||
var _this = this;
|
||||
|
||||
this.app = new _.Server(opts);
|
||||
var srv = this.server = this.app.server;
|
||||
var ctx = this;
|
||||
this.server.listen(function (err) {
|
||||
if (err) return done(err);
|
||||
ctx.request = (0, _supertest2.default)(srv).get(_this.app.rootPath).expect(200, done);
|
||||
});
|
||||
};
|
||||
};
|
||||
module.exports = exports['default'];
|
19
book/node_modules/tiny-lr/src_test/http.js
generated
vendored
Normal file
19
book/node_modules/tiny-lr/src_test/http.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var _app = require('../examples/express/app');
|
||||
|
||||
var _app2 = _interopRequireDefault(_app);
|
||||
|
||||
var _supertest = require('supertest');
|
||||
|
||||
var _supertest2 = _interopRequireDefault(_supertest);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
describe('mocha spec examples', function () {
|
||||
describe('tinylr', function () {
|
||||
it('GET /', function (done) {
|
||||
(0, _supertest2.default)(_app2.default).get('/').expect('Content-Type', /text\/html/).expect(/Testing/).expect(200, done);
|
||||
});
|
||||
});
|
||||
});
|
85
book/node_modules/tiny-lr/src_test/middleware.js
generated
vendored
Normal file
85
book/node_modules/tiny-lr/src_test/middleware.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
var http = require('http');
|
||||
var express = require('express');
|
||||
var request = require('supertest');
|
||||
var debug = require('debug')('tinylr:test');
|
||||
var Server = require('..').Server;
|
||||
|
||||
var port = parseInt(process.env.npm_package_config_test_port || 0, 10);
|
||||
|
||||
describe('Express Middleware', function () {
|
||||
before(function () {
|
||||
this.app = express();
|
||||
this.lr = new Server();
|
||||
|
||||
this.app.use(this.lr.handler.bind(this.lr));
|
||||
|
||||
this.server = http.createServer(this.app);
|
||||
debug('Start %s suite, listen on %d', 'Express', port);
|
||||
this.server.listen(port);
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
this.server.close(done);
|
||||
});
|
||||
|
||||
describe('GET /', function () {
|
||||
it('respond with nothing, but respond', function (done) {
|
||||
request(this.server).get('/').expect('Content-Type', /json/).expect(/\{"tinylr":"Welcome","version":"[\d].[\d].[\d]+"\}/).expect(200, done);
|
||||
});
|
||||
|
||||
it('unknown route are noop with middlewares, next-ing', function (done) {
|
||||
request(this.server).get('/whatev').expect('Content-Type', /text\/html/).expect(/Cannot GET \/whatev/).expect(404, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /changed', function () {
|
||||
it('with no clients, no files', function (done) {
|
||||
request(this.server).get('/changed').expect('Content-Type', /json/).expect(/"clients":\[\]/).expect(/"files":\[\]/).expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some files', function (done) {
|
||||
request(this.server).get('/changed?files=gonna.css,test.css,it.css').expect('Content-Type', /json/).expect('{"clients":[],"files":["gonna.css","test.css","it.css"]}').expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /changed', function () {
|
||||
it('with no clients, no files', function (done) {
|
||||
request(this.server).post('/changed').expect('Content-Type', /json/).expect(/"clients":\[\]/).expect(/"files":\[\]/).expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some files', function (done) {
|
||||
var data = { clients: [], files: ['cat.css', 'sed.css', 'ack.js'] };
|
||||
request(this.server).post('/changed').send({ files: data.files }).expect('Content-Type', /json/)
|
||||
// .expect(JSON.stringify(data))
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /alert', function () {
|
||||
it('with no clients, no message', function (done) {
|
||||
var data = { clients: [] };
|
||||
request(this.server).post('/alert').expect('Content-Type', /json/).expect(JSON.stringify(data)).expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some message', function (done) {
|
||||
var message = 'Hello Client!';
|
||||
var data = { clients: [], message: message };
|
||||
request(this.server).post('/alert').send({ message: message }).expect('Content-Type', /json/).expect(JSON.stringify(data)).expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /livereload.js', function () {
|
||||
it('respond with livereload script', function (done) {
|
||||
request(this.server).get('/livereload.js').expect(/LiveReload/).expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /kill', function () {
|
||||
it('shutdown the server', function (done) {
|
||||
var server = this.server;
|
||||
request(server).get('/kill').expect(200, done);
|
||||
});
|
||||
});
|
||||
});
|
106
book/node_modules/tiny-lr/src_test/server.js
generated
vendored
Normal file
106
book/node_modules/tiny-lr/src_test/server.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
'use strict';
|
||||
|
||||
var _supertest = require('supertest');
|
||||
|
||||
var _supertest2 = _interopRequireDefault(_supertest);
|
||||
|
||||
var _assert = require('assert');
|
||||
|
||||
var _assert2 = _interopRequireDefault(_assert);
|
||||
|
||||
var _listen = require('./helpers/listen');
|
||||
|
||||
var _listen2 = _interopRequireDefault(_listen);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function testRoutes() {
|
||||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
var _ref$prefix = _ref.prefix;
|
||||
var prefix = _ref$prefix === undefined ? '' : _ref$prefix;
|
||||
|
||||
var buildUrl = function buildUrl(url) {
|
||||
return prefix ? '/' + prefix + url : url;
|
||||
};
|
||||
|
||||
describe('GET /', function () {
|
||||
it('respond with nothing, but respond', function (done) {
|
||||
(0, _supertest2.default)(this.server).get(buildUrl('/')).expect('Content-Type', /json/).expect(/\{"tinylr":"Welcome","version":"[\d].[\d].[\d]+"\}/).expect(200, done);
|
||||
});
|
||||
|
||||
it('unknown route respond with proper 404 and error message', function (done) {
|
||||
(0, _supertest2.default)(this.server).get(buildUrl('/whatev')).expect('Content-Type', /json/).expect('{"error":"not_found","reason":"no such route"}').expect(404, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /changed', function () {
|
||||
it('with no clients, no files', function (done) {
|
||||
(0, _supertest2.default)(this.server).get(buildUrl('/changed')).expect('Content-Type', /json/).expect(/"clients":\[\]/).expect(/"files":\[\]/).expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some files', function (done) {
|
||||
(0, _supertest2.default)(this.server).get(buildUrl('/changed?files=gonna.css,test.css,it.css')).expect('Content-Type', /json/).expect('{"clients":[],"files":["gonna.css","test.css","it.css"]}').expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /changed', function () {
|
||||
it('with no clients, no files', function (done) {
|
||||
(0, _supertest2.default)(this.server).post(buildUrl('/changed')).expect('Content-Type', /json/).expect(/"clients":\[\]/).expect(/"files":\[\]/).expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some files', function (done) {
|
||||
var data = { clients: [], files: ['cat.css', 'sed.css', 'ack.js'] };
|
||||
|
||||
(0, _supertest2.default)(this.server).post(buildUrl('/changed'))
|
||||
// .type('json')
|
||||
.send({ files: data.files }).expect('Content-Type', /json/).expect(JSON.stringify(data)).expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /alert', function () {
|
||||
it('with no clients, no message', function (done) {
|
||||
var data = { clients: [] };
|
||||
(0, _supertest2.default)(this.server).post(buildUrl('/alert')).expect('Content-Type', /json/).expect(JSON.stringify(data)).expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some message', function (done) {
|
||||
var message = 'Hello Client!';
|
||||
var data = { clients: [], message: message };
|
||||
(0, _supertest2.default)(this.server).post(buildUrl('/alert')).send({ message: message }).expect('Content-Type', /json/).expect(JSON.stringify(data)).expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /livereload.js', function () {
|
||||
it('respond with livereload script', function (done) {
|
||||
(0, _supertest2.default)(this.server).get(buildUrl('/livereload.js')).expect(/LiveReload/).expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /kill', function () {
|
||||
it('shutdown the server', function (done) {
|
||||
var srv = this.server;
|
||||
(0, _supertest2.default)(srv).get(buildUrl('/kill')).expect(200, function (err) {
|
||||
if (err) return done(err);
|
||||
_assert2.default.ok(!srv._handle);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('Server', function () {
|
||||
context('with no options', function () {
|
||||
before((0, _listen2.default)());
|
||||
testRoutes();
|
||||
});
|
||||
|
||||
context('with prefix option', function () {
|
||||
var options = {
|
||||
prefix: 'tiny-lr'
|
||||
};
|
||||
|
||||
before((0, _listen2.default)(options));
|
||||
testRoutes(options);
|
||||
});
|
||||
});
|
46
book/node_modules/tiny-lr/test/client.js
generated
vendored
Normal file
46
book/node_modules/tiny-lr/test/client.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
import request from 'supertest';
|
||||
import assert from 'assert';
|
||||
import {parse} from 'url';
|
||||
import listen from './helpers/listen';
|
||||
import {Client as WebSocket} from 'faye-websocket';
|
||||
|
||||
describe('tiny-lr', () => {
|
||||
before(listen());
|
||||
it('accepts ws clients', function (done) {
|
||||
const url = parse(this.request.url);
|
||||
const server = this.app;
|
||||
|
||||
const ws = this.ws = new WebSocket('ws://' + url.host + '/livereload');
|
||||
|
||||
ws.onopen = event => {
|
||||
const hello = {
|
||||
command: 'hello',
|
||||
protocols: ['http://livereload.com/protocols/official-7']
|
||||
};
|
||||
|
||||
ws.send(JSON.stringify(hello));
|
||||
};
|
||||
|
||||
ws.onmessage = event => {
|
||||
assert.deepEqual(event.data, JSON.stringify({
|
||||
command: 'hello',
|
||||
protocols: ['http://livereload.com/protocols/official-7'],
|
||||
serverName: 'tiny-lr'
|
||||
}));
|
||||
|
||||
assert.ok(Object.keys(server.clients).length);
|
||||
done();
|
||||
};
|
||||
});
|
||||
|
||||
it('properly cleans up established connection on exit', function (done) {
|
||||
const ws = this.ws;
|
||||
|
||||
ws.onclose = done.bind(null, null);
|
||||
|
||||
request(this.server)
|
||||
.get('/kill')
|
||||
.expect(200, () => {});
|
||||
});
|
||||
});
|
19
book/node_modules/tiny-lr/test/helpers/listen.js
generated
vendored
Normal file
19
book/node_modules/tiny-lr/test/helpers/listen.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
import {Server} from '../..';
|
||||
import request from 'supertest';
|
||||
|
||||
export default function listen (opts) {
|
||||
opts = opts || {};
|
||||
|
||||
return function _listen (done) {
|
||||
this.app = new Server(opts);
|
||||
const srv = this.server = this.app.server;
|
||||
const ctx = this;
|
||||
this.server.listen(err => {
|
||||
if (err) return done(err);
|
||||
ctx.request = request(srv)
|
||||
.get(this.app.rootPath)
|
||||
.expect(200, done);
|
||||
});
|
||||
};
|
||||
};
|
14
book/node_modules/tiny-lr/test/http.js
generated
vendored
Normal file
14
book/node_modules/tiny-lr/test/http.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import app from '../examples/express/app';
|
||||
import request from 'supertest';
|
||||
|
||||
describe('mocha spec examples', () => {
|
||||
describe('tinylr', () => {
|
||||
it('GET /', done => {
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('Content-Type', /text\/html/)
|
||||
.expect(/Testing/)
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
});
|
123
book/node_modules/tiny-lr/test/middleware.js
generated
vendored
Normal file
123
book/node_modules/tiny-lr/test/middleware.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
|
||||
var http = require('http');
|
||||
var express = require('express');
|
||||
var request = require('supertest');
|
||||
var debug = require('debug')('tinylr:test');
|
||||
var Server = require('..').Server;
|
||||
|
||||
var port = parseInt(process.env.npm_package_config_test_port || 0, 10);
|
||||
|
||||
describe('Express Middleware', () => {
|
||||
before(function () {
|
||||
this.app = express();
|
||||
this.lr = new Server();
|
||||
|
||||
this.app.use(this.lr.handler.bind(this.lr));
|
||||
|
||||
this.server = http.createServer(this.app);
|
||||
debug('Start %s suite, listen on %d', 'Express', port);
|
||||
this.server.listen(port);
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
this.server.close(done);
|
||||
});
|
||||
|
||||
describe('GET /', function () {
|
||||
it('respond with nothing, but respond', function (done) {
|
||||
request(this.server)
|
||||
.get('/')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(/\{"tinylr":"Welcome","version":"[\d].[\d].[\d]+"\}/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('unknown route are noop with middlewares, next-ing', function (done) {
|
||||
request(this.server)
|
||||
.get('/whatev')
|
||||
.expect('Content-Type', /text\/html/)
|
||||
.expect(/Cannot GET \/whatev/)
|
||||
.expect(404, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /changed', function () {
|
||||
it('with no clients, no files', function (done) {
|
||||
request(this.server)
|
||||
.get('/changed')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(/"clients":\[\]/)
|
||||
.expect(/"files":\[\]/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some files', function (done) {
|
||||
request(this.server)
|
||||
.get('/changed?files=gonna.css,test.css,it.css')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('{"clients":[],"files":["gonna.css","test.css","it.css"]}')
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /changed', function () {
|
||||
it('with no clients, no files', function (done) {
|
||||
request(this.server)
|
||||
.post('/changed')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(/"clients":\[\]/)
|
||||
.expect(/"files":\[\]/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some files', function (done) {
|
||||
var data = { clients: [], files: ['cat.css', 'sed.css', 'ack.js'] };
|
||||
request(this.server)
|
||||
.post('/changed')
|
||||
.send({ files: data.files })
|
||||
.expect('Content-Type', /json/)
|
||||
// .expect(JSON.stringify(data))
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /alert', function () {
|
||||
it('with no clients, no message', function (done) {
|
||||
var data = { clients: [] };
|
||||
request(this.server)
|
||||
.post('/alert')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(JSON.stringify(data))
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some message', function (done) {
|
||||
var message = 'Hello Client!';
|
||||
var data = { clients: [], message: message };
|
||||
request(this.server)
|
||||
.post('/alert')
|
||||
.send({ message: message })
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(JSON.stringify(data))
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /livereload.js', function () {
|
||||
it('respond with livereload script', function (done) {
|
||||
request(this.server)
|
||||
.get('/livereload.js')
|
||||
.expect(/LiveReload/)
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /kill', function () {
|
||||
it('shutdown the server', function (done) {
|
||||
var server = this.server;
|
||||
request(server)
|
||||
.get('/kill')
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
});
|
127
book/node_modules/tiny-lr/test/server.js
generated
vendored
Normal file
127
book/node_modules/tiny-lr/test/server.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
import request from 'supertest';
|
||||
import assert from 'assert';
|
||||
import listen from './helpers/listen';
|
||||
|
||||
function testRoutes ({ prefix = '' } = {}) {
|
||||
const buildUrl = url => prefix ? `/${prefix}${url}` : url;
|
||||
|
||||
describe('GET /', function () {
|
||||
it('respond with nothing, but respond', function (done) {
|
||||
request(this.server)
|
||||
.get(buildUrl('/'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(/\{"tinylr":"Welcome","version":"[\d].[\d].[\d]+"\}/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('unknown route respond with proper 404 and error message', function (done) {
|
||||
request(this.server)
|
||||
.get(buildUrl('/whatev'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('{"error":"not_found","reason":"no such route"}')
|
||||
.expect(404, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /changed', function () {
|
||||
it('with no clients, no files', function (done) {
|
||||
request(this.server)
|
||||
.get(buildUrl('/changed'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(/"clients":\[\]/)
|
||||
.expect(/"files":\[\]/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some files', function (done) {
|
||||
request(this.server)
|
||||
.get(buildUrl('/changed?files=gonna.css,test.css,it.css'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('{"clients":[],"files":["gonna.css","test.css","it.css"]}')
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /changed', function () {
|
||||
it('with no clients, no files', function (done) {
|
||||
request(this.server)
|
||||
.post(buildUrl('/changed'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(/"clients":\[\]/)
|
||||
.expect(/"files":\[\]/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some files', function (done) {
|
||||
const data = { clients: [], files: ['cat.css', 'sed.css', 'ack.js'] };
|
||||
|
||||
request(this.server)
|
||||
.post(buildUrl('/changed'))
|
||||
// .type('json')
|
||||
.send({ files: data.files })
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(JSON.stringify(data))
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /alert', function () {
|
||||
it('with no clients, no message', function (done) {
|
||||
const data = { clients: [] };
|
||||
request(this.server)
|
||||
.post(buildUrl('/alert'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(JSON.stringify(data))
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('with no clients, some message', function (done) {
|
||||
const message = 'Hello Client!';
|
||||
const data = { clients: [], message: message };
|
||||
request(this.server)
|
||||
.post(buildUrl('/alert'))
|
||||
.send({ message: message })
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(JSON.stringify(data))
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /livereload.js', function () {
|
||||
it('respond with livereload script', function (done) {
|
||||
request(this.server)
|
||||
.get(buildUrl('/livereload.js'))
|
||||
.expect(/LiveReload/)
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /kill', function () {
|
||||
it('shutdown the server', function (done) {
|
||||
const srv = this.server;
|
||||
request(srv)
|
||||
.get(buildUrl('/kill'))
|
||||
.expect(200, err => {
|
||||
if (err) return done(err);
|
||||
assert.ok(!srv._handle);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('Server', () => {
|
||||
context('with no options', function () {
|
||||
before(listen());
|
||||
testRoutes();
|
||||
});
|
||||
|
||||
context('with prefix option', function () {
|
||||
const options = {
|
||||
prefix: 'tiny-lr'
|
||||
};
|
||||
|
||||
before(listen(options));
|
||||
testRoutes(options);
|
||||
});
|
||||
});
|
3628
book/node_modules/tiny-lr/yarn.lock
generated
vendored
Normal file
3628
book/node_modules/tiny-lr/yarn.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user