vona-module-a-static 5.0.10 → 5.0.12
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.
- package/dist/.metadata/index.d.ts +18 -19
- package/dist/index.js +164 -3
- package/package.json +2 -2
- package/dist/.metadata/index.js +0 -23
- package/dist/.metadata/this.js +0 -2
- package/dist/bean/event.resolvePath.js +0 -13
- package/dist/bean/middlewareSystem.static.js +0 -130
- package/dist/lib/beanStaticBase.js +0 -10
- package/dist/lib/index.js +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/static.js +0 -1
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** event: end */
|
|
4
|
-
/** event: begin */
|
|
5
|
-
import type { EventResolvePath } from '../bean/event.resolvePath.ts';
|
|
6
|
-
/** event: end */
|
|
7
|
-
/** event: begin */
|
|
8
|
-
import type { TypeEventResolvePathData, TypeEventResolvePathResult } from '../bean/event.resolvePath.ts';
|
|
9
|
-
/** middlewareSystem: end */
|
|
10
|
-
/** event: begin */
|
|
1
|
+
/** middlewareSystem: begin */
|
|
2
|
+
export * from '../bean/middlewareSystem.static.ts';
|
|
11
3
|
import type { IMiddlewareSystemOptionsStatic } from '../bean/middlewareSystem.static.ts';
|
|
12
|
-
/** event: end */
|
|
13
|
-
/** scope: begin */
|
|
14
|
-
import { BeanScopeBase } from 'vona';
|
|
15
|
-
import 'vona';
|
|
16
4
|
import 'vona';
|
|
17
|
-
import 'vona';
|
|
18
|
-
export * from '../bean/event.resolvePath.ts';
|
|
19
5
|
declare module 'vona-module-a-aspect' {
|
|
20
6
|
interface IMiddlewareSystemRecord {
|
|
21
7
|
'a-static:static': IMiddlewareSystemOptionsStatic;
|
|
@@ -25,28 +11,41 @@ declare module 'vona-module-a-static' {
|
|
|
25
11
|
interface MiddlewareSystemStatic {
|
|
26
12
|
}
|
|
27
13
|
}
|
|
28
|
-
/** middlewareSystem:
|
|
29
|
-
|
|
14
|
+
/** middlewareSystem: end */
|
|
15
|
+
/** event: begin */
|
|
16
|
+
export * from '../bean/event.resolvePath.ts';
|
|
17
|
+
import 'vona';
|
|
30
18
|
declare module 'vona' {
|
|
31
19
|
}
|
|
32
20
|
declare module 'vona-module-a-static' {
|
|
33
21
|
interface EventResolvePath {
|
|
34
22
|
}
|
|
35
23
|
}
|
|
24
|
+
/** event: end */
|
|
25
|
+
/** event: begin */
|
|
26
|
+
import type { EventResolvePath } from '../bean/event.resolvePath.ts';
|
|
36
27
|
export interface IModuleEvent {
|
|
37
|
-
resolvePath: EventResolvePath;
|
|
28
|
+
'resolvePath': EventResolvePath;
|
|
38
29
|
}
|
|
30
|
+
/** event: end */
|
|
31
|
+
/** event: begin */
|
|
32
|
+
import type { TypeEventResolvePathData, TypeEventResolvePathResult } from '../bean/event.resolvePath.ts';
|
|
33
|
+
import type { EventOn } from 'vona-module-a-event';
|
|
39
34
|
declare module 'vona-module-a-event' {
|
|
40
35
|
interface IEventRecord {
|
|
41
36
|
'a-static:resolvePath': EventOn<TypeEventResolvePathData, TypeEventResolvePathResult>;
|
|
42
37
|
}
|
|
43
38
|
}
|
|
39
|
+
/** event: end */
|
|
40
|
+
/** scope: begin */
|
|
41
|
+
import { BeanScopeBase, type BeanScopeUtil } from 'vona';
|
|
44
42
|
export declare class ScopeModuleAStatic extends BeanScopeBase {
|
|
45
43
|
}
|
|
46
44
|
export interface ScopeModuleAStatic {
|
|
47
45
|
util: BeanScopeUtil;
|
|
48
46
|
event: IModuleEvent;
|
|
49
47
|
}
|
|
48
|
+
import 'vona';
|
|
50
49
|
declare module 'vona' {
|
|
51
50
|
interface IBeanScopeRecord {
|
|
52
51
|
'a-static': ScopeModuleAStatic;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,164 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BeanInfo, BeanBase, compose, BeanScopeBase, SymbolModuleBelong } from 'vona';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import staticCache from '@cabloy/koa-static-cache';
|
|
6
|
+
import { isObject, isString } from '@cabloy/utils';
|
|
7
|
+
import range from 'koa-range';
|
|
8
|
+
import { MiddlewareSystem } from 'vona-module-a-aspect';
|
|
9
|
+
import { LRU } from 'ylru';
|
|
10
|
+
import { Event, BeanEventBase } from 'vona-module-a-event';
|
|
11
|
+
import { Scope } from 'vona-module-a-bean';
|
|
12
|
+
|
|
13
|
+
const __ThisModule__ = 'a-static';
|
|
14
|
+
|
|
15
|
+
const SymbolStaticGetFullPathInner = Symbol('SymbolStaticGetFullPathInner');
|
|
16
|
+
|
|
17
|
+
var _dec$2, _dec2$2, _class$2;
|
|
18
|
+
let MiddlewareSystemStatic = (_dec$2 = MiddlewareSystem({
|
|
19
|
+
dependencies: 'a-instance:appReady',
|
|
20
|
+
apiStaticPrefix: '/api/static/',
|
|
21
|
+
dirs: [],
|
|
22
|
+
dynamic: true,
|
|
23
|
+
preload: false,
|
|
24
|
+
maxFiles: 1000,
|
|
25
|
+
alias: {
|
|
26
|
+
'/favicon.ico': '/api/static/home/index/img/vona.png'
|
|
27
|
+
},
|
|
28
|
+
getFullPath
|
|
29
|
+
// maxAge: undefined,
|
|
30
|
+
// buffer: false,
|
|
31
|
+
// dir: '',
|
|
32
|
+
// prefix: '/', // should be always '/', so as to support ssr site
|
|
33
|
+
}), _dec2$2 = BeanInfo({
|
|
34
|
+
module: "a-static"
|
|
35
|
+
}), _dec$2(_class$2 = _dec2$2(_class$2 = class MiddlewareSystemStatic extends BeanBase {
|
|
36
|
+
constructor(...args) {
|
|
37
|
+
super(...args);
|
|
38
|
+
this._composer = void 0;
|
|
39
|
+
}
|
|
40
|
+
async execute(options, next) {
|
|
41
|
+
return this._getComposer(options)(this.ctx, next);
|
|
42
|
+
}
|
|
43
|
+
_getComposer(options) {
|
|
44
|
+
if (!this._composer) {
|
|
45
|
+
const middlewares = this._createMiddlewares(options);
|
|
46
|
+
this._composer = compose(middlewares);
|
|
47
|
+
}
|
|
48
|
+
return this._composer;
|
|
49
|
+
}
|
|
50
|
+
_createMiddlewares(options) {
|
|
51
|
+
options = Object.assign({
|
|
52
|
+
maxAge: this.app.meta.isProd ? 31536000 : 0,
|
|
53
|
+
buffer: !!this.app.meta.isProd,
|
|
54
|
+
dir: this.app.config.server.publicDir,
|
|
55
|
+
prefix: '/'
|
|
56
|
+
}, options);
|
|
57
|
+
const dirs = (options.dirs || []).concat(options.dir);
|
|
58
|
+
const prefixs = [];
|
|
59
|
+
function rangeMiddleware(ctx, next) {
|
|
60
|
+
// if match static file, and use range middleware.
|
|
61
|
+
const isMatch = prefixs.some(p => ctx.path.startsWith(p));
|
|
62
|
+
if (isMatch) {
|
|
63
|
+
return range(ctx, next);
|
|
64
|
+
}
|
|
65
|
+
return next();
|
|
66
|
+
}
|
|
67
|
+
const middlewares = [rangeMiddleware];
|
|
68
|
+
for (const dirObj of dirs) {
|
|
69
|
+
assert(isObject(dirObj) || isString(dirObj), '`config.static.dir` must be `string | Array<string|object>`.');
|
|
70
|
+
let newOptions;
|
|
71
|
+
if (isString(dirObj)) {
|
|
72
|
+
// copy origin options to new options ensure the safety of objects
|
|
73
|
+
newOptions = Object.assign({}, options, {
|
|
74
|
+
dir: dirObj
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
assert(isString(dirObj.dir), '`config.static.dir` should contains `[].dir` property when object style.');
|
|
78
|
+
newOptions = Object.assign({}, options, dirObj);
|
|
79
|
+
}
|
|
80
|
+
if (newOptions.dynamic && !newOptions.files) {
|
|
81
|
+
newOptions.files = new LRU(newOptions.maxFiles);
|
|
82
|
+
}
|
|
83
|
+
if (newOptions.prefix) {
|
|
84
|
+
prefixs.push(newOptions.prefix);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ensure directory exists
|
|
88
|
+
if (!existsSync(newOptions.dir)) {
|
|
89
|
+
mkdirSync(newOptions.dir, {
|
|
90
|
+
recursive: true
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
middlewares.push(staticCache(newOptions));
|
|
94
|
+
}
|
|
95
|
+
return middlewares;
|
|
96
|
+
}
|
|
97
|
+
}) || _class$2) || _class$2);
|
|
98
|
+
async function getFullPath(ctx, dir, filename, options) {
|
|
99
|
+
if (process.env.META_MODE === 'dev') {
|
|
100
|
+
ctx[SymbolStaticGetFullPathInner] = () => {
|
|
101
|
+
return _getFullPathInner(ctx, dir, filename, options);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const scopeSelf = ctx.app.bean.scope(__ThisModule__);
|
|
105
|
+
return scopeSelf.event.resolvePath.emit({
|
|
106
|
+
dir,
|
|
107
|
+
filename,
|
|
108
|
+
options
|
|
109
|
+
}, ({
|
|
110
|
+
dir,
|
|
111
|
+
filename,
|
|
112
|
+
options
|
|
113
|
+
}) => {
|
|
114
|
+
return _getFullPathInner(ctx, dir, filename, options);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async function _getFullPathInner(ctx, dir, filename, options) {
|
|
118
|
+
// trim prefix
|
|
119
|
+
if (options.apiStaticPrefix !== '/') {
|
|
120
|
+
const filePrefix = path.normalize(options.apiStaticPrefix.replace(/^\//, ''));
|
|
121
|
+
if (filename.indexOf(filePrefix) !== 0) return;
|
|
122
|
+
filename = filename.slice(filePrefix.length);
|
|
123
|
+
}
|
|
124
|
+
// check
|
|
125
|
+
const parts = filename.split(path.sep);
|
|
126
|
+
const wordFirst = parts.shift();
|
|
127
|
+
// public
|
|
128
|
+
if (wordFirst === 'public') {
|
|
129
|
+
const fullPath = path.normalize(path.join(dir, parts.join(path.sep)));
|
|
130
|
+
// files that can be accessd should be under options.dir
|
|
131
|
+
if (fullPath.indexOf(dir) !== 0) return;
|
|
132
|
+
return fullPath;
|
|
133
|
+
}
|
|
134
|
+
// static
|
|
135
|
+
const moduleRelativeName = `${wordFirst}-${parts.shift()}`;
|
|
136
|
+
const module = ctx.app.meta.modules[moduleRelativeName];
|
|
137
|
+
if (!module) return;
|
|
138
|
+
const fullPath = ctx.app.util.getAssetPathPhysical(moduleRelativeName, 'static', parts.join(path.sep));
|
|
139
|
+
return fullPath;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var _dec$1, _dec2$1, _class$1;
|
|
143
|
+
let EventResolvePath = (_dec$1 = Event(), _dec2$1 = BeanInfo({
|
|
144
|
+
module: "a-static"
|
|
145
|
+
}), _dec$1(_class$1 = _dec2$1(_class$1 = class EventResolvePath extends BeanEventBase {}) || _class$1) || _class$1);
|
|
146
|
+
|
|
147
|
+
var _dec, _dec2, _class;
|
|
148
|
+
let ScopeModuleAStatic = (_dec = Scope(), _dec2 = BeanInfo({
|
|
149
|
+
module: "a-static"
|
|
150
|
+
}), _dec(_class = _dec2(_class = class ScopeModuleAStatic extends BeanScopeBase {}) || _class) || _class);
|
|
151
|
+
|
|
152
|
+
/** scope: end */
|
|
153
|
+
|
|
154
|
+
class BeanStaticBase extends BeanBase {
|
|
155
|
+
__get__(prop) {
|
|
156
|
+
if (prop === 'get') {
|
|
157
|
+
return path => {
|
|
158
|
+
return this.app.util.combineStaticPath(path, this[SymbolModuleBelong]);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { BeanStaticBase, EventResolvePath, MiddlewareSystemStatic, ScopeModuleAStatic, SymbolStaticGetFullPathInner };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-static",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.12",
|
|
5
5
|
"title": "a-static",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"dependencies": {},
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"clean": "rimraf dist tsconfig.build.tsbuildinfo",
|
|
46
|
-
"tsc:publish": "npm run clean && tsc -p tsconfig.build.json"
|
|
46
|
+
"tsc:publish": "npm run clean && vona :bin:buildModule && tsc -p tsconfig.build.json"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/dist/.metadata/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
/** event: end */
|
|
8
|
-
/** scope: begin */
|
|
9
|
-
import { BeanScopeBase } from 'vona';
|
|
10
|
-
import { Scope } from 'vona-module-a-bean';
|
|
11
|
-
import 'vona';
|
|
12
|
-
import 'vona';
|
|
13
|
-
import 'vona';
|
|
14
|
-
export * from "../bean/event.resolvePath.js";
|
|
15
|
-
/** middlewareSystem: begin */
|
|
16
|
-
export * from "../bean/middlewareSystem.static.js";
|
|
17
|
-
let ScopeModuleAStatic = class ScopeModuleAStatic extends BeanScopeBase {
|
|
18
|
-
};
|
|
19
|
-
ScopeModuleAStatic = __decorate([
|
|
20
|
-
Scope()
|
|
21
|
-
], ScopeModuleAStatic);
|
|
22
|
-
export { ScopeModuleAStatic };
|
|
23
|
-
/** scope: end */
|
package/dist/.metadata/this.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { BeanEventBase, Event } from 'vona-module-a-event';
|
|
8
|
-
let EventResolvePath = class EventResolvePath extends BeanEventBase {
|
|
9
|
-
};
|
|
10
|
-
EventResolvePath = __decorate([
|
|
11
|
-
Event()
|
|
12
|
-
], EventResolvePath);
|
|
13
|
-
export { EventResolvePath };
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import assert from 'node:assert';
|
|
8
|
-
import { existsSync, mkdirSync } from 'node:fs';
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import staticCache from '@cabloy/koa-static-cache';
|
|
11
|
-
import { isObject, isString } from '@cabloy/utils';
|
|
12
|
-
import range from 'koa-range';
|
|
13
|
-
import { BeanBase, compose } from 'vona';
|
|
14
|
-
import { MiddlewareSystem } from 'vona-module-a-aspect';
|
|
15
|
-
import { LRU } from 'ylru';
|
|
16
|
-
import { __ThisModule__ } from "../.metadata/this.js";
|
|
17
|
-
import { SymbolStaticGetFullPathInner } from "../types/static.js";
|
|
18
|
-
let MiddlewareSystemStatic = class MiddlewareSystemStatic extends BeanBase {
|
|
19
|
-
_composer;
|
|
20
|
-
async execute(options, next) {
|
|
21
|
-
return this._getComposer(options)(this.ctx, next);
|
|
22
|
-
}
|
|
23
|
-
_getComposer(options) {
|
|
24
|
-
if (!this._composer) {
|
|
25
|
-
const middlewares = this._createMiddlewares(options);
|
|
26
|
-
this._composer = compose(middlewares);
|
|
27
|
-
}
|
|
28
|
-
return this._composer;
|
|
29
|
-
}
|
|
30
|
-
_createMiddlewares(options) {
|
|
31
|
-
options = Object.assign({
|
|
32
|
-
maxAge: this.app.meta.isProd ? 31536000 : 0,
|
|
33
|
-
buffer: !!this.app.meta.isProd,
|
|
34
|
-
dir: this.app.config.server.publicDir,
|
|
35
|
-
prefix: '/',
|
|
36
|
-
}, options);
|
|
37
|
-
const dirs = (options.dirs || []).concat(options.dir);
|
|
38
|
-
const prefixs = [];
|
|
39
|
-
function rangeMiddleware(ctx, next) {
|
|
40
|
-
// if match static file, and use range middleware.
|
|
41
|
-
const isMatch = prefixs.some(p => ctx.path.startsWith(p));
|
|
42
|
-
if (isMatch) {
|
|
43
|
-
return range(ctx, next);
|
|
44
|
-
}
|
|
45
|
-
return next();
|
|
46
|
-
}
|
|
47
|
-
const middlewares = [rangeMiddleware];
|
|
48
|
-
for (const dirObj of dirs) {
|
|
49
|
-
assert(isObject(dirObj) || isString(dirObj), '`config.static.dir` must be `string | Array<string|object>`.');
|
|
50
|
-
let newOptions;
|
|
51
|
-
if (isString(dirObj)) {
|
|
52
|
-
// copy origin options to new options ensure the safety of objects
|
|
53
|
-
newOptions = Object.assign({}, options, { dir: dirObj });
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
assert(isString(dirObj.dir), '`config.static.dir` should contains `[].dir` property when object style.');
|
|
57
|
-
newOptions = Object.assign({}, options, dirObj);
|
|
58
|
-
}
|
|
59
|
-
if (newOptions.dynamic && !newOptions.files) {
|
|
60
|
-
newOptions.files = new LRU(newOptions.maxFiles);
|
|
61
|
-
}
|
|
62
|
-
if (newOptions.prefix) {
|
|
63
|
-
prefixs.push(newOptions.prefix);
|
|
64
|
-
}
|
|
65
|
-
// ensure directory exists
|
|
66
|
-
if (!existsSync(newOptions.dir)) {
|
|
67
|
-
mkdirSync(newOptions.dir, { recursive: true });
|
|
68
|
-
}
|
|
69
|
-
middlewares.push(staticCache(newOptions));
|
|
70
|
-
}
|
|
71
|
-
return middlewares;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
MiddlewareSystemStatic = __decorate([
|
|
75
|
-
MiddlewareSystem({
|
|
76
|
-
dependencies: 'a-instance:appReady',
|
|
77
|
-
apiStaticPrefix: '/api/static/',
|
|
78
|
-
dirs: [],
|
|
79
|
-
dynamic: true,
|
|
80
|
-
preload: false,
|
|
81
|
-
maxFiles: 1000,
|
|
82
|
-
alias: {
|
|
83
|
-
'/favicon.ico': '/api/static/home/index/img/vona.png',
|
|
84
|
-
},
|
|
85
|
-
getFullPath,
|
|
86
|
-
// maxAge: undefined,
|
|
87
|
-
// buffer: false,
|
|
88
|
-
// dir: '',
|
|
89
|
-
// prefix: '/', // should be always '/', so as to support ssr site
|
|
90
|
-
})
|
|
91
|
-
], MiddlewareSystemStatic);
|
|
92
|
-
export { MiddlewareSystemStatic };
|
|
93
|
-
async function getFullPath(ctx, dir, filename, options) {
|
|
94
|
-
if (process.env.META_MODE === 'local') {
|
|
95
|
-
ctx[SymbolStaticGetFullPathInner] = () => {
|
|
96
|
-
return _getFullPathInner(ctx, dir, filename, options);
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
const scopeSelf = ctx.app.bean.scope(__ThisModule__);
|
|
100
|
-
return scopeSelf.event.resolvePath.emit({ dir, filename, options }, ({ dir, filename, options }) => {
|
|
101
|
-
return _getFullPathInner(ctx, dir, filename, options);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
async function _getFullPathInner(ctx, dir, filename, options) {
|
|
105
|
-
// trim prefix
|
|
106
|
-
if (options.apiStaticPrefix !== '/') {
|
|
107
|
-
const filePrefix = path.normalize(options.apiStaticPrefix.replace(/^\//, ''));
|
|
108
|
-
if (filename.indexOf(filePrefix) !== 0)
|
|
109
|
-
return;
|
|
110
|
-
filename = filename.slice(filePrefix.length);
|
|
111
|
-
}
|
|
112
|
-
// check
|
|
113
|
-
const parts = filename.split(path.sep);
|
|
114
|
-
const wordFirst = parts.shift();
|
|
115
|
-
// public
|
|
116
|
-
if (wordFirst === 'public') {
|
|
117
|
-
const fullPath = path.normalize(path.join(dir, parts.join(path.sep)));
|
|
118
|
-
// files that can be accessd should be under options.dir
|
|
119
|
-
if (fullPath.indexOf(dir) !== 0)
|
|
120
|
-
return;
|
|
121
|
-
return fullPath;
|
|
122
|
-
}
|
|
123
|
-
// static
|
|
124
|
-
const moduleRelativeName = `${wordFirst}-${parts.shift()}`;
|
|
125
|
-
const module = ctx.app.meta.modules[moduleRelativeName];
|
|
126
|
-
if (!module)
|
|
127
|
-
return;
|
|
128
|
-
const fullPath = ctx.app.util.getAssetPathPhysical(moduleRelativeName, 'static', parts.join(path.sep));
|
|
129
|
-
return fullPath;
|
|
130
|
-
}
|
package/dist/lib/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./beanStaticBase.js";
|
package/dist/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./static.js";
|
package/dist/types/static.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const SymbolStaticGetFullPathInner = Symbol('SymbolStaticGetFullPathInner');
|