@olenbetong/appframe-vite 6.10.0 → 6.12.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/lib/build.d.ts CHANGED
@@ -29,6 +29,16 @@ export type PlatformManifest = {
29
29
  platform?: string;
30
30
  /** The package versions the app resolved at build time. */
31
31
  upstream: Record<string, string>;
32
+ /**
33
+ * What the app puts in the site toolbar, so the template can render the page right before
34
+ * any script runs. `drawer`: the app renders a navigation drawer toggle into the drawer slot,
35
+ * and the toolbar must reserve that slot server-side (the deploy writes a `ToolbarDrawer`
36
+ * block; without it the brand sits at the edge). Detected from the source, overridable with
37
+ * `appframe.toolbar.drawer` in package.json.
38
+ */
39
+ toolbar?: {
40
+ drawer: boolean;
41
+ };
32
42
  };
33
43
  /**
34
44
  * Writes `dist/platform.json` after a platform build: the platform version the app was built
package/lib/build.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { existsSync } from "node:fs";
2
- import { readFile, writeFile } from "node:fs/promises";
2
+ import { readdir, readFile, writeFile } from "node:fs/promises";
3
3
  import { dirname, resolve } from "node:path";
4
4
  import { visualizer } from "rollup-plugin-visualizer";
5
5
  import { esmExternalRequirePlugin } from "vite";
@@ -27,6 +27,9 @@ export const PLATFORM_EXTERNALS = [
27
27
  "@olenbetong/appframe-ds/mdi",
28
28
  "@olenbetong/appframe-ds/progress",
29
29
  "@olenbetong/appframe-ds/report-downloader",
30
+ "pdfjs-dist",
31
+ "react-pdf",
32
+ "pdf-lib",
30
33
  ];
31
34
  /**
32
35
  * The IIFE global each platform specifier is published under (`buildConfig.entries` in the
@@ -49,6 +52,9 @@ export const PLATFORM_GLOBALS = {
49
52
  "@olenbetong/appframe-ds/mdi": "SynergiPlatform.appframeDsMdi",
50
53
  "@olenbetong/appframe-ds/progress": "SynergiPlatform.appframeDsProgress",
51
54
  "@olenbetong/appframe-ds/report-downloader": "SynergiPlatform.appframeDsReportDownloader",
55
+ "pdfjs-dist": "SynergiPlatform.pdfjs",
56
+ "react-pdf": "SynergiPlatform.reactPdf",
57
+ "pdf-lib": "SynergiPlatform.pdfLib",
52
58
  };
53
59
  export function usesPlatform(appframe) {
54
60
  return appframe?.build?.platform === true;
@@ -68,7 +74,43 @@ export const PLATFORM_UPSTREAM = [
68
74
  "@olenbetong/appframe-data",
69
75
  "@olenbetong/appframe-react",
70
76
  "@olenbetong/appframe-ds",
77
+ "pdfjs-dist",
78
+ "react-pdf",
79
+ "pdf-lib",
71
80
  ];
81
+ /**
82
+ * Whether the app renders `ToolbarDrawerToggle` (synergi-react) anywhere under `src/`: a plain
83
+ * word search, since the module graph cannot tell - the toggle shares a module with the
84
+ * breadcrumbs every app renders. `appframe.toolbar.drawer` in package.json wins when set.
85
+ */
86
+ async function detectToolbarDrawer(cwd, appframe) {
87
+ let setting = appframe?.toolbar?.drawer;
88
+ if (typeof setting === "boolean")
89
+ return setting;
90
+ let pattern = /\bToolbarDrawerToggle\b/;
91
+ async function scan(dir) {
92
+ let entries = await readdir(dir, { withFileTypes: true });
93
+ for (let entry of entries) {
94
+ let path = resolve(dir, entry.name);
95
+ if (entry.isDirectory()) {
96
+ if (entry.name === "node_modules" || entry.name === "shared")
97
+ continue;
98
+ if (await scan(path))
99
+ return true;
100
+ }
101
+ else if (/\.(tsx?|jsx?)$/.test(entry.name) && pattern.test(await readFile(path, "utf8"))) {
102
+ return true;
103
+ }
104
+ }
105
+ return false;
106
+ }
107
+ try {
108
+ return await scan(resolve(cwd, "src"));
109
+ }
110
+ catch {
111
+ return false;
112
+ }
113
+ }
72
114
  /**
73
115
  * The platform package's version as the app sees it: its own copy under node_modules when it
74
116
  * depends on `@olenbetong/synergi-platform`, otherwise the workspace's `packages/synergi-platform`
@@ -121,6 +163,8 @@ export function platformManifest() {
121
163
  // appframe-ds, say); only what the app resolved is recorded and checked.
122
164
  }
123
165
  }
166
+ let appframe = JSON.parse(await readFile(resolve(process.cwd(), "package.json"), "utf8")).appframe;
167
+ manifest.toolbar = { drawer: await detectToolbarDrawer(process.cwd(), appframe) };
124
168
  await writeFile(resolve(process.cwd(), "dist", "platform.json"), `${JSON.stringify(manifest, null, "\t")}\n`);
125
169
  },
126
170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/appframe-vite",
3
- "version": "6.10.0",
3
+ "version": "6.12.0",
4
4
  "description": "Tools to use and deploy Vite applications to Appframe",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -37,14 +37,14 @@
37
37
  "fuzzy": "^0.1.3",
38
38
  "inquirer": "^14.2.2",
39
39
  "inquirer-autocomplete-standalone": "^0.8.1",
40
- "jsdom": "30.0.1",
40
+ "jsdom": "30.1.0",
41
41
  "rollup-plugin-visualizer": "^7.1.1",
42
42
  "yaml": "^2.9.1",
43
43
  "@olenbetong/appframe-data": "1.7.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/jsdom": "^30.0.0",
47
- "@types/node": "26.5.1",
47
+ "@types/node": "26.6.1",
48
48
  "typescript": "7.0.2",
49
49
  "vite": "8.3.0"
50
50
  },