create-flow-os 0.0.1-dev.1771840262 → 0.0.1-dev.1771979366

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 (230) hide show
  1. package/package.json +8 -23
  2. package/{profiles/server/packages/style → src/create}/index.ts +31 -30
  3. package/src/index.ts +14 -0
  4. package/src/init/index.ts +66 -0
  5. package/src/init/lib.ts +36 -0
  6. package/src/init/scaffold.ts +43 -0
  7. package/LICENSE +0 -97
  8. package/README.md +0 -26
  9. package/bin/index.js +0 -1215
  10. package/config.json +0 -89
  11. package/lib/utils.ts +0 -91
  12. package/packages/client/client/root.css +0 -9
  13. package/packages/client/client/root.tsx +0 -6
  14. package/packages/client/client/routes/404.tsx +0 -24
  15. package/packages/client/client/routes/index.tsx +0 -48
  16. package/packages/server/server/routes/hello.get.ts +0 -3
  17. package/profiles/client/.dockerignore +0 -12
  18. package/profiles/client/.oxfmtrc.json +0 -7
  19. package/profiles/client/.oxlintrc.json +0 -13
  20. package/profiles/client/.vscode/settings.json +0 -12
  21. package/profiles/client/Dockerfile +0 -26
  22. package/profiles/client/README.md +0 -34
  23. package/profiles/client/bun.lock +0 -352
  24. package/profiles/client/client/root.css +0 -9
  25. package/profiles/client/client/root.tsx +0 -6
  26. package/profiles/client/client/routes/404.tsx +0 -24
  27. package/profiles/client/client/routes/about.tsx +0 -7
  28. package/profiles/client/client/routes/index.tsx +0 -48
  29. package/profiles/client/flow.config.ts +0 -6
  30. package/profiles/client/index.html +0 -5
  31. package/profiles/client/package.json +0 -32
  32. package/profiles/client/packages/client/LICENSE +0 -97
  33. package/profiles/client/packages/client/build/config.ts +0 -211
  34. package/profiles/client/packages/client/build/vite.ts +0 -98
  35. package/profiles/client/packages/client/features/attrs.ts +0 -32
  36. package/profiles/client/packages/client/features/class-flow.ts +0 -116
  37. package/profiles/client/packages/client/features/index.ts +0 -8
  38. package/profiles/client/packages/client/features/pseudo-injector.ts +0 -40
  39. package/profiles/client/packages/client/features/style-flow.ts +0 -106
  40. package/profiles/client/packages/client/features/style.ts +0 -27
  41. package/profiles/client/packages/client/features/utils.ts +0 -4
  42. package/profiles/client/packages/client/features/viewport.ts +0 -20
  43. package/profiles/client/packages/client/index.ts +0 -7
  44. package/profiles/client/packages/client/package.json +0 -48
  45. package/profiles/client/packages/client/runtime/dom.ts +0 -2
  46. package/profiles/client/packages/client/runtime/jsx-dev-runtime.ts +0 -1
  47. package/profiles/client/packages/client/runtime/jsx-runtime.ts +0 -1
  48. package/profiles/client/packages/client/runtime/jsx-types.d.ts +0 -66
  49. package/profiles/client/packages/client/runtime/jsx.ts +0 -101
  50. package/profiles/client/packages/client/scripts/build.ts +0 -14
  51. package/profiles/client/packages/client/scripts/preview.ts +0 -14
  52. package/profiles/client/packages/client/scripts/start-dev.ts +0 -49
  53. package/profiles/client/packages/core/LICENSE +0 -97
  54. package/profiles/client/packages/core/dom.ts +0 -43
  55. package/profiles/client/packages/core/for.ts +0 -42
  56. package/profiles/client/packages/core/index.ts +0 -5
  57. package/profiles/client/packages/core/lifecycle.ts +0 -6
  58. package/profiles/client/packages/core/package.json +0 -16
  59. package/profiles/client/packages/core/show-switch.ts +0 -56
  60. package/profiles/client/packages/core/state.ts +0 -56
  61. package/profiles/client/packages/router/LICENSE +0 -97
  62. package/profiles/client/packages/router/index.ts +0 -20
  63. package/profiles/client/packages/router/matcher.ts +0 -105
  64. package/profiles/client/packages/router/package.json +0 -15
  65. package/profiles/client/packages/router/router.ts +0 -185
  66. package/profiles/client/packages/router/types.ts +0 -34
  67. package/profiles/client/packages/router/utils.ts +0 -45
  68. package/profiles/client/packages/style/LICENSE +0 -97
  69. package/profiles/client/packages/style/breakpoints.ts +0 -20
  70. package/profiles/client/packages/style/extension/.vscodeignore +0 -5
  71. package/profiles/client/packages/style/extension/flow-style-colors-0.0.1.vsix +0 -0
  72. package/profiles/client/packages/style/extension/out/extension.js +0 -130
  73. package/profiles/client/packages/style/extension/package.json +0 -24
  74. package/profiles/client/packages/style/extension/src/extension.ts +0 -146
  75. package/profiles/client/packages/style/extension/tsconfig.json +0 -12
  76. package/profiles/client/packages/style/index.ts +0 -30
  77. package/profiles/client/packages/style/package.json +0 -20
  78. package/profiles/client/packages/style/react.ts +0 -68
  79. package/profiles/client/packages/style/resolve.ts +0 -127
  80. package/profiles/client/packages/style/server.ts +0 -299
  81. package/profiles/client/packages/style/shorthand.ts +0 -96
  82. package/profiles/client/packages/style/style-builder/button.ts +0 -41
  83. package/profiles/client/packages/style/style-builder/constants.ts +0 -16
  84. package/profiles/client/packages/style/style-builder/dom.ts +0 -18
  85. package/profiles/client/packages/style/style-builder/index.ts +0 -48
  86. package/profiles/client/packages/style/style-builder/panel.ts +0 -69
  87. package/profiles/client/packages/style/style-builder/position.ts +0 -25
  88. package/profiles/client/packages/style/visual-builder.ts +0 -822
  89. package/profiles/client/packages/style/vite-plugin.ts +0 -86
  90. package/profiles/client/tsconfig.json +0 -30
  91. package/profiles/full/.dockerignore +0 -12
  92. package/profiles/full/.oxfmtrc.json +0 -7
  93. package/profiles/full/.oxlintrc.json +0 -13
  94. package/profiles/full/.vscode/settings.json +0 -12
  95. package/profiles/full/Dockerfile +0 -26
  96. package/profiles/full/README.md +0 -34
  97. package/profiles/full/bun.lock +0 -352
  98. package/profiles/full/client/root.css +0 -9
  99. package/profiles/full/client/root.tsx +0 -6
  100. package/profiles/full/client/routes/404.tsx +0 -24
  101. package/profiles/full/client/routes/about.tsx +0 -7
  102. package/profiles/full/client/routes/index.tsx +0 -48
  103. package/profiles/full/flow.config.ts +0 -6
  104. package/profiles/full/index.html +0 -5
  105. package/profiles/full/package.json +0 -33
  106. package/profiles/full/packages/client/LICENSE +0 -97
  107. package/profiles/full/packages/client/build/config.ts +0 -211
  108. package/profiles/full/packages/client/build/vite.ts +0 -98
  109. package/profiles/full/packages/client/features/attrs.ts +0 -32
  110. package/profiles/full/packages/client/features/class-flow.ts +0 -116
  111. package/profiles/full/packages/client/features/index.ts +0 -8
  112. package/profiles/full/packages/client/features/pseudo-injector.ts +0 -40
  113. package/profiles/full/packages/client/features/style-flow.ts +0 -106
  114. package/profiles/full/packages/client/features/style.ts +0 -27
  115. package/profiles/full/packages/client/features/utils.ts +0 -4
  116. package/profiles/full/packages/client/features/viewport.ts +0 -20
  117. package/profiles/full/packages/client/index.ts +0 -7
  118. package/profiles/full/packages/client/package.json +0 -48
  119. package/profiles/full/packages/client/runtime/dom.ts +0 -2
  120. package/profiles/full/packages/client/runtime/jsx-dev-runtime.ts +0 -1
  121. package/profiles/full/packages/client/runtime/jsx-runtime.ts +0 -1
  122. package/profiles/full/packages/client/runtime/jsx-types.d.ts +0 -66
  123. package/profiles/full/packages/client/runtime/jsx.ts +0 -101
  124. package/profiles/full/packages/client/scripts/build.ts +0 -14
  125. package/profiles/full/packages/client/scripts/preview.ts +0 -14
  126. package/profiles/full/packages/client/scripts/start-dev.ts +0 -49
  127. package/profiles/full/packages/core/LICENSE +0 -97
  128. package/profiles/full/packages/core/dom.ts +0 -43
  129. package/profiles/full/packages/core/for.ts +0 -42
  130. package/profiles/full/packages/core/index.ts +0 -5
  131. package/profiles/full/packages/core/lifecycle.ts +0 -6
  132. package/profiles/full/packages/core/package.json +0 -16
  133. package/profiles/full/packages/core/show-switch.ts +0 -56
  134. package/profiles/full/packages/core/state.ts +0 -56
  135. package/profiles/full/packages/router/LICENSE +0 -97
  136. package/profiles/full/packages/router/index.ts +0 -20
  137. package/profiles/full/packages/router/matcher.ts +0 -105
  138. package/profiles/full/packages/router/package.json +0 -15
  139. package/profiles/full/packages/router/router.ts +0 -185
  140. package/profiles/full/packages/router/types.ts +0 -34
  141. package/profiles/full/packages/router/utils.ts +0 -45
  142. package/profiles/full/packages/server/LICENSE +0 -97
  143. package/profiles/full/packages/server/core.ts +0 -140
  144. package/profiles/full/packages/server/index.ts +0 -24
  145. package/profiles/full/packages/server/package.json +0 -32
  146. package/profiles/full/packages/server/plugin.ts +0 -79
  147. package/profiles/full/packages/server/production.ts +0 -75
  148. package/profiles/full/packages/server/scripts/start.ts +0 -11
  149. package/profiles/full/packages/style/LICENSE +0 -97
  150. package/profiles/full/packages/style/breakpoints.ts +0 -20
  151. package/profiles/full/packages/style/extension/.vscodeignore +0 -5
  152. package/profiles/full/packages/style/extension/flow-style-colors-0.0.1.vsix +0 -0
  153. package/profiles/full/packages/style/extension/out/extension.js +0 -130
  154. package/profiles/full/packages/style/extension/package.json +0 -24
  155. package/profiles/full/packages/style/extension/src/extension.ts +0 -146
  156. package/profiles/full/packages/style/extension/tsconfig.json +0 -12
  157. package/profiles/full/packages/style/index.ts +0 -30
  158. package/profiles/full/packages/style/package.json +0 -20
  159. package/profiles/full/packages/style/react.ts +0 -68
  160. package/profiles/full/packages/style/resolve.ts +0 -127
  161. package/profiles/full/packages/style/server.ts +0 -299
  162. package/profiles/full/packages/style/shorthand.ts +0 -96
  163. package/profiles/full/packages/style/style-builder/button.ts +0 -41
  164. package/profiles/full/packages/style/style-builder/constants.ts +0 -16
  165. package/profiles/full/packages/style/style-builder/dom.ts +0 -18
  166. package/profiles/full/packages/style/style-builder/index.ts +0 -48
  167. package/profiles/full/packages/style/style-builder/panel.ts +0 -69
  168. package/profiles/full/packages/style/style-builder/position.ts +0 -25
  169. package/profiles/full/packages/style/visual-builder.ts +0 -822
  170. package/profiles/full/packages/style/vite-plugin.ts +0 -86
  171. package/profiles/full/server/routes/hello.get.ts +0 -3
  172. package/profiles/full/tsconfig.json +0 -30
  173. package/profiles/server/.dockerignore +0 -12
  174. package/profiles/server/.oxfmtrc.json +0 -7
  175. package/profiles/server/.oxlintrc.json +0 -13
  176. package/profiles/server/.vscode/settings.json +0 -12
  177. package/profiles/server/Dockerfile +0 -26
  178. package/profiles/server/README.md +0 -34
  179. package/profiles/server/bun.lock +0 -352
  180. package/profiles/server/flow.config.ts +0 -7
  181. package/profiles/server/index.html +0 -5
  182. package/profiles/server/package.json +0 -30
  183. package/profiles/server/packages/core/LICENSE +0 -97
  184. package/profiles/server/packages/core/dom.ts +0 -43
  185. package/profiles/server/packages/core/for.ts +0 -42
  186. package/profiles/server/packages/core/index.ts +0 -5
  187. package/profiles/server/packages/core/lifecycle.ts +0 -6
  188. package/profiles/server/packages/core/package.json +0 -16
  189. package/profiles/server/packages/core/show-switch.ts +0 -56
  190. package/profiles/server/packages/core/state.ts +0 -56
  191. package/profiles/server/packages/router/LICENSE +0 -97
  192. package/profiles/server/packages/router/index.ts +0 -20
  193. package/profiles/server/packages/router/matcher.ts +0 -105
  194. package/profiles/server/packages/router/package.json +0 -15
  195. package/profiles/server/packages/router/router.ts +0 -185
  196. package/profiles/server/packages/router/types.ts +0 -34
  197. package/profiles/server/packages/router/utils.ts +0 -45
  198. package/profiles/server/packages/server/LICENSE +0 -97
  199. package/profiles/server/packages/server/core.ts +0 -140
  200. package/profiles/server/packages/server/index.ts +0 -24
  201. package/profiles/server/packages/server/package.json +0 -32
  202. package/profiles/server/packages/server/plugin.ts +0 -79
  203. package/profiles/server/packages/server/production.ts +0 -75
  204. package/profiles/server/packages/server/scripts/start.ts +0 -11
  205. package/profiles/server/packages/style/LICENSE +0 -97
  206. package/profiles/server/packages/style/breakpoints.ts +0 -20
  207. package/profiles/server/packages/style/extension/.vscodeignore +0 -5
  208. package/profiles/server/packages/style/extension/flow-style-colors-0.0.1.vsix +0 -0
  209. package/profiles/server/packages/style/extension/out/extension.js +0 -130
  210. package/profiles/server/packages/style/extension/package.json +0 -24
  211. package/profiles/server/packages/style/extension/src/extension.ts +0 -146
  212. package/profiles/server/packages/style/extension/tsconfig.json +0 -12
  213. package/profiles/server/packages/style/package.json +0 -20
  214. package/profiles/server/packages/style/react.ts +0 -68
  215. package/profiles/server/packages/style/resolve.ts +0 -127
  216. package/profiles/server/packages/style/server.ts +0 -299
  217. package/profiles/server/packages/style/shorthand.ts +0 -96
  218. package/profiles/server/packages/style/style-builder/button.ts +0 -41
  219. package/profiles/server/packages/style/style-builder/constants.ts +0 -16
  220. package/profiles/server/packages/style/style-builder/dom.ts +0 -18
  221. package/profiles/server/packages/style/style-builder/index.ts +0 -48
  222. package/profiles/server/packages/style/style-builder/panel.ts +0 -69
  223. package/profiles/server/packages/style/style-builder/position.ts +0 -25
  224. package/profiles/server/packages/style/visual-builder.ts +0 -822
  225. package/profiles/server/packages/style/vite-plugin.ts +0 -86
  226. package/profiles/server/server/routes/hello.get.ts +0 -3
  227. package/profiles/server/tsconfig.json +0 -30
  228. package/templates/flow.config.client.ts +0 -6
  229. package/templates/flow.config.full.ts +0 -6
  230. package/templates/flow.config.server.ts +0 -7
