<commit_before>/*
	This Source Code Form is subject to the terms of the
	Mozilla Public License, v. 2.0. If a copy of the MPL
	was not distributed with this file, You can obtain
	one at https://mozilla.org/MPL/2.0/.
*/
package
{
	import weavejs.WeaveAPI;
	import weavejs.api.core.ICallbackCollection;
	import weavejs.api.core.IDisposableObject;
	import weavejs.api.core.ILinkableHashMap;
	import weavejs.api.core.ILinkableObject;
	import weavejs.api.core.ISessionManager;
	import weavejs.core.SessionStateLog;
	import weavejs.path.WeavePath;
	import weavejs.path.WeavePathUI;
	import weavejs.util.Dictionary2D;
	import weavejs.util.JS;
	import weavejs.util.StandardLib;
	
	public class Weave implements IDisposableObject
	{
		public static const HISTORY_SYNC_DELAY:int = 100;
		public static const FRAME_INTERVAL:Number = 1000/30;
		
		public function Weave()
		{
			// set this property for backwards compatibility
			this['WeavePath'] = WeavePathUI;
			
			root = disposableChild(this, WeaveAPI.ClassRegistry.getImplementations(ILinkableHashMap)[0]);
			history = disposableChild(this, new SessionStateLog(root, HISTORY_SYNC_DELAY));
			map_root_weave.set(root, this);
		}
		
		public function dispose():void
		{
			Weave.dispose(this);
			map_root_weave['delete'](root);
			root = null;
			history = null;
		}
		
		/**
		 * The root object in the session state
		 */
		public var root:ILinkableHashMap;
		
		/**
		 * The session history
		 */
		public var history:SessionStateLog;
		
		/**
		 * Creates a WeavePath object.  WeavePath objects are immutable after they are created.
		 * This is a shortcut for "new WeavePath(weave, basePath)".
		 * @param basePath An optional Array (or multiple parameters) specifying the path to an object in the session state.
		 *                 A child index number may be used in place of a name in the path when its parent object is a LinkableHashMap.
		 * @return A WeavePath object.
		 * @see WeavePath
		 */
		public function path(...basePath):WeavePath
		{
			if (basePath.length == 1 && basePath[0] is Array)
				basePath = basePath[0];
			// handle path(linkableObject)
			if (basePath.length == 1 && isLinkable(basePath[0]))
				basePath = findPath(root, basePath[0]);
			return new WeavePathUI(this, basePath);
		}
		
		/**
		 * Gets the ILinkableObject at a specified path.
		 * @param path An Array (or multiple parameters) specifying the path to an object in the session state.
		 *             A child index number may be used in place of a name in the path when its parent object is a LinkableHashMap.
		 */
		public function getObject(...path):ILinkableObject
		{
			if (path.length == 1)
			{
				if (path[0] is WeavePath)
					return (path[0] as WeavePath).getObject();
				if (path[0] is Array)
					path = path[0];
			}
			return Weave.followPath(root, path);
		}

		
		
		
		//////////////////////////////////////////////////////////////////////////////////
		// static functions for linkable objects
		//////////////////////////////////////////////////////////////////////////////////
		<commit_msg>path() now returning null if path cannot be found for an ILinkableObject<commit_after>/*
	This Source Code Form is subject to the terms of the
	Mozilla Public License, v. 2.0. If a copy of the MPL
	was not distributed with this file, You can obtain
	one at https://mozilla.org/MPL/2.0/.
*/
package
{
	import weavejs.WeaveAPI;
	import weavejs.api.core.ICallbackCollection;
	import weavejs.api.core.IDisposableObject;
	import weavejs.api.core.ILinkableHashMap;
	import weavejs.api.core.ILinkableObject;
	import weavejs.api.core.ISessionManager;
	import weavejs.core.SessionStateLog;
	import weavejs.path.WeavePath;
	import weavejs.path.WeavePathUI;
	import weavejs.util.Dictionary2D;
	import weavejs.util.JS;
	import weavejs.util.StandardLib;
	
	public class Weave implements IDisposableObject
	{
		public static const HISTORY_SYNC_DELAY:int = 100;
		public static const FRAME_INTERVAL:Number = 1000/30;
		
		public function Weave()
		{
			// set this property for backwards compatibility
			this['WeavePath'] = WeavePathUI;
			
			root = disposableChild(this, WeaveAPI.ClassRegistry.getImplementations(ILinkableHashMap)[0]);
			history = disposableChild(this, new SessionStateLog(root, HISTORY_SYNC_DELAY));
			map_root_weave.set(root, this);
		}
		
		public function dispose():void
		{
			Weave.dispose(this);
			map_root_weave['delete'](root);
			root = null;
			history = null;
		}
		
		/**
		 * The root object in the session state
		 */
		public var root:ILinkableHashMap;
		
		/**
		 * The session history
		 */
		public var history:SessionStateLog;
		
		/**
		 * Creates a WeavePath object.  WeavePath objects are immutable after they are created.
		 * This is a shortcut for "new WeavePath(weave, basePath)".
		 * @param basePath An optional Array (or multiple parameters) specifying the path to an object in the session state.
		 *                 A child index number may be used in place of a name in the path when its parent object is a LinkableHashMap.
		 * @return A WeavePath object.
		 * @see WeavePath
		 */
		public function path(...basePath):WeavePath
		{
			if (basePath.length == 1 && basePath[0] is Array)
				basePath = basePath[0];
			// handle path(linkableObject)
			if (basePath.length == 1 && isLinkable(basePath[0]))
				basePath = findPath(root, basePath[0]);
			return basePath ? new WeavePathUI(this, basePath) : null;
		}
		
		/**
		 * Gets the ILinkableObject at a specified path.
		 * @param path An Array (or multiple parameters) specifying the path to an object in the session state.
		 *             A child index number may be used in place of a name in the path when its parent object is a LinkableHashMap.
		 */
		public function getObject(...path):ILinkableObject
		{
			if (path.length == 1)
			{
				if (path[0] is WeavePath)
					return (path[0] as WeavePath).getObject();
				if (path[0] is Array)
					path = path[0];
			}
			return Weave.followPath(root, path);
		}

		
		
		
		//////////////////////////////////////////////////////////////////////////////////
		// static functions for linkable objects
		//////////////////////////////////////////////////////////////////////////////////
		
{'fraction_non_alphanumeric': 0.14131311501855137, 'fraction_numerical': 0.008388449749959672, 'mean_word_length': 2.6904761904761907, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1263164', 'n_tokens_mistral': 2144, 'n_tokens_neox': 1834, 'n_words': 584}