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,EACT,aAAc,CACV,CACI,GAAI,CAAC,EAAK,EAAK,IACJ,EAAyB,EAAoB,GAExD,MAAO,IAAI,OAAO,EAAkB,OAExC,CACI,GAAI,CAAC,EAAK,EAAK,IACJ,EAAyB,EAAoB,GAExD,MAAO,IAAI,OAAO,EAAiB,SAI/C,gBAAiB,YACjB,YACA,QAAS,IAEb,MAAM,EAAe,CACjB,SAAU,IACV,UAAW,cACX,QAAS,GAEP,EAAW,IAAI,UAAU,SAAS,GACxC,EAAS,QACT,MAAM,EAAU,IAAI,UAAU,QACxB,EAAc,CAChB,SAAU,IACN,YAAW,KACP,EAAS,QAAQ,EAAU,GAC5B,EAAa,EAEpB,UACA,yBAEJ,EAAQ,MAAM,GACI,UAAd,GACA,MAAM,QAAQ,EAAW,CACrB,IAAK,IAGb,UACJ,CACA,QAAQ,KAAO","file":"/npm/aemfed@0.1.1/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/aemfed@0.1.1/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar __importStar = (this && this.__importStar) || function (mod) {\n    if (mod && mod.__esModule) return mod;\n    var result = {};\n    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n    result[\"default\"] = mod;\n    return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst aemsync_1 = require(\"aemsync\");\nconst chalk_1 = __importDefault(require(\"chalk\"));\nconst decode_html_1 = __importDefault(require(\"decode-html\"));\nconst graceful_fs_1 = __importDefault(require(\"graceful-fs\"));\nconst minimist_1 = __importDefault(require(\"minimist\"));\nconst opn_1 = __importDefault(require(\"opn\"));\nconst path_1 = __importDefault(require(\"path\"));\nconst package_json_1 = __importDefault(require(\"./../package.json\"));\nconst bsWrapper = __importStar(require(\"./bs-wrapper\"));\nconst messages = __importStar(require(\"./messages\"));\nconst UpdateCheck = __importStar(require(\"./update-check\"));\nconst bsQrCodePlugin = require(\"./bs-qr-code\");\nfunction separate() {\n    console.log(\"---------------------------------------\");\n}\nconst MSG_HELP = `Usage: aemfed [OPTIONS]\nOptions:\n  -t targets           Default is http://admin:admin@localhost:4502\n  -p proxy_port        Default is 3000\n  -w path_to_watch     Default is current\n  -e exclude_filter    Anymatch exclude filter; disabled by default\n  -i sync_interval     Update interval in milliseconds; default is 100\n  -o open_page         Browser page to be opened after successful launch; default is \"false\".\n  -b browser           Browser where page should be opened in; this parameter is platform dependent; for example, Chrome is \"google chrome\" on OS X, \"google-chrome\" on Linux and \"chrome\" on Windows; default is \"google chrome\"\n  -q load_qr           Enable QR code plugin for connected browsers; default is \"true\".\n  -h                   Displays this screen\n  -v                   Displays version of this package`;\nconst workingDirs = [];\nfunction reloadBrowser(error, host, inputList, packItems) {\n    if (!error) {\n        bsWrapper.reload(host, inputList);\n    }\n    else {\n        console.error(chalk_1.default `[{blue ${host}}] [{red Error}] when pushing pack: ${decode_html_1.default(error)}`);\n        const ref = messages.getRef(error, /systemId: file:\\/\\/.*?\\/jcr_root(\\/.*?); lineNumber: (\\d+); columnNumber: (\\d+);/, workingDirs);\n        const logLine = messages.formatMessage(ref);\n        if (logLine) {\n            console.log(logLine);\n        }\n    }\n}\nfunction init() {\n    \"use strict\";\n    const args = minimist_1.default(process.argv.slice(2));\n    if (args.h) {\n        console.log(MSG_HELP);\n        return;\n    }\n    if (args.v) {\n        console.log(package_json_1.default.version);\n        return;\n    }\n    workingDirs.splice(0, workingDirs.length);\n    const dirs = args.w ? args.w : \".\";\n    dirs.split(\",\").forEach((dir) => {\n        const absDir = path_1.default.resolve(dir);\n        if (!graceful_fs_1.default.existsSync(absDir)) {\n            console.log(\"Invalid path, so skipping:\", chalk_1.default.yellow(absDir));\n        }\n        else {\n            workingDirs.push(absDir);\n        }\n    });\n    if (workingDirs.length === 0) {\n        console.log(\"No valid paths found in: \", chalk_1.default.yellow(args.w));\n        return;\n    }\n    const targets = args.t || \"http://admin:admin@localhost:4502\";\n    const proxyPort = parseInt(args.p, 10) || 3000;\n    const pushInterval = parseInt(args.i, 10) || 100;\n    const exclude = args.e || \"\";\n    const startPage = args.o || \"false\";\n    const startBrowser = args.b || \"google chrome\";\n    const bsPlugins = [];\n    if (args.q !== \"false\") {\n        bsPlugins.push({\n            module: bsQrCodePlugin,\n            options: {\n                onload: false\n            }\n        });\n    }\n    separate();\n    console.log(\"Working dirs:\", workingDirs);\n    console.log(\"Targets:\", targets);\n    console.log(\"Proxy port:\", proxyPort);\n    console.log(\"Interval:\", pushInterval);\n    console.log(\"Exclude:\", exclude);\n    separate();\n    console.log(chalk_1.default `Something missing or not working as expected, open an issue on GitHub: {yellow https://github.com/abmaonline/aemfed/issues}`);\n    separate();\n    UpdateCheck.check(package_json_1.default)\n        .then(update => {\n        const message = messages.formatUpdateMessage(update);\n        if (message) {\n            console.log(message);\n        }\n    })\n        .catch(err => {\n        console.error(`Failed to check for updates: ${err}`);\n    });\n    const targetList = targets.split(\",\");\n    const styleLinkPattern = '(<link rel=\"stylesheet\" href=\"/[^\">]*?)(.min)?(.[0-9a-f]{32})?(.css)(\"[^>]*>)';\n    const jsScriptPattern = '(<script type=\".*?/javascript\" src=\"/[^\">]*?(.min)?(.[0-9a-f]{32})?)(.js)(\"[^>]*>)';\n    function rewriteClientlibIncludes(matchedLinkElement, pattern) {\n        const regex = new RegExp(pattern, \"i\");\n        const match = regex.exec(matchedLinkElement);\n        if (match) {\n            return match[1] + match[4] + \"?browsersync=\" + Date.now() + match[5];\n        }\n        else {\n            console.warn(\"Could not rematch \" +\n                matchedLinkElement +\n                \" to rewrite url w/o .min and .hash\");\n            return matchedLinkElement;\n        }\n    }\n    bsWrapper.create({\n        bsOptions: {\n            plugins: bsPlugins,\n            rewriteRules: [\n                {\n                    fn: (req, res, matchedLinkElement) => {\n                        return rewriteClientlibIncludes(matchedLinkElement, styleLinkPattern);\n                    },\n                    match: new RegExp(styleLinkPattern, \"gi\")\n                },\n                {\n                    fn: (req, res, matchedLinkElement) => {\n                        return rewriteClientlibIncludes(matchedLinkElement, jsScriptPattern);\n                    },\n                    match: new RegExp(jsScriptPattern, \"gi\")\n                }\n            ]\n        },\n        jcrContentRoots: workingDirs,\n        proxyPort,\n        servers: targetList\n    });\n    const pipelineArgs = {\n        interval: 600,\n        onPushEnd: reloadBrowser,\n        targets: targetList\n    };\n    const pipeline = new aemsync_1.Pipeline(pipelineArgs);\n    pipeline.start();\n    const watcher = new aemsync_1.Watcher();\n    const watcherArgs = {\n        callback: localPath => {\n            setTimeout(() => {\n                pipeline.enqueue(localPath);\n            }, pushInterval);\n        },\n        exclude,\n        workingDirs\n    };\n    watcher.watch(watcherArgs);\n    if (startPage !== \"false\") {\n        opn_1.default(startPage, {\n            app: startBrowser\n        });\n    }\n    separate();\n}\nexports.init = init;\n"]}