@effindomv2/fui-as 0.1.3 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effindomv2/fui-as",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "license": "AGPL-3.0-only OR LicenseRef-EffinDom-Commercial",
6
6
  "description": "EffinDom v2 AssemblyScript frontend framework SDK and browser harness",
@@ -88,8 +88,8 @@ case "${BUILD_TARGET}" in
88
88
  build_demo_app "demo/src/routes/demo_home.ts" "${DEMO_OUT_DIR}/home.wasm"
89
89
  build_demo_app "demo/src/routes/demo_advanced_controls.ts" "${DEMO_OUT_DIR}/advanced-controls.wasm"
90
90
  build_demo_app "demo/src/routes/templated-controls.ts" "${DEMO_OUT_DIR}/templated-controls.wasm"
91
- build_demo_app "templates/demo-mvc/src/routes/mvc_home.ts" "${MVC_OUT_DIR}/mvc-home.wasm"
92
- build_demo_app "templates/demo-mvc/src/routes/mvc_settings.ts" "${MVC_OUT_DIR}/mvc-settings.wasm"
91
+ build_demo_app "templates/demo-mvc/src/routes/HomeApp.ts" "${MVC_OUT_DIR}/home.wasm"
92
+ build_demo_app "templates/demo-mvc/src/routes/SettingsApp.ts" "${MVC_OUT_DIR}/settings.wasm"
93
93
  build_demo_app "templates/demo-hello-world/src/App.ts" "${HELLO_OUT_DIR}/app.wasm"
94
94
  ;;
95
95
  dashboard)
@@ -104,18 +104,18 @@ case "${BUILD_TARGET}" in
104
104
  templated-controls|templated)
105
105
  build_demo_app "demo/src/routes/templated-controls.ts" "${DEMO_OUT_DIR}/templated-controls.wasm"
106
106
  ;;
107
- mvc-home|mvc-home-page)
108
- build_demo_app "templates/demo-mvc/src/routes/mvc_home.ts" "${MVC_OUT_DIR}/mvc-home.wasm"
107
+ routed-home|route-home|home-route)
108
+ build_demo_app "templates/demo-mvc/src/routes/HomeApp.ts" "${MVC_OUT_DIR}/home.wasm"
109
109
  ;;
110
- mvc-settings|mvc-settings-page)
111
- build_demo_app "templates/demo-mvc/src/routes/mvc_settings.ts" "${MVC_OUT_DIR}/mvc-settings.wasm"
110
+ routed-settings|route-settings|settings-route)
111
+ build_demo_app "templates/demo-mvc/src/routes/SettingsApp.ts" "${MVC_OUT_DIR}/settings.wasm"
112
112
  ;;
113
113
  hello-world|hello)
114
114
  build_demo_app "templates/demo-hello-world/src/App.ts" "${HELLO_OUT_DIR}/app.wasm"
115
115
  ;;
116
116
  *)
117
117
  echo "Unknown build target: ${BUILD_TARGET}" >&2
118
- echo "Usage: bash scripts/build-demo-as.sh [all|dashboard|home|advanced-controls|templated-controls|mvc-home|mvc-settings|hello-world]" >&2
118
+ echo "Usage: bash scripts/build-demo-as.sh [all|dashboard|home|advanced-controls|templated-controls|routed-home|routed-settings|hello-world]" >&2
119
119
  exit 1
120
120
  ;;
121
121
  esac
package/scripts/build.sh CHANGED
@@ -263,8 +263,8 @@ build_app "demo/src/dashboard.ts" "${DEMO_OUT_DIR}/demo.wasm"
263
263
  build_app "demo/src/routes/demo_home.ts" "${DEMO_OUT_DIR}/home.wasm"
264
264
  build_app "demo/src/routes/demo_advanced_controls.ts" "${DEMO_OUT_DIR}/advanced-controls.wasm"
265
265
  build_app "demo/src/routes/templated-controls.ts" "${DEMO_OUT_DIR}/templated-controls.wasm"
266
- build_app "templates/demo-mvc/src/routes/mvc_home.ts" "${MVC_OUT_DIR}/mvc-home.wasm"
267
- build_app "templates/demo-mvc/src/routes/mvc_settings.ts" "${MVC_OUT_DIR}/mvc-settings.wasm"
266
+ build_app "templates/demo-mvc/src/routes/HomeApp.ts" "${MVC_OUT_DIR}/home.wasm"
267
+ build_app "templates/demo-mvc/src/routes/SettingsApp.ts" "${MVC_OUT_DIR}/settings.wasm"
268
268
  build_app "templates/demo-hello-world/src/App.ts" "${HELLO_OUT_DIR}/app.wasm"
269
269
  build_workers
270
270
  write_worker_manifest
@@ -350,19 +350,19 @@ cp "${PACKAGE_DIR}/demo/demo-secondary-texture.png" "${DEMO_OUT_DIR}/demo-second
350
350
  mkdir -p "${DEMO_OUT_DIR}/advanced-controls" "${DEMO_OUT_DIR}/templated-controls"
351
351
  cp "${PACKAGE_DIR}/demo/route-shell.html" "${DEMO_OUT_DIR}/advanced-controls/index.html"
352
352
  cp "${PACKAGE_DIR}/demo/route-shell.html" "${DEMO_OUT_DIR}/templated-controls/index.html"
