Compare commits

..

No commits in common. "master" and "v1.4.0" have entirely different histories.

13 changed files with 318 additions and 10105 deletions

View File

@ -1,4 +0,0 @@
.eslintrc.js
babel.config.js
webpack.config.js
dist/

View File

@ -1,22 +0,0 @@
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended'
],
overrides: [
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: [
'@typescript-eslint'
],
rules: {
}
}

2
.npmrc
View File

@ -1 +1 @@
package-lock=true package-lock=false

View File

@ -1,6 +0,0 @@
module.exports = {
presets: [
'@babel/preset-env',
'@babel/preset-typescript'
]
}

266
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

10003
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +1,30 @@
{ {
"name": "@ijl/fire.app", "name": "@ijl/fire.app",
"version": "1.6.1", "version": "1.4.0",
"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"
"build:prod": "webpack --mode production"
}, },
"author": "innoavvlasov@gmail.com", "author": "innoavvlasov@gmail.com",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.21.0", "@types/node": "13.7.0",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.21.0",
"@types/node": "16.18.12",
"@types/systemjs": "6.1.0", "@types/systemjs": "6.1.0",
"@typescript-eslint/eslint-plugin": "^5.53.0", "awesome-typescript-loader": "5.2.1",
"@typescript-eslint/parser": "^5.53.0",
"babel-loader": "^9.1.2",
"clean-webpack-plugin": "3.0.0", "clean-webpack-plugin": "3.0.0",
"es6-promise": "4.2.8", "es6-promise": "4.2.8",
"eslint": "^8.34.0",
"exports-loader": "0.7.0", "exports-loader": "0.7.0",
"fbjs": "1.0.0", "fbjs": "1.0.0",
"file-loader": "5.0.2",
"history": "4.10.1", "history": "4.10.1",
"imports-loader": "0.8.0", "imports-loader": "0.8.0",
"nodemon": "^2.0.20",
"rimraf": "3.0.1", "rimraf": "3.0.1",
"systemjs": "6.2.2", "systemjs": "6.2.2",
"typescript": "^4.9.5", "typescript": "3.7.5",
"webpack": "^5.75.0", "webpack": "4.41.5",
"webpack-cli": "^5.0.1" "webpack-cli": "3.3.10",
"whatwg-fetch": "3.0.0"
} }
} }

View File

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

View File

@ -1,14 +1,11 @@
/* eslint-disable prefer-const */
import "systemjs/dist/system"; 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 "regenerator-runtime/runtime"; 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(
@ -17,20 +14,13 @@ const systemJSImport = async (requestUrl: string) => {
return { component, mount, unmount } return { component, mount, unmount }
} }
let mainMountElement = document.getElementById('app');
if (!mainMountElement) {
mainMountElement = document.createElement('div');
mainMountElement.id = 'app';
document.body.append(mainMountElement);
}
export default async ({ apps: rawApps, navigations, config, features }) => { export default async ({ apps: rawApps, navigations, config, features }) => {
defineVirtualModule({ navigations, config, features }) defineVirtualModule({ navigations, config, features })
const apps = new Apps(rawApps) const apps = new Apps(rawApps)
const history = createBrowserHistory()
let prevPathname = window.location.pathname let prevPathname = window.location.pathname
async function getApp() { async function getApp() {
@ -48,7 +38,7 @@ export default async ({ apps: rawApps, navigations, config, features }) => {
} }
let { component, mount, unmount } = await getApp() let { component, mount, unmount } = await getApp()
mount(component.default, mainMountElement); mount(component.default);
history.listen(async (location) => { history.listen(async (location) => {
if (location.pathname !== prevPathname) { if (location.pathname !== prevPathname) {
@ -56,7 +46,7 @@ export default async ({ apps: rawApps, navigations, config, features }) => {
unmount() unmount()
const nextApp = await getApp(); const nextApp = await getApp();
nextApp.mount(nextApp.component.default, mainMountElement) nextApp.mount(nextApp.component.default)
unmount = nextApp.unmount; unmount = nextApp.unmount;
} }
}) })

View File

@ -1,17 +1,15 @@
import history from './history';
const createVirtualModule = ({ config, navigations, features }) => ({ const createVirtualModule = ({ config, navigations, features }) => ({
getConfig: () => config, getConfig: () => config,
getConfigValue: (pkg: string) => config[pkg], getConfigValue: (pkg: string) => config[pkg],
getNavigations: () => navigations, getNavigations: () => navigations,
getNavigationsValue: (pkg: string) => navigations[pkg], getNavigationsValue: (pkg: string) => navigations[pkg],
getAllFeatures: () => features, getAllFeatures: () => features,
getFeatures: (pkg: string) => features[pkg], 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
System.set('root.scope', { System.set('root.scope', {
...virtualModule ...virtualModule
}); });

View File

@ -1,23 +1,29 @@
{ {
"compilerOptions": { "compilerOptions": {
"lib": [ "lib": [
"dom", "dom",
"ESNext" "es7"
], ],
"outDir": "./dist/", "baseUrl": ".",
"sourceMap": true, "paths": {
"esModuleInterop": true, "*": [
"downlevelIteration": true, "*",
"noImplicitAny": false, "src/*",
"module": "commonjs", "lib/*",
"target": "es6", "dist/*"
"typeRoots": [ ]
"node_modules/@types", },
"src/typings", "outDir": "./dist/",
"../../node_modules/@types" "sourceMap": true,
"esModuleInterop": true,
"downlevelIteration" :true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es6",
"jsx": "react",
"typeRoots": ["node_modules/@types", "src/typings", "../../node_modules/@types"]
},
"exclude": [
"node_modules"
] ]
},
"exclude": [
"node_modules"
]
} }

View File

@ -6,20 +6,21 @@ const outputDirectory = 'dist';
const pkg = require('./package.json') const pkg = require('./package.json')
module.exports = { module.exports = {
mode: "development",
entry: { entry: {
index: './src/main.ts' index: "./src/main.ts"
}, },
output: { output: {
library: 'fireapp', library: "fireapp",
path: path.resolve(__dirname, outputDirectory), path: path.resolve(__dirname, outputDirectory),
libraryExport: 'default', libraryExport: "default",
publicPath: `/fireapp/${pkg.version}/` publicPath: `/fireapp/${pkg.version}/`
}, },
plugins: [new CleanWebpackPlugin()], plugins: [new CleanWebpackPlugin()],
resolve: { resolve: {
extensions: ['.ts', '.js'] extensions: [".ts", ".js"]
}, },
module: { module: {
@ -27,7 +28,11 @@ module.exports = {
{ parser: { system: false } }, { parser: { system: false } },
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
loader: 'babel-loader' loader: "awesome-typescript-loader"
},
{
test: /\.(jpe?g|gif|png|svg|woff|ttf|eot|wav|mp3)$/,
loader: "file-loader"
} }
] ]
} }