@effindomv2/create-fui-as-app 0.1.5 → 0.1.7

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.
Files changed (68) hide show
  1. package/README.md +26 -0
  2. package/dist/src/templates.js +1 -1
  3. package/dist/src/versions.d.ts +1 -1
  4. package/dist/src/versions.js +1 -1
  5. package/dist/tests/scaffold.test.js +5 -2
  6. package/package.json +5 -4
  7. package/templates/hello/README.md +20 -0
  8. package/{build/templates → templates}/hello/package.json +2 -2
  9. package/{build/templates → templates}/hello/src/App.ts +1 -1
  10. package/{build/templates → templates}/hello/src/HelloWorld.ts +32 -21
  11. package/templates/hello/src/fui/Fui.ts +1 -0
  12. package/templates/hello/src/fui/FuiBrowser.ts +1 -0
  13. package/templates/hello/src/fui/FuiExports.ts +1 -0
  14. package/templates/hello/src/fui/FuiPrimitives.ts +1 -0
  15. package/templates/mvc/README.md +27 -0
  16. package/{build/templates → templates}/mvc/harness.ts +9 -9
  17. package/templates/mvc/index.html +11 -0
  18. package/{build/templates → templates}/mvc/package.json +5 -5
  19. package/{build/templates → templates}/mvc/route-shell.html +2 -2
  20. package/{build/templates → templates}/mvc/scripts/prepare-runtime.ts +4 -4
  21. package/{build/templates → templates}/mvc/scripts/smoke.ts +4 -4
  22. package/templates/mvc/src/fui/Fui.ts +1 -0
  23. package/templates/mvc/src/fui/FuiBrowser.ts +1 -0
  24. package/templates/mvc/src/fui/FuiExports.ts +1 -0
  25. package/templates/mvc/src/fui/FuiPrimitives.ts +1 -0
  26. package/templates/mvc/src/routes/HomeApp.ts +16 -0
  27. package/templates/mvc/src/routes/SettingsApp.ts +16 -0
  28. package/{build/templates/mvc/src/routes/mvc/pages → templates/mvc/src/routes}/home/HomeController.ts +8 -10
  29. package/{build/templates/mvc/src/routes/mvc/pages → templates/mvc/src/routes}/home/HomeView.ts +37 -25
  30. package/{build/templates/mvc/src/routes/mvc/pages → templates/mvc/src/routes}/settings/SettingsController.ts +5 -7
  31. package/templates/mvc/src/routes/settings/SettingsView.ts +73 -0
  32. package/templates/mvc/src/routes/shared/design-system/NavBar.ts +18 -0
  33. package/templates/mvc/src/routes/shared/design-system/NavPill.ts +59 -0
  34. package/{build/templates/mvc/src/routes/mvc/shared/design-system/MvcPrimaryButton.ts → templates/mvc/src/routes/shared/design-system/PrimaryButton.ts} +2 -7
  35. package/{build/templates/mvc/src/routes/mvc → templates/mvc/src/routes}/shared/routes.ts +7 -7
  36. package/build/templates/hello/src/fui/Fui.ts +0 -1
  37. package/build/templates/hello/src/fui/FuiBrowser.ts +0 -1
  38. package/build/templates/hello/src/fui/FuiExports.ts +0 -1
  39. package/build/templates/hello/src/fui/FuiPrimitives.ts +0 -1
  40. package/build/templates/mvc/index.html +0 -11
  41. package/build/templates/mvc/src/fui/Fui.ts +0 -1
  42. package/build/templates/mvc/src/fui/FuiBrowser.ts +0 -1
  43. package/build/templates/mvc/src/fui/FuiExports.ts +0 -1
  44. package/build/templates/mvc/src/fui/FuiPrimitives.ts +0 -1
  45. package/build/templates/mvc/src/routes/mvc/pages/settings/SettingsView.ts +0 -61
  46. package/build/templates/mvc/src/routes/mvc/shared/design-system/MvcNavPill.ts +0 -42
  47. package/build/templates/mvc/src/routes/mvc_home.ts +0 -20
  48. package/build/templates/mvc/src/routes/mvc_settings.ts +0 -20
  49. package/dist/scripts/sync-templates.d.ts +0 -1
  50. package/dist/scripts/sync-templates.js +0 -297
  51. /package/{build/templates → templates}/hello/asconfig.json +0 -0
  52. /package/{build/templates → templates}/hello/harness.ts +0 -0
  53. /package/{build/templates → templates}/hello/index.html +0 -0
  54. /package/{build/templates → templates}/hello/scripts/prepare-runtime.ts +0 -0
  55. /package/{build/templates → templates}/hello/scripts/smoke.ts +0 -0
  56. /package/{build/templates → templates}/hello/src/host/generated/HostEvents.ts +0 -0
  57. /package/{build/templates → templates}/hello/src/host/generated/HostServices.ts +0 -0
  58. /package/{build/templates → templates}/hello/src/host/host-events.ts +0 -0
  59. /package/{build/templates → templates}/hello/src/host/host-services.ts +0 -0
  60. /package/{build/templates → templates}/hello/tsconfig.json +0 -0
  61. /package/{build/templates → templates}/mvc/asconfig.json +0 -0
  62. /package/{build/templates → templates}/mvc/src/host/generated/HostEvents.ts +0 -0
  63. /package/{build/templates → templates}/mvc/src/host/generated/HostServices.ts +0 -0
  64. /package/{build/templates → templates}/mvc/src/host/host-events.ts +0 -0
  65. /package/{build/templates → templates}/mvc/src/host/host-services.ts +0 -0
  66. /package/{build/templates/mvc/src/routes/mvc/pages → templates/mvc/src/routes}/home/HomeModel.ts +0 -0
  67. /package/{build/templates/mvc/src/routes/mvc/pages → templates/mvc/src/routes}/settings/SettingsModel.ts +0 -0
  68. /package/{build/templates → templates}/mvc/tsconfig.json +0 -0
