26 Commits

Author SHA1 Message Date
b718dd3b03 1.4.5 2021-06-06 12:34:57 +03:00
ff2f20aebe 1.4.4 2021-06-06 12:21:03 +03:00
1e76d60284 1.4.3 2021-05-30 21:20:58 +03:00
612f326515 history 2021-05-30 21:20:51 +03:00
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
d5e08e4178 1.2.0 2020-03-31 00:16:40 +03:00
14e5c02a03 fireapp 2020-03-31 00:16:30 +03:00
ac1e2a4df3 1.1.0 2020-03-31 00:08:19 +03:00
Andrey Vlasov
0636ce1ff2 fix virtual module 2020-03-29 12:49:07 +03:00
Andrey Vlasov
47839a963c 1.0.5 2020-03-29 10:53:19 +03:00
Andrey Vlasov
3683151cb2 build 2020-03-29 10:52:08 +03:00
Andrey Vlasov
033865105f 1.0.4 2020-03-28 23:37:51 +03:00
Andrey Vlasov
556c31c56c add entry 2020-03-28 23:37:43 +03:00
Andrey Vlasov
a008842899 1.0.3 2020-03-28 23:33:09 +03:00
Andrey Vlasov
84cf7b72a0 rename virtual module 2020-03-28 23:32:35 +03:00
Andrey Vlasov
03eec8c836 change license 2020-03-28 23:08:24 +03:00
7 changed files with 81 additions and 77 deletions

54
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,15 +1,14 @@
{ {
"name": "@ijl/fire.app", "name": "@ijl/fire.app",
"version": "1.0.2", "version": "1.4.5",
"description": "", "description": "",
"main": "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": "MIT", "license": "ISC",
"devDependencies": { "devDependencies": {
"@types/node": "13.7.0", "@types/node": "13.7.0",
"@types/systemjs": "6.1.0", "@types/systemjs": "6.1.0",

6
src/history.ts Normal file
View File

@@ -0,0 +1,6 @@
import { createBrowserHistory } from 'history'
const history = createBrowserHistory();
export default history;

View File

@@ -1,11 +1,11 @@
import "systemjs/dist/s"; import "systemjs/dist/system";
import "systemjs/dist/extras/amd"; import "systemjs/dist/extras/amd";
import "systemjs/dist/extras/named-register"; import "systemjs/dist/extras/named-register";
import "systemjs/dist/extras/named-exports"; import "systemjs/dist/extras/named-exports";
import "systemjs/dist/extras/transform"; import "systemjs/dist/extras/transform";
import { createBrowserHistory } from 'history'
import { Apps } from './apps' import { Apps } from './apps'
import { defineVirtualModule } from './virtual-module' import { defineVirtualModule } from './virtual-module'
import history from './history';
const systemJSImport = async (requestUrl: string) => { const systemJSImport = async (requestUrl: string) => {
const { default: component, mount, unmount } = await System.import( const { default: component, mount, unmount } = await System.import(
@@ -14,50 +14,38 @@ 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)
const history = createBrowserHistory()
let prevPathname = window.location.pathname let prevPathname = window.location.pathname
const app = apps.findApp(history.location.pathname) async function getApp() {
const app = apps.findApp(history.location.pathname)
const publicPath = `/${app.name}/${app.version}` const publicPath = `/${app.name}/${app.version}`
__webpack_public_path__ = `${config.baseUrl}${publicPath}${__webpack_public_path__}`
const appPath = `${config.baseUrl}${publicPath}/index.js`
const { component, mount, unmount } = await systemJSImport(appPath);
__webpack_public_path__ = `${config.baseUrl}${publicPath}${__webpack_public_path__}` return { component, mount, unmount };
}
const appPath = `${config.baseUrl}${publicPath}/index.js`
const { component, mount, unmount } = await systemJSImport(appPath);
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,12 +1,20 @@
import history from './history';
const createVirtualModule = ({ config, navigations, features }) => ({
getConfig: () => config,
getConfigValue: (pkg: string) => config[pkg],
getNavigations: () => navigations,
getNavigationsValue: (pkg: string) => navigations[pkg],
getAllFeatures: () => features,
getFeatures: (pkg: string) => features[pkg],
getHistory: () => history,
})
export const defineVirtualModule = (params) => { export const defineVirtualModule = (params) => {
const virtualModule = createVirtualModule(params) const virtualModule = createVirtualModule(params)
// @ts-ignore // @ts-ignore
global.define('root.scope.env', [], virtualModule) System.set('root.scope', {
...virtualModule
});
} }
const createVirtualModule = ({config, navigations}) => ({
getConfig: () => config,
getConfigValue: (key) => config[key],
getNavigations: () => navigations,
getNavigationsValue: (key) => navigations[key],
})

View File

@@ -4,15 +4,6 @@
"dom", "dom",
"es7" "es7"
], ],
"baseUrl": ".",
"paths": {
"*": [
"*",
"src/*",
"lib/*",
"dist/*"
]
},
"outDir": "./dist/", "outDir": "./dist/",
"sourceMap": true, "sourceMap": true,
"esModuleInterop": true, "esModuleInterop": true,

View File

@@ -11,10 +11,10 @@ module.exports = {
index: "./src/main.ts" index: "./src/main.ts"
}, },
output: { output: {
library: "bootstrap", library: "fireapp",
path: path.resolve(__dirname, outputDirectory), path: path.resolve(__dirname, outputDirectory),
libraryExport: "default", libraryExport: "default",
publicPath: `/boorstrap/${pkg.version}/` publicPath: `/fireapp/${pkg.version}/`
}, },
plugins: [new CleanWebpackPlugin()], plugins: [new CleanWebpackPlugin()],