@adaptive-js/web 0.0.0-stage → 0.0.1

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 (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/dist/front/context-runtime.d.ts +22 -0
  4. package/dist/front/context-runtime.js +27 -0
  5. package/dist/front/context-runtime.js.map +1 -0
  6. package/dist/front/handler-scope.d.ts +13 -0
  7. package/dist/front/handler-scope.js +102 -0
  8. package/dist/front/handler-scope.js.map +1 -0
  9. package/dist/front/router.d.ts +47 -0
  10. package/dist/front/router.js +329 -0
  11. package/dist/front/router.js.map +1 -0
  12. package/dist/hy/boundary/bind.d.ts +6 -0
  13. package/dist/hy/boundary/bind.js +110 -0
  14. package/dist/hy/boundary/bind.js.map +1 -0
  15. package/dist/hy/boundary/cleanup.d.ts +2 -0
  16. package/dist/hy/boundary/cleanup.js +17 -0
  17. package/dist/hy/boundary/cleanup.js.map +1 -0
  18. package/dist/hy/boundary/collect.d.ts +11 -0
  19. package/dist/hy/boundary/collect.js +135 -0
  20. package/dist/hy/boundary/collect.js.map +1 -0
  21. package/dist/hy/boundary/debug.d.ts +8 -0
  22. package/dist/hy/boundary/debug.js +16 -0
  23. package/dist/hy/boundary/debug.js.map +1 -0
  24. package/dist/hy/boundary/dev-logs.d.ts +21 -0
  25. package/dist/hy/boundary/dev-logs.js +52 -0
  26. package/dist/hy/boundary/dev-logs.js.map +1 -0
  27. package/dist/hy/boundary/discovery.d.ts +29 -0
  28. package/dist/hy/boundary/discovery.js +90 -0
  29. package/dist/hy/boundary/discovery.js.map +1 -0
  30. package/dist/hy/boundary/factory.d.ts +9 -0
  31. package/dist/hy/boundary/factory.js +82 -0
  32. package/dist/hy/boundary/factory.js.map +1 -0
  33. package/dist/hy/boundary/hydrate.d.ts +17 -0
  34. package/dist/hy/boundary/hydrate.js +99 -0
  35. package/dist/hy/boundary/hydrate.js.map +1 -0
  36. package/dist/hy/boundary/hydration-trace.d.ts +39 -0
  37. package/dist/hy/boundary/hydration-trace.js +60 -0
  38. package/dist/hy/boundary/hydration-trace.js.map +1 -0
  39. package/dist/hy/boundary/index.d.ts +4 -0
  40. package/dist/hy/boundary/index.js +157 -0
  41. package/dist/hy/boundary/index.js.map +1 -0
  42. package/dist/hy/boundary/mount.d.ts +2 -0
  43. package/dist/hy/boundary/mount.js +31 -0
  44. package/dist/hy/boundary/mount.js.map +1 -0
  45. package/dist/hy/boundary/props-serialization.d.ts +3 -0
  46. package/dist/hy/boundary/props-serialization.js +73 -0
  47. package/dist/hy/boundary/props-serialization.js.map +1 -0
  48. package/dist/hy/boundary/registry.d.ts +13 -0
  49. package/dist/hy/boundary/registry.js +19 -0
  50. package/dist/hy/boundary/registry.js.map +1 -0
  51. package/dist/hy/hydrate/cleanup.d.ts +3 -0
  52. package/dist/hy/hydrate/cleanup.js +61 -0
  53. package/dist/hy/hydrate/cleanup.js.map +1 -0
  54. package/dist/hy/hydrate/constants.d.ts +4 -0
  55. package/dist/hy/hydrate/constants.js +23 -0
  56. package/dist/hy/hydrate/constants.js.map +1 -0
  57. package/dist/hy/hydrate/dom.d.ts +4 -0
  58. package/dist/hy/hydrate/dom.js +32 -0
  59. package/dist/hy/hydrate/dom.js.map +1 -0
  60. package/dist/hy/hydrate/elements.d.ts +2 -0
  61. package/dist/hy/hydrate/elements.js +59 -0
  62. package/dist/hy/hydrate/elements.js.map +1 -0
  63. package/dist/hy/hydrate/events.d.ts +2 -0
  64. package/dist/hy/hydrate/events.js +25 -0
  65. package/dist/hy/hydrate/events.js.map +1 -0
  66. package/dist/hy/hydrate/index.d.ts +5 -0
  67. package/dist/hy/hydrate/index.js +9 -0
  68. package/dist/hy/hydrate/index.js.map +1 -0
  69. package/dist/hy/hydrate/inplace.d.ts +8 -0
  70. package/dist/hy/hydrate/inplace.js +230 -0
  71. package/dist/hy/hydrate/inplace.js.map +1 -0
  72. package/dist/hy/hydrate/instructions.d.ts +3 -0
  73. package/dist/hy/hydrate/instructions.js +154 -0
  74. package/dist/hy/hydrate/instructions.js.map +1 -0
  75. package/dist/hy/hydrate/markers.d.ts +5 -0
  76. package/dist/hy/hydrate/markers.js +60 -0
  77. package/dist/hy/hydrate/markers.js.map +1 -0
  78. package/dist/hy/hydrate/mismatch.d.ts +35 -0
  79. package/dist/hy/hydrate/mismatch.js +140 -0
  80. package/dist/hy/hydrate/mismatch.js.map +1 -0
  81. package/dist/hy/hydrate/props.d.ts +9 -0
  82. package/dist/hy/hydrate/props.js +50 -0
  83. package/dist/hy/hydrate/props.js.map +1 -0
  84. package/dist/hy/hydrate/reactive-markers.d.ts +8 -0
  85. package/dist/hy/hydrate/reactive-markers.js +105 -0
  86. package/dist/hy/hydrate/reactive-markers.js.map +1 -0
  87. package/dist/hy/hydrate/reactive.d.ts +45 -0
  88. package/dist/hy/hydrate/reactive.js +268 -0
  89. package/dist/hy/hydrate/reactive.js.map +1 -0
  90. package/dist/hy/hydrate/render-to-dom.d.ts +1 -0
  91. package/dist/hy/hydrate/render-to-dom.js +122 -0
  92. package/dist/hy/hydrate/render-to-dom.js.map +1 -0
  93. package/dist/hy/hydrate/style.d.ts +1 -0
  94. package/dist/hy/hydrate/style.js +18 -0
  95. package/dist/hy/hydrate/style.js.map +1 -0
  96. package/dist/hy/hydrate/types.d.ts +56 -0
  97. package/dist/hy/hydrate/types.js +2 -0
  98. package/dist/hy/hydrate/types.js.map +1 -0
  99. package/dist/hy/keyed-reactive-block.d.ts +10 -0
  100. package/dist/hy/keyed-reactive-block.js +107 -0
  101. package/dist/hy/keyed-reactive-block.js.map +1 -0
  102. package/dist/hy/style-shared.d.ts +3 -0
  103. package/dist/hy/style-shared.js +28 -0
  104. package/dist/hy/style-shared.js.map +1 -0
  105. package/dist/index.d.ts +48 -0
  106. package/dist/index.js +80 -0
  107. package/dist/index.js.map +1 -0
  108. package/dist/jsx-dev-runtime.d.ts +1 -0
  109. package/dist/jsx-dev-runtime.js +8 -0
  110. package/dist/jsx-dev-runtime.js.map +1 -0
  111. package/dist/jsx-runtime.d.ts +2 -0
  112. package/dist/jsx-runtime.js +8 -0
  113. package/dist/jsx-runtime.js.map +1 -0
  114. package/dist/reactive/adaptive-observer.d.ts +12 -0
  115. package/dist/reactive/adaptive-observer.js +35 -0
  116. package/dist/reactive/adaptive-observer.js.map +1 -0
  117. package/dist/reactive/events.d.ts +158 -0
  118. package/dist/reactive/events.js +559 -0
  119. package/dist/reactive/events.js.map +1 -0
  120. package/dist/reactive/index.d.ts +5 -0
  121. package/dist/reactive/index.js +11 -0
  122. package/dist/reactive/index.js.map +1 -0
  123. package/dist/reactive/init.d.ts +25 -0
  124. package/dist/reactive/init.js +73 -0
  125. package/dist/reactive/init.js.map +1 -0
  126. package/dist/reactive/reactive.d.ts +29 -0
  127. package/dist/reactive/reactive.js +108 -0
  128. package/dist/reactive/reactive.js.map +1 -0
  129. package/package.json +60 -4
@@ -0,0 +1,107 @@
1
+ /*
2
+ * Licensed under the MIT License.
3
+ *
4
+ * Bloco reativo com estabilidade por key (on/off).
5
+ * Versão corrigida: extrai key de vnode.key OU props.key
6
+ */
7
+ import { cleanupEffectScope, createEffectScope, runWithEffectScope, } from "../reactive/index.js";
8
+ import { createReactiveEffect } from "../reactive/events.js";
9
+ /**
10
+ * Extrai key de um vnode Adaptive.
11
+ * Em Adaptive/JSX a key pode estar em:
12
+ * - vnode.key (padrão React-like)
13
+ * - vnode.props.key
14
+ * - vnode.props["data-key"]
15
+ */
16
+ export function getVNodeKey(value) {
17
+ if (value == null || value === false || value === true)
18
+ return null;
19
+ if (typeof value === "function")
20
+ return null;
21
+ if (Array.isArray(value)) {
22
+ const list = value.flat(Infinity).filter((v) => v != null && v !== false && v !== true);
23
+ if (list.length === 1)
24
+ return getVNodeKey(list[0]);
25
+ const keys = list.map(getVNodeKey);
26
+ if (keys.every((k) => k != null))
27
+ return keys.join("|");
28
+ return null;
29
+ }
30
+ if (typeof value === "object") {
31
+ // 1. vnode.key direto (JSX runtime padrão)
32
+ if (value.key != null && value.key !== false) {
33
+ return value.key;
34
+ }
35
+ // 2. props.key
36
+ if (value.props != null) {
37
+ const k = value.props.key;
38
+ if (k != null && k !== false)
39
+ return k;
40
+ // fallback para data-key
41
+ const dk = value.props["data-key"];
42
+ if (dk != null && dk !== false)
43
+ return dk;
44
+ }
45
+ }
46
+ return null;
47
+ }
48
+ export function mountKeyedReactiveFunction(thunk, namespace, renderToDOM) {
49
+ const start = document.createTextNode("");
50
+ const end = document.createTextNode("");
51
+ const fragment = document.createDocumentFragment();
52
+ fragment.appendChild(start);
53
+ fragment.appendChild(end);
54
+ let currentKey = undefined;
55
+ let currentScope = null;
56
+ let hasMounted = false;
57
+ // Cache por key: on -> off -> on restaura sem remontar
58
+ const cache = new Map();
59
+ // Final cleanup: quando o componente pai desmontar, limpa tudo que ficou em cache
60
+ // Este efeito roda uma vez e só é disposto no unmount final
61
+ createReactiveEffect(() => {
62
+ return () => {
63
+ for (const entry of cache.values()) {
64
+ cleanupEffectScope(entry.scope);
65
+ }
66
+ cache.clear();
67
+ if (currentScope) {
68
+ cleanupEffectScope(currentScope);
69
+ currentScope = null;
70
+ }
71
+ };
72
+ }, "layout");
73
+ // Efeito reativo principal: troca de key com cache
74
+ createReactiveEffect(() => {
75
+ const nextValue = thunk();
76
+ const parent = start.parentNode;
77
+ if (!parent)
78
+ return;
79
+ const nextKey = getVNodeKey(nextValue); // "on" | "off" | null
80
+ // mesma key → não mexe (count 1→2→3)
81
+ if (hasMounted &&
82
+ nextKey != null &&
83
+ currentKey != null &&
84
+ Object.is(nextKey, currentKey)) {
85
+ return;
86
+ }
87
+ // branch mudou (ou primeira vez): destrói o atual de verdade
88
+ if (currentScope) {
89
+ cleanupEffectScope(currentScope); // ← unmounting BeerCSS
90
+ currentScope = null;
91
+ }
92
+ let node = start.nextSibling;
93
+ while (node && node !== end) {
94
+ const next = node.nextSibling;
95
+ parent.removeChild(node);
96
+ node = next;
97
+ }
98
+ // monta o branch novo
99
+ currentScope = createEffectScope(`reactive-keyed:${String(nextKey ?? "nokey")}`);
100
+ const rendered = runWithEffectScope(currentScope, () => renderToDOM(nextValue, namespace));
101
+ parent.insertBefore(rendered, end);
102
+ currentKey = nextKey;
103
+ hasMounted = true;
104
+ });
105
+ return fragment;
106
+ }
107
+ //# sourceMappingURL=keyed-reactive-block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed-reactive-block.js","sourceRoot":"","sources":["../../src/hy/keyed-reactive-block.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAI7D;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAU;IAClC,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACpE,IAAI,OAAO,KAAK,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IAE7C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QACxF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,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iB,CAC5B,kBAAkB,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,CACjD,CAAC;QACF,MAAM,QAAQ,GAAG,kBAAkB,CAAC,YAAY,EAAE,GAAG,EAAE,CACnD,WAAW,CAAC,SAAS,EAAE,SAAS,CAAC,CACpC,CAAC;QACF,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAEnC,UAAU,GAAG,OAAO,CAAC;QACrB,UAAU,GAAG,IAAI,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AACpB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function toCssPropertyName(styleKey: string): string;
2
+ export declare function resolveStyleEntries(style: Record<string, any> | (() => Record<string, any>) | null | undefined): [string, any][];
3
+ export declare function serializeStyleLike(style: Record<string, any> | (() => Record<string, any>) | null | undefined): string;
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (c) 2026 Antonio Johnathan
3
+ *
4
+ * Licensed under the MIT License.
5
+ * See LICENSE file in the project root for full license information.
6
+ */
7
+ export function toCssPropertyName(styleKey) {
8
+ return styleKey.replace(/([A-Z])/g, "-$1").toLowerCase();
9
+ }
10
+ export function resolveStyleEntries(style) {
11
+ const resolved = typeof style === "function" ? style() : style;
12
+ if (!resolved || typeof resolved !== "object") {
13
+ return [];
14
+ }
15
+ return Object.entries(resolved).flatMap(([styleKey, styleValue]) => {
16
+ const value = typeof styleValue === "function" ? styleValue() : styleValue;
17
+ if (value == null || value === false) {
18
+ return [];
19
+ }
20
+ return [[styleKey, value]];
21
+ });
22
+ }
23
+ export function serializeStyleLike(style) {
24
+ return resolveStyleEntries(style)
25
+ .map(([styleKey, styleValue]) => `${toCssPropertyName(styleKey)}:${styleValue}`)
26
+ .join(";");
27
+ }
28
+ //# sourceMappingURL=style-shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-shared.js","sourceRoot":"","sources":["../../src/hy/style-shared.ts"],"names":[],"mapp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fragment } from "@adaptive-js/jsx";
5
+ export type { AdaptiveChild, AdaptiveNode, AdaptiveType, Ref, StyleObject, MaybeSignal } from "@adaptive-js/jsx";
6
+ export { getClientComponentMetadata } from "@adaptive-js/shared";
7
+ export type { ClientMetadata } from "@adaptive-js/shared";
8
+ /**
9
+ * Marca um export como componente client/hydrate.
10
+ * O ci injeta esta chamada no rodapé de cada módulo com diretiva,
11
+ * depois que a diretiva é removida do código.
12
+ */
13
+ export declare function markClientExport(value: unknown, moduleId: string, exportName: string, mode: "client" | "hydrate"): void;
14
+ /**
15
+ * Executado no bundle do client para localizar os componentes marcados.
16
+ * A implementação real vive em hy/boundary: ela varre os comentários
17
+ * <!--adaptive-client-*-> que o SSR deixou no HTML, monta as islands "client" e
18
+ * hidrata as "hydrate" reusing os nós que o servidor já renderizou.
19
+ *
20
+ * Continua sendo executado só no bundle do browser - no SSR puro nada chama
21
+ * isto, e hy/boundary não toca em window/document no topo do módulo.
22
+ */
23
+ export { hydrateClientComponents } from "./hy/boundary/index.js";
24
+ export { HYDRATION_ERROR_EVENT, HYDRATION_MISMATCH_EVENT, clearHydrationMismatches, getHydrationMismatches, reportHydrationError, warnMismatch, } from "./hy/hydrate/mismatch.js";
25
+ export { renderToDOM } from "./hy/hydrate/index.js";
26
+ export * from "./front/handler-scope.js";
27
+ export * from "./front/context-runtime.js";
28
+ export * from "./front/router.js";
29
+ export * from "./reactive/index.js";
30
+ export type PageContext = AdaptiveRouteContext;
31
+ export { callServerAction } from "@adaptive-js/shared";
32
+ export { isClientEnabled, ENABLED_CLIENT_FLAG } from "./hy/boundary/dev-logs.js";
33
+ /**
34
+ * Marca um export como componente "client" e devolve o vnode que o SSR
35
+ * transforma no marcador da ilha.
36
+ *
37
+ * O codegen sempre passa a implementacao como serverRender nos dois modos, e
38
+ * quem decide se ela roda no servidor e a flag ADAPTIVE_ENABLED_CLIENT:
39
+ * "client" so server-renderiza com a flag ligada, desligada cai num
40
+ * placeholder. Ver factory.ts.
41
+ */
42
+ export declare function createClientComponent(moduleId: string, exportName?: string, serverRender?: ((props?: Record<string, any>) => any) | null): ClientComponentFunction;
43
+ /**
44
+ * Marca um export como componente "hydrate": o server renderiza e o client
45
+ * assume depois sobre o DOM existente. serverRender aqui e o SSR da ilha, e
46
+ * roda mesmo com ADAPTIVE_ENABLED_CLIENT desligada.
47
+ */
48
+ export declare function createHydrateComponent(moduleId: string, exportName?: string, serverRender?: ((props?: Record<string, any>) => any) | null): ClientComponentFunction;
package/dist/index.js ADDED
@@ -0,0 +1,80 @@
1
+ /*
2
+ * Copyright (c) 2026 Antonio Johnathan
3
+ *
4
+ * Licensed under the MIT License.
5
+ *
6
+ * Ponto de entrada do runtime web. As funções exportadas aqui são o contrato
7
+ * com o ci: o build injeta chamadas a elas no bundle gerado (markClientExport,
8
+ * hydrateClientComponents, callServerAction), então o nome e a assinatura são
9
+ * parte do contrato e não podem mudar sem quebrar o build gerado.
10
+ */
11
+ import { CLIENT_BOUNDARY_MODE_CLIENT, CLIENT_BOUNDARY_MODE_HYDRATE, CLIENT_COMPONENT_SYMBOL, } from "@adaptive-js/shared";
12
+ import { createBoundaryComponent } from "./hy/boundary/factory.js";
13
+ import { wrapHydratePropsForServer } from "./hy/boundary/index.js";
14
+ export * from "./jsx-runtime.js";
15
+ export { Fragment } from "@adaptive-js/jsx";
16
+ export { getClientComponentMetadata } from "@adaptive-js/shared";
17
+ /**
18
+ * Marca um export como componente client/hydrate.
19
+ * O ci injeta esta chamada no rodapé de cada módulo com diretiva,
20
+ * depois que a diretiva é removida do código.
21
+ */
22
+ export function markClientExport(value, moduleId, exportName, mode) {
23
+ if (typeof value !== "function")
24
+ return;
25
+ value[CLIENT_COMPONENT_SYMBOL] = {
26
+ moduleId,
27
+ exportName,
28
+ mode,
29
+ };
30
+ }
31
+ /**
32
+ * Executado no bundle do client para localizar os componentes marcados.
33
+ * A implementação real vive em hy/boundary: ela varre os comentários
34
+ * <!--adaptive-client-*-> que o SSR deixou no HTML, monta as islands "client" e
35
+ * hidrata as "hydrate" reusing os nós que o servidor já renderizou.
36
+ *
37
+ * Continua sendo executado só no bundle do browser - no SSR puro nada chama
38
+ * isto, e hy/boundary não toca em window/document no topo do módulo.
39
+ */
40
+ export { hydrateClientComponents } from "./hy/boundary/index.js";
41
+ export { HYDRATION_ERROR_EVENT, HYDRATION_MISMATCH_EVENT, clearHydrationMismatches, getHydrationMismatches, reportHydrationError, warnMismatch, } from "./hy/hydrate/mismatch.js";
42
+ export { renderToDOM } from "./hy/hydrate/index.js";
43
+ export * from "./front/handler-scope.js";
44
+ export * from "./front/context-runtime.js";
45
+ export * from "./front/router.js";
46
+ export * from "./reactive/index.js";
47
+ export { callServerAction } from "@adaptive-js/shared";
48
+ export { isClientEnabled, ENABLED_CLIENT_FLAG } from "./hy/boundary/dev-logs.js";
49
+ /**
50
+ * Marca um export como componente "client" e devolve o vnode que o SSR
51
+ * transforma no marcador da ilha.
52
+ *
53
+ * O codegen sempre passa a implementacao como serverRender nos dois modos, e
54
+ * quem decide se ela roda no servidor e a flag ADAPTIVE_ENABLED_CLIENT:
55
+ * "client" so server-renderiza com a flag ligada, desligada cai num
56
+ * placeholder. Ver factory.ts.
57
+ */
58
+ export function createClientComponent(moduleId, exportName = "default", serverRender) {
59
+ return createBoundaryComponent({
60
+ mode: CLIENT_BOUNDARY_MODE_CLIENT,
61
+ moduleId,
62
+ exportName,
63
+ serverRender
64
+ });
65
+ }
66
+ /**
67
+ * Marca um export como componente "hydrate": o server renderiza e o client
68
+ * assume depois sobre o DOM existente. serverRender aqui e o SSR da ilha, e
69
+ * roda mesmo com ADAPTIVE_ENABLED_CLIENT desligada.
70
+ */
71
+ export function createHydrateComponent(moduleId, exportName = "default", serverRender) {
72
+ return createBoundaryComponent({
73
+ mode: CLIENT_BOUNDARY_MODE_HYDRATE,
74
+ moduleId,
75
+ exportName,
76
+ serverRender,
77
+ wrapServerProps: wrapHydratePropsForServer
78
+ });
79
+ }
80
+ //# sourceMappingURL=index.js.map
@@ -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E9D,OAAO,uBAAuB,CAAC;QAC7B,IAAI,EAAE,2BAA2B;QACjC,QAAQ;QACR,UAAU;QACV,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAgB,EAChB,UAAU,GAAG,SAAS,EACtB,YAA4D;IAE9D,OAAO,uBAAuB,CAAC;QAC7B,IAAI,EAAE,4BAA4B;QAClC,QAAQ;QACR,UAAU;QACV,YAAY;QACZ,eAAe,EAAE,yBAAyB;KAC3C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "@adaptive-js/jsx/jsx-runtime";
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright (c) 2026 Antonio Johnathan
3
+ *
4
+ * Licensed under the MIT License.
5
+ * See LICENSE file in the project root for full license information.
6
+ */
7
+ export * from "@adaptive-js/jsx/jsx-runtime";
8
+ //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-dev-runtime.js","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "@adaptive-js/jsx/jsx-dev-runtime";
2
+ export type { AdaptiveNode } from "@adaptive-js/jsx";
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright (c) 2026 Antonio Johnathan
3
+ *
4
+ * Licensed under the MIT License.
5
+ * See LICENSE file in the project root for full license information.
6
+ */
7
+ export * from "@adaptive-js/jsx/jsx-dev-runtime";
8
+ //# sourceMappingURL=jsx-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { ReactiveSource, EffectFn } from "./events.js";
2
+ export declare class AdaptiveObserver<T> implements ReactiveSource {
3
+ private _get;
4
+ private _set;
5
+ private _source;
6
+ constructor(initial: T);
7
+ get(): T;
8
+ set(value: T | ((prev: T) => T)): void;
9
+ update(fn: (prev: T) => T): void;
10
+ removeSubscriber(effect: EffectFn): void;
11
+ get value(): T;
12
+ }
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright (c) 2026 Antonio Johnathan
3
+ *
4
+ * Licensed under the MIT License.
5
+ * See LICENSE file in the project root for full license information.
6
+ */
7
+ import { createEventSignal } from "./events.js";
8
+ export class AdaptiveObserver {
9
+ _get;
10
+ _set;
11
+ _source;
12
+ constructor(initial) {
13
+ const [get, set] = createEventSignal(initial);
14
+ this._get = get;
15
+ this._set = set;
16
+ this._source = set.__adaptiveSource;
17
+ }
18
+ get() {
19
+ return this._get();
20
+ }
21
+ set(value) {
22
+ this._set(value);
23
+ }
24
+ update(fn) {
25
+ this._source.update(fn);
26
+ }
27
+ removeSubscriber(effect) {
28
+ this._source.removeSubscriber(effect);
29
+ }
30
+ // compat: alguns lugares antigos acessavam .value direto
31
+ get value() {
32
+ return this._get();
33
+ }
34
+ }
35
+ //# sourceMappingURL=adaptive-observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adaptive-observer.js","sourceRoot":"","sources":["../../src/reactive/adaptive-observer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,iBAAiB,EAAwC,MAAM,aAAa,CAAC;AAErF,MAAM,OAAO,gBAAgB;IACjB,IAAI,CAAU;IACd,IAAI,CAAiC;IACrC,OAAO,CAAiB;IAEhC,YAAY,OAAU;QAClB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,GAAU,CAAC;QACvB,IAAI,CAAC,OAAO,GAAI,GAAW,CAAC,gBAAkC,CAAC;IACnE,CAAC;IAED,GAAG;QACC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAED,GAAG,CAAC,KAA2B;QAC1B,IAAI,CAAC,IAAY,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,EAAkB;QACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,gBAAgB,CAAC,MAAgB;QAC7B,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED,yDAAyD;IACzD,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;CACJ"}
@@ -0,0 +1,158 @@
1
+ export type Cleanup = void | (() => void);
2
+ export type EffectFn = () => Cleanup;
3
+ export type DependencyList = any[];
4
+ export type EffectPhase = "layout" | "effect";
5
+ export type ReactiveSource = {
6
+ removeSubscriber(effect: EffectFn): void;
7
+ /** Le o valor atual. E o read que assina o effect ativo. */
8
+ get?(): any;
9
+ };
10
+ export type ReactiveSetterLike = Function & {
11
+ __adaptiveSource?: ReactiveSource;
12
+ };
13
+ export type EventsOptions = {
14
+ ignore?: Array<ReactiveSetterLike | {
15
+ __adaptiveSource?: ReactiveSource;
16
+ }>;
17
+ phase?: EffectPhase;
18
+ /**
19
+ * Assina o effect nessas sources sem executar o corpo na primeira vez.
20
+ * Para quem ja calculou o valor e so precisa da reatividade.
21
+ */
22
+ subscribeTo?: ReactiveSource[];
23
+ };
24
+ export type EffectScope = {
25
+ id: number;
26
+ label?: string;
27
+ context?: Map<symbol, any>;
28
+ hooks: any[];
29
+ hookIndex: number;
30
+ };
31
+ export declare const isSSR: () => boolean;
32
+ declare function isAdaptiveHydrationDebugEnabled(): boolean;
33
+ declare function debugSignalLog(...args: any[]): void;
34
+ export type EffectInstruction = {
35
+ kind: "layout-effect" | "effect";
36
+ effect: EffectFn;
37
+ deps?: DependencyList;
38
+ ignoredSources?: ReactiveSource[];
39
+ };
40
+ export declare function runHydrationCollection<T>(fn: () => T): {
41
+ value: T;
42
+ unsupportedFeatures: string[];
43
+ effectInstructions: EffectInstruction[];
44
+ };
45
+ export declare function markUnsupportedFeature(name: string): void;
46
+ declare class EventSystem {
47
+ private currentEffect;
48
+ private currentScope;
49
+ private cleanups;
50
+ private effectSources;
51
+ private ignoredSources;
52
+ private effectPhases;
53
+ private effectScopes;
54
+ private disposedEffects;
55
+ private pending;
56
+ private layoutQueue;
57
+ private effectQueue;
58
+ private flushing;
59
+ private batchDepth;
60
+ private nextScopeId;
61
+ private noScopeCache;
62
+ getCurrentEffect(): EffectFn | null;
63
+ getCurrentScope(): EffectScope | null;
64
+ isDisposed(effect: EffectFn): boolean;
65
+ setCurrentEffect(effect: EffectFn | null): void;
66
+ createScope(label?: string): EffectScope;
67
+ runWithScope<T>(scope: EffectScope, fn: () => T): T;
68
+ runWithContext<T>(ctxId: symbol, value: any, fn: () => T): T;
69
+ readContext<T>(ctxId: symbol, defaultValue: T): T;
70
+ trackSource(effect: EffectFn, source: ReactiveSource): void;
71
+ cleanupSources(effect: EffectFn): void;
72
+ runCleanup(effect: EffectFn): void;
73
+ disposeEffect(effect: EffectFn): void;
74
+ registerCleanup(effect: EffectFn, cleanup: Cleanup): void;
75
+ setIgnoredSources(effect: EffectFn, sources?: ReactiveSource[]): void;
76
+ setEffectPhase(effect: EffectFn, phase: EffectPhase): void;
77
+ shouldIgnoreTrigger(effect: EffectFn, source: ReactiveSource): boolean;
78
+ schedule(effect: EffectFn, phase?: EffectPhase): void;
79
+ scheduleFromSource(effect: EffectFn, source: ReactiveSource): void;
80
+ private executeEffect;
81
+ flush(): void;
82
+ batch<T>(fn: () => T): T;
83
+ untrack<T>(fn: () => T): T;
84
+ /**
85
+ * Executa fn e devolve quais sources ela leu, sem agendar nada.
86
+ *
87
+ * Serve para quem precisa do valor síncrono E da lista de dependências,
88
+ * sem pagar uma segunda execução da função. O memo é o caso: ele
89
+ * calcula na hora para ter o valor durante o render, mas se o effect
90
+ * rodar logo em seguida para computar de novo, a função é executada
91
+ * duas vezes no cliente e uma no servidor.
92
+ */
93
+ trackSources<T>(fn: () => T): {
94
+ value: T;
95
+ sources: ReactiveSource[];
96
+ };
97
+ /**
98
+ * Assina effect em sources sem executar o corpo dele.
99
+ *
100
+ * Assinar exige ler a source com o effect ativo -- é o read que registra
101
+ * a assinatura. Ler uma source pura não roda código de usuário, então
102
+ * dá para assinar sem recomputar.
103
+ */
104
+ linkSources(effect: EffectFn, sources: ReactiveSource[]): void;
105
+ cleanupScope(scope: EffectScope): void;
106
+ cleanupAll(): void;
107
+ getNoScopeEntry(effect: EffectFn): {
108
+ deps?: DependencyList;
109
+ runner: EffectFn;
110
+ } | undefined;
111
+ setNoScopeEntry(effect: EffectFn, deps: DependencyList | undefined, runner: EffectFn): void;
112
+ }
113
+ export declare class EventSource<T> implements ReactiveSource {
114
+ private subscribers;
115
+ private value;
116
+ constructor(initial: T);
117
+ get(): T;
118
+ set(next: T): void;
119
+ update(fn: (prev: T) => T): void;
120
+ removeSubscriber(effect: EffectFn): void;
121
+ _getSubscribers(): Set<EffectFn>;
122
+ }
123
+ export declare function createEventSignal<T>(initial: T): [() => T, ((v: T | ((p: T) => T)) => void) & {
124
+ __adaptiveSource: EventSource<T>;
125
+ }];
126
+ /** Bridge: signal legado avisa este motor no set(). */
127
+ export declare function notifyExternalSource(source: ReactiveSource, subscribers: Iterable<EffectFn>): void;
128
+ /** Bridge: signal legado assina no get() se houver effect ativo. */
129
+ export declare function trackExternalSource(effect: EffectFn, source: ReactiveSource): void;
130
+ export declare function runWithContext<T>(ctxId: symbol, value: any, fn: () => T): T;
131
+ export declare function readContext<T>(ctxId: symbol, defaultValue: T): T;
132
+ export declare function useHookSlot<T>(factory: () => T): T;
133
+ export declare function events(effect: EffectFn, deps?: DependencyList, options?: EventsOptions): void;
134
+ export declare function layoutEvents(effect: EffectFn, deps?: DependencyList, options?: Omit<EventsOptions, "phase">): void;
135
+ export declare function batch<T>(fn: () => T): T;
136
+ export declare function flushEvents(): void;
137
+ export declare function flushEffects(): void;
138
+ export declare function untrack<T>(fn: () => T): T;
139
+ export declare function trackSources<T>(fn: () => T): {
140
+ value: T;
141
+ sources: ReactiveSource[];
142
+ };
143
+ export declare function createEventsScope(label?: string): EffectScope;
144
+ export declare function createEffectScope(label?: string): EffectScope;
145
+ export declare function runWithEventsScope<T>(scope: EffectScope, fn: () => T): T;
146
+ export declare function runWithEffectScope<T>(scope: EffectScope, fn: () => T): T;
147
+ export declare function cleanupEventsScope(scope: EffectScope): void;
148
+ export declare function cleanupEffectScope(scope: EffectScope): void;
149
+ export declare function cleanupAllEvents(): void;
150
+ export declare function cleanupAllEffects(): void;
151
+ export declare function getEventsSystem(): EventSystem;
152
+ export { debugSignalLog, isAdaptiveHydrationDebugEnabled };
153
+ export declare function createReactiveEffect(effect: EffectFn, phase?: EffectPhase, options?: Pick<EventsOptions, "ignore">): () => void;
154
+ export type ReactiveSetter<T> = {
155
+ (value: T | ((prev: T) => T)): void;
156
+ __adaptiveSource?: ReactiveSource;
157
+ };
158
+ export type Subscriber = EffectFn;