xanix 1.0.0 → 1.0.3

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 (120) hide show
  1. package/dist/BaseDocument.d.ts +1 -1
  2. package/dist/BaseDocument.js +3 -3
  3. package/dist/bin/bundler/buildCache.js +6 -23
  4. package/dist/bin/bundler/plugins/XanixReactRefresh.js +33 -33
  5. package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.js +5 -0
  6. package/dist/bin/bundler/plugins/XanixTsconfigAlias.d.ts +2 -0
  7. package/dist/bin/bundler/plugins/{xanixTsconfigAlias.js → XanixTsconfigAlias.js} +3 -5
  8. package/dist/bin/bundler/plugins/plugins.js +6 -0
  9. package/dist/bin/bundler/watchClient.js +7 -1
  10. package/dist/bin/cli/build.js +3 -1
  11. package/dist/bin/cli/dev.js +3 -0
  12. package/dist/bin/cli/start copy.d.ts +2 -0
  13. package/dist/bin/cli/start copy.js +34 -0
  14. package/dist/bin/index.js +0 -0
  15. package/dist/client/client-runtime.d.ts +10 -0
  16. package/dist/client/client-runtime.js +98 -0
  17. package/dist/client/index.d.ts +2 -2
  18. package/dist/client/index.js +2 -2
  19. package/dist/client/navigation.d.ts +3 -4
  20. package/dist/client/navigation.js +23 -10
  21. package/dist/client/runtime.d.ts +1 -1
  22. package/dist/components/Document/context.d.ts +4 -10
  23. package/dist/components/Document/context.js +6 -5
  24. package/dist/components/Document/index.d.ts +6 -5
  25. package/dist/components/Document/index.js +3 -7
  26. package/dist/components/Head.js +1 -1
  27. package/dist/document/Body.js +1 -2
  28. package/dist/document/Document.js +1 -2
  29. package/dist/document/DocumentContext.d.ts +1 -0
  30. package/dist/document/Head.js +4 -3
  31. package/dist/document/index.d.ts +1 -1
  32. package/dist/document/index.js +1 -1
  33. package/dist/document/useDocument.d.ts +1 -1
  34. package/dist/hooks/useCookie.d.ts +2 -0
  35. package/dist/hooks/useCookie.js +13 -0
  36. package/dist/hooks/useData.js +1 -3
  37. package/dist/hooks/useRequest copy.d.ts +2 -0
  38. package/dist/hooks/useRequest copy.js +8 -0
  39. package/dist/index.d.ts +0 -5
  40. package/dist/index.js +0 -4
  41. package/dist/navigation/navigate.js +6 -6
  42. package/dist/navigation/useLocation.js +1 -1
  43. package/dist/router/index.d.ts +3 -1
  44. package/dist/router/index.js +3 -1
  45. package/dist/router/useParams.d.ts +1 -9
  46. package/dist/router/useParams.js +3 -48
  47. package/dist/router/usePathname.d.ts +1 -0
  48. package/dist/router/usePathname.js +8 -0
  49. package/dist/router/useSearchParams.js +2 -8
  50. package/dist/runtime/createServer.d.ts +12 -0
  51. package/dist/runtime/createServer.js +40 -0
  52. package/dist/runtime/index.d.ts +12 -0
  53. package/dist/runtime/index.js +40 -0
  54. package/dist/runtime/readManifest.d.ts +14 -0
  55. package/dist/runtime/readManifest.js +8 -0
  56. package/dist/runtime/xanixPage.d.ts +9 -0
  57. package/dist/runtime/xanixPage.js +62 -0
  58. package/dist/server/createServer.d.ts +12 -0
  59. package/dist/server/createServer.js +40 -0
  60. package/dist/server/page.js +2 -0
  61. package/dist/server/runtime copy.d.ts +12 -0
  62. package/dist/server/runtime copy.js +40 -0
  63. package/dist/server/runtime.d.ts +12 -0
  64. package/dist/server/runtime.js +40 -0
  65. package/dist/server/xanixPage.d.ts +9 -0
  66. package/dist/server/xanixPage.js +62 -0
  67. package/dist/utils/index.d.ts +0 -9
  68. package/dist/utils/index.js +1 -27
  69. package/dist/xanix.js +12 -12
  70. package/package.json +73 -73
  71. package/{src/xanix-env.d.ts → xanix-env.d.ts} +79 -79
  72. package/dist/Document.d.ts +0 -7
  73. package/dist/Document.js +0 -7
  74. package/dist/bin/bundler/plugins/XanixWatchChange copy.d.ts +0 -10
  75. package/dist/bin/bundler/plugins/XanixWatchChange copy.js +0 -30
  76. package/dist/bin/bundler/plugins/XanixWatchChange.d.ts +0 -9
  77. package/dist/bin/bundler/plugins/XanixWatchChange.js +0 -27
  78. package/dist/bin/bundler/plugins/XanixWatchChangeClient.d.ts +0 -7
  79. package/dist/bin/bundler/plugins/XanixWatchChangeClient.js +0 -15
  80. package/dist/bin/bundler/plugins/pathResolver.d.ts +0 -5
  81. package/dist/bin/bundler/plugins/pathResolver.js +0 -57
  82. package/dist/bin/bundler/plugins/xanixServerData.d.ts +0 -6
  83. package/dist/bin/bundler/plugins/xanixServerData.js +0 -224
  84. package/dist/bin/bundler/plugins/xanixTsconfigAlias.d.ts +0 -6
  85. package/dist/client/components/Body.d.ts +0 -5
  86. package/dist/client/components/Body.js +0 -10
  87. package/dist/client/components/Document/context.d.ts +0 -3
  88. package/dist/client/components/Document/context.js +0 -14
  89. package/dist/client/components/Document/index.d.ts +0 -8
  90. package/dist/client/components/Document/index.js +0 -6
  91. package/dist/client/components/Head copy.d.ts +0 -5
  92. package/dist/client/components/Head copy.js +0 -8
  93. package/dist/client/components/Head.d.ts +0 -5
  94. package/dist/client/components/Head.js +0 -10
  95. package/dist/client/components/Link.d.ts +0 -6
  96. package/dist/client/components/Link.js +0 -10
  97. package/dist/client/refresh.d.ts +0 -7
  98. package/dist/client/refresh.js +0 -15
  99. package/dist/components/Document/Document.d.ts +0 -16
  100. package/dist/components/Document/Document.js +0 -15
  101. package/dist/components/DocumentContext/DocumentContext.d.ts +0 -15
  102. package/dist/components/DocumentContext/DocumentContext.js +0 -18
  103. package/dist/components/DocumentContext/context.d.ts +0 -11
  104. package/dist/components/DocumentContext/context.js +0 -14
  105. package/dist/components/DocumentContext/index.d.ts +0 -15
  106. package/dist/components/DocumentContext/index.js +0 -18
  107. package/dist/components/DocumentProvider.d.ts +0 -13
  108. package/dist/components/DocumentProvider.js +0 -7
  109. package/dist/document/Document/Document.d.ts +0 -7
  110. package/dist/document/Document/Document.js +0 -10
  111. package/dist/document/Document/context.d.ts +0 -17
  112. package/dist/document/Document/context.js +0 -13
  113. package/dist/document/Document/index.d.ts +0 -7
  114. package/dist/document/Document/index.js +0 -10
  115. package/dist/document/context.d.ts +0 -17
  116. package/dist/document/context.js +0 -13
  117. package/dist/loader.d.ts +0 -11
  118. package/dist/loader.js +0 -16
  119. package/dist/router/useSearchParams .d.ts +0 -9
  120. package/dist/router/useSearchParams .js +0 -50
