@askrjs/askr 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 (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +298 -0
  3. package/dist/chunk-4CV4JOE5.js +27 -0
  4. package/dist/chunk-4CV4JOE5.js.map +1 -0
  5. package/dist/chunk-HIWJVOS4.js +503 -0
  6. package/dist/chunk-HIWJVOS4.js.map +1 -0
  7. package/dist/chunk-L7RL4LYV.js +3442 -0
  8. package/dist/chunk-L7RL4LYV.js.map +1 -0
  9. package/dist/chunk-UUM5W2RM.js +84 -0
  10. package/dist/chunk-UUM5W2RM.js.map +1 -0
  11. package/dist/chunk-YNH3D4KW.js +29 -0
  12. package/dist/chunk-YNH3D4KW.js.map +1 -0
  13. package/dist/index.cjs +4733 -0
  14. package/dist/index.cjs.map +1 -0
  15. package/dist/index.d.cts +446 -0
  16. package/dist/index.d.ts +446 -0
  17. package/dist/index.js +683 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/jsx/jsx-dev-runtime.cjs +40 -0
  20. package/dist/jsx/jsx-dev-runtime.cjs.map +1 -0
  21. package/dist/jsx/jsx-dev-runtime.d.cts +16 -0
  22. package/dist/jsx/jsx-dev-runtime.d.ts +16 -0
  23. package/dist/jsx/jsx-dev-runtime.js +16 -0
  24. package/dist/jsx/jsx-dev-runtime.js.map +1 -0
  25. package/dist/jsx/jsx-runtime.cjs +45 -0
  26. package/dist/jsx/jsx-runtime.cjs.map +1 -0
  27. package/dist/jsx/jsx-runtime.d.cts +17 -0
  28. package/dist/jsx/jsx-runtime.d.ts +17 -0
  29. package/dist/jsx/jsx-runtime.js +14 -0
  30. package/dist/jsx/jsx-runtime.js.map +1 -0
  31. package/dist/navigate-NLQOZQGM.js +16 -0
  32. package/dist/navigate-NLQOZQGM.js.map +1 -0
  33. package/dist/route-TVYWYCEJ.js +31 -0
  34. package/dist/route-TVYWYCEJ.js.map +1 -0
  35. package/dist/ssr-4ELUFK65.js +24 -0
  36. package/dist/ssr-4ELUFK65.js.map +1 -0
  37. package/dist/types-DUDmnzD8.d.cts +38 -0
  38. package/dist/types-DUDmnzD8.d.ts +38 -0
  39. package/package.json +83 -0
  40. package/src/jsx/jsx-dev-runtime.ts +26 -0
  41. package/src/jsx/jsx-runtime.ts +36 -0
  42. package/src/jsx/react-jsx-runtime.d.ts +0 -0
  43. package/src/jsx/types.ts +27 -0
@@ -0,0 +1,84 @@
1
+ import {
2
+ cleanupComponent,
3
+ init_component,
4
+ init_logger,
5
+ lockRouteRegistration,
6
+ logger,
7
+ mountComponent,
8
+ resolveRoute
9
+ } from "./chunk-L7RL4LYV.js";
10
+
11
+ // src/router/navigate.ts
12
+ init_component();
13
+ init_logger();
14
+ var currentInstance = null;
15
+ function registerAppInstance(instance, _path) {
16
+ currentInstance = instance;
17
+ if (process.env.NODE_ENV === "production") {
18
+ lockRouteRegistration();
19
+ }
20
+ }
21
+ function navigate(path) {
22
+ if (typeof window === "undefined") {
23
+ return;
24
+ }
25
+ const resolved = resolveRoute(path);
26
+ if (!resolved) {
27
+ if (process.env.NODE_ENV !== "production") {
28
+ logger.warn(`No route found for path: ${path}`);
29
+ }
30
+ return;
31
+ }
32
+ window.history.pushState({ path }, "", path);
33
+ if (currentInstance) {
34
+ cleanupComponent(currentInstance);
35
+ currentInstance.fn = resolved.handler;
36
+ currentInstance.props = resolved.params;
37
+ currentInstance.stateValues = [];
38
+ currentInstance.expectedStateIndices = [];
39
+ currentInstance.firstRenderComplete = false;
40
+ currentInstance.stateIndexCheck = -1;
41
+ currentInstance.evaluationGeneration++;
42
+ currentInstance.notifyUpdate = null;
43
+ currentInstance.abortController = new AbortController();
44
+ mountComponent(currentInstance);
45
+ }
46
+ }
47
+ function handlePopState(_event) {
48
+ const path = window.location.pathname;
49
+ if (!currentInstance) {
50
+ return;
51
+ }
52
+ const resolved = resolveRoute(path);
53
+ if (resolved) {
54
+ cleanupComponent(currentInstance);
55
+ currentInstance.fn = resolved.handler;
56
+ currentInstance.props = resolved.params;
57
+ currentInstance.stateValues = [];
58
+ currentInstance.expectedStateIndices = [];
59
+ currentInstance.firstRenderComplete = false;
60
+ currentInstance.stateIndexCheck = -1;
61
+ currentInstance.evaluationGeneration++;
62
+ currentInstance.notifyUpdate = null;
63
+ currentInstance.abortController = new AbortController();
64
+ mountComponent(currentInstance);
65
+ }
66
+ }
67
+ function initializeNavigation() {
68
+ if (typeof window !== "undefined") {
69
+ window.addEventListener("popstate", handlePopState);
70
+ }
71
+ }
72
+ function cleanupNavigation() {
73
+ if (typeof window !== "undefined") {
74
+ window.removeEventListener("popstate", handlePopState);
75
+ }
76
+ }
77
+
78
+ export {
79
+ registerAppInstance,
80
+ navigate,
81
+ initializeNavigation,
82
+ cleanupNavigation
83
+ };
84
+ //# sourceMappingURL=chunk-UUM5W2RM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/navigate.ts"],"sourcesContent":["/**\n * Client-side navigation with History API\n */\n\nimport { resolveRoute, lockRouteRegistration } from './route';\nimport {\n mountComponent,\n cleanupComponent,\n type ComponentInstance,\n} from '../runtime/component';\nimport { logger } from '../dev/logger';\n\n// Global app state for navigation\nlet currentInstance: ComponentInstance | null = null;\n\n/**\n * Register the current app instance (called by createApp)\n */\nexport function registerAppInstance(\n instance: ComponentInstance,\n _path: string\n): void {\n currentInstance = instance;\n // Lock further route registrations after the app has started — but allow tests to register routes.\n // Enforce only in production to avoid breaking test infra which registers routes dynamically.\n if (process.env.NODE_ENV === 'production') {\n lockRouteRegistration();\n }\n}\n\n/**\n * Navigate to a new path\n * Updates URL, resolves route, and re-mounts app with new handler\n */\nexport function navigate(path: string): void {\n if (typeof window === 'undefined') {\n // SSR context\n return;\n }\n\n // Resolve the new path to a route\n const resolved = resolveRoute(path);\n\n if (!resolved) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`No route found for path: ${path}`);\n }\n return;\n }\n\n // Update browser history\n window.history.pushState({ path }, '', path);\n\n // Re-render with the new route handler and params\n if (currentInstance) {\n // Cleanup previous route (abort pending operations)\n cleanupComponent(currentInstance);\n\n // The route handler IS the component function\n // It takes params as props and renders the route\n currentInstance.fn = resolved.handler as ComponentInstance['fn'];\n currentInstance.props = resolved.params;\n\n // Reset state to prevent leakage from previous route\n // Each route navigation starts completely fresh\n currentInstance.stateValues = [];\n currentInstance.expectedStateIndices = [];\n currentInstance.firstRenderComplete = false;\n currentInstance.stateIndexCheck = -1;\n // Increment generation to invalidate pending async evaluations from previous route\n currentInstance.evaluationGeneration++;\n currentInstance.notifyUpdate = null;\n\n // CRITICAL FIX: Create new AbortController for new route\n // Old controller is already aborted; we need a fresh one for async operations\n currentInstance.abortController = new AbortController();\n\n // Re-execute and re-mount component\n mountComponent(currentInstance);\n }\n}\n\n/**\n * Handle browser back/forward buttons\n */\nfunction handlePopState(_event: PopStateEvent): void {\n const path = window.location.pathname;\n\n if (!currentInstance) {\n return;\n }\n\n const resolved = resolveRoute(path);\n\n if (resolved) {\n // Cleanup old component\n cleanupComponent(currentInstance);\n\n // The route handler IS the component function\n currentInstance.fn = resolved.handler as ComponentInstance['fn'];\n currentInstance.props = resolved.params;\n\n // Reset state to prevent leakage from previous route\n currentInstance.stateValues = [];\n currentInstance.expectedStateIndices = [];\n currentInstance.firstRenderComplete = false;\n currentInstance.stateIndexCheck = -1;\n // Increment generation to invalidate pending async evaluations from previous route\n currentInstance.evaluationGeneration++;\n currentInstance.notifyUpdate = null;\n\n // CRITICAL FIX: Create new AbortController for back/forward navigation\n currentInstance.abortController = new AbortController();\n\n mountComponent(currentInstance);\n }\n}\n\n/**\n * Setup popstate listener for browser navigation\n */\nexport function initializeNavigation(): void {\n if (typeof window !== 'undefined') {\n window.addEventListener('popstate', handlePopState);\n }\n}\n\n/**\n * Cleanup navigation listeners\n */\nexport function cleanupNavigation(): void {\n if (typeof window !== 'undefined') {\n window.removeEventListener('popstate', handlePopState);\n }\n}\n"],"mappings":";;;;;;;;;;;AAKA;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ACjC,WAAO,iBAAiB,YAAY,cAAc;AAAA,EACpD;AACF;AAKO,SAAS,oBAA0B;AACxC,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,oBAAoB,YAAY,cAAc;AAAA,EACvD;AACF;","names":[]}
@@ -0,0 +1,29 @@
1
+ import {
2
+ __esm
3
+ } from "./chunk-4CV4JOE5.js";
4
+
5
+ // src/jsx/jsx-runtime.ts
6
+ function jsx(type, props, key) {
7
+ return {
8
+ type,
9
+ props: props || {},
10
+ key
11
+ };
12
+ }
13
+ function jsxs(type, props, key) {
14
+ return jsx(type, props, key);
15
+ }
16
+ var Fragment;
17
+ var init_jsx_runtime = __esm({
18
+ "src/jsx/jsx-runtime.ts"() {
19
+ Fragment = /* @__PURE__ */ Symbol.for("@askrjs/askr.Fragment");
20
+ }
21
+ });
22
+
23
+ export {
24
+ jsx,
25
+ jsxs,
26
+ Fragment,
27
+ init_jsx_runtime
28
+ };
29
+ //# sourceMappingURL=chunk-YNH3D4KW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/jsx/jsx-runtime.ts"],"sourcesContent":["/**\n * JSX runtime factory\n * Thin layer — no scheduling, no logic\n */\n\nimport './types';\n\nexport interface JSXElement {\n type: unknown;\n props: Record<string, unknown>;\n key?: string | number;\n}\n\nexport function jsx(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n): JSXElement {\n return {\n type,\n props: props || {},\n key,\n };\n}\n\nexport function jsxs(\n type: unknown,\n props: Record<string, unknown> | null,\n key?: string | number\n): JSXElement {\n return jsx(type, props, key);\n}\n\n// Fragment for rendering multiple elements without wrapper\n// Unique fragment symbol for Askr\nexport const Fragment = Symbol.for('@askrjs/askr.Fragment');\n"],"mappings":";;;;;AAaO,SAAS,IACd,MACA,OACA,KACY;AACZ,SAAO;AAAA,IACL;AAAA,IACA,OAAO,SAAS,CAAC;AAAA,IACjB;AAAA,EACF;AACF;AAEO,SAAS,KACd,MACA,OACA,KACY;AACZ,SAAO,IAAI,MAAM,OAAO,GAAG;AAC7B;AA/BA,IAmCa;AAnCb;AAAA;AAmCO,IAAM,WAAW,uBAAO,IAAI,uBAAuB;AAAA;AAAA;","names":[]}