@zerotal/flow 1.0.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +21 -0
  3. package/README.md +148 -0
  4. package/package.json +84 -0
  5. package/src/Component.ts +1498 -0
  6. package/src/Form.ts +189 -0
  7. package/src/Layout.ts +47 -0
  8. package/src/augment.ts +94 -0
  9. package/src/client/FlowClientError.ts +12 -0
  10. package/src/client/FlowComponent.ts +96 -0
  11. package/src/client/alpinejs-morph.d.ts +5 -0
  12. package/src/client/bridge.ts +3463 -0
  13. package/src/client/confirm.ts +338 -0
  14. package/src/client/cspAdapter.ts +79 -0
  15. package/src/client/cspEvaluator.ts +494 -0
  16. package/src/client/errorOverlay.ts +124 -0
  17. package/src/client/headless.ts +948 -0
  18. package/src/client/index.csp.ts +47 -0
  19. package/src/client/index.ts +56 -0
  20. package/src/client/optimistic.ts +52 -0
  21. package/src/client/timeline.ts +160 -0
  22. package/src/client/url.ts +51 -0
  23. package/src/commands/MakeFlowCommand.ts +290 -0
  24. package/src/compiler/cache.ts +101 -0
  25. package/src/compiler/directives.ts +107 -0
  26. package/src/compiler/helpers.ts +26 -0
  27. package/src/compiler/index.ts +172 -0
  28. package/src/compiler/transform.ts +2070 -0
  29. package/src/components.ts +1465 -0
  30. package/src/config.ts +52 -0
  31. package/src/decorators.ts +978 -0
  32. package/src/dehydrate.ts +333 -0
  33. package/src/durable.ts +243 -0
  34. package/src/events.ts +118 -0
  35. package/src/frameworkEvents.ts +40 -0
  36. package/src/headless.ts +1147 -0
  37. package/src/index.ts +267 -0
  38. package/src/jsx-dev-runtime.ts +14 -0
  39. package/src/jsx-runtime.ts +1272 -0
  40. package/src/mixins.ts +199 -0
  41. package/src/observability.ts +167 -0
  42. package/src/pagination.ts +300 -0
  43. package/src/presence.ts +81 -0
  44. package/src/provider/FlowProvider.ts +1401 -0
  45. package/src/registry.ts +118 -0
  46. package/src/renderContext.ts +55 -0
  47. package/src/router.ts +401 -0
  48. package/src/shared.ts +226 -0
  49. package/src/store.ts +116 -0
  50. package/src/synths/CarbonIntervalSynth.ts +22 -0
  51. package/src/synths/CarbonSynth.ts +20 -0
  52. package/src/synths/CollectionSynth.ts +62 -0
  53. package/src/synths/DateSynth.ts +24 -0
  54. package/src/synths/ModelSynth.ts +78 -0
  55. package/src/synths/TemporaryUploadedFileSynth.ts +19 -0
  56. package/src/synths/index.ts +148 -0
  57. package/src/testing.ts +361 -0
  58. package/src/types.ts +315 -0
  59. package/src/uploads/FileUploads.ts +94 -0
  60. package/src/uploads/TemporaryUploadedFile.ts +274 -0
  61. package/src/uploads/sign.ts +18 -0
  62. package/src/urlSafety.ts +0 -0
  63. package/src/utils.ts +216 -0
  64. package/src/validation.ts +55 -0
package/src/config.ts ADDED
@@ -0,0 +1,52 @@
1
+ import { deepMerge, env } from "@zerotal/core";
2
+ import type { MiddlewareClass } from "@zerotal/core";
3
+
4
+ export interface FlowConfigShape {
5
+ /**
6
+ * Serve the client runtime in CSP-safe mode — no `'unsafe-eval'` required.
7
+ *
8
+ * Costs a little payload and start-up time, so it is off unless you actually
9
+ * ship a Content-Security-Policy without `unsafe-eval`.
10
+ *
11
+ * Default: `false`, or the `ZT_FLOW_CSP_SAFE` / `APP_CSP_SAFE` env flag.
12
+ */
13
+ cspSafe: boolean;
14
+ /**
15
+ * Global middleware re-applied on every WebSocket update (Livewire-style
16
+ * persistent middleware). Entries are matched against the app's global
17
+ * pipeline by class reference or by class name.
18
+ *
19
+ * Route middleware always re-runs and does not need to be listed here.
20
+ *
21
+ * Default: `["SessionMiddleware", "PersistUserMiddleware", "BearerTokenMiddleware"]`
22
+ */
23
+ persistentMiddleware: (string | MiddlewareClass)[];
24
+ }
25
+
26
+ /** Global middleware re-run on every WebSocket action unless overridden. */
27
+ export const DEFAULT_PERSISTENT_MIDDLEWARE: (string | MiddlewareClass)[] = [
28
+ "SessionMiddleware",
29
+ "PersistUserMiddleware",
30
+ "BearerTokenMiddleware",
31
+ ];
32
+
33
+ const defaults: FlowConfigShape = {
34
+ cspSafe: env("ZT_FLOW_CSP_SAFE", false) || env("APP_CSP_SAFE", false),
35
+ persistentMiddleware: [...DEFAULT_PERSISTENT_MIDDLEWARE],
36
+ };
37
+
38
+ /**
39
+ * @example
40
+ * import { FlowConfig } from '@zerotal/flow';
41
+ * export default FlowConfig({ cspSafe: true });
42
+ */
43
+ export function FlowConfig(options: Partial<FlowConfigShape> = {}): FlowConfigShape {
44
+ return deepMerge(defaults, options);
45
+ }
46
+
47
+ // Register this package's config namespace for typed config() dot-paths.
48
+ declare module "@zerotal/core" {
49
+ interface ConfigRegistry {
50
+ flow: FlowConfigShape;
51
+ }
52
+ }