@@ -1,224 +0,0 @@
1
- import path from "node:path";
2
- import crypto from "node:crypto";
3
- import { parse } from "@babel/parser";
4
- import traverse from "@babel/traverse";
5
- import generate from "@babel/generator";
6
- import * as t from "@babel/types";
7
- function createLoaderId(filename, start) {
8
- const relative = path.relative(process.cwd(), filename).replace(/\\/g, "/");
9
- const value = `${relative}:${start}`;
10
- return crypto.createHash("sha256").update(value).digest("hex").slice(0, 16);
11
- }
12
- function getArgumentNames(node) {
13
- const names = [];
14
- for (const property of node.properties) {
15
- if (!t.isObjectProperty(property)) {
16
- continue;
17
- }
18
- if (t.isIdentifier(property.key)) {
19
- names.push(property.key.name);
20
- }
21
- }
22
- return names;
23
- }
24
- export default function xanixServerData(options = {}) {
25
- const root = options.root ?? process.cwd();
26
- return {
27
- name: "xanix-server-data",
28
- transform(code, id) {
29
- if (id.includes("node_modules") || !/\.(js|jsx|ts|tsx)$/.test(id)) {
30
- return null;
31
- }
32
- const ast = parse(code, {
33
- sourceType: "module",
34
- plugins: ["typescript", "jsx"],
35
- });
36
- let hasUseData = false;
37
- let changed = false;
38
- const loaderStatements = [];
39
- // --------------------------------------------------
40
- // Find useData
41
- // --------------------------------------------------
42
- traverse(ast, {
43
- ImportDeclaration(importPath) {
44
- if (importPath.node.source.value !== "xanix") {
45
- return;
46
- }
47
- for (const specifier of importPath.node.specifiers) {
48
- if (t.isImportSpecifier(specifier) &&
49
- t.isIdentifier(specifier.imported) &&
50
- specifier.imported.name === "useData") {
51
- hasUseData = true;
52
- }
53
- }
54
- },
55
- });
56
- if (!hasUseData) {
57
- return null;
58
- }
59
- // --------------------------------------------------
60
- // Transform useData()
61
- // --------------------------------------------------
62
- traverse(ast, {
63
- CallExpression(callPath) {
64
- const node = callPath.node;
65
- if (!t.isIdentifier(node.callee) || node.callee.name !== "useData") {
66
- return;
67
- }
68
- const callback = node.arguments[0];
69
- const args = node.arguments[1];
70
- if (!callback ||
71
- !(t.isArrowFunctionExpression(callback) ||
72
- t.isFunctionExpression(callback))) {
73
- return;
74
- }
75
- if (!args || !t.isObjectExpression(args)) {
76
- return;
77
- }
78
- const loaderId = createLoaderId(id, node.start ?? 0);
79
- const argumentNames = getArgumentNames(args);
80
- // ----------------------------------------------
81
- // Clone callback body
82
- // ----------------------------------------------
83
- const callbackBody = t.cloneNode(callback.body, true);
84
- // ----------------------------------------------
85
- // Create:
86
- //
87
- // async ({ category }) => {
88
- // ...
89
- // }
90
- // ----------------------------------------------
91
- const parameterProperties = argumentNames.map((name) => t.objectProperty(t.identifier(name), t.identifier(name), false, true));
92
- const loaderParameter = t.objectPattern(parameterProperties);
93
- let loaderFunction;
94
- if (t.isBlockStatement(callbackBody)) {
95
- loaderFunction = t.arrowFunctionExpression([loaderParameter], callbackBody, callback.async);
96
- }
97
- else {
98
- loaderFunction = t.arrowFunctionExpression([loaderParameter], callbackBody, callback.async);
99
- }
100
- // ----------------------------------------------
101
- // registerLoader(...)
102
- // ----------------------------------------------
103
- const registerLoader = t.expressionStatement(t.callExpression(t.identifier("registerLoader"), [
104
- t.stringLiteral(loaderId),
105
- loaderFunction,
106
- ]));
107
- loaderStatements.push(registerLoader);
108
- // ----------------------------------------------
109
- // Replace:
110
- //
111
- // useData(callback, args)
112
- //
113
- // with:
114
- //
115
- // useLoader(
116
- // page.pageId,
117
- // "id",
118
- // args
119
- // )
120
- // ----------------------------------------------
121
- const useLoader = t.callExpression(t.identifier("useLoader"), [
122
- t.memberExpression(t.identifier("page"), t.identifier("pageId")),
123
- t.stringLiteral(loaderId),
124
- t.cloneNode(args, true),
125
- ]);
126
- callPath.replaceWith(useLoader);
127
- changed = true;
128
- },
129
- });
130
- if (!changed) {
131
- return null;
132
- }
133
- // --------------------------------------------------
134
- // Remove useData from import
135
- // --------------------------------------------------
136
- traverse(ast, {
137
- ImportDeclaration(importPath) {
138
- if (importPath.node.source.value !== "xanix") {
139
- return;
140
- }
141
- importPath.node.specifiers = importPath.node.specifiers.filter((specifier) => {
142
- return !(t.isImportSpecifier(specifier) &&
143
- t.isIdentifier(specifier.imported) &&
144
- specifier.imported.name === "useData");
145
- });
146
- if (importPath.node.specifiers.length === 0) {
147
- importPath.remove();
148
- }
149
- },
150
- });
151
- // --------------------------------------------------
152
- // Add imports
153
- // --------------------------------------------------
154
- const program = ast.program;
155
- let importEnd = 0;
156
- while (importEnd < program.body.length &&
157
- t.isImportDeclaration(program.body[importEnd])) {
158
- importEnd++;
159
- }
160
- const usePageImport = t.importDeclaration([t.importSpecifier(t.identifier("usePage"), t.identifier("usePage"))], t.stringLiteral("xanix"));
161
- const loaderImport = t.importDeclaration([
162
- t.importSpecifier(t.identifier("useLoader"), t.identifier("useLoader")),
163
- t.importSpecifier(t.identifier("registerLoader"), t.identifier("registerLoader")),
164
- ], t.stringLiteral("xanix/runtime/loader"));
165
- program.body.splice(importEnd, 0, usePageImport, loaderImport);
166
- // --------------------------------------------------
167
- // Insert registerLoader calls
168
- // after imports
169
- // --------------------------------------------------
170
- program.body.splice(importEnd + 2, 0, ...loaderStatements);
171
- // --------------------------------------------------
172
- // Add:
173
- //
174
- // const page = usePage();
175
- //
176
- // to function containing useLoader()
177
- // --------------------------------------------------
178
- traverse(ast, {
179
- Function(functionPath) {
180
- let hasUseLoader = false;
181
- functionPath.traverse({
182
- CallExpression(innerPath) {
183
- if (t.isIdentifier(innerPath.node.callee, {
184
- name: "useLoader",
185
- })) {
186
- hasUseLoader = true;
187
- innerPath.stop();
188
- }
189
- },
190
- });
191
- if (!hasUseLoader) {
192
- return;
193
- }
194
- if (!t.isBlockStatement(functionPath.node.body)) {
195
- return;
196
- }
197
- const alreadyHasPage = functionPath.node.body.body.some((statement) => {
198
- if (!t.isVariableDeclaration(statement)) {
199
- return false;
200
- }
201
- return statement.declarations.some((declaration) => t.isIdentifier(declaration.id, {
202
- name: "page",
203
- }));
204
- });
205
- if (alreadyHasPage) {
206
- return;
207
- }
208
- const declaration = t.variableDeclaration("const", [
209
- t.variableDeclarator(t.identifier("page"), t.callExpression(t.identifier("usePage"), [])),
210
- ]);
211
- functionPath.node.body.body.unshift(declaration);
212
- },
213
- });
214
- const output = generate(ast, {
215
- sourceMaps: true,
216
- sourceFileName: id,
217
- }, code);
218
- return {
219
- code: output.code,
220
- map: output.map,
221
- };
222
- },
223
- };
224
- }
@@ -1,6 +0,0 @@
1
- import type { Plugin } from "rollup";
2
- export interface XanixTsconfigAliasOptions {
3
- tsconfigPath?: string;
4
- root?: string;
5
- }
6
- export default function xanixTsconfigAlias(options?: XanixTsconfigAliasOptions): Plugin;
@@ -1,5 +0,0 @@
1
- type BodyProps = {
2
- children?: React.ReactNode;
3
- };
4
- declare const Body: ({ children }: BodyProps) => import("react").JSX.Element;
5
- export default Body;
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useDocument } from "./Document/context.js";
3
- const Body = ({ children }) => {
4
- const { scripts } = useDocument();
5
- return (_jsxs("body", { children: [children, Array.isArray(scripts) &&
6
- scripts
7
- .filter(({ placement }) => placement === "body")
8
- .map((s) => (_jsx("script", { src: s.src, type: s.type || "text/javascript" }, s.src)))] }));
9
- };
10
- export default Body;
@@ -1,3 +0,0 @@
1
- import { XanixDocumentData } from "../../../types";
2
- export declare const DocumentContext: import("react").Context<XanixDocumentData>;
3
- export declare const useDocument: () => XanixDocumentData;
@@ -1,14 +0,0 @@
1
- import { createContext, useContext } from "react";
2
- export const DocumentContext = createContext({
3
- title: "",
4
- meta: new Map(),
5
- styles: new Set(),
6
- scripts: [],
7
- });
8
- export const useDocument = () => {
9
- const context = useContext(DocumentContext);
10
- if (!context) {
11
- throw new Error("useDocument must be used within a DocumentProvider");
12
- }
13
- return context;
14
- };
@@ -1,8 +0,0 @@
1
- import type { XanixDocumentData } from "../../../types";
2
- import { HTMLProps } from "react";
3
- export type DocumentProps = HTMLProps<HTMLHtmlElement> & {
4
- document: XanixDocumentData;
5
- children: React.ReactNode;
6
- };
7
- declare const Document: ({ document, children, ...props }: DocumentProps) => import("react").JSX.Element;
8
- export default Document;
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { DocumentContext } from "./context";
3
- const Document = ({ document, children, ...props }) => {
4
- return (_jsx(DocumentContext.Provider, { value: document, children: _jsx("html", { ...props, children: children }) }));
5
- };
6
- export default Document;
@@ -1,5 +0,0 @@
1
- type HeadProps = {
2
- children?: React.ReactNode;
3
- };
4
- declare const Head: ({ children }: HeadProps) => import("react").JSX.Element;
5
- export default Head;
@@ -1,8 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { getDocumentData } from "../../utils/index.js";
3
- const doc = getDocumentData();
4
- const Head = ({ children }) => {
5
- doc.head = children;
6
- return _jsx(_Fragment, {});
7
- };
8
- export default Head;
@@ -1,5 +0,0 @@
1
- type HeadProps = {
2
- children?: React.ReactNode;
3
- };
4
- declare const Head: ({ children }: HeadProps) => import("react").JSX.Element;
5
- export default Head;
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useDocument } from "./Document/context.js";
3
- const Head = ({ children }) => {
4
- const { title, meta, styles, scripts } = useDocument();
5
- return (_jsxs("head", { children: [_jsx("title", { children: title }), Array.from(meta.entries()).map(([name, content]) => (_jsx("meta", { name: name, content: content }, name))), children, Array.from(styles).map((href) => (_jsx("link", { rel: "stylesheet", href: href }, href))), Array.isArray(scripts) &&
6
- scripts
7
- .filter(({ placement }) => placement === "head")
8
- .map((s) => (_jsx("script", { src: s.src, type: s.type || "text/javascript" }, s.src)))] }));
9
- };
10
- export default Head;
@@ -1,6 +0,0 @@
1
- import { HTMLProps } from "react";
2
- export type LinkProps = Omit<HTMLProps<HTMLAnchorElement>, "href"> & {
3
- href: string;
4
- };
5
- declare const Link: ({ children, ...props }: LinkProps) => import("react").JSX.Element;
6
- export default Link;
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { navigate } from "../navigation";
3
- const Link = ({ children, ...props }) => {
4
- return (_jsx("a", { ...props, onClick: (e) => {
5
- e.preventDefault();
6
- e.stopPropagation();
7
- navigate(props.href);
8
- }, children: children }));
9
- };
10
- export default Link;
@@ -1,7 +0,0 @@
1
- export type RefreshRecord = {
2
- id: string;
3
- current: Function;
4
- previous?: Function;
5
- };
6
- export declare function register(component: Function, id: string): void;
7
- export declare function performRefresh(): void;
@@ -1,15 +0,0 @@
1
- // refresh/index.ts
2
- import RefreshRuntime from "react-refresh";
3
- const runtime = RefreshRuntime;
4
- // if (typeof window !== "undefined") {
5
- // RefreshRuntime.injectIntoGlobalHook(window);
6
- // const win = window as any;
7
- // win.$RefreshReg$ = () => {};
8
- // win.$RefreshSig$ = () => (type: any) => type;
9
- // }
10
- export function register(component, id) {
11
- runtime.register(component, id);
12
- }
13
- export function performRefresh() {
14
- runtime.performReactRefresh();
15
- }
@@ -1,16 +0,0 @@
1
- export type DocumentContextData = {
2
- pageId?: string;
3
- props: Record<string, any>;
4
- title: string;
5
- meta: Array<{
6
- name: string;
7
- content: string;
8
- }>;
9
- };
10
- export declare const useDocument: () => DocumentContextData | null;
11
- export type DocumentProps = {
12
- children?: React.ReactNode;
13
- document: DocumentContextData;
14
- };
15
- declare const Document: ({ children, document }: DocumentProps) => import("react").JSX.Element;
16
- export default Document;
@@ -1,15 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from "react";
3
- const DocumentContext = createContext(null);
4
- export const useDocument = () => {
5
- return useContext(DocumentContext);
6
- };
7
- const DocumentProvider = DocumentContext.Provider;
8
- const Document = ({ children, document }) => {
9
- const isClient = typeof window !== "undefined";
10
- if (isClient) {
11
- return _jsx(DocumentProvider, { value: document, children: children });
12
- }
13
- return (_jsx(DocumentProvider, { value: document, children: _jsx("html", { children: children }) }));
14
- };
15
- export default Document;
@@ -1,15 +0,0 @@
1
- export type XanixDocumentData = {
2
- pageId?: string;
3
- props: Record<string, any>;
4
- title: string;
5
- meta: Array<{
6
- name: string;
7
- content: string;
8
- }>;
9
- };
10
- export declare const DocumentContext: import("react").Context<XanixDocumentData>;
11
- export declare const useDocument: () => XanixDocumentData;
12
- export declare const DocumentProvider: ({ children, value, }: {
13
- children: React.ReactNode;
14
- value: XanixDocumentData;
15
- }) => import("react").JSX.Element;
@@ -1,18 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from "react";
3
- export const DocumentContext = createContext({
4
- pageId: "",
5
- title: "",
6
- props: {},
7
- meta: [],
8
- });
9
- export const useDocument = () => {
10
- const context = useContext(DocumentContext);
11
- if (!context) {
12
- throw new Error("useDocument must be used within a DocumentProvider");
13
- }
14
- return context;
15
- };
16
- export const DocumentProvider = ({ children, value, }) => {
17
- return (_jsx(DocumentContext.Provider, { value: value, children: children }));
18
- };
@@ -1,11 +0,0 @@
1
- export type XanixDocumentData = {
2
- pageId?: string;
3
- props: Record<string, any>;
4
- title: string;
5
- meta: Array<{
6
- name: string;
7
- content: string;
8
- }>;
9
- };
10
- export declare const DocumentContext: import("react").Context<XanixDocumentData>;
11
- export declare const useDocument: () => XanixDocumentData;
@@ -1,14 +0,0 @@
1
- import { createContext, useContext } from "react";
2
- export const DocumentContext = createContext({
3
- pageId: "",
4
- title: "",
5
- props: {},
6
- meta: [],
7
- });
8
- export const useDocument = () => {
9
- const context = useContext(DocumentContext);
10
- if (!context) {
11
- throw new Error("useDocument must be used within a DocumentProvider");
12
- }
13
- return context;
14
- };
@@ -1,15 +0,0 @@
1
- export type XanixDocumentData = {
2
- pageId?: string;
3
- props: Record<string, any>;
4
- title: string;
5
- meta: Array<{
6
- name: string;
7
- content: string;
8
- }>;
9
- };
10
- export declare const DocumentContext: import("react").Context<XanixDocumentData>;
11
- export declare const useDocument: () => XanixDocumentData;
12
- export declare const DocumentProvider: ({ children, value, }: {
13
- children: React.ReactNode;
14
- value: XanixDocumentData;
15
- }) => import("react").JSX.Element;
@@ -1,18 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from "react";
3
- export const DocumentContext = createContext({
4
- pageId: "",
5
- title: "",
6
- props: {},
7
- meta: [],
8
- });
9
- export const useDocument = () => {
10
- const context = useContext(DocumentContext);
11
- if (!context) {
12
- throw new Error("useDocument must be used within a DocumentProvider");
13
- }
14
- return context;
15
- };
16
- export const DocumentProvider = ({ children, value, }) => {
17
- return (_jsx(DocumentContext.Provider, { value: value, children: children }));
18
- };
@@ -1,13 +0,0 @@
1
- export type DocumentContextData = {
2
- pageId?: string;
3
- props: Record<string, any>;
4
- title: string;
5
- meta: Array<{
6
- name: string;
7
- content: string;
8
- }>;
9
- };
10
- export declare const DocumentContext: import("react").Context<DocumentContextData | null>;
11
- export declare const useDocument: () => DocumentContextData | null;
12
- declare const DocumentProvider: import("react").Provider<DocumentContextData | null>;
13
- export default DocumentProvider;
@@ -1,7 +0,0 @@
1
- import { createContext, useContext } from "react";
2
- export const DocumentContext = createContext(null);
3
- export const useDocument = () => {
4
- return useContext(DocumentContext);
5
- };
6
- const DocumentProvider = DocumentContext.Provider;
7
- export default DocumentProvider;
@@ -1,7 +0,0 @@
1
- import { DocumentContextData } from "../context.js";
2
- export type DocumentProps = {
3
- children?: React.ReactNode;
4
- document: DocumentContextData;
5
- };
6
- declare const Document: ({ children, document }: DocumentProps) => import("react").JSX.Element;
7
- export default Document;
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { DocumentProvider } from "../context.js";
3
- const Document = ({ children, document }) => {
4
- const isClient = typeof window !== "undefined";
5
- if (isClient) {
6
- return _jsx(DocumentProvider, { value: document, children: children });
7
- }
8
- return (_jsx(DocumentProvider, { value: document, children: _jsx("html", { children: children }) }));
9
- };
10
- export default Document;
@@ -1,17 +0,0 @@
1
- export type DocumentContextData = {
2
- pageId: string;
3
- props: Record<string, any>;
4
- title: string;
5
- meta: Array<{
6
- name: string;
7
- content: string;
8
- }>;
9
- request?: Express.Request;
10
- };
11
- export declare const DocumentContext: import("react").Context<DocumentContextData | null>;
12
- export declare const useDocument: () => DocumentContextData;
13
- export type DocumentProviderProps = {
14
- children: React.ReactNode;
15
- value: DocumentContextData;
16
- };
17
- export declare const DocumentProvider: ({ children, value, }: DocumentProviderProps) => import("react").JSX.Element;
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from "react";
3
- export const DocumentContext = createContext(null);
4
- export const useDocument = () => {
5
- const context = useContext(DocumentContext);
6
- if (!context) {
7
- throw new Error("useDocument must be used within a DocumentProvider");
8
- }
9
- return context;
10
- };
11
- export const DocumentProvider = ({ children, value, }) => {
12
- return (_jsx(DocumentContext.Provider, { value: value, children: children }));
13
- };
@@ -1,7 +0,0 @@
1
- import { DocumentContextData } from "../context.js";
2
- export type DocumentProps = {
3
- children?: React.ReactNode;
4
- document: DocumentContextData;
5
- };
6
- declare const Document: ({ children, document }: DocumentProps) => import("react").JSX.Element;
7
- export default Document;
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { DocumentProvider } from "../context.js";
3
- const Document = ({ children, document }) => {
4
- const isClient = typeof window !== "undefined";
5
- if (isClient) {
6
- return _jsx(DocumentProvider, { value: document, children: children });
7
- }
8
- return (_jsx(DocumentProvider, { value: document, children: _jsx("html", { children: children }) }));
9
- };
10
- export default Document;
@@ -1,17 +0,0 @@
1
- export type DocumentContextData = {
2
- pageId: string;
3
- props: Record<string, any>;
4
- title: string;
5
- meta: Array<{
6
- name: string;
7
- content: string;
8
- }>;
9
- request?: Express.Request;
10
- };
11
- export declare const DocumentContext: import("react").Context<DocumentContextData | null>;
12
- export declare const useDocument: () => DocumentContextData;
13
- export type DocumentProviderProps = {
14
- children: React.ReactNode;
15
- value: DocumentContextData;
16
- };
17
- export declare const DocumentProvider: ({ children, value, }: DocumentProviderProps) => import("react").JSX.Element;
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from "react";
3
- export const DocumentContext = createContext(null);
4
- export const useDocument = () => {
5
- const context = useContext(DocumentContext);
6
- if (!context) {
7
- throw new Error("useDocument must be used within a DocumentProvider");
8
- }
9
- return context;
10
- };
11
- export const DocumentProvider = ({ children, value, }) => {
12
- return (_jsx(DocumentContext.Provider, { value: value, children: children }));
13
- };
package/dist/loader.d.ts DELETED
@@ -1,11 +0,0 @@
1
- type PageId = string;
2
- type LoaderEntry = {
3
- args: any[];
4
- callback: () => any;
5
- data: any;
6
- };
7
- declare const loader: {
8
- get: (pageId: PageId) => any;
9
- set: (pageId: PageId, entry: LoaderEntry) => void;
10
- };
11
- export default loader;