backend-plus 2.0.0-rc.19 → 2.0.0-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ /// <reference types="websql" />
1
2
  import { TableDefinition } from "backend-plus";
2
3
  export type Key = string[];
3
4
  type DetectFeatures = {
@@ -134,7 +134,7 @@ export type MenuInfoPath={
134
134
  path:string
135
135
  } & MenuInfoMinimo;
136
136
  export interface ClientModuleDefinition{
137
- type:'js'|'css'|'ttf'
137
+ type:'js'|'css'|'ttf'|'mjs'
138
138
  module?:string // module where to search in node_modules (node_modules/module/modPath/file) to serve
139
139
  modPath?:string // path inside module where to find file to serve
140
140
  src?:string // full path where browser search file (path/file)
@@ -130,6 +130,9 @@ class AppBackend{
130
130
  // @ts-ignore
131
131
  this.server = null;
132
132
  }
133
+ esJavascript(type){
134
+ return ['js','mjs'].includes(type)
135
+ }
133
136
  clearCaches(){
134
137
  this.caches={
135
138
  procedures:{}
@@ -536,7 +539,7 @@ var imgExts = ['jpg', 'png', 'jpeg', 'ico', 'gif', 'svg']
536
539
 
537
540
  AppBackend.prototype.exts = {
538
541
  img: imgExts,
539
- normal: ['', 'js', 'map', 'html', 'css', ...imgExts, 'appcache', 'manifest', 'json', 'webmanifest', 'zip', 'pdf', ...fontExts, 'xlsx', 'csv']
542
+ normal: ['', 'js', 'map', 'html', 'css', ...imgExts, 'appcache', 'manifest', 'json', 'webmanifest', 'zip', 'pdf', ...fontExts, 'xlsx', 'csv', 'mjs']
540
543
  };
541
544
 
542
545
  /**
@@ -1965,7 +1968,7 @@ AppBackend.prototype.addUnloggedServices = function addUnloggedServices(mainApp,
1965
1968
  if(baseUrl=='/'){
1966
1969
  baseUrl='';
1967
1970
  }
1968
- let baseLib = baseUrl + '/' + (moduleDef.path ? moduleDef.path : moduleDef.type == 'js'? 'lib': 'css');
1971
+ let baseLib = baseUrl + '/' + (moduleDef.path ? moduleDef.path : be.esJavascript(moduleDef.type)? 'lib': 'css');
1969
1972
  try {
1970
1973
  var allowedExts=(moduleDef.type=='js'?['js','map']:[moduleDef.type]);
1971
1974
  mainApp.use(baseLib, serveContent(resolve_module_dir(moduleDef.module, moduleDef.modPath), { allowedExts }));
@@ -2100,6 +2103,7 @@ AppBackend.prototype.clientIncludes = function clientIncludes(req, opts) {
2100
2103
 
2101
2104
  AppBackend.prototype.clientIncludesCompleted = function clientIncludesCompleted(req, opts) {
2102
2105
  let list = this.clientIncludes(req, opts);
2106
+ var be = this;
2103
2107
  if(this.config.devel && this.config.devel.useFileDevelopment){
2104
2108
  list=list.map(includeDef=>{
2105
2109
  if(includeDef.fileProduction){
@@ -2115,14 +2119,15 @@ AppBackend.prototype.clientIncludesCompleted = function clientIncludesCompleted(
2115
2119
  return list.map(inclusion =>{
2116
2120
  var filename = inclusion.file? inclusion.file: (inclusion.module? Path.basename(require_resolve(inclusion.module,rPaths)): '');
2117
2121
  return changing({
2118
- src: inclusion.type == 'js' ? ((inclusion.path ? inclusion.path : 'lib') + '/' + (inclusion.file ? inclusion.file : filename)) : '',
2122
+ src: be.esJavascript(inclusion.type) ? ((inclusion.path ? inclusion.path : 'lib') + '/' + (inclusion.file ? inclusion.file : filename)) : '',
2119
2123
  href: inclusion.type == 'css' ? ((inclusion.path ? inclusion.path : 'css') + '/' + (inclusion.file ? inclusion.file : (inclusion.module + '.css'))) : ''
2120
2124
  }, inclusion);
2121
2125
  });
2122
2126
  }
2123
2127
 
2124
2128
  AppBackend.prototype.clientModules = function clientModules(req, opts) {
2125
- return { scripts: this.clientIncludesCompleted(req, opts).filter(x => x.type == 'js').map(mod => {return { src: mod.src }})};
2129
+ var be = this;
2130
+ return { scripts: this.clientIncludesCompleted(req, opts).filter(x => be.esJavascript(x.type)).map(mod => {return { src: mod.src, type:mod.type=='mjs'?"module":null }})};
2126
2131
  }
2127
2132
 
2128
2133
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backend-plus",
3
3
  "description": "Backend for the anti Pareto rule",
4
- "version": "2.0.0-rc.19",
4
+ "version": "2.0.0-rc.20",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",