11 Commits

Author SHA1 Message Date
fcb72a4547 1.4.2 2021-04-01 22:53:50 +03:00
a028c2b767 1.4.1 2021-01-11 20:22:16 +03:00
8ea30cb9a0 build for version 2021-01-11 20:22:06 +03:00
f6f5eab087 1.4.0 2021-01-11 16:08:00 +03:00
1a7309dc38 get features from hbs 2021-01-11 16:07:53 +03:00
60300a769b 1.3.1 2020-12-10 20:55:41 +03:00
ed64c788d5 Merged in unmount-fix (pull request #1)
fixed unmount)

Approved-by: Andrey Vlasov
2020-12-10 17:49:21 +00:00
c19d5fc0de fixed unmount) 2020-12-10 20:11:25 +03:00
Andrey Vlasov
f2209f6708 1.3.0 2020-12-06 19:49:43 +03:00
Andrey Vlasov
753eaada75 add features 2020-12-06 19:49:08 +03:00
fe6d5df006 No test specified 2020-04-04 11:20:21 +03:00
4 changed files with 29 additions and 38 deletions

6
dist/index.js vendored
View File

@@ -78,7 +78,7 @@ var fireapp =
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/ /******/
/******/ // __webpack_public_path__ /******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/fireapp/1.1.0/"; /******/ __webpack_require__.p = "/fireapp/1.4.0/";
/******/ /******/
/******/ /******/
/******/ // Load entry module and return exports /******/ // Load entry module and return exports
@@ -245,7 +245,7 @@ eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nclass
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__webpack_require__(/*! systemjs/dist/system */ \"./node_modules/systemjs/dist/system.js\");\n__webpack_require__(/*! systemjs/dist/extras/amd */ \"./node_modules/systemjs/dist/extras/amd.js\");\n__webpack_require__(/*! systemjs/dist/extras/named-register */ \"./node_modules/systemjs/dist/extras/named-register.js\");\n__webpack_require__(/*! systemjs/dist/extras/named-exports */ \"./node_modules/systemjs/dist/extras/named-exports.js\");\n__webpack_require__(/*! systemjs/dist/extras/transform */ \"./node_modules/systemjs/dist/extras/transform.js\");\nconst history_1 = __webpack_require__(/*! history */ \"./node_modules/history/esm/history.js\");\nconst apps_1 = __webpack_require__(/*! ./apps */ \"./src/apps.ts\");\nconst virtual_module_1 = __webpack_require__(/*! ./virtual-module */ \"./src/virtual-module.ts\");\nconst systemJSImport = (requestUrl) => __awaiter(void 0, void 0, void 0, function* () {\n const { default: component, mount, unmount } = yield System.import(requestUrl);\n return { component, mount, unmount };\n});\n// const defaultNavigations = {\n// login: '/login',\n// main: '/main',\n// news: '/news',\n// org: '/org',\n// sections: '/sections',\n// 'news.details': '/news/{{id}}',\n// 'org.details': '/org/{{name}}',\n// 'sections.details': '/sections/{{name}}'\n// }\n// const defaultApps = {\n// login: { version: '1.0.0', name: 'login' },\n// main: { version: '1.0.1', name: 'main' },\n// news: { version: '1.0.0', name: 'news' },\n// org: { version: '1.0.0', name: 'org' },\n// sections: { version: '1.0.0', name: 'sections' }\n// }\nexports.default = ({ apps: rawApps, navigations, config }) => __awaiter(void 0, void 0, void 0, function* () {\n virtual_module_1.defineVirtualModule({ navigations, config });\n const apps = new apps_1.Apps(rawApps);\n const history = history_1.createBrowserHistory();\n let prevPathname = window.location.pathname;\n const app = apps.findApp(history.location.pathname);\n const publicPath = `/${app.name}/${app.version}`;\n __webpack_require__.p = `${config.baseUrl}${publicPath}${__webpack_require__.p}`;\n const appPath = `${config.baseUrl}${publicPath}/index.js`;\n const { component, mount, unmount } = yield systemJSImport(appPath);\n mount(component.default);\n history.listen((location) => {\n if (location.pathname !== prevPathname) {\n prevPathname = location.pathname;\n unmount();\n }\n });\n});\n\n\n//# sourceURL=webpack://fireapp/./src/main.ts?"); eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__webpack_require__(/*! systemjs/dist/system */ \"./node_modules/systemjs/dist/system.js\");\n__webpack_require__(/*! systemjs/dist/extras/amd */ \"./node_modules/systemjs/dist/extras/amd.js\");\n__webpack_require__(/*! systemjs/dist/extras/named-register */ \"./node_modules/systemjs/dist/extras/named-register.js\");\n__webpack_require__(/*! systemjs/dist/extras/named-exports */ \"./node_modules/systemjs/dist/extras/named-exports.js\");\n__webpack_require__(/*! systemjs/dist/extras/transform */ \"./node_modules/systemjs/dist/extras/transform.js\");\nconst history_1 = __webpack_require__(/*! history */ \"./node_modules/history/esm/history.js\");\nconst apps_1 = __webpack_require__(/*! ./apps */ \"./src/apps.ts\");\nconst virtual_module_1 = __webpack_require__(/*! ./virtual-module */ \"./src/virtual-module.ts\");\nconst systemJSImport = (requestUrl) => __awaiter(void 0, void 0, void 0, function* () {\n const { default: component, mount, unmount } = yield System.import(requestUrl);\n return { component, mount, unmount };\n});\nexports.default = ({ apps: rawApps, navigations, config, features }) => __awaiter(void 0, void 0, void 0, function* () {\n virtual_module_1.defineVirtualModule({ navigations, config, features });\n const apps = new apps_1.Apps(rawApps);\n const history = history_1.createBrowserHistory();\n let prevPathname = window.location.pathname;\n function getApp() {\n return __awaiter(this, void 0, void 0, function* () {\n const app = apps.findApp(history.location.pathname);\n const publicPath = `/${app.name}/${app.version}`;\n __webpack_require__.p = `${config.baseUrl}${publicPath}${__webpack_require__.p}`;\n const appPath = `${config.baseUrl}${publicPath}/index.js`;\n const { component, mount, unmount } = yield systemJSImport(appPath);\n return { component, mount, unmount };\n });\n }\n let { component, mount, unmount } = yield getApp();\n mount(component.default);\n history.listen((location) => __awaiter(void 0, void 0, void 0, function* () {\n if (location.pathname !== prevPathname) {\n prevPathname = location.pathname;\n unmount();\n const nextApp = yield getApp();\n nextApp.mount(nextApp.component.default);\n unmount = nextApp.unmount;\n }\n }));\n});\n\n\n//# sourceURL=webpack://fireapp/./src/main.ts?");
/***/ }), /***/ }),
@@ -257,7 +257,7 @@ eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _argument
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "use strict";
eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst createVirtualModule = ({ config, navigations }) => ({\n getConfig: () => config,\n getConfigValue: (key) => config[key],\n getNavigations: () => navigations,\n getNavigationsValue: (key) => navigations[key],\n});\nexports.defineVirtualModule = (params) => {\n const virtualModule = createVirtualModule(params);\n // @ts-ignore\n System.set('root.scope', Object.assign({}, virtualModule));\n};\n\n\n//# sourceURL=webpack://fireapp/./src/virtual-module.ts?"); eval("\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst createVirtualModule = ({ config, navigations, features }) => ({\n getConfig: () => config,\n getConfigValue: (pkg) => config[pkg],\n getNavigations: () => navigations,\n getNavigationsValue: (pkg) => navigations[pkg],\n getAllFeatures: () => features,\n getFeatures: (pkg) => features[pkg]\n});\nexports.defineVirtualModule = (params) => {\n const virtualModule = createVirtualModule(params);\n // @ts-ignore\n System.set('root.scope', Object.assign({}, virtualModule));\n};\n\n\n//# sourceURL=webpack://fireapp/./src/virtual-module.ts?");
/***/ }) /***/ })

