• R/O
  • SSH

fcf-framework-core: Commit

Main functions and classes of the FCF framework


Commit MetaInfo

Révisionb2dbe2d5889199fb80f9aa6d3e2edba3bc22c11b (tree)
l'heure2022-12-07 13:48:47
Auteurvmarkin
Commitervmarkin

Message de Log

Added comment description for fcf.module

Change Summary

Modification

diff -r 16364e5fcbd8 -r b2dbe2d58891 fcf.js
--- a/fcf.js Wed Dec 07 07:42:35 2022 +0300
+++ b/fcf.js Wed Dec 07 07:48:47 2022 +0300
@@ -1938,77 +1938,6 @@
19381938 /// @details JS files act as module dependencies. If the dependency file does not use the fcf.module() declaration, then the module data is:
19391939 /// - On the NODEJS server side: Data exported to the module.exports variable
19401940 /// - On the browser side: A global variable that is declared in the configuration for a module:
1941- /// - Example:
1942- ///
1943- /// ---------------------------
1944- /// File /package/helloWorld.js:
1945- ///
1946- /// window.someGlobalVariable = window.someGlobalVariable || {};
1947- /// window.someGlobalVariable.helloWorld = function(){
1948- /// document.write("<h3>Hello world</h3>")
1949- /// }
1950- ///
1951- /// ---------------------------
1952- /// File /package/page.js:
1953- ///
1954- /// fcf.module({
1955- /// name: "package:page.js",
1956- /// dependencies: ["package:helloWorld.js"],
1957- /// module: (helloWorld)=>{
1958- /// return function() {
1959- /// document.write("<h1>Title</h1>");
1960- /// helloWorld();
1961- /// };
1962- /// }
1963- /// });
1964- ///
1965- /// ---------------------------
1966- /// File /index.html
1967- ///
1968- /// <html>
1969- /// <head>
1970- /// <script src="/node_modules/fcf-framework-core/fcf.js"></script>
1971- /// <script>
1972- /// // Adding data about the new package "package" to the configuration
1973- /// fcf.configuration.append({
1974- /// webModules: {
1975- ///
1976- /// // Path to package files
1977- /// "package": {
1978- ///
1979- /// // Path to package files
1980- /// path: "/modules/package",
1981- ///
1982- /// // mapping a module and a global variable as a result of module execution
1983- /// results: {
1984- /// "helloWorld.js": "someGlobalVariable.helloWorld",
1985- /// },
1986- ///
1987- /// }
1988- /// }
1989- /// });
1990- /// </script>
1991- /// </head>
1992- /// <body>
1993- /// <script>
1994- /// fcf.require("package:page.js")
1995- /// .then(([page])=>{
1996- /// page();
1997- /// });
1998- /// .catch((a_error)=>{
1999- /// console.error(a_error);
2000- /// })
2001- /// </script>
2002- /// </body>
2003- /// </html>
2004- ///
2005- /// ---------------------------
2006- /// Result in browser:
2007- ///
2008- /// Title
2009- ///
2010- /// Hello world
2011- ///
20121941 /// @param object a_options - Module options
20131942 /// - string name - Path (name) of the module in FCF notation
20141943 /// - array dependencies - Array with module dependency paths in FCF notation
@@ -2019,6 +1948,73 @@
20191948 /// - function module - A module function that should return module data.
20201949 /// The function arguments are the data of the modules declared in the dependencies property.
20211950 /// - Function signature: mixed module(<DEPENDENCY1, DEPENDENCY2, ...>)
1951+ /// @example
1952+ ///
1953+ /// ---------------------------
1954+ /// File /package/helloWorld.js:
1955+ ///
1956+ /// window.someGlobalVariable = window.someGlobalVariable || {};
1957+ /// window.someGlobalVariable.helloWorld = function(){
1958+ /// document.write("<h3>Hello world</h3>")
1959+ /// }
1960+ ///
1961+ /// ---------------------------
1962+ /// File /package/page.js:
1963+ ///
1964+ /// fcf.module({
1965+ /// name: "package:page.js",
1966+ /// dependencies: ["package:helloWorld.js"],
1967+ /// module: (helloWorld)=>{
1968+ /// return function() {
1969+ /// document.write("<h1>Title</h1>");
1970+ /// helloWorld();
1971+ /// };
1972+ /// }
1973+ /// });
1974+ ///
1975+ /// ---------------------------
1976+ /// File /index.html
1977+ ///
1978+ /// <html>
1979+ /// <head>
1980+ /// <script src="/node_modules/fcf-framework-core/fcf.js"></script>
1981+ /// <script>
1982+ /// // Adding data about the new package "package" to the configuration
1983+ /// fcf.configuration.append({
1984+ /// webModules: {
1985+ ///
1986+ /// // Path to package files
1987+ /// "package": {
1988+ ///
1989+ /// // Path to package files
1990+ /// path: "/modules/package",
1991+ ///
1992+ /// // mapping a module and a global variable as a result of module execution
1993+ /// results: {
1994+ /// "helloWorld.js": "someGlobalVariable.helloWorld",
1995+ /// },
1996+ ///
1997+ /// }
1998+ /// }
1999+ /// });
2000+ /// </script>
2001+ /// </head>
2002+ /// <body>
2003+ /// <script>
2004+ /// fcf.require("package:page.js")
2005+ /// .then(([page])=>{
2006+ /// page();
2007+ /// });
2008+ /// </script>
2009+ /// </body>
2010+ /// </html>
2011+ ///
2012+ /// ---------------------------
2013+ /// Result in browser:
2014+ ///
2015+ /// Title
2016+ ///
2017+ /// Hello world
20222018 ///
20232019 fcf.module = (a_options) => {
20242020 let moduleName = _getModulePath(a_options.name);
Afficher sur ancien navigateur de dépôt.