create-flow-os 0.0.3 → 0.0.5

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 (187) hide show
  1. package/package.json +8 -21
  2. package/src/create/index.ts +31 -0
  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 -7
  9. package/bin/index.js +0 -1139
  10. package/config.json +0 -86
  11. package/flow.config.client.ts +0 -3
  12. package/packages/client/client/root.css +0 -9
  13. package/packages/client/client/root.tsx +0 -13
  14. package/packages/client/client/routes/404.tsx +0 -24
  15. package/packages/client/client/routes/index.tsx +0 -47
  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/LICENSE +0 -97
  23. package/profiles/client/bun.lock +0 -335
  24. package/profiles/client/client/root.css +0 -10
  25. package/profiles/client/client/root.tsx +0 -14
  26. package/profiles/client/client/routes/404.tsx +0 -25
  27. package/profiles/client/client/routes/index.tsx +0 -48
  28. package/profiles/client/flow.config.ts +0 -3
  29. package/profiles/client/index.html +0 -5
  30. package/profiles/client/package.json +0 -29
  31. package/profiles/client/packages/client/LICENSE +0 -97
  32. package/profiles/client/packages/client/build.ts +0 -14
  33. package/profiles/client/packages/client/config.ts +0 -141
  34. package/profiles/client/packages/client/dom.ts +0 -5
  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 -4
  44. package/profiles/client/packages/client/jsx-dev-runtime.ts +0 -1
  45. package/profiles/client/packages/client/jsx-runtime.ts +0 -1
  46. package/profiles/client/packages/client/jsx-types.d.ts +0 -64
  47. package/profiles/client/packages/client/jsx.ts +0 -99
  48. package/profiles/client/packages/client/package.json +0 -42
  49. package/profiles/client/packages/client/preview.ts +0 -14
  50. package/profiles/client/packages/client/start-dev.ts +0 -23
  51. package/profiles/client/packages/client/vite.ts +0 -54
  52. package/profiles/client/packages/core/LICENSE +0 -97
  53. package/profiles/client/packages/core/dom.ts +0 -43
  54. package/profiles/client/packages/core/for.ts +0 -42
  55. package/profiles/client/packages/core/index.ts +0 -5
  56. package/profiles/client/packages/core/lifecycle.ts +0 -6
  57. package/profiles/client/packages/core/package.json +0 -15
  58. package/profiles/client/packages/core/show-switch.ts +0 -56
  59. package/profiles/client/packages/core/state.ts +0 -56
  60. package/profiles/client/packages/router/LICENSE +0 -97
  61. package/profiles/client/packages/router/index.ts +0 -174
  62. package/profiles/client/packages/router/package.json +0 -10
  63. package/profiles/client/packages/style/LICENSE +0 -97
  64. package/profiles/client/packages/style/breakpoints.ts +0 -20
  65. package/profiles/client/packages/style/extension/.vscodeignore +0 -5
  66. package/profiles/client/packages/style/extension/README.md +0 -7
  67. package/profiles/client/packages/style/extension/flow-style-colors-0.0.1.vsix +0 -0
  68. package/profiles/client/packages/style/extension/out/extension.js +0 -130
  69. package/profiles/client/packages/style/extension/package.json +0 -24
  70. package/profiles/client/packages/style/extension/src/extension.ts +0 -146
  71. package/profiles/client/packages/style/extension/tsconfig.json +0 -12
  72. package/profiles/client/packages/style/index.ts +0 -16
  73. package/profiles/client/packages/style/package.json +0 -14
  74. package/profiles/client/packages/style/resolve.ts +0 -84
  75. package/profiles/client/packages/style/shorthand.ts +0 -62
  76. package/profiles/client/tsconfig.json +0 -30
  77. package/profiles/full/.dockerignore +0 -12
  78. package/profiles/full/.oxfmtrc.json +0 -7
  79. package/profiles/full/.oxlintrc.json +0 -13
  80. package/profiles/full/.vscode/settings.json +0 -12
  81. package/profiles/full/Dockerfile +0 -26
  82. package/profiles/full/LICENSE +0 -97
  83. package/profiles/full/bun.lock +0 -335
  84. package/profiles/full/client/root.css +0 -10
  85. package/profiles/full/client/root.tsx +0 -14
  86. package/profiles/full/client/routes/404.tsx +0 -25
  87. package/profiles/full/client/routes/index.tsx +0 -48
  88. package/profiles/full/flow.config.ts +0 -8
  89. package/profiles/full/index.html +0 -5
  90. package/profiles/full/package.json +0 -29
  91. package/profiles/full/packages/client/LICENSE +0 -97
  92. package/profiles/full/packages/client/build.ts +0 -14
  93. package/profiles/full/packages/client/config.ts +0 -141
  94. package/profiles/full/packages/client/dom.ts +0 -5
  95. package/profiles/full/packages/client/features/attrs.ts +0 -32
  96. package/profiles/full/packages/client/features/class-flow.ts +0 -116
  97. package/profiles/full/packages/client/features/index.ts +0 -8
  98. package/profiles/full/packages/client/features/pseudo-injector.ts +0 -40
  99. package/profiles/full/packages/client/features/style-flow.ts +0 -106
  100. package/profiles/full/packages/client/features/style.ts +0 -27
  101. package/profiles/full/packages/client/features/utils.ts +0 -4
  102. package/profiles/full/packages/client/features/viewport.ts +0 -20
  103. package/profiles/full/packages/client/index.ts +0 -4
  104. package/profiles/full/packages/client/jsx-dev-runtime.ts +0 -1
  105. package/profiles/full/packages/client/jsx-runtime.ts +0 -1
  106. package/profiles/full/packages/client/jsx-types.d.ts +0 -64
  107. package/profiles/full/packages/client/jsx.ts +0 -99
  108. package/profiles/full/packages/client/package.json +0 -42
  109. package/profiles/full/packages/client/preview.ts +0 -14
  110. package/profiles/full/packages/client/start-dev.ts +0 -23
  111. package/profiles/full/packages/client/vite.ts +0 -54
  112. package/profiles/full/packages/core/LICENSE +0 -97
  113. package/profiles/full/packages/core/dom.ts +0 -43
  114. package/profiles/full/packages/core/for.ts +0 -42
  115. package/profiles/full/packages/core/index.ts +0 -5
  116. package/profiles/full/packages/core/lifecycle.ts +0 -6
  117. package/profiles/full/packages/core/package.json +0 -15
  118. package/profiles/full/packages/core/show-switch.ts +0 -56
  119. package/profiles/full/packages/core/state.ts +0 -56
  120. package/profiles/full/packages/router/LICENSE +0 -97
  121. package/profiles/full/packages/router/index.ts +0 -174
  122. package/profiles/full/packages/router/package.json +0 -10
  123. package/profiles/full/packages/server/LICENSE +0 -97
  124. package/profiles/full/packages/server/core.ts +0 -140
  125. package/profiles/full/packages/server/index.ts +0 -24
  126. package/profiles/full/packages/server/package.json +0 -29
  127. package/profiles/full/packages/server/plugin.ts +0 -79
  128. package/profiles/full/packages/server/production.ts +0 -75
  129. package/profiles/full/packages/server/start.ts +0 -15
  130. package/profiles/full/packages/style/LICENSE +0 -97
  131. package/profiles/full/packages/style/breakpoints.ts +0 -20
  132. package/profiles/full/packages/style/extension/.vscodeignore +0 -5
  133. package/profiles/full/packages/style/extension/README.md +0 -7
  134. package/profiles/full/packages/style/extension/flow-style-colors-0.0.1.vsix +0 -0
  135. package/profiles/full/packages/style/extension/out/extension.js +0 -130
  136. package/profiles/full/packages/style/extension/package.json +0 -24
  137. package/profiles/full/packages/style/extension/src/extension.ts +0 -146
  138. package/profiles/full/packages/style/extension/tsconfig.json +0 -12
  139. package/profiles/full/packages/style/index.ts +0 -16
  140. package/profiles/full/packages/style/package.json +0 -14
  141. package/profiles/full/packages/style/resolve.ts +0 -84
  142. package/profiles/full/packages/style/shorthand.ts +0 -62
  143. package/profiles/full/server/routes/hello.get.ts +0 -4
  144. package/profiles/full/tsconfig.json +0 -30
  145. package/profiles/server/.dockerignore +0 -12
  146. package/profiles/server/.oxfmtrc.json +0 -7
  147. package/profiles/server/.oxlintrc.json +0 -13
  148. package/profiles/server/.vscode/settings.json +0 -12
  149. package/profiles/server/Dockerfile +0 -26
  150. package/profiles/server/LICENSE +0 -97
  151. package/profiles/server/bun.lock +0 -335
  152. package/profiles/server/flow.config.ts +0 -8
  153. package/profiles/server/index.html +0 -5
  154. package/profiles/server/package.json +0 -29
  155. package/profiles/server/packages/core/LICENSE +0 -97
  156. package/profiles/server/packages/core/dom.ts +0 -43
  157. package/profiles/server/packages/core/for.ts +0 -42
  158. package/profiles/server/packages/core/index.ts +0 -5
  159. package/profiles/server/packages/core/lifecycle.ts +0 -6
  160. package/profiles/server/packages/core/package.json +0 -15
  161. package/profiles/server/packages/core/show-switch.ts +0 -56
  162. package/profiles/server/packages/core/state.ts +0 -56
  163. package/profiles/server/packages/router/LICENSE +0 -97
  164. package/profiles/server/packages/router/index.ts +0 -174
  165. package/profiles/server/packages/router/package.json +0 -10
  166. package/profiles/server/packages/server/LICENSE +0 -97
  167. package/profiles/server/packages/server/core.ts +0 -140
  168. package/profiles/server/packages/server/index.ts +0 -24
  169. package/profiles/server/packages/server/package.json +0 -29
  170. package/profiles/server/packages/server/plugin.ts +0 -79
  171. package/profiles/server/packages/server/production.ts +0 -75
  172. package/profiles/server/packages/server/start.ts +0 -15
  173. package/profiles/server/packages/style/LICENSE +0 -97
  174. package/profiles/server/packages/style/breakpoints.ts +0 -20
  175. package/profiles/server/packages/style/extension/.vscodeignore +0 -5
  176. package/profiles/server/packages/style/extension/README.md +0 -7
  177. package/profiles/server/packages/style/extension/flow-style-colors-0.0.1.vsix +0 -0
  178. package/profiles/server/packages/style/extension/out/extension.js +0 -130
  179. package/profiles/server/packages/style/extension/package.json +0 -24
  180. package/profiles/server/packages/style/extension/src/extension.ts +0 -146
  181. package/profiles/server/packages/style/extension/tsconfig.json +0 -12
  182. package/profiles/server/packages/style/index.ts +0 -16
  183. package/profiles/server/packages/style/package.json +0 -14
  184. package/profiles/server/packages/style/resolve.ts +0 -84
  185. package/profiles/server/packages/style/shorthand.ts +0 -62
  186. package/profiles/server/server/routes/hello.get.ts +0 -4
  187. package/profiles/server/tsconfig.json +0 -30