View File

@@ -1,12 +1,11 @@
{ {
"name": "@ijl/fire.app", "name": "@ijl/fire.app",
"version": "1.2.0", "version": "1.4.2",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"start": "nodemon ./stubs/server.js", "start": "nodemon ./stubs/server.js",
"build": "webpack --mode development", "build": "webpack --mode development"
"test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "innoavvlasov@gmail.com", "author": "innoavvlasov@gmail.com",
"license": "ISC", "license": "ISC",

View File

@@ -14,27 +14,8 @@ const systemJSImport = async (requestUrl: string) => {
return { component, mount, unmount } return { component, mount, unmount }
} }
// const defaultNavigations = { export default async ({ apps: rawApps, navigations, config, features }) => {
// login: '/login', defineVirtualModule({ navigations, config, features })
// main: '/main',
// news: '/news',
// org: '/org',
// sections: '/sections',
// 'news.details': '/news/{{id}}',
// 'org.details': '/org/{{name}}',
// 'sections.details': '/sections/{{name}}'
// }
// const defaultApps = {
// login: { version: '1.0.0', name: 'login' },
// main: { version: '1.0.1', name: 'main' },
// news: { version: '1.0.0', name: 'news' },
// org: { version: '1.0.0', name: 'org' },
// sections: { version: '1.0.0', name: 'sections' }
// }
export default async ({ apps: rawApps, navigations, config }) => {
defineVirtualModule({ navigations, config })
const apps = new Apps(rawApps) const apps = new Apps(rawApps)
@@ -42,6 +23,7 @@ export default async ({ apps: rawApps, navigations, config }) => {
let prevPathname = window.location.pathname let prevPathname = window.location.pathname
async function getApp() {
const app = apps.findApp(history.location.pathname) const app = apps.findApp(history.location.pathname)
const publicPath = `/${app.name}/${app.version}` const publicPath = `/${app.name}/${app.version}`
@@ -52,12 +34,20 @@ export default async ({ apps: rawApps, navigations, config }) => {
const { component, mount, unmount } = await systemJSImport(appPath); const { component, mount, unmount } = await systemJSImport(appPath);
return { component, mount, unmount };
}
let { component, mount, unmount } = await getApp()
mount(component.default); mount(component.default);
history.listen((location) => { history.listen(async (location) => {
if (location.pathname !== prevPathname) { if (location.pathname !== prevPathname) {
prevPathname = location.pathname prevPathname = location.pathname
unmount() unmount()
const nextApp = await getApp();
nextApp.mount(nextApp.component.default)
unmount = nextApp.unmount;
} }
}) })
}; };

View File

@@ -1,8 +1,10 @@
const createVirtualModule = ({ config, navigations }) => ({ const createVirtualModule = ({ config, navigations, features }) => ({
getConfig: () => config, getConfig: () => config,
getConfigValue: (key) => config[key], getConfigValue: (pkg: string) => config[pkg],
getNavigations: () => navigations, getNavigations: () => navigations,
getNavigationsValue: (key) => navigations[key], getNavigationsValue: (pkg: string) => navigations[pkg],
getAllFeatures: () => features,
getFeatures: (pkg: string) => features[pkg]
}) })
export const defineVirtualModule = (params) => { export const defineVirtualModule = (params) => {