353
- mkdir -p "${MVC_OUT_DIR}/mvc-home" "${MVC_OUT_DIR}/mvc-settings"
354
- cp "${PACKAGE_DIR}/templates/demo-mvc/route-shell.html" "${MVC_OUT_DIR}/mvc-home/index.html"
355
- cp "${PACKAGE_DIR}/templates/demo-mvc/route-shell.html" "${MVC_OUT_DIR}/mvc-settings/index.html"
353
+ mkdir -p "${MVC_OUT_DIR}/home" "${MVC_OUT_DIR}/settings"
354
+ cp "${PACKAGE_DIR}/templates/demo-mvc/route-shell.html" "${MVC_OUT_DIR}/home/index.html"
355
+ cp "${PACKAGE_DIR}/templates/demo-mvc/route-shell.html" "${MVC_OUT_DIR}/settings/index.html"
356
356
  cat > "${MVC_OUT_DIR}/index.html" <<'EOF'
357
357
  <!doctype html>
358
358
  <html lang="en">
359
359
  <head>
360
360
  <meta charset="utf-8" />
361
- <meta http-equiv="refresh" content="0; url=./mvc-home/" />
362
- <title>FUI-AS MVC Demo</title>
361
+ <meta http-equiv="refresh" content="0; url=./home/" />
362
+ <title>FUI-AS Routed Demo</title>
363
363
  </head>
364
364
  <body>
365
- <p>Redirecting to <a href="./mvc-home/">MVC Home</a>…</p>
365
+ <p>Redirecting to <a href="./home/">Home</a>…</p>
366
366
  </body>
367
367
  </html>
368
368
  EOF
@@ -381,5 +381,5 @@ write_runtime_config "${MVC_OUT_DIR}" "${DEFAULT_MANIFEST_PATH}"
381
381
  write_runtime_config "${HELLO_OUT_DIR}" "${DEFAULT_MANIFEST_PATH}"
382
382
  write_runtime_config "${DEMO_OUT_DIR}/advanced-controls" "../runtime/dist/effindom.v2.manifest.json"
383
383
  write_runtime_config "${DEMO_OUT_DIR}/templated-controls" "../runtime/dist/effindom.v2.manifest.json"
384
- write_runtime_config "${MVC_OUT_DIR}/mvc-home" "../runtime/dist/effindom.v2.manifest.json"
385
- write_runtime_config "${MVC_OUT_DIR}/mvc-settings" "../runtime/dist/effindom.v2.manifest.json"
384
+ write_runtime_config "${MVC_OUT_DIR}/home" "../runtime/dist/effindom.v2.manifest.json"
385
+ write_runtime_config "${MVC_OUT_DIR}/settings" "../runtime/dist/effindom.v2.manifest.json"
package/src/Fui.ts CHANGED
@@ -1,4 +1,10 @@
1
- export { Application, ApplicationRegistration, createApplication, createManagedApplication } from "./core/Application";
1
+ export {
2
+ Application,
3
+ ApplicationRegistration,
4
+ ManagedApplicationController,
5
+ createApplication,
6
+ createManagedApplication,
7
+ } from "./core/Application";
2
8
  export { Action, CallbackAction, HandlerAction, NodeAction, SignalHandler } from "./core/Action";
3
9
  export { ObjectDisposedError } from "./core/Errors";
4
10
  export {
@@ -271,6 +271,20 @@ export class Application<TPage> {
271
271
  }
272
272
  }
273
273
 
274
+ export class ManagedApplicationController {
275
+ getRoot(): Node {
276
+ throw new Error("ManagedApplicationController.getRoot() must be overridden.");
277
+ }
278
+
279
+ mount(): void {
280
+ Application.mount(this.getRoot());
281
+ }
282
+
283
+ dispose(): void {
284
+ Application.unmount();
285
+ }
286
+ }
287
+
274
288
  function getNodeRoot(page: Node): Node {
275
289
  return page;
276
290
  }
@@ -283,11 +297,21 @@ export function createApplication(buildPage: () => Node): Application<Node> {
283
297
 
284
298
  export function createManagedApplication<TPage>(
285
299
  buildPage: () => TPage,
286
- getRoot: (page: TPage) => Node,
287
- mountPage: ((page: TPage) => void) | null,
288
- disposePage: ((page: TPage) => void) | null,
300
+ getRoot: ((page: TPage) => Node) | null = null,
301
+ mountPage: ((page: TPage) => void) | null = null,
302
+ disposePage: ((page: TPage) => void) | null = null,
289
303
  ): Application<TPage> {
290
- const app = new Application<TPage>(buildPage, getRoot, mountPage, disposePage);
304
+ let managedGetRootFn: (page: TPage) => Node;
305
+ let managedMountPageFn = mountPage;
306
+ let managedDisposePageFn = disposePage;
307
+ if (getRoot === null) {
308
+ managedGetRootFn = (page: TPage): Node => changetype<ManagedApplicationController>(page).getRoot();
309
+ managedMountPageFn = (page: TPage): void => changetype<ManagedApplicationController>(page).mount();
310
+ managedDisposePageFn = (page: TPage): void => changetype<ManagedApplicationController>(page).dispose();
311
+ } else {
312
+ managedGetRootFn = getRoot;
313
+ }
314
+ const app = new Application<TPage>(buildPage, managedGetRootFn, managedMountPageFn, managedDisposePageFn);
291
315
  exportedApplication = changetype<Application<Node>>(app);
292
316
  return app;
293
317
  }