@noego/forge 0.0.11 → 0.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/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.mjs +113 -117
- package/dist/client.mjs.map +1 -1
- package/dist/options/ServerOptions.cjs +28 -0
- package/dist/options/ServerOptions.cjs.map +1 -0
- package/dist/options/ServerOptions.d.ts +19 -0
- package/dist/options/ServerOptions.mjs +21 -0
- package/dist/options/ServerOptions.mjs.map +1 -0
- package/dist/options/assets.cjs +42 -0
- package/dist/options/assets.cjs.map +1 -0
- package/dist/options/assets.d.ts +46 -0
- package/dist/options/assets.mjs +38 -0
- package/dist/options/assets.mjs.map +1 -0
- package/dist/plugins/serverOnlyStub.d.ts +6 -0
- package/dist/plugins-cjs/index.plugins.js +9 -0
- package/dist/plugins-cjs/index.plugins.js.map +1 -0
- package/dist/plugins-cjs/options/ServerOptions.js +28 -0
- package/dist/plugins-cjs/options/ServerOptions.js.map +1 -0
- package/dist/plugins-cjs/options/assets.js +42 -0
- package/dist/plugins-cjs/options/assets.js.map +1 -0
- package/dist/plugins-cjs/plugins/serverOnlyStub.js +226 -0
- package/dist/plugins-cjs/plugins/serverOnlyStub.js.map +1 -0
- package/dist/plugins-cjs/routing/html_render/html_render.js +62 -0
- package/dist/plugins-cjs/routing/html_render/html_render.js.map +1 -0
- package/dist/plugins-cjs/stubs/server-only.js +10 -0
- package/dist/plugins-cjs/stubs/server-only.js.map +1 -0
- package/dist/plugins-es/index.plugins.d.ts +2 -0
- package/dist/plugins-es/index.plugins.js +2 -0
- package/dist/plugins-es/index.plugins.js.map +1 -0
- package/dist/plugins-es/options/ServerOptions.d.ts +19 -0
- package/dist/plugins-es/options/ServerOptions.js +21 -0
- package/dist/plugins-es/options/ServerOptions.js.map +1 -0
- package/dist/plugins-es/options/assets.d.ts +46 -0
- package/dist/plugins-es/options/assets.js +38 -0
- package/dist/plugins-es/options/assets.js.map +1 -0
- package/dist/plugins-es/plugins/serverOnlyStub.d.ts +6 -0
- package/dist/plugins-es/plugins/serverOnlyStub.js +200 -0
- package/dist/plugins-es/plugins/serverOnlyStub.js.map +1 -0
- package/dist/plugins-es/routing/html_render/html_render.d.ts +19 -0
- package/dist/plugins-es/routing/html_render/html_render.js +53 -0
- package/dist/plugins-es/routing/html_render/html_render.js.map +1 -0
- package/dist/plugins-es/stubs/server-only.d.ts +3 -0
- package/dist/plugins-es/stubs/server-only.js +7 -0
- package/dist/plugins-es/stubs/server-only.js.map +1 -0
- package/dist/routing/html_render/html_render.d.ts +19 -0
- package/dist/routing/html_render/html_render.js +53 -0
- package/dist/routing/html_render/html_render.js.map +1 -0
- package/dist-ssr/server.cjs +162 -23
- package/dist-ssr/server.cjs.map +1 -1
- package/dist-ssr/server.js +162 -23
- package/dist-ssr/server.js.map +1 -1
- package/package.json +11 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assets = void 0;
|
|
4
|
+
const toArray = (value) => {
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
return value.filter(Boolean);
|
|
7
|
+
}
|
|
8
|
+
return value ? [value] : [];
|
|
9
|
+
};
|
|
10
|
+
const mergeRecords = (target, additions) => {
|
|
11
|
+
if (!additions) {
|
|
12
|
+
return target;
|
|
13
|
+
}
|
|
14
|
+
for (const [mountPath, value] of Object.entries(additions)) {
|
|
15
|
+
if (value == null) {
|
|
16
|
+
delete target[mountPath];
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const entries = toArray(value);
|
|
20
|
+
if (entries.length === 0) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const existing = target[mountPath] ?? [];
|
|
24
|
+
const merged = new Set([...existing, ...entries]);
|
|
25
|
+
target[mountPath] = Array.from(merged);
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
function assets(overrides = {}, config = {}) {
|
|
30
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
31
|
+
const base = {
|
|
32
|
+
'/assets': ['.hammer/assets']
|
|
33
|
+
};
|
|
34
|
+
if (isProduction) {
|
|
35
|
+
const entries = new Set(base['/assets']);
|
|
36
|
+
base['/assets'] = Array.from(entries);
|
|
37
|
+
}
|
|
38
|
+
mergeRecords(base, overrides);
|
|
39
|
+
return base;
|
|
40
|
+
}
|
|
41
|
+
exports.assets = assets;
|
|
42
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../../src/options/assets.ts"],"names":[],"mappings":";;;AA8CA,MAAM,OAAO,GAAG,CAAC,KAAwB,EAAY,EAAE;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CACjB,MAAgC,EAChC,SAAgC,EAClC,EAAE;IACA,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACzD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC;YACzB,SAAS;QACb,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,SAAS;QACb,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,SAAgB,MAAM,CAClB,YAAkC,EAAE,EACpC,SAA4B,EAAE;IAE9B,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IAE3D,MAAM,IAAI,GAA6B;QACnC,SAAS,EAAE,CAAC,gBAAgB,CAAC;KAChC,CAAC;IAEF,IAAI,YAAY,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAE9B,OAAO,IAAI,CAAC;AAChB,CAAC;AAlBD,wBAkBC"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
// src/plugins/serverOnlyStub.ts
|
|
27
|
+
const fs = __importStar(require("node:fs"));
|
|
28
|
+
const path = __importStar(require("node:path"));
|
|
29
|
+
const es_module_lexer_1 = require("es-module-lexer");
|
|
30
|
+
const DEFAULT_STUB = `export const __server_only__ = true;
|
|
31
|
+
|
|
32
|
+
const __serverOnlyThrow = (name) => {
|
|
33
|
+
throw new Error('[server-only] Client tried to access: ' + name);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const __serverOnlyProxy = new Proxy(() => {
|
|
37
|
+
__serverOnlyThrow('default export');
|
|
38
|
+
}, {
|
|
39
|
+
get(_t, prop) {
|
|
40
|
+
if (prop === Symbol.toStringTag) return 'ServerOnlyStub';
|
|
41
|
+
if (prop === 'toString') return () => 'ServerOnlyStub';
|
|
42
|
+
__serverOnlyThrow('default export.' + String(prop));
|
|
43
|
+
},
|
|
44
|
+
apply() {
|
|
45
|
+
__serverOnlyThrow('default export');
|
|
46
|
+
},
|
|
47
|
+
construct() {
|
|
48
|
+
__serverOnlyThrow('default export');
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export default __serverOnlyProxy;
|
|
53
|
+
`;
|
|
54
|
+
const stubCache = new Map();
|
|
55
|
+
function toArray(value) {
|
|
56
|
+
return Array.isArray(value) ? value : [value];
|
|
57
|
+
}
|
|
58
|
+
function resolvePath(root, input) {
|
|
59
|
+
return path.isAbsolute(input) ? input : path.resolve(root, input);
|
|
60
|
+
}
|
|
61
|
+
function normalise(realPathCandidate) {
|
|
62
|
+
return fs.realpathSync(realPathCandidate);
|
|
63
|
+
}
|
|
64
|
+
function categoriseTargets(root, include) {
|
|
65
|
+
const files = new Set();
|
|
66
|
+
const dirs = [];
|
|
67
|
+
for (const entry of toArray(include)) {
|
|
68
|
+
const abs = resolvePath(root, entry);
|
|
69
|
+
if (!fs.existsSync(abs)) {
|
|
70
|
+
throw new Error(`[serverOnlyStub] include path not found: ${entry}`);
|
|
71
|
+
}
|
|
72
|
+
const stat = fs.statSync(abs);
|
|
73
|
+
const real = normalise(abs);
|
|
74
|
+
if (stat.isDirectory()) {
|
|
75
|
+
dirs.push(real);
|
|
76
|
+
}
|
|
77
|
+
else if (stat.isFile()) {
|
|
78
|
+
files.add(real);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw new Error(`[serverOnlyStub] include must be a file or directory: ${entry}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { files, dirs };
|
|
85
|
+
}
|
|
86
|
+
function pickStub(root, stubFile) {
|
|
87
|
+
if (!stubFile)
|
|
88
|
+
return null;
|
|
89
|
+
const abs = resolvePath(root, stubFile);
|
|
90
|
+
if (!fs.existsSync(abs)) {
|
|
91
|
+
throw new Error(`[serverOnlyStub] stubFile not found: ${stubFile}`);
|
|
92
|
+
}
|
|
93
|
+
return fs.readFileSync(abs, 'utf8');
|
|
94
|
+
}
|
|
95
|
+
function normaliseLoadedId(root, id) {
|
|
96
|
+
const base = id.split('?')[0];
|
|
97
|
+
const withoutFsPrefix = base.startsWith('/@fs/') ? base.slice(4) : base;
|
|
98
|
+
const candidate = path.isAbsolute(withoutFsPrefix) ? withoutFsPrefix : path.resolve(root, withoutFsPrefix);
|
|
99
|
+
try {
|
|
100
|
+
return normalise(candidate);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function toDisplayPath(root, filePath) {
|
|
107
|
+
const rel = path.relative(root, filePath);
|
|
108
|
+
if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) {
|
|
109
|
+
return rel.split(path.sep).join('/');
|
|
110
|
+
}
|
|
111
|
+
return filePath.split(path.sep).join('/');
|
|
112
|
+
}
|
|
113
|
+
function extractExportInfo(code, id) {
|
|
114
|
+
const [, exportEntries] = (0, es_module_lexer_1.parse)(code, id);
|
|
115
|
+
let hasDefault = false;
|
|
116
|
+
let hasStar = false;
|
|
117
|
+
const named = new Set();
|
|
118
|
+
for (const entry of exportEntries) {
|
|
119
|
+
const exportedName = entry.n;
|
|
120
|
+
if (exportedName === 'default') {
|
|
121
|
+
hasDefault = true;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (exportedName === '*') {
|
|
125
|
+
hasStar = true;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (exportedName) {
|
|
129
|
+
named.add(exportedName);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return { hasDefault, named: Array.from(named).sort(), hasStar };
|
|
133
|
+
}
|
|
134
|
+
function buildDynamicStub(moduleDisplay, info) {
|
|
135
|
+
if (info.hasStar) {
|
|
136
|
+
return DEFAULT_STUB;
|
|
137
|
+
}
|
|
138
|
+
const lines = [];
|
|
139
|
+
lines.push('export const __server_only__ = true;');
|
|
140
|
+
lines.push(`const __serverOnlyModuleId = ${JSON.stringify(moduleDisplay)};`);
|
|
141
|
+
lines.push(`function __serverOnlyFailure(name) { throw new Error('[server-only] Client tried to access: ' + __serverOnlyModuleId + (name ? ' -> ' + name : '')); }`);
|
|
142
|
+
lines.push('function __createServerOnlyStub(name) {');
|
|
143
|
+
lines.push(' const label = name ?? "default export";');
|
|
144
|
+
lines.push(' const fn = function () { __serverOnlyFailure(label); };');
|
|
145
|
+
lines.push(' return new Proxy(fn, {');
|
|
146
|
+
lines.push(' get(_target, prop) {');
|
|
147
|
+
lines.push(' if (prop === Symbol.toStringTag) return "ServerOnlyStub";');
|
|
148
|
+
lines.push(' if (prop === "toString") return () => "ServerOnlyStub";');
|
|
149
|
+
lines.push(' __serverOnlyFailure(label + "." + String(prop));');
|
|
150
|
+
lines.push(' },');
|
|
151
|
+
lines.push(' apply() { __serverOnlyFailure(label); },');
|
|
152
|
+
lines.push(' construct() { __serverOnlyFailure(label); }');
|
|
153
|
+
lines.push(' });');
|
|
154
|
+
lines.push('}');
|
|
155
|
+
for (const name of info.named) {
|
|
156
|
+
lines.push(`export const ${name} = __createServerOnlyStub(${JSON.stringify(name)});`);
|
|
157
|
+
}
|
|
158
|
+
if (info.hasDefault) {
|
|
159
|
+
lines.push('const __defaultExport = __createServerOnlyStub("default export");');
|
|
160
|
+
lines.push('export default __defaultExport;');
|
|
161
|
+
}
|
|
162
|
+
return lines.join('\n');
|
|
163
|
+
}
|
|
164
|
+
function generateStubForFile(root, filePath) {
|
|
165
|
+
try {
|
|
166
|
+
const stat = fs.statSync(filePath);
|
|
167
|
+
const cached = stubCache.get(filePath);
|
|
168
|
+
if (cached && cached.mtimeMs === stat.mtimeMs) {
|
|
169
|
+
return cached.code;
|
|
170
|
+
}
|
|
171
|
+
const source = fs.readFileSync(filePath, 'utf8');
|
|
172
|
+
let code;
|
|
173
|
+
try {
|
|
174
|
+
const info = extractExportInfo(source, filePath);
|
|
175
|
+
code = buildDynamicStub(toDisplayPath(root, filePath), info);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
code = DEFAULT_STUB;
|
|
179
|
+
}
|
|
180
|
+
stubCache.set(filePath, { mtimeMs: stat.mtimeMs, code });
|
|
181
|
+
return code;
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return DEFAULT_STUB;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function serverOnlyStub(options) {
|
|
188
|
+
if (!options?.include) {
|
|
189
|
+
throw new TypeError('[serverOnlyStub] include is required.');
|
|
190
|
+
}
|
|
191
|
+
let rootDir = process.cwd();
|
|
192
|
+
let targets = { files: new Set(), dirs: [] };
|
|
193
|
+
let customStub = null;
|
|
194
|
+
let parserReady = false;
|
|
195
|
+
return {
|
|
196
|
+
name: 'server-only-stub',
|
|
197
|
+
enforce: 'pre',
|
|
198
|
+
async configResolved(config) {
|
|
199
|
+
rootDir = config.root ?? rootDir;
|
|
200
|
+
targets = categoriseTargets(rootDir, options.include);
|
|
201
|
+
customStub = pickStub(rootDir, options.stubFile);
|
|
202
|
+
if (!options.stubFile && !parserReady) {
|
|
203
|
+
await es_module_lexer_1.init;
|
|
204
|
+
parserReady = true;
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
async load(id, loadOptions) {
|
|
208
|
+
if (loadOptions?.ssr)
|
|
209
|
+
return null;
|
|
210
|
+
const realId = normaliseLoadedId(rootDir, id);
|
|
211
|
+
if (!realId)
|
|
212
|
+
return null;
|
|
213
|
+
if (targets.files.has(realId)) {
|
|
214
|
+
return customStub ?? generateStubForFile(rootDir, realId);
|
|
215
|
+
}
|
|
216
|
+
for (const dir of targets.dirs) {
|
|
217
|
+
if (realId === dir || realId.startsWith(dir + path.sep)) {
|
|
218
|
+
return customStub ?? generateStubForFile(rootDir, realId);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
exports.default = serverOnlyStub;
|
|
226
|
+
//# sourceMappingURL=serverOnlyStub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverOnlyStub.js","sourceRoot":"","sources":["../../../src/plugins/serverOnlyStub.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gCAAgC;AAChC,4CAA8B;AAC9B,gDAAkC;AAElC,qDAA8C;A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AAC;gBAC5D,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AA1CD,iCA0CC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LiveHTMLRender = exports.DefaultHTMLRender = exports.BaseHTMLRender = void 0;
|
|
7
|
+
const handlebars_1 = __importDefault(require("handlebars"));
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const default_template = `
|
|
10
|
+
<!DOCTYPE html>
|
|
11
|
+
<html lang="en">
|
|
12
|
+
<head>
|
|
13
|
+
{{{HEAD}}}
|
|
14
|
+
<style>{{{CSS}}}</style>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="app">{{{APP}}}</div>
|
|
18
|
+
<script>window.__INITIAL_DATA__ = {{{DATA}}}</script>
|
|
19
|
+
|
|
20
|
+
<script type="module">
|
|
21
|
+
import { createApp } from '/src/client/client.ts';
|
|
22
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
23
|
+
createApp('/components/');
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
|
28
|
+
`;
|
|
29
|
+
class BaseHTMLRender {
|
|
30
|
+
constructor(template = default_template) {
|
|
31
|
+
this.template = template;
|
|
32
|
+
}
|
|
33
|
+
async getTemplate() {
|
|
34
|
+
return this.template;
|
|
35
|
+
}
|
|
36
|
+
async renderHTML(data) {
|
|
37
|
+
const template = handlebars_1.default.compile(await this.getTemplate());
|
|
38
|
+
return template(data);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.BaseHTMLRender = BaseHTMLRender;
|
|
42
|
+
class DefaultHTMLRender extends BaseHTMLRender {
|
|
43
|
+
constructor() {
|
|
44
|
+
super();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.DefaultHTMLRender = DefaultHTMLRender;
|
|
48
|
+
class LiveHTMLRender {
|
|
49
|
+
constructor(html_path) {
|
|
50
|
+
this.html_path = html_path;
|
|
51
|
+
}
|
|
52
|
+
async renderHTML(data) {
|
|
53
|
+
const template = handlebars_1.default.compile(await this.getTemplate());
|
|
54
|
+
return template(data);
|
|
55
|
+
}
|
|
56
|
+
async getTemplate() {
|
|
57
|
+
const file_content = await promises_1.default.readFile(this.html_path, 'utf8');
|
|
58
|
+
return file_content;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.LiveHTMLRender = LiveHTMLRender;
|
|
62
|
+
//# sourceMappingURL=html_render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html_render.js","sourceRoot":"","sources":["../../../../src/routing/html_render/html_render.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAmC;AACnC,2DAA4B;AAE5B,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;CAmBxB,CAAA;AAUD,MAAa,cAAc;IACvB,YAAoB,WAAkB,gBAAgB;QAAlC,aAAQ,GAAR,QAAQ,CAA0B;IAEtD,CAAC;IACH,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAEC,KAAK,CAAC,UAAU,CAAC,IAAQ;QACrB,MAAM,QAAQ,GAAG,oBAAU,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;QAC7D,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;CACJ;AAZD,wCAYC;AAED,MAAa,iBAAkB,SAAQ,cAAc;IACjD;QACI,KAAK,EAAE,CAAA;IACX,CAAC;CACJ;AAJD,8CAIC;AAID,MAAa,cAAc;IACzB,YAAoB,SAAgB;QAAhB,cAAS,GAAT,SAAS,CAAO;IACpC,CAAC;IACD,KAAK,CAAC,UAAU,CAAC,IAAS;QACxB,MAAM,QAAQ,GAAG,oBAAU,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;QAC7D,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IACD,KAAK,CAAC,WAAW;QACf,MAAM,YAAY,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC9D,OAAO,YAAY,CAAA;IACrB,CAAC;CACF;AAXD,wCAWC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__server_only__ = void 0;
|
|
4
|
+
exports.__server_only__ = true;
|
|
5
|
+
exports.default = new Proxy({}, {
|
|
6
|
+
get(_t, prop) {
|
|
7
|
+
throw new Error(`[server-only] Client tried to access: ${String(prop)}`);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=server-only.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-only.js","sourceRoot":"","sources":["../../../src/stubs/server-only.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,IAAI,CAAC;AAEpC,kBAAe,IAAI,KAAK,CAAC,EAAE,EAAE;IAC3B,GAAG,CAAC,EAAE,EAAE,IAAI;QACV,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.plugins.js","sourceRoot":"","sources":["../../src/index.plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IHTMLRender } from '../routing/html_render/html_render';
|
|
2
|
+
export { assets } from './assets';
|
|
3
|
+
export type htmlRenderer = 'default' | string | IHTMLRender;
|
|
4
|
+
export type ContextBuilder = (req: any, res: any) => Record<string, any>;
|
|
5
|
+
export interface ServerOptions {
|
|
6
|
+
development?: boolean;
|
|
7
|
+
viteOptions?: any;
|
|
8
|
+
component_dir?: string;
|
|
9
|
+
build_dir?: string;
|
|
10
|
+
renderer?: htmlRenderer;
|
|
11
|
+
open_api_path?: string;
|
|
12
|
+
manifest_path?: string;
|
|
13
|
+
manifest_endpoint?: string;
|
|
14
|
+
assets?: Record<string, string[]>;
|
|
15
|
+
context_builder?: ContextBuilder;
|
|
16
|
+
middleware_path?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const defaultViteOptions: any;
|
|
19
|
+
export declare const defaultOptions: ServerOptions;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export { assets } from './assets';
|
|
3
|
+
export const defaultViteOptions = {
|
|
4
|
+
appType: 'custom',
|
|
5
|
+
root: process.cwd(),
|
|
6
|
+
server: { middlewareMode: true },
|
|
7
|
+
ssr: {
|
|
8
|
+
noExternal: ['svelte', /^svelte\/.*/]
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export const defaultOptions = {
|
|
12
|
+
development: process.env.NODE_ENV !== 'production',
|
|
13
|
+
viteOptions: defaultViteOptions,
|
|
14
|
+
component_dir: '/',
|
|
15
|
+
build_dir: 'dist_ssr',
|
|
16
|
+
renderer: 'default',
|
|
17
|
+
open_api_path: path.join(process.cwd(), 'openapi.yaml'),
|
|
18
|
+
manifest_endpoint: '/manifest.json',
|
|
19
|
+
middleware_path: undefined
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=ServerOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerOptions.js","sourceRoot":"","sources":["../../../src/options/ServerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAmBlC,MAAM,CAAC,MAAM,kBAAkB,GAAQ;IACnC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE;QACD,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAkB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAClD,WAAW,EAAE,kBAAkB;IAC/B,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;IACvD,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,SAAS;CAC7B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface ForgeAssetsOverrides {
|
|
2
|
+
[mountPath: string]: string | string[] | undefined;
|
|
3
|
+
}
|
|
4
|
+
export interface ForgeAssetsConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Indicates whether the build is running in production mode.
|
|
7
|
+
* Defaults to checking NODE_ENV.
|
|
8
|
+
*/
|
|
9
|
+
isProduction?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Directory that contains compiled client assets relative to project root.
|
|
12
|
+
* Defaults to `dist/client`.
|
|
13
|
+
*/
|
|
14
|
+
clientDir?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Directory that contains compiled SSR modules relative to project root.
|
|
17
|
+
* Defaults to `dist/ssr`.
|
|
18
|
+
*/
|
|
19
|
+
ssrDir?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Directory that contains hashed client assets (JS/CSS) relative to project root.
|
|
22
|
+
* Defaults to `<clientDir>/assets`.
|
|
23
|
+
*/
|
|
24
|
+
clientAssetsDir?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Directory that contains UI static resources relative to project root.
|
|
27
|
+
* Defaults to `ui/resources`.
|
|
28
|
+
*/
|
|
29
|
+
resourcesDir?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Directory that contains UI stylesheets relative to project root.
|
|
32
|
+
* Defaults to `ui/styles`.
|
|
33
|
+
*/
|
|
34
|
+
stylesDir?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Extra asset mappings to merge into the generated map.
|
|
37
|
+
*/
|
|
38
|
+
extras?: ForgeAssetsOverrides;
|
|
39
|
+
/**
|
|
40
|
+
* When true, keeps the styles directory mounted in production.
|
|
41
|
+
* Defaults to false (parity with previous behaviour).
|
|
42
|
+
*/
|
|
43
|
+
includeStylesInProduction?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare function assets(overrides?: ForgeAssetsOverrides, config?: ForgeAssetsConfig): Record<string, string[]>;
|
|
46
|
+
export type ForgeAssets = ReturnType<typeof assets>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const toArray = (value) => {
|
|
2
|
+
if (Array.isArray(value)) {
|
|
3
|
+
return value.filter(Boolean);
|
|
4
|
+
}
|
|
5
|
+
return value ? [value] : [];
|
|
6
|
+
};
|
|
7
|
+
const mergeRecords = (target, additions) => {
|
|
8
|
+
if (!additions) {
|
|
9
|
+
return target;
|
|
10
|
+
}
|
|
11
|
+
for (const [mountPath, value] of Object.entries(additions)) {
|
|
12
|
+
if (value == null) {
|
|
13
|
+
delete target[mountPath];
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const entries = toArray(value);
|
|
17
|
+
if (entries.length === 0) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const existing = target[mountPath] ?? [];
|
|
21
|
+
const merged = new Set([...existing, ...entries]);
|
|
22
|
+
target[mountPath] = Array.from(merged);
|
|
23
|
+
}
|
|
24
|
+
return target;
|
|
25
|
+
};
|
|
26
|
+
export function assets(overrides = {}, config = {}) {
|
|
27
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
28
|
+
const base = {
|
|
29
|
+
'/assets': ['.hammer/assets']
|
|
30
|
+
};
|
|
31
|
+
if (isProduction) {
|
|
32
|
+
const entries = new Set(base['/assets']);
|
|
33
|
+
base['/assets'] = Array.from(entries);
|
|
34
|
+
}
|
|
35
|
+
mergeRecords(base, overrides);
|
|
36
|
+
return base;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../../src/options/assets.ts"],"names":[],"mappings":"AA8CA,MAAM,OAAO,GAAG,CAAC,KAAwB,EAAY,EAAE;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CACjB,MAAgC,EAChC,SAAgC,EAClC,EAAE;IACA,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACzD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC;YACzB,SAAS;QACb,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC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