1import { application } from 'controllers/application'; 2import { Controller } from '@hotwired/stimulus'; 3import { eagerLoadControllersFrom } from '@hotwired/stimulus-loading'; 4 5eagerLoadControllersFrom('controllers/base', application); 6 7// <script type="text/stimulus-controllers"> ì½ê³ localControllersì ì ì¥ + wrapper ìì±íì¬ applicationì ë±ë¡í©ëë¤. 8// ìëì ê°ì íìì¼ë¡ ì¤í¬ë¦½í¸ë¥¼ bodyë´ì ìì±í ì ììµëë¤. ì´ ë°©ë²ì ê° íì´ì§ í¹íë 컨í¸ë¡¤ë¬ë¥¼ ì ìí ë ì ì©í©ëë¤. í¹í íì´ì§ ë¸ë¡ ë´ì í¬í¨ìí¬ ì ììµëë¤. 9// 10// <script type="text/stimulus-controllers"> 11// (function(localControllers, Controller) { 12// localControllers["hindex-indicator"] = class extends Controller { 13// connect() { 14// console.log("Connected!"); 15// } 16// }; 17// })(localControllers, Controller); 18// </script> 19// 20// ì ììììë "local--hindex-indicator"ë¼ë ì´ë¦ì 컨í¸ë¡¤ë¬ê° ì ìë©ëë¤. ì´ ì»¨í¸ë¡¤ë¬ë applicationì "local--hindex-indicator"ë¼ë ì´ë¦ì¼ë¡ ë±ë¡ë©ëë¤. 21// 22// <div data-controller="local--hindex-indicator"> 23// ... 24// </div> 25// 26// ìì ê°ì´ data-controller ìì±ì "local--hindex-indicator"를 ì§ì íì¬ ì¬ì©í ì ììµëë¤. 27 28function registerScriptControllers(root = document) { 29 const scripts = root.querySelectorAll('script[type="text/stimulus-controllers"]'); 30 31 scripts.forEach((script) => { 32 try { 33 // Function ë´ë¶ ì¤ì½íìì í´ëì¤ ì ì 34 const controllers = (function (Controller) { 35 const localControllers = {}; 36 37 // eval ëì Function ì¬ì© (ìì íê² ì§ì ì¤ì½í ì ì§) 38 new Function('localControllers', 'Controller', script.textContent)(localControllers, Controller); 39 40 return localControllers; 41 })(Controller); 42 43 // í´ëì¤ ë±ë¡ 44 Object.entries(controllers).forEach(([name, controllerClass]) => { 45 const fullName = `local--${name}`; 46 if (!application.router.modulesByIdentifier.has(fullName)) { 47 application.register(fullName, controllerClass); 48 if (application.debug) { 49 console.log(`Registered controller: ${fullName}`); 50 } 51 } 52 }); 53 } catch (err) { 54 console.error('Failed to execute script controller', err); 55 } 56 }); 57} 58 59// íì´ì§ ë¡ë ì§í 60registerScriptControllers(); 61 62// MutationObserverë¡ ëì ì½ì ë <script> ì²ë¦¬ ê°ë¥ 63new MutationObserver((mutations) => { 64 mutations.forEach(({ addedNodes }) => { 65 addedNodes.forEach((node) => { 66 if (node.tagName === 'SCRIPT' && node.type === 'text/stimulus-controllers') { 67 registerScriptControllers(node.parentNode || document); 68 } 69 }); 70 }); 71}).observe(document, { subtree: true, childList: true });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.