@@ -1,97 +0,0 @@
1
- Flow OS Framework and all packages in this repository are licensed under the
2
- PolyForm Shield License 1.0.0. This license applies to the entire repository
3
- (framework, packages/*, client, server, and any other code herein).
4
-
5
- Required Notice: Copyright (c) Flow OS. All rights reserved.
6
-
7
- -------------------------------------------------------------------------------
8
-
9
- # PolyForm Shield License 1.0.0
10
-
11
- ## Acceptance
12
-
13
- In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
14
-
15
- ## Copyright License
16
-
17
- The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
18
-
19
- ## Distribution License
20
-
21
- The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
22
-
23
- ## Notices
24
-
25
- You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
26
-
27
- > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
28
-
29
- ## Changes and New Works License
30
-
31
- The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
32
-
33
- ## Patent License
34
-
35
- The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
36
-
37
- ## Noncompete
38
-
39
- Any purpose is a permitted purpose, except for providing any product that competes with the software or any product the licensor or any of its affiliates provides using the software.
40
-
41
- ## Competition
42
-
43
- Goods and services compete even when they provide functionality through different kinds of interfaces or for different technical platforms. Applications can compete with services, libraries with plugins, frameworks with development tools, and so on, even if they're written in different programming languages or for different computer architectures. Goods and services compete even when provided free of charge. If you market a product as a practical substitute for the software or another product, it definitely competes.
44
-
45
- ## New Products
46
-
47
- If you are using the software to provide a product that does not compete, but the licensor or any of its affiliates brings your product into competition by providing a new version of the software or another product using the software, you may continue using versions of the software available under these terms beforehand to provide your competing product, but not any later versions.
48
-
49
- ## Discontinued Products
50
-
51
- You may begin using the software to compete with a product or service that the licensor or any of its affiliates has stopped providing, unless the licensor includes a plain-text line beginning with `Licensor Line of Business:` with the software that mentions that line of business. For example:
52
-
53
- > Licensor Line of Business: YoyodyneCMS Content Management System (http://example.com/cms)
54
-
55
- Licensor Line of Business: Flow OS application framework and development tooling (create-flow, @flow.os/* packages, and related framework components).
56
-
57
- ## Sales of Business
58
-
59
- If the licensor or any of its affiliates sells a line of business developing the software or using the software to provide a product, the buyer can also enforce [Noncompete](#noncompete) for that product.
60
-
61
- ## Fair Use
62
-
63
- You may have "fair use" rights for the software under the law. These terms do not limit them.
64
-
65
- ## No Other Rights
66
-
67
- These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
68
-
69
- ## Patent Defense
70
-
71
- If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
72
-
73
- ## Violations
74
-
75
- The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
76
-
77
- ## No Liability
78
-
79
- ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
80
-
81
- ## Definitions
82
-
83
- The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
84
-
85
- A **product** can be a good or service, or a combination of them.
86
-
87
- **You** refers to the individual or entity agreeing to these terms.
88
-
89
- **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all its affiliates.
90
-
91
- **Affiliates** means the other organizations than an organization has control over, is under the control of, or is under common control with.
92
-
93
- **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
94
-
95
- **Your licenses** are all the licenses granted to you for the software under these terms.
96
-
97
- **Use** means anything you do with the software requiring one of your licenses.
@@ -1,211 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import os from 'node:os';
4
- import net from 'node:net';
5
- import type { Plugin } from 'vite';
6
- import { createLogger } from 'vite';
7
-
8
- function isPortFree(port: number): Promise<boolean> {
9
- return new Promise((resolve) => {
10
- const s = net.createServer();
11
- s.once('error', () => resolve(false));
12
- s.once('listening', () => {
13
- s.close(() => resolve(true));
14
- });
15
- s.listen(port, '127.0.0.1');
16
- });
17
- }
18
-
19
- async function findFreePort(from: number, to: number): Promise<number> {
20
- for (let p = from; p <= to; p++) {
21
- if (await isPortFree(p)) return p;
22
- }
23
- throw new Error(`Nessuna porta libera tra ${from} e ${to}`);
24
- }
25
-
26
- const cyan = (s: string) => `\x1b[36m${s}\x1b[0m`;
27
- const bold = (s: string) => `\x1b[1m${s}\x1b[0m`;
28
- const dim = (s: string) => `\x1b[2m${s}\x1b[0m`;
29
- const stripAnsi = (s: string) => s.replace(/\x1b\[[0-9;]*m/g, '');
30
- const MIN_CONTENT_W = 40;
31
- const EXTRA_BOX_WIDTH = 20;
32
-
33
- function getNetworkUrl(port: number): string | null {
34
- const ifaces = os.networkInterfaces();
35
- for (const list of Object.values(ifaces ?? {})) {
36
- if (!list) continue;
37
- for (const i of list) {
38
- if (i.family === 'IPv4' && !i.internal) return `http://${i.address}:${port}/`;
39
- }
40
- }
41
- return null;
42
- }
43
-
44
- /** Monorepo: alias a path assoluti (Rollup in Docker non segue symlink). Fuori monorepo ritorna {}. */
45
- function resolveAlias(): Record<string, string> {
46
- const root = path.resolve(process.cwd());
47
- const packagesDir = path.join(root, 'packages');
48
- if (!fs.existsSync(packagesDir)) return {};
49
- const alias: Record<string, string> = {};
50
- const clientRuntime = path.join(root, 'packages', 'client', 'runtime');
51
- const jrx = path.join(clientRuntime, 'jsx-runtime.ts');
52
- if (fs.existsSync(jrx)) {
53
- alias['@flow.os/client/jsx-runtime'] = jrx;
54
- alias['@flow.os/client/jsx-dev-runtime'] = path.join(clientRuntime, 'jsx-dev-runtime.ts');
55
- }
56
- for (const name of fs.readdirSync(packagesDir)) {
57
- const dir = path.join(packagesDir, name);
58
- if (!fs.statSync(dir).isDirectory()) continue;
59
- const pkgPath = path.join(dir, 'package.json');
60
- if (!fs.existsSync(pkgPath)) continue;
61
- const abs = path.resolve(dir);
62
- try {
63
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) as { name?: string };
64
- if (pkg.name?.startsWith('@flow.os/') || pkg.name === '@flow.os') alias[pkg.name] = abs;
65
- } catch {}
66
- alias[`@flow.os/${name}`] = abs;
67
- }
68
- return alias;
69
- }
70
-
71
- const FLOW_STYLE_POSITIONS = ['top-left', 'top-right', 'bottom-left', 'bottom-right'] as const;
72
- export type FlowStyleBuilderPosition = (typeof FLOW_STYLE_POSITIONS)[number];
73
-
74
- export type FlowConfigOptions = {
75
- /** Porta del dev server. Default: 3000 */
76
- port?: number;
77
- /** Esporre su rete. Default: true */
78
- host?: boolean;
79
- /**
80
- * Backend in dev: true = server Flow (come flowServer() da @flow.os/server), false/undefined = nessuno.
81
- * Puoi anche passare un plugin Vite (es. server: flowServer() da @flow.os/server).
82
- */
83
- server?: Plugin | boolean;
84
- /** Plugin Vite aggiuntivi. Default: [] */
85
- plugins?: Plugin[];
86
- /**
87
- * In dev: Flow Style Builder. Passa la posizione (es. 'bottom-right').
88
- * Se non lo usi, non mettere la proprietà. Per i plugin Vite: flowStyleBuilder('bottom-right') da @flow.os/style.
89
- */
90
- flowStyleBuilder?: FlowStyleBuilderPosition;
91
- };
92
-
93
- const DEFAULTS = {
94
- port: 3000,
95
- host: true,
96
- server: undefined as Plugin | boolean | undefined,
97
- plugins: [] as Plugin[],
98
- };
99
-
100
- function flowServerUrlPlugin(hostEnabled: boolean): Plugin {
101
- return {
102
- name: 'flow:server-url',
103
- configureServer(server) {
104
- (server as { printUrls?: () => void }).printUrls = () => {};
105
- server.httpServer?.once('listening', () => {
106
- const addr = server.httpServer?.address();
107
- if (!addr || typeof addr !== 'object' || !('port' in addr)) return;
108
- const port = (addr as { port: number }).port;
109
- const host = (addr as { address: string }).address;
110
- const localHost = host === '::' || host === '0.0.0.0' ? 'localhost' : host;
111
- const localUrl = `http://${localHost}:${port}/`;
112
- const networkUrl = hostEnabled ? getNetworkUrl(port) : null;
113
- const styleServerUrl = (server as { __flowStyleServerUrl?: string }).__flowStyleServerUrl;
114
-
115
- const styleLine = styleServerUrl ? dim('Style server: ') + cyan(styleServerUrl) : '';
116
- const contents = [
117
- bold('Flow OS'),
118
- cyan('🏠') + ' ' + dim('Local: ') + cyan(localUrl),
119
- networkUrl ? cyan('🌐') + ' ' + dim('Network: ') + cyan(networkUrl) : '',
120
- styleLine,
121
- ].filter(Boolean);
122
- // Larghezza fissa: max lunghezza testo + extra così il rettangolo chiude bene a destra
123
- const contentWidth =
124
- Math.max(MIN_CONTENT_W, ...contents.map((c) => stripAnsi(c).length)) + EXTRA_BOX_WIDTH;
125
- const borderW = contentWidth + 3;
126
-
127
- const line = (content: string) => {
128
- const pad = Math.max(0, contentWidth - stripAnsi(content).length);
129
- return dim(' │ ') + content + ' '.repeat(pad) + dim(' │');
130
- };
131
- const top = dim(' ╭') + '─'.repeat(borderW) + dim('╮');
132
- const bottom = dim(' ╰') + '─'.repeat(borderW) + dim('╯');
133
-
134
- const lines = [
135
- top,
136
- line(bold('Flow OS')),
137
- line(cyan('🏠') + ' ' + dim('Local: ') + cyan(localUrl)),
138
- networkUrl ? line(cyan('🌐') + ' ' + dim('Network: ') + cyan(networkUrl)) : line(''),
139
- ...(styleLine ? [line(styleLine)] : []),
140
- bottom,
141
- ];
142
- // Sovrascrive le 2 righe sopra (comando shell + echo di bun)
143
- process.stdout.write('\x1b[2A\r' + lines.join('\n') + '\n');
144
- });
145
- },
146
- };
147
- }
148
-
149
- /** Config per flow.config.ts. Client + Vite; server opzionale con server: flowServer(). */
150
- export default function config(
151
- options: FlowConfigOptions = {}
152
- ): () => Promise<ReturnType<typeof import('vite').defineConfig>> {
153
- const {
154
- port: optPort = DEFAULTS.port,
155
- host = DEFAULTS.host,
156
- server = DEFAULTS.server,
157
- plugins = DEFAULTS.plugins,
158
- flowStyleBuilder,
159
- } = options;
160
- return async () => {
161
- let port: number;
162
- if (process.env.FLOW_DEV_PORT) {
163
- port = parseInt(process.env.FLOW_DEV_PORT, 10);
164
- } else {
165
- port = await findFreePort(3000, 3020);
166
- }
167
- const serverPlugin: Plugin | undefined =
168
- server === true
169
- ? (await import('@flow.os/server')).flowServer()
170
- : typeof server === 'object' && server != null
171
- ? server
172
- : undefined;
173
- const flowStyleBuilderPosition: FlowStyleBuilderPosition | undefined =
174
- typeof flowStyleBuilder === 'string' && (FLOW_STYLE_POSITIONS as readonly string[]).includes(flowStyleBuilder)
175
- ? flowStyleBuilder
176
- : undefined;
177
- const { flow } = await import('./vite.js');
178
- const stylePlugin =
179
- flowStyleBuilderPosition != null
180
- ? (await import('@flow.os/style/vite-plugin')).styleFlowServerPlugin()
181
- : undefined;
182
- const allPlugins = [
183
- ...(stylePlugin ? [stylePlugin] : []),
184
- flowServerUrlPlugin(host === true),
185
- ...(serverPlugin
186
- ? [serverPlugin, flow({ flowStyleBuilder: flowStyleBuilderPosition }), ...plugins]
187
- : [flow({ flowStyleBuilder: flowStyleBuilderPosition }), ...plugins]),
188
- ];
189
- const alias = resolveAlias();
190
- const baseLogger = createLogger('info');
191
- const customLogger = {
192
- ...baseLogger,
193
- info: (msg: string, opts?: { clear?: boolean }) => {
194
- const t = msg.replace(/\s+/g, ' ');
195
- if (/VITE\s+v?\d|ready\s+in|Local:\s*http|Network:\s*http|press\s+h\s+enter|Port\s+\d+\s+is\s+in\s+use|optimizing\s+dependencies|re-optimizing/i.test(t)) return;
196
- baseLogger.info(msg, opts);
197
- },
198
- };
199
- return {
200
- resolve: Object.keys(alias).length ? { alias } : {},
201
- server: { port, host, strictPort: true },
202
- customLogger,
203
- build: {
204
- rollupOptions: {
205
- external: ['@flow.os/server', /^@flow.os\/server\/.+/],
206
- },
207
- },
208
- plugins: allPlugins,
209
- };
210
- };
211
- }
@@ -1,98 +0,0 @@
1
- /// <reference types="node" />
2
- import { writeFileSync } from 'fs';
3
- import { resolve } from 'path';
4
- import type { Plugin } from 'vite';
5
-
6
- const FLOW_ENTRY_ID = '\0flow-entry';
7
-
8
- const POSITIONS = ['top-left', 'top-right', 'bottom-left', 'bottom-right'] as const;
9
- type Position = (typeof POSITIONS)[number];
10
-
11
- function isPosition(s: unknown): s is Position {
12
- return typeof s === 'string' && (POSITIONS as readonly string[]).includes(s);
13
- }
14
-
15
- function getEntryWithBuilder(position: Position): string {
16
- const pos = JSON.stringify(position);
17
- return `(async () => {
18
- const isPreview = typeof window !== 'undefined' && new URLSearchParams(window.location.search).has('preview');
19
- if (import.meta.env.DEV && !isPreview) {
20
- const app = document.getElementById('app');
21
- if (app) {
22
- app.innerHTML = '';
23
- app.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100vh;z-index:1';
24
- const iframe = document.createElement('iframe');
25
- iframe.setAttribute('data-flow-preview', '1');
26
- iframe.src = window.location.pathname + '?preview=1' + (window.location.hash || '');
27
- iframe.style.cssText = 'width:100%;height:100%;border:0';
28
- app.appendChild(iframe);
29
- const { initFlowStyleBuilder } = await import('@flow.os/style');
30
- initFlowStyleBuilder({ previewIframe: iframe, position: ${pos} });
31
- }
32
- return;
33
- }
34
- const root = await import('/client/root.tsx');
35
- const { run } = await import('@flow.os/router');
36
- const opts = {};
37
- if (root.fallback != null) opts.fallback = root.fallback;
38
- run(root.default, import.meta.glob('/client/routes/**/*.tsx'), Object.keys(opts).length ? opts : undefined);
39
- })();
40
- `;
41
- }
42
-
43
- const ENTRY_DEFAULT = `(async () => {
44
- const root = await import('/client/root.tsx');
45
- const { run } = await import('@flow.os/router');
46
- const opts = {};
47
- if (root.fallback != null) opts.fallback = root.fallback;
48
- run(root.default, import.meta.glob('/client/routes/**/*.tsx'), Object.keys(opts).length ? opts : undefined);
49
- })();
50
- `;
51
-
52
- /** Reset stili browser: niente margin/padding di default, layout full viewport. */
53
- const FLOW_BASE_STYLE = `<style>html,body{margin:0;padding:0;min-height:100vh}#app{min-height:100vh;box-sizing:border-box}*,*::before,*::after{box-sizing:inherit}</style>`;
54
-
55
- const HTML = `<!DOCTYPE html>
56
- <html lang="it">
57
- <head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Flow</title>${FLOW_BASE_STYLE}</head>
58
- <body><div id="app"></div><script type="module" src="/entry.tsx"></script></body>
59
- </html>`;
60
-
61
- export type FlowPluginOptions = {
62
- flowStyleBuilder?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
63
- };
64
-
65
- export function flow(options: FlowPluginOptions = {}): Plugin {
66
- const flowStyleBuilder = options.flowStyleBuilder;
67
- const position: Position | undefined = flowStyleBuilder != null && isPosition(flowStyleBuilder) ? flowStyleBuilder : undefined;
68
- const entryCode = position != null ? getEntryWithBuilder(position) : ENTRY_DEFAULT;
69
- const cwd = process.cwd();
70
- return {
71
- name: 'flow',
72
- config() {
73
- return {
74
- root: resolve(cwd),
75
- base: '/',
76
- esbuild: { jsx: 'automatic', jsxImportSource: '@flow.os/client' },
77
- resolve: { alias: { '~': resolve(cwd, 'client') } },
78
- build: { target: 'esnext', minify: 'esbuild', sourcemap: true },
79
- };
80
- },
81
- configResolved(_config) {
82
- writeFileSync(resolve(cwd, 'index.html'), HTML);
83
- },
84
- resolveId(id) {
85
- return id === '/entry.tsx' ? FLOW_ENTRY_ID : null;
86
- },
87
- load(id) {
88
- return id === FLOW_ENTRY_ID ? entryCode : null;
89
- },
90
- buildEnd(err) {
91
- if (err) {
92
- const msg = err.message ?? String(err);
93
- const stack = err.stack ?? (err as Error).cause?.toString?.();
94
- console.error('[flow] build error:', msg, stack ?? '');
95
- }
96
- },
97
- };
98
- }
@@ -1,32 +0,0 @@
1
- import { effect } from '@flow.os/core';
2
- import { isGetter } from './utils.js';
3
-
4
- /** Props gestite altrove (non passare qui). */
5
- const SKIP = new Set(['children', 'class', 'className', 'classList', 'classFlow', 'style', 's', 'styleFlow']);
6
-
7
- export function applyAttrs(el: HTMLElement, rest: Record<string, unknown>): void {
8
- for (const [k, v] of Object.entries(rest)) {
9
- if (v == null || SKIP.has(k)) continue;
10
- if (k.startsWith('on') && typeof v === 'function') {
11
- el.addEventListener(k.slice(2).toLowerCase(), v as EventListener);
12
- continue;
13
- }
14
- if (isGetter(v)) {
15
- effect(() => {
16
- const x = (v as () => unknown)();
17
- if (typeof x === 'boolean') {
18
- if (x) el.setAttribute(k, '');
19
- else el.removeAttribute(k);
20
- } else {
21
- el.setAttribute(k, String(x));
22
- }
23
- });
24
- continue;
25
- }
26
- if (typeof v === 'boolean') {
27
- if (v) el.setAttribute(k, '');
28
- continue;
29
- }
30
- if (typeof v === 'string' || typeof v === 'number') el.setAttribute(k, String(v));
31
- }
32
- }
@@ -1,116 +0,0 @@
1
- import { effect } from '@flow.os/core';
2
- import { isGetter } from './utils.js';
3
-
4
- export function toStyleValue(v: unknown): string {
5
- return typeof v === 'number' ? `${v}px` : String(v ?? '');
6
- }
7
-
8
- export function setStyleProp(el: HTMLElement, key: string, value: string): void {
9
- if (key.startsWith('--')) el.style.setProperty(key, value);
10
- else (el.style as unknown as Record<string, string>)[key] = value;
11
- }
12
-
13
- const CLASS_FLOW_MAP: Record<string, string> = {
14
- text: 'fontSize',
15
- mb: 'marginBottom',
16
- mt: 'marginTop',
17
- ml: 'marginLeft',
18
- mr: 'marginRight',
19
- mx: 'marginLeft',
20
- my: 'marginTop',
21
- m: 'margin',
22
- pb: 'paddingBottom',
23
- pt: 'paddingTop',
24
- pl: 'paddingLeft',
25
- pr: 'paddingRight',
26
- px: 'paddingLeft',
27
- py: 'paddingTop',
28
- p: 'padding',
29
- w: 'width',
30
- h: 'height',
31
- minW: 'minWidth',
32
- minH: 'minHeight',
33
- maxW: 'maxWidth',
34
- maxH: 'maxHeight',
35
- gap: 'gap',
36
- rounded: 'borderRadius',
37
- top: 'top',
38
- left: 'left',
39
- right: 'right',
40
- bottom: 'bottom',
41
- };
42
-
43
- function resolveClassFlowKey(k: string): string {
44
- if (k.startsWith('--')) return k;
45
- return CLASS_FLOW_MAP[k] ?? k;
46
- }
47
-
48
- function isClassFlowReactive(val: unknown): boolean {
49
- return isGetter(val) || (Array.isArray(val) && val.length === 2 && isGetter(val[0]));
50
- }
51
-
52
- function resolveClassFlowValue(val: unknown): string {
53
- if (isGetter(val)) return toStyleValue((val as () => unknown)());
54
- if (Array.isArray(val) && val.length === 2 && isGetter(val[0]))
55
- return String((val[0] as () => unknown)()) + String(val[1]);
56
- return toStyleValue(val);
57
- }
58
-
59
- function applyClassFlowObj(el: HTMLElement, obj: Record<string, unknown>): void {
60
- for (const [k, val] of Object.entries(obj))
61
- setStyleProp(el, resolveClassFlowKey(k), resolveClassFlowValue(val));
62
- }
63
-
64
- export function applyClassFlow(el: HTMLElement, classFlowVal: unknown): void {
65
- if (classFlowVal == null) return;
66
- if (isGetter(classFlowVal)) {
67
- effect(() => applyClassFlowObj(el, (classFlowVal as () => Record<string, unknown>)()));
68
- return;
69
- }
70
- if (typeof classFlowVal !== 'object' || Array.isArray(classFlowVal) || classFlowVal instanceof Node) return;
71
- const obj = classFlowVal as Record<string, unknown>;
72
- const hasReactive = Object.values(obj).some(isClassFlowReactive);
73
- if (hasReactive) {
74
- effect(() => {
75
- for (const [k, val] of Object.entries(obj))
76
- setStyleProp(el, resolveClassFlowKey(k), resolveClassFlowValue(val));
77
- });
78
- } else {
79
- applyClassFlowObj(el, obj);
80
- }
81
- }
82
-
83
- export function applyClassAndClassList(
84
- el: HTMLElement,
85
- classVal: unknown,
86
- classNameVal: unknown,
87
- classListVal: unknown
88
- ): void {
89
- const base = classVal ?? classNameVal;
90
- if (base == null && (classListVal == null || typeof classListVal !== 'object')) return;
91
- effect(() => {
92
- let baseStr = '';
93
- if (base != null) {
94
- if (Array.isArray(base)) {
95
- baseStr = base
96
- .map((item) => (isGetter(item) ? String((item as () => unknown)()) : String(item)))
97
- .filter(Boolean)
98
- .join(' ');
99
- } else if (isGetter(base)) {
100
- baseStr = String((base as () => unknown)());
101
- } else {
102
- baseStr = String(base);
103
- }
104
- }
105
- const list = classListVal as Record<string, boolean | (() => boolean)> | undefined;
106
- const truthy: string[] = [];
107
- if (list && typeof list === 'object' && !(list instanceof Node)) {
108
- for (const [cls, val] of Object.entries(list)) {
109
- const v = isGetter(val) ? (val as () => boolean)() : val;
110
- if (v) truthy.push(cls);
111
- }
112
- }
113
- const full = [baseStr, ...truthy].filter(Boolean).join(' ');
114
- el.setAttribute('class', full);
115
- });
116
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Feature applicate a div, p, button, ecc.
3
- * Un file per feature; qui si raggruppano e si espongono a jsx.
4
- */
5
- export { applyClassFlow, applyClassAndClassList } from './class-flow.js';
6
- export { applyStyle } from './style.js';
7
- export { applyStyleFlow } from './style-flow.js';
8
- export { applyAttrs } from './attrs.js';
@@ -1,40 +0,0 @@
1
- import { styleToCssText } from '@flow.os/style';
2
- import type { PseudoKey } from '@flow.os/style';
3
-
4
- const PSEUDO_SELECTOR: Record<PseudoKey, string> = {
5
- hover: ':hover',
6
- active: ':active',
7
- focus: ':focus',
8
- focusVisible: ':focus-visible',
9
- };
10
-
11
- let styleEl: HTMLStyleElement | null = null;
12
- const cache = new Map<string, string>();
13
- let id = 0;
14
-
15
- function ensureStyleEl(): HTMLStyleElement {
16
- if (styleEl) return styleEl;
17
- styleEl = document.createElement('style');
18
- styleEl.setAttribute('data-flow-style', '');
19
- document.head.appendChild(styleEl);
20
- return styleEl;
21
- }
22
-
23
- /** Restituisce className da aggiungere all'elemento. La regola .sf-{pseudo}-{id}:{pseudo} { ... } è iniettata una sola volta. */
24
- export function getPseudoClass(
25
- pseudo: PseudoKey,
26
- style: Record<string, string>
27
- ): string {
28
- const cssText = styleToCssText(style);
29
- if (!cssText) return '';
30
- const key = `${pseudo}:${cssText}`;
31
- let className = cache.get(key);
32
- if (className) return className;
33
- className = `sf-${pseudo}-${++id}`;
34
- cache.set(key, className);
35
- const selector = `.${className}${PSEUDO_SELECTOR[pseudo]}`;
36
- const rule = `${selector} { ${cssText} }`;
37
- const el = ensureStyleEl();
38
- el.appendChild(document.createTextNode(rule));
39
- return className;
40
- }