@celljs/vite 0.0.0-stage → 4.0.0
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/README.md +29 -2
- package/assets/favicon.ico +0 -0
- package/lib/builder/cell-builder.d.ts +19 -0
- package/lib/builder/cell-builder.d.ts.map +1 -0
- package/lib/builder/cell-builder.js +59 -0
- package/lib/builder/cell-builder.js.map +1 -0
- package/lib/builder/cell-builder.spec.d.ts +2 -0
- package/lib/builder/cell-builder.spec.d.ts.map +1 -0
- package/lib/builder/cell-builder.spec.js +280 -0
- package/lib/builder/cell-builder.spec.js.map +1 -0
- package/lib/constants.d.ts +24 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +23 -0
- package/lib/constants.js.map +1 -0
- package/lib/dev/cell-dev-server.d.ts +113 -0
- package/lib/dev/cell-dev-server.d.ts.map +1 -0
- package/lib/dev/cell-dev-server.js +307 -0
- package/lib/dev/cell-dev-server.js.map +1 -0
- package/lib/dev/cell-dev-server.spec.d.ts +2 -0
- package/lib/dev/cell-dev-server.spec.d.ts.map +1 -0
- package/lib/dev/cell-dev-server.spec.js +188 -0
- package/lib/dev/cell-dev-server.spec.js.map +1 -0
- package/lib/expression/expression-evaluator.d.ts +24 -0
- package/lib/expression/expression-evaluator.d.ts.map +1 -0
- package/lib/expression/expression-evaluator.js +97 -0
- package/lib/expression/expression-evaluator.js.map +1 -0
- package/lib/expression/expression-evaluator.spec.d.ts +2 -0
- package/lib/expression/expression-evaluator.spec.d.ts.map +1 -0
- package/lib/expression/expression-evaluator.spec.js +23 -0
- package/lib/expression/expression-evaluator.spec.js.map +1 -0
- package/lib/generator/config-generator.d.ts +18 -0
- package/lib/generator/config-generator.d.ts.map +1 -0
- package/lib/generator/config-generator.js +45 -0
- package/lib/generator/config-generator.js.map +1 -0
- package/lib/generator/container-generator.d.ts +13 -0
- package/lib/generator/container-generator.d.ts.map +1 -0
- package/lib/generator/container-generator.js +41 -0
- package/lib/generator/container-generator.js.map +1 -0
- package/lib/generator/generator.spec.d.ts +2 -0
- package/lib/generator/generator.spec.d.ts.map +1 -0
- package/lib/generator/generator.spec.js +61 -0
- package/lib/generator/generator.spec.js.map +1 -0
- package/lib/generator/html-generator.d.ts +13 -0
- package/lib/generator/html-generator.d.ts.map +1 -0
- package/lib/generator/html-generator.js +42 -0
- package/lib/generator/html-generator.js.map +1 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/output/asset-embedder.d.ts +19 -0
- package/lib/output/asset-embedder.d.ts.map +1 -0
- package/lib/output/asset-embedder.js +35 -0
- package/lib/output/asset-embedder.js.map +1 -0
- package/lib/output/externals-copier.d.ts +20 -0
- package/lib/output/externals-copier.d.ts.map +1 -0
- package/lib/output/externals-copier.js +62 -0
- package/lib/output/externals-copier.js.map +1 -0
- package/lib/output/externals-copier.spec.d.ts +2 -0
- package/lib/output/externals-copier.spec.d.ts.map +1 -0
- package/lib/output/externals-copier.spec.js +30 -0
- package/lib/output/externals-copier.spec.js.map +1 -0
- package/lib/output/output-writer.d.ts +39 -0
- package/lib/output/output-writer.d.ts.map +1 -0
- package/lib/output/output-writer.js +102 -0
- package/lib/output/output-writer.js.map +1 -0
- package/lib/output/output-writer.spec.d.ts +2 -0
- package/lib/output/output-writer.spec.d.ts.map +1 -0
- package/lib/output/output-writer.spec.js +34 -0
- package/lib/output/output-writer.spec.js.map +1 -0
- package/lib/plugin/cell-plugin.d.ts +134 -0
- package/lib/plugin/cell-plugin.d.ts.map +1 -0
- package/lib/plugin/cell-plugin.js +429 -0
- package/lib/plugin/cell-plugin.js.map +1 -0
- package/lib/plugin/cell-plugin.spec.d.ts +2 -0
- package/lib/plugin/cell-plugin.spec.d.ts.map +1 -0
- package/lib/plugin/cell-plugin.spec.js +74 -0
- package/lib/plugin/cell-plugin.spec.js.map +1 -0
- package/lib/plugin/node-polyfills.d.ts +13 -0
- package/lib/plugin/node-polyfills.d.ts.map +1 -0
- package/lib/plugin/node-polyfills.js +55 -0
- package/lib/plugin/node-polyfills.js.map +1 -0
- package/lib/plugin/node-polyfills.spec.d.ts +2 -0
- package/lib/plugin/node-polyfills.spec.d.ts.map +1 -0
- package/lib/plugin/node-polyfills.spec.js +16 -0
- package/lib/plugin/node-polyfills.spec.js.map +1 -0
- package/lib/project/component-collector.d.ts +32 -0
- package/lib/project/component-collector.d.ts.map +1 -0
- package/lib/project/component-collector.js +93 -0
- package/lib/project/component-collector.js.map +1 -0
- package/lib/project/config-loader.d.ts +16 -0
- package/lib/project/config-loader.d.ts.map +1 -0
- package/lib/project/config-loader.js +76 -0
- package/lib/project/config-loader.js.map +1 -0
- package/lib/project/env-overrides.d.ts +23 -0
- package/lib/project/env-overrides.d.ts.map +1 -0
- package/lib/project/env-overrides.js +48 -0
- package/lib/project/env-overrides.js.map +1 -0
- package/lib/project/env-overrides.spec.d.ts +2 -0
- package/lib/project/env-overrides.spec.d.ts.map +1 -0
- package/lib/project/env-overrides.spec.js +41 -0
- package/lib/project/env-overrides.spec.js.map +1 -0
- package/lib/project/module-resolver.d.ts +15 -0
- package/lib/project/module-resolver.d.ts.map +1 -0
- package/lib/project/module-resolver.js +32 -0
- package/lib/project/module-resolver.js.map +1 -0
- package/lib/project/project-loader.d.ts +54 -0
- package/lib/project/project-loader.d.ts.map +1 -0
- package/lib/project/project-loader.js +117 -0
- package/lib/project/project-loader.js.map +1 -0
- package/lib/project/project-loader.spec.d.ts +2 -0
- package/lib/project/project-loader.spec.d.ts.map +1 -0
- package/lib/project/project-loader.spec.js +178 -0
- package/lib/project/project-loader.spec.js.map +1 -0
- package/lib/test/fixture-project.d.ts +17 -0
- package/lib/test/fixture-project.d.ts.map +1 -0
- package/lib/test/fixture-project.js +43 -0
- package/lib/test/fixture-project.js.map +1 -0
- package/lib/testing/memory-http.d.ts +82 -0
- package/lib/testing/memory-http.d.ts.map +1 -0
- package/lib/testing/memory-http.js +210 -0
- package/lib/testing/memory-http.js.map +1 -0
- package/lib/testing/test-app.d.ts +54 -0
- package/lib/testing/test-app.d.ts.map +1 -0
- package/lib/testing/test-app.js +132 -0
- package/lib/testing/test-app.js.map +1 -0
- package/lib/testing/test-app.spec.d.ts +2 -0
- package/lib/testing/test-app.spec.d.ts.map +1 -0
- package/lib/testing/test-app.spec.js +115 -0
- package/lib/testing/test-app.spec.js.map +1 -0
- package/lib/utils/config-util.d.ts +6 -0
- package/lib/utils/config-util.d.ts.map +1 -0
- package/lib/utils/config-util.js +25 -0
- package/lib/utils/config-util.js.map +1 -0
- package/lib/utils/config-util.spec.d.ts +2 -0
- package/lib/utils/config-util.spec.d.ts.map +1 -0
- package/lib/utils/config-util.spec.js +22 -0
- package/lib/utils/config-util.spec.js.map +1 -0
- package/lib/utils/tsconfig-util.d.ts +5 -0
- package/lib/utils/tsconfig-util.d.ts.map +1 -0
- package/lib/utils/tsconfig-util.js +21 -0
- package/lib/utils/tsconfig-util.js.map +1 -0
- package/package.json +50 -4
- package/src/builder/cell-builder.ts +72 -0
- package/src/constants.ts +30 -0
- package/src/dev/cell-dev-server.ts +387 -0
- package/src/expression/expression-evaluator.ts +106 -0
- package/src/generator/config-generator.ts +45 -0
- package/src/generator/container-generator.ts +41 -0
- package/src/generator/html-generator.ts +43 -0
- package/src/index.ts +20 -0
- package/src/output/asset-embedder.ts +42 -0
- package/src/output/externals-copier.ts +64 -0
- package/src/output/output-writer.ts +113 -0
- package/src/plugin/cell-plugin.ts +481 -0
- package/src/plugin/node-polyfills.ts +57 -0
- package/src/project/component-collector.ts +107 -0
- package/src/project/config-loader.ts +77 -0
- package/src/project/env-overrides.ts +55 -0
- package/src/project/module-resolver.ts +39 -0
- package/src/project/project-loader.ts +153 -0
- package/src/test/fixture-project.ts +50 -0
- package/src/testing/memory-http.ts +238 -0
- package/src/testing/test-app.ts +155 -0
- package/src/utils/config-util.ts +21 -0
- package/src/utils/tsconfig-util.ts +19 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import { existsSync, readFileSync, realpathSync, rmSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
4
|
+
import { CellError, type ModuleRef, type ProjectModel, type ServerRuntime, type Target } from '@celljs/kit';
|
|
5
|
+
import type { ConfigEnv, Plugin, UserConfig, ViteBuilder } from 'vite';
|
|
6
|
+
import { ASSETS_ID, ENTRY_URL, ENVIRONMENT_OF, SINGLE_ENTRY_ID, TARGET_OF, WORKERD_SERVER_FILE } from '../constants.js';
|
|
7
|
+
import { ExpressionEvaluator } from '../expression/expression-evaluator.js';
|
|
8
|
+
import { ConfigGenerator } from '../generator/config-generator.js';
|
|
9
|
+
import { ContainerGenerator } from '../generator/container-generator.js';
|
|
10
|
+
import { HtmlGenerator } from '../generator/html-generator.js';
|
|
11
|
+
import { AssetEmbedder } from '../output/asset-embedder.js';
|
|
12
|
+
import { OutputWriter } from '../output/output-writer.js';
|
|
13
|
+
import { ProjectLoader, type ProjectLoaderOptions } from '../project/project-loader.js';
|
|
14
|
+
import { TsconfigUtil } from '../utils/tsconfig-util.js';
|
|
15
|
+
import { NodePolyfills } from './node-polyfills.js';
|
|
16
|
+
|
|
17
|
+
export interface CellPluginOptions extends ProjectLoaderOptions {
|
|
18
|
+
/** Server bundle format. Default `esm` (`server/index.mjs`); `cjs` emits `server/index.cjs`. */
|
|
19
|
+
format?: 'esm' | 'cjs';
|
|
20
|
+
/** Output directory, relative to the project root. Default `.cell/output`. */
|
|
21
|
+
outDir?: string;
|
|
22
|
+
/** Packages the server bundle must not inline; they are copied into `server/node_modules`. */
|
|
23
|
+
external?: string[];
|
|
24
|
+
sourcemap?: boolean;
|
|
25
|
+
/** Name of the preset that chose the options, recorded in manifest.json. */
|
|
26
|
+
preset?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Runtime of the server bundle. Default `node`. `workerd` (Cloudflare Workers) has no
|
|
29
|
+
* `import.meta.url` / `dirname` / `filename`: the bundle uses {@link WORKERD_SERVER_FILE} instead.
|
|
30
|
+
*/
|
|
31
|
+
runtime?: ServerRuntime;
|
|
32
|
+
/**
|
|
33
|
+
* Embed the frontend in the server bundle (`cell build --single`): the server serves it from
|
|
34
|
+
* memory, and the output has no public directory. Only with both targets.
|
|
35
|
+
*/
|
|
36
|
+
single?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type ResolveContext = { resolve(id: string, importer?: string, options?: { skipSelf?: boolean }): Promise<{ id: string } | null> };
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Turns the component graph into the DI container and configuration of each target and builds the
|
|
43
|
+
* `client` environment (frontend → `<outDir>/public`) and the `server` environment (backend, one
|
|
44
|
+
* file → `<outDir>/server`). Exposed to Vite through {@link cell}.
|
|
45
|
+
*/
|
|
46
|
+
export class CellPlugin {
|
|
47
|
+
protected model: ProjectModel;
|
|
48
|
+
protected root: string;
|
|
49
|
+
protected coreDir: string;
|
|
50
|
+
protected output: OutputWriter;
|
|
51
|
+
protected evaluator: ExpressionEvaluator;
|
|
52
|
+
protected polyfills: NodePolyfills;
|
|
53
|
+
protected command: ConfigEnv['command'] = 'build';
|
|
54
|
+
protected readonly format: 'esm' | 'cjs';
|
|
55
|
+
|
|
56
|
+
constructor(protected readonly options: CellPluginOptions = {}) {
|
|
57
|
+
this.format = options.format ?? 'esm';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get project(): ProjectModel {
|
|
61
|
+
return this.model;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
toVitePlugin(): Plugin {
|
|
65
|
+
const self = this;
|
|
66
|
+
return {
|
|
67
|
+
name: 'cell',
|
|
68
|
+
enforce: 'pre',
|
|
69
|
+
config: (userConfig, env) => this.config(userConfig, env),
|
|
70
|
+
resolveId(id, importer) {
|
|
71
|
+
return self.resolveId(this, this.environment.name, id, importer);
|
|
72
|
+
},
|
|
73
|
+
load(id) {
|
|
74
|
+
return self.load(this, this.environment.name, id);
|
|
75
|
+
},
|
|
76
|
+
transform(code, id) {
|
|
77
|
+
if (self.command === 'build') {
|
|
78
|
+
return CellPlugin.withoutRequireShim(code);
|
|
79
|
+
}
|
|
80
|
+
// In development Node runs the files: Cell packages keep their require shim, sources get one.
|
|
81
|
+
return this.environment.name === 'server' ? CellPlugin.withRequire(code, id) : null;
|
|
82
|
+
},
|
|
83
|
+
renderChunk(code) {
|
|
84
|
+
if (this.environment.name !== 'server' || self.format !== 'esm') {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const withGlobals = CellPlugin.withCommonJsGlobals(code, self.options.runtime) ?? code;
|
|
88
|
+
const result = self.options.runtime === 'workerd' ? withGlobals : CellPlugin.withImportMetaPaths(withGlobals);
|
|
89
|
+
return result === code ? null : result;
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The line `scripts/build-esm.ts` adds to ESM files of Cell packages that call `require`. */
|
|
95
|
+
static readonly REQUIRE_SHIM = /^const require = __cellCreateRequire\(import\.meta\.url\);$/m;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Cell packages built as ES modules keep node-only `require('x')` calls working in Node through a
|
|
99
|
+
* local `const require = createRequire(import.meta.url)`. The bundler cannot see through that local
|
|
100
|
+
* binding, so the required packages would stay outside the bundle and be missing next to it. Drop
|
|
101
|
+
* the shim in the bundle: `require('x')` is then bundled like any other dependency.
|
|
102
|
+
*/
|
|
103
|
+
static withoutRequireShim(code: string): string | null {
|
|
104
|
+
return CellPlugin.REQUIRE_SHIM.test(code) ? code.replace(CellPlugin.REQUIRE_SHIM, '') : null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The module runner of `cell dev` evaluates sources as ES modules, which have no `require`; the
|
|
109
|
+
* bundler of `cell build` accepts `require('x')` next to `import`. Give TypeScript and JavaScript
|
|
110
|
+
* sources outside node_modules that call `require(` a module-local one, as the ESM builds of
|
|
111
|
+
* Cell packages have.
|
|
112
|
+
*/
|
|
113
|
+
static withRequire(code: string, id: string): string | null {
|
|
114
|
+
const file = id.split('?')[0];
|
|
115
|
+
if (!/\.[cm]?[jt]sx?$/.test(file) || file.includes('/node_modules/') || !/(^|[^.\w$])require\s*\(/.test(code)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
if (/(^|\n)\s*(const|let|var|function)\s+require\b/.test(code) || /\bimport\s+require\b/.test(code)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return `import { createRequire as __cellCreateRequire } from 'node:module'; const require = __cellCreateRequire(import.meta.url);${code}`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* CommonJS files of the project (generated clients like prisma's) cannot run as ES modules in the
|
|
126
|
+
* module runner of `cell dev`. Node loads them instead, in the same process, and the module
|
|
127
|
+
* re-exports what they export.
|
|
128
|
+
*/
|
|
129
|
+
static commonJsWrapper(id: string): string | null {
|
|
130
|
+
const file = id.split('?')[0];
|
|
131
|
+
if (!isAbsolute(file) || file.includes('/node_modules/') || !CellPlugin.isCommonJsFile(file)) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const require = createRequire(file);
|
|
135
|
+
delete require.cache[file];
|
|
136
|
+
const exported = require(file) as Record<string, unknown>;
|
|
137
|
+
const names = Object.keys(exported ?? {}).filter(name => /^[A-Za-z_$][\w$]*$/.test(name) && name !== 'default');
|
|
138
|
+
return [
|
|
139
|
+
"import { createRequire } from 'node:module';",
|
|
140
|
+
`const __cellModule = createRequire(import.meta.url)(${JSON.stringify(file)});`,
|
|
141
|
+
'export default __cellModule;',
|
|
142
|
+
...(names.length > 0 ? [`export const { ${names.join(', ')} } = __cellModule;`] : []),
|
|
143
|
+
'',
|
|
144
|
+
].join('\n');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static isCommonJsFile(file: string): boolean {
|
|
148
|
+
if (file.endsWith('.cjs')) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (!file.endsWith('.js') || !existsSync(file)) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
for (let dir = dirname(file); ; dir = dirname(dir)) {
|
|
155
|
+
const manifest = join(dir, 'package.json');
|
|
156
|
+
if (existsSync(manifest)) {
|
|
157
|
+
try {
|
|
158
|
+
if (JSON.parse(readFileSync(manifest, 'utf8')).type === 'module') {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
// An unreadable package.json says nothing about the format.
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
if (dirname(dir) === dir) {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const code = readFileSync(file, 'utf8');
|
|
171
|
+
return /\b(module\.exports|exports\.[\w$]+\s*=|Object\.defineProperty\(exports)/.test(code) && !/(^|\n)\s*(import|export)\s/.test(code);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* CommonJS libraries bundled into the ESM server expect what a CommonJS server gives them: a
|
|
176
|
+
* `require` in scope (prisma loads its engine with `eval('require')`) and `require.main` (app-root-path,
|
|
177
|
+
* used by typeorm, reads `require.main.filename`). Expose the bundle's `__require` as `require`, with
|
|
178
|
+
* the bundle itself as the main module.
|
|
179
|
+
*/
|
|
180
|
+
static withCommonJsGlobals(code: string, runtime: ServerRuntime = 'node'): string | null {
|
|
181
|
+
// Rolldown renames the helper (`__require$1`) when a bundled module declares its own `__require`.
|
|
182
|
+
const declaration = /^var (__require(?:\$\d+)?) = .*createRequire\(import\.meta\.url\).*;$/m.exec(code);
|
|
183
|
+
if (!declaration) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const name = declaration[1];
|
|
187
|
+
const meta = CellPlugin.importMeta(runtime);
|
|
188
|
+
const globals = [
|
|
189
|
+
// Bun's require.main is a read-only accessor: define it on the function instead of assigning.
|
|
190
|
+
`if (!${name}.main) Object.defineProperty(${name}, 'main', { value: { id: '.', filename: ${meta.filename}, path: ${meta.dirname}, exports: {}, loaded: true, children: [], paths: [] }, configurable: true, writable: true });`,
|
|
191
|
+
`var require = ${name};`,
|
|
192
|
+
].join('\n');
|
|
193
|
+
const end = declaration.index + declaration[0].length;
|
|
194
|
+
return `${code.slice(0, declaration.index)}${declaration[0].replace('import.meta.url', meta.url)}\n${globals}${code.slice(end)}`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* `import.meta.dirname` / `filename` exist from Node.js 20.11; the Node.js of FC (20.10) and SCF (18)
|
|
199
|
+
* lack them, so the bundle sets them from `import.meta.url` when they are missing.
|
|
200
|
+
*/
|
|
201
|
+
static withImportMetaPaths(code: string): string {
|
|
202
|
+
if (!code.includes('import.meta.dirname') && !code.includes('import.meta.filename')) {
|
|
203
|
+
return code;
|
|
204
|
+
}
|
|
205
|
+
return [
|
|
206
|
+
'import.meta.filename ??= decodeURIComponent(new URL(import.meta.url).pathname);',
|
|
207
|
+
"import.meta.dirname ??= decodeURIComponent(new URL('.', import.meta.url).pathname).replace(/\\/$/, '');",
|
|
208
|
+
code,
|
|
209
|
+
].join('\n');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* How the server bundle refers to its own location: `import.meta` on Node.js; fixed paths under
|
|
214
|
+
* `/bundle` on workerd, which leaves `import.meta.url` undefined (`createRequire` then throws).
|
|
215
|
+
*/
|
|
216
|
+
static importMeta(runtime: ServerRuntime = 'node'): { url: string; dirname: string; filename: string } {
|
|
217
|
+
if (runtime === 'workerd') {
|
|
218
|
+
return {
|
|
219
|
+
url: JSON.stringify(`file://${WORKERD_SERVER_FILE}`),
|
|
220
|
+
dirname: JSON.stringify(dirname(WORKERD_SERVER_FILE)),
|
|
221
|
+
filename: JSON.stringify(WORKERD_SERVER_FILE),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return { url: 'import.meta.url', dirname: 'import.meta.dirname', filename: 'import.meta.filename' };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
protected config(userConfig: UserConfig, env: ConfigEnv): UserConfig {
|
|
228
|
+
this.command = env.command;
|
|
229
|
+
this.root = realpathSync(resolve(userConfig.root ?? this.options.root ?? process.cwd()));
|
|
230
|
+
const mode = this.options.mode ?? [env.command === 'build' ? 'production' : 'development'];
|
|
231
|
+
this.model = new ProjectLoader({ ...this.options, root: this.root, mode }).load();
|
|
232
|
+
this.coreDir = this.resolveCoreDir();
|
|
233
|
+
this.output = new OutputWriter(this.model, resolve(this.root, this.options.outDir ?? '.cell/output'), this.format, this.options.preset);
|
|
234
|
+
this.evaluator = new ExpressionEvaluator(this.root);
|
|
235
|
+
this.polyfills = new NodePolyfills(this.root);
|
|
236
|
+
this.output.writeGenerated('project.json', `${JSON.stringify(this.model, null, 2)}\n`);
|
|
237
|
+
const nodeEnv = JSON.stringify(env.command === 'build' ? 'production' : 'development');
|
|
238
|
+
if (env.command === 'serve') {
|
|
239
|
+
return this.devConfig(nodeEnv);
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
appType: 'custom',
|
|
243
|
+
publicDir: false,
|
|
244
|
+
base: './',
|
|
245
|
+
oxc: { decorator: { legacy: true, emitDecoratorMetadata: true }, jsx: { runtime: TsconfigUtil.jsxRuntime(this.root) } },
|
|
246
|
+
environments: {
|
|
247
|
+
client: {
|
|
248
|
+
define: { 'process.env.NODE_ENV': nodeEnv, global: 'globalThis' },
|
|
249
|
+
build: {
|
|
250
|
+
outDir: this.output.publicDir,
|
|
251
|
+
emptyOutDir: true,
|
|
252
|
+
sourcemap: this.options.sourcemap ?? false,
|
|
253
|
+
rolldownOptions: { input: { index: this.htmlFile } },
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
server: {
|
|
257
|
+
consumer: 'server',
|
|
258
|
+
define: this.serverDefines(nodeEnv),
|
|
259
|
+
resolve: { noExternal: true },
|
|
260
|
+
build: {
|
|
261
|
+
ssr: this.single ? SINGLE_ENTRY_ID : (this.model.backend?.entry ?? true),
|
|
262
|
+
outDir: this.output.serverDir,
|
|
263
|
+
// Emptied by buildApp: Vite's own emptying reports the removal of large copied
|
|
264
|
+
// externals (server/node_modules) as a slow plugin on every rebuild.
|
|
265
|
+
emptyOutDir: false,
|
|
266
|
+
minify: false,
|
|
267
|
+
sourcemap: this.options.sourcemap ?? false,
|
|
268
|
+
target: 'node20',
|
|
269
|
+
rolldownOptions: {
|
|
270
|
+
external: (id: string) => this.isExternal(id),
|
|
271
|
+
output: { format: this.format, entryFileNames: this.output.serverEntry, codeSplitting: false },
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
builder: { buildApp: builder => this.buildApp(builder) },
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* `cell dev`: the client environment serves the frontend with HMR, the server environment runs the
|
|
282
|
+
* backend in a module runner. Cell packages go through the plugin in both (they must see the
|
|
283
|
+
* generated container and configuration, and share one @celljs/core); other dependencies stay
|
|
284
|
+
* in node_modules: pre-bundled for the browser, loaded by Node for the server.
|
|
285
|
+
*/
|
|
286
|
+
protected devConfig(nodeEnv: string): UserConfig {
|
|
287
|
+
const cellPackages = [/^@celljs\//, ...this.componentNames];
|
|
288
|
+
return {
|
|
289
|
+
appType: 'custom',
|
|
290
|
+
publicDir: false,
|
|
291
|
+
oxc: { decorator: { legacy: true, emitDecoratorMetadata: true }, jsx: { runtime: TsconfigUtil.jsxRuntime(this.root) } },
|
|
292
|
+
environments: {
|
|
293
|
+
client: {
|
|
294
|
+
define: { 'process.env.NODE_ENV': nodeEnv, global: 'globalThis' },
|
|
295
|
+
optimizeDeps: { exclude: ['@celljs/core', ...this.componentNames] },
|
|
296
|
+
},
|
|
297
|
+
server: {
|
|
298
|
+
consumer: 'server',
|
|
299
|
+
define: { 'process.env.NODE_ENV': nodeEnv },
|
|
300
|
+
resolve: { noExternal: cellPackages },
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** Components of the project other than itself. */
|
|
307
|
+
protected get componentNames(): string[] {
|
|
308
|
+
return this.model.components.filter(c => !c.root).map(c => c.name);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** A file of the public directory that is copied, not built (favicon, component assets); see {@link OutputWriter.frontendFile}. */
|
|
312
|
+
frontendFile(path: string): string | undefined {
|
|
313
|
+
return this.output.frontendFile(path);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** The page of the frontend: the project's index.html or the built-in one, with the frontend configuration applied. */
|
|
317
|
+
renderHtml(): string {
|
|
318
|
+
const template = existsSync(this.htmlFile) ? readFileSync(this.htmlFile, 'utf8') : undefined;
|
|
319
|
+
return new HtmlGenerator(this.evaluator).generate(this.model.frontend?.config ?? {}, template);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** `--single` with a frontend and a backend: the frontend goes into the server bundle. */
|
|
323
|
+
protected get single(): boolean {
|
|
324
|
+
return this.options.single === true && this.model.targets.includes('frontend') && this.model.targets.includes('backend');
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** Builds the targets of the project (the frontend first, as a single server embeds it), then writes the files around the bundles. */
|
|
328
|
+
protected async buildApp(builder: ViteBuilder): Promise<void> {
|
|
329
|
+
this.output.clean();
|
|
330
|
+
for (const target of this.model.targets) {
|
|
331
|
+
await builder.build(builder.environments[ENVIRONMENT_OF[target]]);
|
|
332
|
+
if (target === 'frontend') {
|
|
333
|
+
this.output.copyFrontendFiles();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (this.model.targets.includes('backend')) {
|
|
337
|
+
this.output.copyExternals(this.externals);
|
|
338
|
+
}
|
|
339
|
+
if (this.single) {
|
|
340
|
+
rmSync(this.output.publicDir, { recursive: true, force: true });
|
|
341
|
+
}
|
|
342
|
+
this.output.writeManifest(this.single);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
protected resolveId(ctx: ResolveContext, environment: string, id: string, importer?: string) {
|
|
346
|
+
if (environment === 'server') {
|
|
347
|
+
if (this.single && (id === SINGLE_ENTRY_ID || id === ASSETS_ID || id === join(this.root, SINGLE_ENTRY_ID))) {
|
|
348
|
+
return `\0${id === ASSETS_ID ? ASSETS_ID : SINGLE_ENTRY_ID}`;
|
|
349
|
+
}
|
|
350
|
+
// Vite joins a package-specifier entry onto the root; resolve it from the project instead.
|
|
351
|
+
const entry = this.model.backend?.entry;
|
|
352
|
+
const fromEntry = importer === undefined || importer === `\0${SINGLE_ENTRY_ID}`;
|
|
353
|
+
const isEntry = fromEntry && entry !== undefined && (id === entry || id === join(this.root, entry));
|
|
354
|
+
return isEntry ? ctx.resolve(entry, join(this.root, 'package.json'), { skipSelf: true }) : null;
|
|
355
|
+
}
|
|
356
|
+
if (environment !== 'client') {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
if (id === ENTRY_URL || id.endsWith(ENTRY_URL)) {
|
|
360
|
+
const entry = this.model.frontend?.entry;
|
|
361
|
+
return entry ? ctx.resolve(entry, join(this.root, 'package.json'), { skipSelf: true }) : null;
|
|
362
|
+
}
|
|
363
|
+
if (id === this.htmlFile) {
|
|
364
|
+
return id;
|
|
365
|
+
}
|
|
366
|
+
return this.polyfills.resolve(id) ?? null;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
protected async load(ctx: ResolveContext, environment: string, id: string): Promise<string | null> {
|
|
370
|
+
if (this.command === 'serve' && environment === 'server') {
|
|
371
|
+
const wrapper = CellPlugin.commonJsWrapper(id);
|
|
372
|
+
if (wrapper) {
|
|
373
|
+
return wrapper;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (environment === 'server' && this.single) {
|
|
377
|
+
if (id === `\0${SINGLE_ENTRY_ID}`) {
|
|
378
|
+
// ES modules run their imports in order: the files are registered before the application starts.
|
|
379
|
+
return `import ${JSON.stringify(ASSETS_ID)};\nimport ${JSON.stringify(this.model.backend?.entry)};\n`;
|
|
380
|
+
}
|
|
381
|
+
if (id === `\0${ASSETS_ID}`) {
|
|
382
|
+
return new AssetEmbedder(this.output.publicDir).generate();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
const target = TARGET_OF[environment];
|
|
386
|
+
const targetModel = target && this.model[target];
|
|
387
|
+
if (!targetModel) {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
if (environment === 'client' && id === this.htmlFile) {
|
|
391
|
+
return this.renderHtml();
|
|
392
|
+
}
|
|
393
|
+
if (this.isCoreFile(id, 'common/container/dynamic-container.js')) {
|
|
394
|
+
const code = new ContainerGenerator(target).generate(
|
|
395
|
+
await this.resolveModules(ctx, target, targetModel.staticModules),
|
|
396
|
+
await this.resolveModules(ctx, target, targetModel.modules),
|
|
397
|
+
);
|
|
398
|
+
this.output.writeGenerated(`${target}/container.js`, code);
|
|
399
|
+
return code;
|
|
400
|
+
}
|
|
401
|
+
if (this.isCoreFile(id, 'common/config/dynamic-config.js')) {
|
|
402
|
+
this.output.writeGenerated(`${target}/config.json`, `${JSON.stringify(targetModel.config, null, 2)}\n`);
|
|
403
|
+
const outputDir = this.command === 'serve' ? resolve(this.root, this.options.outDir ?? '.cell/output') : undefined;
|
|
404
|
+
return new ConfigGenerator(target, this.format, outputDir).generate(targetModel.config);
|
|
405
|
+
}
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
protected async resolveModules(ctx: ResolveContext, target: Target, refs: ModuleRef[]): Promise<string[]> {
|
|
410
|
+
const ids: string[] = [];
|
|
411
|
+
for (const ref of refs) {
|
|
412
|
+
const resolved = await ctx.resolve(ref.specifier, ref.importer, { skipSelf: true });
|
|
413
|
+
if (!resolved) {
|
|
414
|
+
throw new CellError({
|
|
415
|
+
code: 'CELL_MODULE_NOT_FOUND',
|
|
416
|
+
message: `Cannot resolve DI module ${ref.specifier} of ${ref.component} for the ${target}.`,
|
|
417
|
+
file: ref.importer,
|
|
418
|
+
hint: 'Build the component first (bun run build), or fix the module path in the `cell` field of its package.json.',
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
ids.push(resolved.id);
|
|
422
|
+
}
|
|
423
|
+
return ids;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* CommonJS dependencies inlined into an ES module bundle still reference the free `__dirname` and
|
|
428
|
+
* `__filename`; point them at the bundle file, as a CommonJS bundle would.
|
|
429
|
+
*/
|
|
430
|
+
protected serverDefines(nodeEnv: string): Record<string, string> {
|
|
431
|
+
const defines: Record<string, string> = { 'process.env.NODE_ENV': nodeEnv };
|
|
432
|
+
if (this.format === 'esm') {
|
|
433
|
+
const meta = CellPlugin.importMeta(this.options.runtime);
|
|
434
|
+
defines.__dirname = meta.dirname;
|
|
435
|
+
defines.__filename = meta.filename;
|
|
436
|
+
if (this.options.runtime === 'workerd') {
|
|
437
|
+
defines['import.meta.url'] = meta.url;
|
|
438
|
+
defines['import.meta.dirname'] = meta.dirname;
|
|
439
|
+
defines['import.meta.filename'] = meta.filename;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return defines;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
protected get htmlFile(): string {
|
|
446
|
+
return join(this.root, 'index.html');
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
protected get externals(): string[] {
|
|
450
|
+
return [...new Set([...(this.options.external ?? []), ...this.model.components.flatMap(c => c.optionalDependencies)])];
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
protected isExternal(id: string): boolean {
|
|
454
|
+
return this.externals.some(name => id === name || id.startsWith(`${name}/`));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
protected isCoreFile(id: string, path: string): boolean {
|
|
458
|
+
const file = id.split('?')[0].replace(/\\/g, '/');
|
|
459
|
+
return file.startsWith(this.coreDir) && (file.endsWith(`/esm/${path}`) || file.endsWith(`/lib/${path}`));
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
protected resolveCoreDir(): string {
|
|
463
|
+
try {
|
|
464
|
+
const manifest = createRequire(join(this.root, 'package.json')).resolve('@celljs/core/package.json');
|
|
465
|
+
return realpathSync(dirname(manifest)).replace(/\\/g, '/');
|
|
466
|
+
} catch (cause) {
|
|
467
|
+
throw new CellError({
|
|
468
|
+
code: 'CELL_CORE_NOT_FOUND',
|
|
469
|
+
message: 'The project does not depend on @celljs/core.',
|
|
470
|
+
file: join(this.root, 'package.json'),
|
|
471
|
+
hint: 'Add @celljs/core to dependencies and install.',
|
|
472
|
+
cause,
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** The Cell Vite plugin: `plugins: [cell()]` in vite.config.ts, then `vite build`. */
|
|
479
|
+
export function cell(options: CellPluginOptions = {}): Plugin {
|
|
480
|
+
return new CellPlugin(options).toVitePlugin();
|
|
481
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Browser replacements for Node built-ins, limited to the polyfill packages the project has
|
|
6
|
+
* installed; the toolchain itself ships none (docs/design/architecture.md, dependency policy).
|
|
7
|
+
*/
|
|
8
|
+
export class NodePolyfills {
|
|
9
|
+
static readonly PACKAGES: Record<string, string> = {
|
|
10
|
+
assert: 'assert/',
|
|
11
|
+
buffer: 'buffer/',
|
|
12
|
+
constants: 'constants-browserify',
|
|
13
|
+
crypto: 'crypto-browserify',
|
|
14
|
+
events: 'events/',
|
|
15
|
+
http: 'stream-http',
|
|
16
|
+
https: 'https-browserify',
|
|
17
|
+
os: 'os-browserify/browser',
|
|
18
|
+
path: 'path-browserify',
|
|
19
|
+
process: 'process/browser',
|
|
20
|
+
punycode: 'punycode/',
|
|
21
|
+
querystring: 'querystring-es3',
|
|
22
|
+
stream: 'stream-browserify',
|
|
23
|
+
string_decoder: 'string_decoder/',
|
|
24
|
+
timers: 'timers-browserify',
|
|
25
|
+
tty: 'tty-browserify',
|
|
26
|
+
url: 'url/',
|
|
27
|
+
util: 'util/',
|
|
28
|
+
vm: 'vm-browserify',
|
|
29
|
+
zlib: 'browserify-zlib',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
protected readonly resolved = new Map<string, string | undefined>();
|
|
33
|
+
protected readonly require: NodeJS.Require;
|
|
34
|
+
|
|
35
|
+
constructor(root: string) {
|
|
36
|
+
this.require = createRequire(join(root, 'package.json'));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** File of the polyfill for `id` (`buffer` or `node:buffer`), if one is installed. */
|
|
40
|
+
resolve(id: string): string | undefined {
|
|
41
|
+
const name = id.startsWith('node:') ? id.slice(5) : id;
|
|
42
|
+
const spec = NodePolyfills.PACKAGES[name];
|
|
43
|
+
if (!spec) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
if (!this.resolved.has(name)) {
|
|
47
|
+
let file: string | undefined;
|
|
48
|
+
try {
|
|
49
|
+
file = this.require.resolve(spec);
|
|
50
|
+
} catch {
|
|
51
|
+
file = undefined;
|
|
52
|
+
}
|
|
53
|
+
this.resolved.set(name, file);
|
|
54
|
+
}
|
|
55
|
+
return this.resolved.get(name);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { CellError, type ComponentInfo, type ComponentManifest } from '@celljs/kit';
|
|
5
|
+
|
|
6
|
+
export interface PackageJson {
|
|
7
|
+
name: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
dependencies?: Record<string, string>;
|
|
10
|
+
cell?: ComponentManifest;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface Component extends ComponentInfo {
|
|
14
|
+
manifest: ComponentManifest;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Finds the components of a project: every package reachable through `dependencies` whose
|
|
19
|
+
* package.json has a `cell` field, plus the project itself. Dependencies come before dependents
|
|
20
|
+
* (depth-first, in declaration order), so later components override earlier ones.
|
|
21
|
+
*/
|
|
22
|
+
export class ComponentCollector {
|
|
23
|
+
protected readonly visited = new Set<string>();
|
|
24
|
+
protected readonly sorted: Component[] = [];
|
|
25
|
+
protected readonly skipped: string[] = [];
|
|
26
|
+
|
|
27
|
+
/** @param disabled components to leave out, together with the dependencies only they lead to. */
|
|
28
|
+
constructor(
|
|
29
|
+
protected readonly root: string,
|
|
30
|
+
protected readonly disabled: ReadonlySet<string> = new Set(),
|
|
31
|
+
) {}
|
|
32
|
+
|
|
33
|
+
/** Disabled components that were found (and left out) during {@link collect}. */
|
|
34
|
+
get excluded(): readonly string[] {
|
|
35
|
+
return this.skipped;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static readPackageJson(file: string): PackageJson {
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(readFileSync(file, 'utf8')) as PackageJson;
|
|
41
|
+
} catch (cause) {
|
|
42
|
+
throw new CellError({
|
|
43
|
+
code: 'CELL_PACKAGE_JSON_INVALID',
|
|
44
|
+
message: `Cannot read ${file}.`,
|
|
45
|
+
file,
|
|
46
|
+
hint: 'Fix the JSON syntax of this package.json.',
|
|
47
|
+
cause,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
collect(): Component[] {
|
|
53
|
+
const pkg = ComponentCollector.readPackageJson(join(this.root, 'package.json'));
|
|
54
|
+
this.visit(pkg, this.root);
|
|
55
|
+
this.sorted.push(this.createComponent(pkg, this.root, true));
|
|
56
|
+
return this.sorted;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected visit(pkg: PackageJson, from: string): void {
|
|
60
|
+
const require = createRequire(join(from, 'package.json'));
|
|
61
|
+
for (const name of Object.keys(pkg.dependencies ?? {})) {
|
|
62
|
+
if (this.visited.has(name)) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
this.visited.add(name);
|
|
66
|
+
const manifestPath = this.resolveManifest(require, name);
|
|
67
|
+
if (!manifestPath) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const dep = ComponentCollector.readPackageJson(manifestPath);
|
|
71
|
+
if (!dep.cell) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (this.disabled.has(name)) {
|
|
75
|
+
this.skipped.push(name);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const dir = realpathSync(dirname(manifestPath));
|
|
79
|
+
this.visit(dep, dir);
|
|
80
|
+
this.sorted.push(this.createComponent(dep, dir, false));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
protected resolveManifest(require: NodeJS.Require, name: string): string | undefined {
|
|
85
|
+
try {
|
|
86
|
+
return require.resolve(`${name}/package.json`);
|
|
87
|
+
} catch {
|
|
88
|
+
return undefined; // not installed, or package.json not exported: not a Cell component
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected createComponent(pkg: PackageJson, dir: string, root: boolean): Component {
|
|
93
|
+
const manifest = pkg.cell ?? {};
|
|
94
|
+
return {
|
|
95
|
+
name: pkg.name,
|
|
96
|
+
version: pkg.version ?? '0.0.0',
|
|
97
|
+
dir,
|
|
98
|
+
root,
|
|
99
|
+
configFiles: [],
|
|
100
|
+
optionalDependencies: manifest.optionalDependencies ?? [],
|
|
101
|
+
targets: manifest.targets ?? [],
|
|
102
|
+
entries: manifest.entries ?? {},
|
|
103
|
+
...(manifest.toolchain ? { toolchain: manifest.toolchain } : {}),
|
|
104
|
+
manifest,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|