@@ -1,297 +0,0 @@
1
- import { cpSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
2
- import { dirname, join, relative, resolve } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
5
- const REPO_ROOT = resolve(PACKAGE_ROOT, "..", "..");
6
- const FUI_AS_ROOT = join(REPO_ROOT, "v2", "fui-as");
7
- const FUI_AS_TEMPLATES_ROOT = join(FUI_AS_ROOT, "templates");
8
- const TEMPLATES_ROOT = join(PACKAGE_ROOT, "build", "templates");
9
- const LEGACY_TEMPLATES_ROOT = join(PACKAGE_ROOT, "templates");
10
- function writeTextFile(filePath, contents) {
11
- mkdirSync(dirname(filePath), { recursive: true });
12
- writeFileSync(filePath, contents, "utf8");
13
- }
14
- function posixRelativeImport(fromFilePath, toFilePath) {
15
- const fromDirectory = dirname(fromFilePath);
16
- let specifier = relative(fromDirectory, toFilePath).replaceAll("\\", "/");
17
- if (specifier.endsWith(".ts")) {
18
- specifier = specifier.slice(0, -3);
19
- }
20
- if (!specifier.startsWith(".")) {
21
- specifier = `./${specifier}`;
22
- }
23
- return specifier;
24
- }
25
- function rewriteSdkImportsInFile(filePath, templateSrcRoot) {
26
- const original = readFileSync(filePath, "utf8");
27
- const rewritten = original
28
- .replace(/(['"])(?:\.\.\/)+src\/(Fui|FuiExports|FuiPrimitives|FuiBrowser)\1/g, (_full, quote, symbolName) => {
29
- const targetPath = join(templateSrcRoot, "fui", `${symbolName}.ts`);
30
- const relativeSpecifier = posixRelativeImport(filePath, targetPath);
31
- return `${quote}${relativeSpecifier}${quote}`;
32
- })
33
- .replace(/(['"])(?:\.\.\/)+browser\/src\/(?:host-events|host-services)\1/g, '"@effindomv2/fui-as/browser"');
34
- if (rewritten !== original) {
35
- writeFileSync(filePath, rewritten, "utf8");
36
- }
37
- }
38
- function walkFiles(root, callback) {
39
- for (const entry of readdirSync(root)) {
40
- const absolutePath = join(root, entry);
41
- const stats = statSync(absolutePath);
42
- if (stats.isDirectory()) {
43
- walkFiles(absolutePath, callback);
44
- continue;
45
- }
46
- callback(absolutePath);
47
- }
48
- }
49
- function writeSharedSdkShims(templateRoot) {
50
- const fuiRoot = join(templateRoot, "src", "fui");
51
- writeTextFile(join(fuiRoot, "Fui.ts"), 'export * from "../../node_modules/@effindomv2/fui-as/src/Fui";\n');
52
- writeTextFile(join(fuiRoot, "FuiExports.ts"), 'export * from "../../node_modules/@effindomv2/fui-as/src/FuiExports";\n');
53
- writeTextFile(join(fuiRoot, "FuiPrimitives.ts"), 'export * from "../../node_modules/@effindomv2/fui-as/src/FuiPrimitives";\n');
54
- writeTextFile(join(fuiRoot, "FuiBrowser.ts"), 'export * from "../../node_modules/@effindomv2/fui-as/browser/src/index";\n');
55
- }
56
- function writeAsconfig(templateRoot) {
57
- writeTextFile(join(templateRoot, "asconfig.json"), JSON.stringify({
58
- targets: {
59
- debug: {
60
- debug: true,
61
- exportRuntime: true,
62
- bindings: "esm",
63
- outFile: "public/app.wasm",
64
- sourceMap: true,
65
- textFile: "public/app.wat",
66
- },
67
- release: {
68
- exportRuntime: true,
69
- bindings: "esm",
70
- optimizeLevel: 3,
71
- outFile: "public/app.wasm",
72
- shrinkLevel: 1,
73
- sourceMap: false,
74
- textFile: "public/app.wat",
75
- },
76
- },
77
- options: {
78
- runtime: "stub",
79
- },
80
- }, null, 2) + "\n");
81
- }
82
- function writeTsconfig(templateRoot) {
83
- writeTextFile(join(templateRoot, "tsconfig.json"), JSON.stringify({
84
- extends: "assemblyscript/std/assembly.json",
85
- compilerOptions: {
86
- noEmit: true,
87
- },
88
- include: ["src/**/*.ts"],
89
- }, null, 2) + "\n");
90
- }
91
- function writePackageJsonTemplate(templateRoot, scripts, description) {
92
- writeTextFile(join(templateRoot, "package.json"), JSON.stringify({
93
- name: "__PACKAGE_NAME__",
94
- version: "0.1.0",
95
- private: true,
96
- type: "module",
97
- description,
98
- scripts,
99
- dependencies: {
100
- "@effindomv2/fui-as": "__FUI_AS_VERSION__",
101
- "@effindomv2/runtime": "__RUNTIME_VERSION__",
102
- },
103
- devDependencies: {
104
- assemblyscript: "0.28.17",
105
- "chokidar-cli": "^3.0.0",
106
- concurrently: "^9.2.1",
107
- esbuild: "^0.27.7",
108
- "http-server": "^14.1.1",
109
- tsx: "^4.20.6",
110
- },
111
- }, null, 2) + "\n");
112
- }
113
- function writeHelloSupportFiles(templateRoot) {
114
- writeTextFile(join(templateRoot, "scripts", "prepare-runtime.ts"), `import { copyFileSync, cpSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
115
-
116
- const outputDir = "public";
117
- rmSync(outputDir, { recursive: true, force: true });
118
- mkdirSync(\`\${outputDir}/runtime\`, { recursive: true });
119
-
120
- cpSync("node_modules/@effindomv2/runtime/dist", \`\${outputDir}/runtime/dist\`, { recursive: true });
121
- cpSync("node_modules/@effindomv2/runtime/dist/fonts", \`\${outputDir}/runtime/fonts\`, { recursive: true });
122
- copyFileSync("node_modules/@effindomv2/runtime/dist/bridge.js", \`\${outputDir}/bridge.js\`);
123
- if (existsSync("node_modules/@effindomv2/runtime/dist/bridge.js.map")) {
124
- copyFileSync("node_modules/@effindomv2/runtime/dist/bridge.js.map", \`\${outputDir}/bridge.js.map\`);
125
- }
126
- writeFileSync(
127
- \`\${outputDir}/effindom-runtime-config.js\`,
128
- 'window.__effindomRuntime = Object.assign({}, window.__effindomRuntime, { manifestUrl: "./runtime/dist/effindom.v2.manifest.json" });\\n',
129
- "utf8",
130
- );
131
- copyFileSync("index.html", \`\${outputDir}/index.html\`);
132
- `);
133
- writeTextFile(join(templateRoot, "scripts", "smoke.ts"), `import { accessSync } from "node:fs";
134
-
135
- const expectedFiles = [
136
- "public/index.html",
137
- "public/harness.js",
138
- "public/app.wasm",
139
- "public/bridge.js",
140
- "public/effindom-runtime-config.js",
141
- "public/runtime/dist/effindom.v2.manifest.json",
142
- "public/runtime/fonts/NotoSans-Regular.ttf",
143
- ];
144
-
145
- for (const filePath of expectedFiles) {
146
- accessSync(filePath);
147
- }
148
- `);
149
- writePackageJsonTemplate(templateRoot, {
150
- build: "npm run generate:host && npm run build:assets && npm run build:wasm && npm run build:harness",
151
- "build:assets": "tsx scripts/prepare-runtime.ts",
152
- "build:wasm": "asc src/App.ts --config asconfig.json --target release",
153
- "build:harness": "esbuild harness.ts --bundle --format=esm --platform=browser --outfile=public/harness.js",
154
- "generate:host-services": "tsx ./node_modules/@effindomv2/fui-as/scripts/generate-host-services.ts src/host/host-services.ts appHostServices src/host/generated/HostServices.ts ../../fui/FuiPrimitives",
155
- "generate:host-events": "tsx ./node_modules/@effindomv2/fui-as/scripts/generate-host-events.ts src/host/host-events.ts appHostEvents src/host/generated/HostEvents.ts ../../fui/FuiPrimitives",
156
- "generate:host": "npm run generate:host-services && npm run generate:host-events",
157
- watch: 'chokidar "src/**/*.ts" "harness.ts" "index.html" "asconfig.json" --ignore "src/host/generated/**" -c "npm run build"',
158
- serve: "http-server public -p 8080 -c-1",
159
- dev: 'npm run build && concurrently -k -n watch,serve "npm run watch" "npm run serve"',
160
- test: "npm run build && tsx scripts/smoke.ts",
161
- }, "Scaffolded FUI-AS hello-world app");
162
- }
163
- function writeMvcSupportFiles(templateRoot) {
164
- writeTextFile(join(templateRoot, "index.html"), `<!doctype html>
165
- <html lang="en">
166
- <head>
167
- <meta charset="utf-8" />
168
- <meta http-equiv="refresh" content="0; url=/mvc-home/" />
169
- <title>FUI-AS MVC App</title>
170
- </head>
171
- <body>
172
- <p>Redirecting to <a href="/mvc-home/">/mvc-home/</a>…</p>
173
- </body>
174
- </html>
175
- `);
176
- writeTextFile(join(templateRoot, "scripts", "prepare-runtime.ts"), `import { copyFileSync, cpSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
177
-
178
- const outputDir = "public";
179
- rmSync(outputDir, { recursive: true, force: true });
180
- mkdirSync(\`\${outputDir}/runtime\`, { recursive: true });
181
- mkdirSync(\`\${outputDir}/mvc-home\`, { recursive: true });
182
- mkdirSync(\`\${outputDir}/mvc-settings\`, { recursive: true });
183
-
184
- cpSync("node_modules/@effindomv2/runtime/dist", \`\${outputDir}/runtime/dist\`, { recursive: true });
185
- cpSync("node_modules/@effindomv2/runtime/dist/fonts", \`\${outputDir}/runtime/fonts\`, { recursive: true });
186
- copyFileSync("node_modules/@effindomv2/runtime/dist/bridge.js", \`\${outputDir}/bridge.js\`);
187
- if (existsSync("node_modules/@effindomv2/runtime/dist/bridge.js.map")) {
188
- copyFileSync("node_modules/@effindomv2/runtime/dist/bridge.js.map", \`\${outputDir}/bridge.js.map\`);
189
- }
190
- writeFileSync(
191
- \`\${outputDir}/effindom-runtime-config.js\`,
192
- 'window.__effindomRuntime = Object.assign({}, window.__effindomRuntime, { manifestUrl: "./runtime/dist/effindom.v2.manifest.json" });\\n',
193
- "utf8",
194
- );
195
- copyFileSync("index.html", \`\${outputDir}/index.html\`);
196
- copyFileSync("route-shell.html", \`\${outputDir}/mvc-home/index.html\`);
197
- copyFileSync("route-shell.html", \`\${outputDir}/mvc-settings/index.html\`);
198
- `);
199
- writeTextFile(join(templateRoot, "scripts", "smoke.ts"), `import { accessSync } from "node:fs";
200
-
201
- const expectedFiles = [
202
- "public/index.html",
203
- "public/harness.js",
204
- "public/mvc-home/index.html",
205
- "public/mvc-settings/index.html",
206
- "public/mvc-home.wasm",
207
- "public/mvc-settings.wasm",
208
- "public/bridge.js",
209
- "public/effindom-runtime-config.js",
210
- "public/runtime/dist/effindom.v2.manifest.json",
211
- "public/runtime/fonts/NotoSans-Regular.ttf",
212
- ];
213
-
214
- for (const filePath of expectedFiles) {
215
- accessSync(filePath);
216
- }
217
- `);
218
- writePackageJsonTemplate(templateRoot, {
219
- build: "npm run generate:host && npm run build:assets && npm run build:wasm && npm run build:harness",
220
- "build:assets": "tsx scripts/prepare-runtime.ts",
221
- "build:wasm": "npm run build:wasm:home && npm run build:wasm:settings",
222
- "build:wasm:home": "asc src/routes/mvc_home.ts --config asconfig.json --target release --outFile public/mvc-home.wasm",
223
- "build:wasm:settings": "asc src/routes/mvc_settings.ts --config asconfig.json --target release --outFile public/mvc-settings.wasm",
224
- "build:harness": "esbuild harness.ts --bundle --format=esm --platform=browser --outfile=public/harness.js",
225
- "generate:host-services": "tsx ./node_modules/@effindomv2/fui-as/scripts/generate-host-services.ts src/host/host-services.ts appHostServices src/host/generated/HostServices.ts ../../fui/FuiPrimitives",
226
- "generate:host-events": "tsx ./node_modules/@effindomv2/fui-as/scripts/generate-host-events.ts src/host/host-events.ts appHostEvents src/host/generated/HostEvents.ts ../../fui/FuiPrimitives",
227
- "generate:host": "npm run generate:host-services && npm run generate:host-events",
228
- watch: 'chokidar "src/**/*.ts" "harness.ts" "route-shell.html" "index.html" "asconfig.json" --ignore "src/host/generated/**" -c "npm run build"',
229
- serve: "http-server public -p 8080 -c-1",
230
- dev: 'npm run build && concurrently -k -n watch,serve "npm run watch" "npm run serve"',
231
- test: "npm run build && tsx scripts/smoke.ts",
232
- }, "Scaffolded FUI-AS MVC app");
233
- }
234
- function rewriteHarnessImports(filePath) {
235
- const original = readFileSync(filePath, "utf8");
236
- const rewritten = original
237
- .replace(/(['"])(?:\.\.\/)+browser\/src\/common-harness\1/g, '"@effindomv2/fui-as/browser"')
238
- .replace(/(['"])(?:\.\.\/)+browser\/src\/routed-harness\1/g, '"@effindomv2/fui-as/browser"')
239
- .replaceAll("?v=midnight-6", "");
240
- if (rewritten !== original) {
241
- writeFileSync(filePath, rewritten, "utf8");
242
- }
243
- }
244
- function normalizeGeneratedHeader(filePath, label) {
245
- const original = readFileSync(filePath, "utf8");
246
- const rewritten = original.replace(/^\/\/ Generated by .*$/m, `// Generated from ${label}.`);
247
- if (rewritten !== original) {
248
- writeFileSync(filePath, rewritten, "utf8");
249
- }
250
- }
251
- function syncHelloTemplate() {
252
- const templateRoot = join(TEMPLATES_ROOT, "hello");
253
- const templateSrcRoot = join(templateRoot, "src");
254
- rmSync(templateRoot, { recursive: true, force: true });
255
- const sourceRoot = join(FUI_AS_TEMPLATES_ROOT, "demo-hello-world");
256
- cpSync(join(sourceRoot, "src"), templateSrcRoot, { recursive: true });
257
- cpSync(join(sourceRoot, "harness.ts"), join(templateRoot, "harness.ts"));
258
- cpSync(join(sourceRoot, "index.html"), join(templateRoot, "index.html"));
259
- writeSharedSdkShims(templateRoot);
260
- writeAsconfig(templateRoot);
261
- writeTsconfig(templateRoot);
262
- writeHelloSupportFiles(templateRoot);
263
- walkFiles(templateSrcRoot, (filePath) => {
264
- if (filePath.endsWith(".ts")) {
265
- rewriteSdkImportsInFile(filePath, templateSrcRoot);
266
- }
267
- });
268
- rewriteHarnessImports(join(templateRoot, "harness.ts"));
269
- normalizeGeneratedHeader(join(templateSrcRoot, "host", "generated", "HostEvents.ts"), "the scaffold host-events definition");
270
- normalizeGeneratedHeader(join(templateSrcRoot, "host", "generated", "HostServices.ts"), "the scaffold host-services definition");
271
- }
272
- function syncMvcTemplate() {
273
- const templateRoot = join(TEMPLATES_ROOT, "mvc");
274
- const templateSrcRoot = join(templateRoot, "src");
275
- rmSync(templateRoot, { recursive: true, force: true });
276
- const sourceRoot = join(FUI_AS_TEMPLATES_ROOT, "demo-mvc");
277
- cpSync(join(sourceRoot, "src"), templateSrcRoot, { recursive: true });
278
- cpSync(join(sourceRoot, "harness.ts"), join(templateRoot, "harness.ts"));
279
- cpSync(join(sourceRoot, "route-shell.html"), join(templateRoot, "route-shell.html"));
280
- writeSharedSdkShims(templateRoot);
281
- writeAsconfig(templateRoot);
282
- writeTsconfig(templateRoot);
283
- writeMvcSupportFiles(templateRoot);
284
- walkFiles(templateSrcRoot, (filePath) => {
285
- if (filePath.endsWith(".ts")) {
286
- rewriteSdkImportsInFile(filePath, templateSrcRoot);
287
- }
288
- });
289
- rewriteHarnessImports(join(templateRoot, "harness.ts"));
290
- normalizeGeneratedHeader(join(templateSrcRoot, "host", "generated", "HostEvents.ts"), "the scaffold host-events definition");
291
- normalizeGeneratedHeader(join(templateSrcRoot, "host", "generated", "HostServices.ts"), "the scaffold host-services definition");
292
- }
293
- rmSync(TEMPLATES_ROOT, { recursive: true, force: true });
294
- rmSync(LEGACY_TEMPLATES_ROOT, { recursive: true, force: true });
295
- mkdirSync(TEMPLATES_ROOT, { recursive: true });
296
- syncHelloTemplate();
297
- syncMvcTemplate();
File without changes
File without changes