@@ -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,43 +0,0 @@
1
- /**
2
- * Helper DOM per Show/For: normalizza children (getter, string, Node, array) e setContent.
3
- */
4
- import { effect } from './state.js';
5
-
6
- function isGetter(fn: unknown): fn is () => unknown {
7
- return typeof fn === 'function' && fn.length === 0;
8
- }
9
-
10
- export function normalizeChild(c: unknown): Node | string | null {
11
- if (c == null) return null;
12
- if (typeof c === 'string' || typeof c === 'number') return String(c);
13
- if (c instanceof Node) return c;
14
- if (isGetter(c)) {
15
- const text = document.createTextNode('');
16
- effect(() => {
17
- text.textContent = String(c());
18
- });
19
- return text;
20
- }
21
- if (Array.isArray(c)) {
22
- const frag = document.createDocumentFragment();
23
- for (const x of c) {
24
- const n = normalizeChild(x);
25
- if (n !== null) frag.appendChild(typeof n === 'string' ? document.createTextNode(n) : n);
26
- }
27
- return frag;
28
- }
29
- return null;
30
- }
31
-
32
- export function setContent(el: HTMLElement, c: unknown): void {
33
- const n = normalizeChild(c);
34
- if (n === null) {
35
- el.replaceChildren();
36
- return;
37
- }
38
- if (typeof n === 'string') {
39
- el.replaceChildren(document.createTextNode(n));
40
- return;
41
- }
42
- el.replaceChildren(n);
43
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * For: lista reattiva. each={() => T[]}, children (item, index) => content.
3
- * Opzionale key (item, index) => string|number per reconciliation keyed.
4
- */
5
- import { effect } from './state.js';
6
- import { normalizeChild } from './dom.js';
7
-
8
- function isGetter(fn: unknown): fn is () => unknown {
9
- return typeof fn === 'function' && fn.length === 0;
10
- }
11
-
12
- function appendNormalized(parent: Node, c: unknown): void {
13
- const n = normalizeChild(c);
14
- if (n === null) return;
15
- parent.appendChild(typeof n === 'string' ? document.createTextNode(n) : n);
16
- }
17
-
18
- /** For: rende una lista reattiva. each=getter array, children=(item, index)=>content, fallback=vuoto. */
19
- export function For<T>(props: {
20
- each: (() => T[]) | T[];
21
- fallback?: unknown;
22
- children: (item: T, index: number) => unknown;
23
- }): HTMLElement {
24
- const container = document.createElement('span');
25
- container.style.display = 'contents';
26
- const getList = isGetter(props.each) ? props.each : () => props.each as T[];
27
- effect(() => {
28
- const list = getList();
29
- const len = Array.isArray(list) ? list.length : 0;
30
- if (len === 0) {
31
- appendNormalized(container, props.fallback);
32
- return;
33
- }
34
- container.replaceChildren();
35
- for (let i = 0; i < len; i++) {
36
- const item = list[i];
37
- if (item === undefined) continue;
38
- appendNormalized(container, props.children(item, i));
39
- }
40
- });
41
- return container;
42
- }
@@ -1,5 +0,0 @@
1
- export { state, effect } from './state.js';
2
- export { onMount, onCleanup } from './lifecycle.js';
3
- export { Show, Switch, Match } from './show-switch.js';
4
- export { For } from './for.js';
5
- export { normalizeChild, setContent } from './dom.js';
@@ -1,6 +0,0 @@
1
- /** Esegue il callback dopo il mount (microtask: subito dopo il sync corrente). */
2
- export function onMount(fn: () => void): void {
3
- queueMicrotask(fn);
4
- }
5
-
6
- export { onCleanup } from './state.js';
@@ -1,15 +0,0 @@
1
- {
2
- "name": "@flow.os/core",
3
- "version": "0.0.2",
4
- "type": "module",
5
- "main": "./index.ts",
6
- "types": "./index.ts",
7
- "dependencies": {},
8
- "exports": {
9
- ".": {
10
- "types": "./index.ts",
11
- "import": "./index.ts",
12
- "default": "./index.ts"
13
- }
14
- }
15
- }
@@ -1,56 +0,0 @@
1
- /**
2
- * Show: rendering condizionale (when/fallback).
3
- * Switch: primo branch con when() truthy, altrimenti fallback.
4
- */
5
- import { effect } from './state.js';
6
- import { setContent } from './dom.js';
7
-
8
- function isGetter(fn: unknown): fn is () => unknown {
9
- return typeof fn === 'function' && fn.length === 0;
10
- }
11
-
12
- /** Show: quando when() è truthy mostra children, altrimenti fallback. */
13
- export function Show(props: {
14
- when: (() => unknown) | unknown;
15
- fallback?: unknown;
16
- children?: unknown;
17
- }): HTMLElement {
18
- const wrapper = document.createElement('span');
19
- wrapper.style.display = 'contents';
20
- const getWhen = isGetter(props.when) ? props.when : () => props.when;
21
- effect(() => {
22
- setContent(wrapper, getWhen() ? props.children : props.fallback);
23
- });
24
- return wrapper;
25
- }
26
-
27
- export type MatchBranch = { when: () => boolean; children: unknown };
28
-
29
- /** Switch: primo branch con when() truthy, altrimenti fallback. branches = [{ when, children }, ...]. */
30
- export function Switch(props: {
31
- fallback?: unknown;
32
- branches: MatchBranch[];
33
- }): HTMLElement {
34
- const wrapper = document.createElement('span');
35
- wrapper.style.display = 'contents';
36
- effect(() => {
37
- const list = props.branches;
38
- for (let i = 0; i < list.length; i++) {
39
- const b = list[i];
40
- if (b === undefined) continue;
41
- const cond = isGetter(b.when) ? b.when() : b.when;
42
- if (cond) {
43
- setContent(wrapper, b.children);
44
- return;
45
- }
46
- }
47
- setContent(wrapper, props.fallback);
48
- });
49
- return wrapper;
50
- }
51
-
52
- /** Helper per costruire i branch di Switch: Match({ when: () => cond, children: <Node/> }) => branch. */
53
- export function Match(props: { when: (() => boolean) | boolean; children?: unknown }): MatchBranch {
54
- const whenFn = isGetter(props.when) ? props.when : () => Boolean(props.when);
55
- return { when: whenFn, children: props.children };
56
- }
@@ -1,56 +0,0 @@
1
- type Subscriber = () => void;
2
- type SubscriberSet = Set<Subscriber>;
3
-
4
- interface EffectRecord {
5
- run: () => void;
6
- deps: Set<SubscriberSet>;
7
- cleanups: Array<() => void>;
8
- }
9
-
10
- let currentEffect: EffectRecord | null = null;
11
-
12
- export function state<T>(initialValue: T): [() => T, (value: T | ((prev: T) => T)) => void] {
13
- let value = initialValue;
14
- const subscribers: SubscriberSet = new Set();
15
-
16
- function get(): T {
17
- if (currentEffect !== null) {
18
- subscribers.add(currentEffect.run);
19
- currentEffect.deps.add(subscribers);
20
- }
21
- return value;
22
- }
23
-
24
- function set(next: T | ((prev: T) => T)): void {
25
- const nextValue = typeof next === 'function' ? (next as (prev: T) => T)(value) : next;
26
- if (Object.is(value, nextValue)) return;
27
- value = nextValue;
28
- const copy = Array.from(subscribers);
29
- copy.forEach((fn) => fn());
30
- }
31
-
32
- return [get, set];
33
- }
34
-
35
- export function effect(fn: Subscriber): void {
36
- const deps = new Set<SubscriberSet>();
37
- const cleanups: Array<() => void> = [];
38
- const run: Subscriber = () => {
39
- for (const fn of cleanups) fn();
40
- cleanups.length = 0;
41
- deps.forEach((subs) => subs.delete(run));
42
- deps.clear();
43
- const prev = currentEffect;
44
- currentEffect = { run, deps, cleanups };
45
- try {
46
- fn();
47
- } finally {
48
- currentEffect = prev;
49
- }
50
- };
51
- run();
52
- }
53
-
54
- export function onCleanup(fn: () => void): void {
55
- if (currentEffect !== null) currentEffect.cleanups.push(fn);
56
- }
@@ -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,174 +0,0 @@
1
- export const APP_ID = 'flow-app';
2
-
3
- /** Contenitore dove il router monta la pagina corrente. In root: <App /> (da @flow.os/router). */
4
- export function App(): HTMLDivElement {
5
- const el = document.createElement('div');
6
- el.id = APP_ID;
7
- el.setAttribute('role', 'main');
8
- return el;
9
- }
10
-
11
- export type RouteModule = {
12
- default: (() => Node) | ((params: Record<string, string>) => Node) | (() => string) | string;
13
- };
14
-
15
- export type RunOptions = {
16
- /** Nodo (o factory) mostrato mentre la route lazy viene caricata. */
17
- fallback?: Node | (() => Node);
18
- /** Pagina 404: se fornita, viene mostrata full-page (sostituisce tutto #app, senza layout comune). */
19
- notFound?: Node | ((path: string) => Node);
20
- };
21
-
22
- function pathToPattern(key: string): string {
23
- const afterRoutes = key.replace(/^.*[/\\]routes[/\\]?/i, '').replace(/\.tsx?$/i, '');
24
- const s = afterRoutes.split(/[/\\]/).filter(Boolean).join('/');
25
- if (s === 'index' || s === '') return '';
26
- return s
27
- .split('/')
28
- .map((x) => (x.startsWith('[') && x.endsWith(']') ? `:${x.slice(1, -1)}` : x))
29
- .join('/');
30
- }
31
-
32
- function match(pattern: string, path: string): Record<string, string> | null {
33
- const pa = pattern ? pattern.split('/').filter(Boolean) : [];
34
- const ph = path.replace(/^\//, '').split('/').filter(Boolean);
35
- if (pa.length !== ph.length) return null;
36
- const params: Record<string, string> = {};
37
- for (let i = 0; i < pa.length; i++) {
38
- if (pa[i]!.startsWith(':')) params[pa[i]!.slice(1)] = ph[i] ?? '';
39
- else if (pa[i] !== ph[i]) return null;
40
- }
41
- return params;
42
- }
43
-
44
- function setContent(container: HTMLElement, content: Node | string): void {
45
- container.innerHTML = '';
46
- if (typeof content === 'string') container.textContent = content;
47
- else container.appendChild(content);
48
- }
49
-
50
- function defaultNotFound(path: string): Node {
51
- const wrap = document.createElement('div');
52
- wrap.setAttribute('role', 'alert');
53
- const h = document.createElement('h1');
54
- h.textContent = '404';
55
- const p = document.createElement('p');
56
- p.textContent = `Pagina non trovata: ${path || '/'}`;
57
- wrap.append(h, p);
58
- return wrap;
59
- }
60
-
61
- type RouterOptions = {
62
- fallback?: Node | (() => Node);
63
- notFound?: Node | ((path: string) => Node);
64
- /** Per 404 full-page: elemento #app e factory del layout da ripristinare quando si naviga via. */
65
- appRoot?: HTMLElement;
66
- getLayout?: () => Node;
67
- };
68
-
69
- export function createRouter(
70
- modules: Record<string, () => Promise<RouteModule>>,
71
- container: HTMLElement,
72
- options: RouterOptions = {}
73
- ) {
74
- const routes = Object.entries(modules).map(([key, loader]) => ({
75
- pattern: pathToPattern(key),
76
- loader,
77
- }));
78
- routes.sort(
79
- (a, b) =>
80
- b.pattern.split('/').filter(Boolean).length - a.pattern.split('/').filter(Boolean).length
81
- );
82
- const notFound = options.notFound ?? defaultNotFound;
83
- const fullPageNotFound = Boolean(options.appRoot && options.getLayout && options.notFound);
84
-
85
- function getContainer(): HTMLElement | null {
86
- return document.getElementById(APP_ID);
87
- }
88
-
89
- async function render(pathname: string): Promise<boolean> {
90
- const path = pathname === '/' ? '' : pathname.slice(1);
91
- for (const { pattern, loader } of routes) {
92
- const params = match(pattern, path);
93
- if (params === null) continue;
94
- let target = getContainer();
95
- if (fullPageNotFound && !target) {
96
- options.appRoot!.innerHTML = '';
97
- options.appRoot!.appendChild(options.getLayout!());
98
- target = getContainer();
99
- }
100
- if (!target) continue;
101
- const fallbackNode =
102
- options.fallback != null
103
- ? typeof options.fallback === 'function'
104
- ? options.fallback()
105
- : options.fallback
106
- : null;
107
- if (fallbackNode) setContent(target, fallbackNode);
108
- const mod = await loader();
109
- const def = mod.default;
110
- if (typeof def === 'function') {
111
- const out = def.length
112
- ? (def as (p: Record<string, string>) => Node)(params)
113
- : (def as () => Node | string)();
114
- if (out instanceof Node) setContent(target, out);
115
- else if (typeof out === 'string') target.innerHTML = out;
116
- else target.innerHTML = '';
117
- } else setContent(target, typeof def === 'string' ? def : (def as unknown as Node));
118
- return true;
119
- }
120
- const nfNode = typeof notFound === 'function' ? notFound(pathname) : notFound;
121
- if (fullPageNotFound) {
122
- options.appRoot!.innerHTML = '';
123
- options.appRoot!.appendChild(nfNode);
124
- } else {
125
- setContent(container, nfNode);
126
- }
127
- return false;
128
- }
129
-
130
- function go(path: string, replace = false): void {
131
- const p = path.startsWith('/') ? path : `/${path}`;
132
- render(p).then((ok) => {
133
- if (ok) (replace ? history.replaceState : history.pushState).call(history, null, '', p);
134
- });
135
- }
136
-
137
- function start(): void {
138
- render(location.pathname || '/');
139
- window.addEventListener('popstate', () => render(location.pathname || '/'));
140
- document.addEventListener('click', (e) => {
141
- const a = (e.target as Element).closest('a');
142
- if (a?.getAttribute('href')?.startsWith('/') && !a.href.startsWith('//')) {
143
- e.preventDefault();
144
- go(a.getAttribute('href')!);
145
- }
146
- });
147
- }
148
-
149
- return { go, start };
150
- }
151
-
152
- /** Monta App e avvia il router. Da usare nell'entry virtuale. */
153
- export function run(
154
- App: () => Node,
155
- modules: Record<string, () => Promise<RouteModule>>,
156
- options?: RunOptions
157
- ): void {
158
- const app = document.getElementById('app')!;
159
- app.appendChild(App());
160
- const appContainer = document.getElementById(APP_ID);
161
- if (!appContainer)
162
- throw new Error(
163
- `#${APP_ID} not found: use <App /> from @flow.os/router in your root layout.`
164
- );
165
- const routerOptions: RouterOptions = {
166
- fallback: options?.fallback,
167
- notFound: options?.notFound,
168
- };
169
- if (options?.notFound != null) {
170
- routerOptions.appRoot = app;
171
- routerOptions.getLayout = () => App();
172
- }
173
- createRouter(modules, appContainer as HTMLElement, routerOptions).start();
174
- }
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@flow.os/router",
3
- "version": "0.0.2",
4
- "type": "module",
5
- "main": "./index.ts",
6
- "types": "./index.ts",
7
- "exports": {
8
- ".": { "types": "./index.ts", "import": "./index.ts", "default": "./index.ts" }
9
- }
10
- }