Index: includes/ajax.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/ajax.inc,v
retrieving revision 1.37
diff -u -p -r1.37 ajax.inc
--- includes/ajax.inc	21 Oct 2010 19:31:39 -0000	1.37
+++ includes/ajax.inc	12 Nov 2010 17:11:32 -0000
@@ -605,7 +605,7 @@ function ajax_pre_render_element($elemen
   // Attach JavaScript settings to the element.
   if (isset($element['#ajax']['event'])) {
     $element['#attached']['library'][] = array('system', 'form');
-    $element['#attached']['js']['misc/ajax.js'] = array('group' => JS_LIBRARY, 'weight' => 2);
+    $element['#attached']['library'][] = array('system', 'ajax');
 
     $settings = $element['#ajax'];
 
@@ -667,10 +667,6 @@ function ajax_pre_render_element($elemen
       $settings['progress']['url'] = url($settings['progress']['path']);
       unset($settings['progress']['path']);
     }
-    // Add progress.js if we're doing a bar display.
-    if ($settings['progress']['type'] == 'bar') {
-      $element['#attached']['js']['misc/progress.js'] = array('cache' => FALSE);
-    }
 
     $element['#attached']['js'][] = array(
       'type' => 'setting',
Index: includes/batch.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/batch.inc,v
retrieving revision 1.53
diff -u -p -r1.53 batch.inc
--- includes/batch.inc	4 Oct 2010 07:34:26 -0000	1.53
+++ includes/batch.inc	12 Nov 2010 17:11:33 -0000
@@ -139,8 +139,7 @@ function _batch_progress_page_js() {
     ),
   );
   drupal_add_js($js_setting, 'setting');
-  drupal_add_js('misc/progress.js', array('cache' => FALSE));
-  drupal_add_js('misc/batch.js', array('cache' => FALSE));
+  drupal_add_library('system', 'batch');
 
   return '<div id="progress"></div>';
 }
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1250
diff -u -p -r1.1250 common.inc
--- includes/common.inc	7 Nov 2010 18:33:52 -0000	1.1250
+++ includes/common.inc	12 Nov 2010 17:11:38 -0000
@@ -738,7 +738,7 @@ function drupal_access_denied() {
  *     call may take. The default is 30 seconds. If a timeout occurs, the error
  *     code is set to the HTTP_REQUEST_TIMEOUT constant.
  *   - context: A context resource created with stream_context_create().
- * 
+ *
  * @return object
  *   An object that can have one or more of the following components:
  *   - request: A string containing the request body that was sent.
@@ -4364,7 +4364,7 @@ function drupal_process_attached($elemen
  * @see form_example_states_form()
  */
 function drupal_process_states(&$elements) {
-  $elements['#attached']['js']['misc/states.js'] = array('group' => JS_LIBRARY, 'weight' => 1);
+  $elements['#attached']['library'][] = array('system', 'states');
   $elements['#attached']['js'][] = array(
     'type' => 'setting',
     'data' => array('states' => array('#' . $elements['#id'] => $elements['#states'])),
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.508
diff -u -p -r1.508 form.inc
--- includes/form.inc	7 Nov 2010 21:46:09 -0000	1.508
+++ includes/form.inc	12 Nov 2010 17:11:42 -0000
@@ -163,7 +163,7 @@
  *   Any additional arguments are passed on to the functions called by
  *   drupal_get_form(), including the unique form constructor function. For
  *   example, the node_edit form requires that a node object is passed in here
- *   when it is called. These are available to implementations of 
+ *   when it is called. These are available to implementations of
  *   hook_form_alter() and hook_form_FORM_ID_alter() as the array
  *   $form_state['build_info']['args'].
  *
@@ -3298,7 +3298,7 @@ function form_process_fieldset(&$element
   }
 
   // Contains form element summary functionalities.
-  $element['#attached']['js']['misc/form.js'] = array('group' => JS_LIBRARY, 'weight' => 1);
+  $element['#attached']['library'][] = array('system', 'drupal-form');
 
   // The .form-wrapper class is required for #states to treat fieldsets like
   // containers.
@@ -3308,7 +3308,7 @@ function form_process_fieldset(&$element
 
   // Collapsible fieldsets
   if (!empty($element['#collapsible'])) {
-    $element['#attached']['js'][] = 'misc/collapse.js';
+    $element['#attached']['library'][] = array('system', 'collapse');
     $element['#attributes']['class'][] = 'collapsible';
     if (!empty($element['#collapsed'])) {
       $element['#attributes']['class'][] = 'collapsed';
@@ -3533,7 +3533,7 @@ function theme_textfield($variables) {
 
   $extra = '';
   if ($element['#autocomplete_path'] && drupal_valid_path($element['#autocomplete_path'])) {
-    drupal_add_js('misc/autocomplete.js');
+    drupal_add_library('autocomplete');
     $element['#attributes']['class'][] = 'form-autocomplete';
 
     $attributes = array();
@@ -3595,7 +3595,7 @@ function theme_textarea($variables) {
 
   // Add resizable behavior.
   if (!empty($element['#resizable'])) {
-    drupal_add_js('misc/textarea.js');
+    drupal_add_library('textarea');
     $wrapper_attributes['class'][] = 'resizable';
   }
 
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.987
diff -u -p -r1.987 system.module
--- modules/system/system.module	7 Nov 2010 00:27:20 -0000	1.987
+++ modules/system/system.module	12 Nov 2010 17:11:45 -0000
@@ -1076,6 +1076,90 @@ function _system_batch_theme() {
  * Implements hook_library().
  */
 function system_library() {
+  // Drupal's AJAX framework.
+  $libraries['ajax'] = array(
+    'title' => 'Drupal AJAX',
+    'website' => 'http://api.drupal.org/api/drupal/includes--ajax.inc/group/ajax/7',
+    'version' => VERSION,
+    'js' => array(
+      'misc/ajax.js' => array('group' => JS_LIBRARY, 'weight' => 2),
+    ),
+    'dependencies' => array(
+      array('system', 'progress'),
+    ),
+  );
+
+  // Drupal's batch API.
+  $libraries['batch'] = array(
+    'title' => 'Drupal batch API',
+    'version' => VERSION,
+    'js' => array(
+      'misc/batch.js' => array('cache' => FALSE),
+    ),
+    'dependencies' => array(
+      array('system', 'progress'),
+    ),
+  );
+
+  // Drupal's progress indicator.
+  $libraries['progress'] = array(
+    'title' => 'Drupal progress indicator',
+    'version' => VERSION,
+    'js' => array(
+      'misc/progress.js' => array('cache' => FALSE),
+    ),
+  );
+
+  // Drupal's form library.
+  // note: Because jQuery got the form namespace first this is oddly named.
+  $libraries['drupal-form'] = array(
+    'title' => 'Drupal form library',
+    'version' => VERSION,
+    'js' => array(
+      'misc/form.js' => array('group' => JS_LIBRARY, 'weight' => 1),
+    ),
+  );
+
+  // Drupal's states library.
+  $libraries['states'] = array(
+    'title' => 'Drupal states',
+    'version' => VERSION,
+    'js' => array(
+      'misc/states.js' => array('group' => JS_LIBRARY, 'weight' => 1),
+    ),
+  );
+
+  // Drupal's collapsible fieldset.
+  $libraries['collapse'] = array(
+    'title' => 'Drupal collapsible fieldset',
+    'version' => VERSION,
+    'js' => array(
+      'misc/collapse.js' => array(),
+    ),
+    'dependencies' => array(
+      // collapse.js relies on drupalGetSummary in form.js
+      array('system', 'form'),
+    ),
+  );
+
+  // Drupal's resizable textarea.
+  $libraries['collapse'] = array(
+    'title' => 'Drupal resizable textarea',
+    'version' => VERSION,
+    'js' => array(
+      'misc/textarea.js' => array(),
+    ),
+  );
+
+  // Drupal's autocomplete widget.
+  $libraries['autocomplete'] = array(
+    'title' => 'Drupal autocomplete',
+    'version' => VERSION,
+    'js' => array(
+      'misc/autocomplete.js' => array(),
+    ),
+  );
+
   // jQuery.
   $libraries['jquery'] = array(
     'title' => 'jQuery',
@@ -1127,6 +1211,10 @@ function system_library() {
     'css' => array(
       'misc/vertical-tabs.css' => array(),
     ),
+    'dependencies' => array(
+      // Vertical tabs relies on drupalGetSummary in form.js
+      array('system', 'form'),
+    ),
   );
 
   // Farbtastic.
