@uniformdev/canvas-next-rsc 19.61.1-alpha.10 → 19.61.1-alpha.18
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.
- package/README.md +2 -2
- package/dist/UniformComposition-38e22896.d.ts +61 -0
- package/dist/UniformComposition-d178d865.d.ts +64 -0
- package/dist/component.d.mts +76 -0
- package/dist/component.d.ts +76 -0
- package/dist/component.js +218 -0
- package/dist/component.mjs +182 -0
- package/dist/config.d.mts +6 -0
- package/dist/config.d.ts +6 -1
- package/dist/config.js +56 -29
- package/dist/config.mjs +41 -0
- package/dist/handler.d.mts +12 -0
- package/dist/handler.d.ts +12 -2
- package/dist/handler.js +703 -2
- package/dist/handler.mjs +682 -0
- package/dist/index.d.mts +245 -0
- package/dist/index.d.ts +245 -23
- package/dist/index.esm.js +974 -0
- package/dist/index.js +1011 -29
- package/dist/index.mjs +974 -0
- package/package.json +24 -16
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// src/components/DefaultNotImplementedComponent.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
var DefaultNotImplementedComponent = ({ component }) => {
|
|
4
|
+
return /* @__PURE__ */ React.createElement("div", null, "The component of type ", component.type, " not been implemented yet.");
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/components/UniformRichText.tsx
|
|
8
|
+
import {
|
|
9
|
+
isRichTextValue,
|
|
10
|
+
isRichTextValueConsideredEmpty
|
|
11
|
+
} from "@uniformdev/richtext";
|
|
12
|
+
import React11 from "react";
|
|
13
|
+
|
|
14
|
+
// src/components/UniformRichTextNode.tsx
|
|
15
|
+
import { isRichTextNode } from "@uniformdev/richtext";
|
|
16
|
+
import React10 from "react";
|
|
17
|
+
|
|
18
|
+
// src/components/nodes/HeadingRichTextNode.tsx
|
|
19
|
+
import React2 from "react";
|
|
20
|
+
var HeadingRichTextNode = ({ children, node }) => {
|
|
21
|
+
const { tag } = node;
|
|
22
|
+
const HTag = tag != null ? tag : "h1";
|
|
23
|
+
return /* @__PURE__ */ React2.createElement(HTag, null, children);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/components/nodes/LinebreakRichTextNode.tsx
|
|
27
|
+
import React3 from "react";
|
|
28
|
+
var LinebreakRichTextNode = () => {
|
|
29
|
+
return /* @__PURE__ */ React3.createElement("br", null);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/components/nodes/LinkRichTextNode.tsx
|
|
33
|
+
import { linkParamValueToHref } from "@uniformdev/richtext";
|
|
34
|
+
import React4 from "react";
|
|
35
|
+
var LinkRichTextNode = ({ children, node }) => {
|
|
36
|
+
const { link } = node;
|
|
37
|
+
return /* @__PURE__ */ React4.createElement("a", { href: linkParamValueToHref(link) }, children);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/components/nodes/ListItemRichTextNode.tsx
|
|
41
|
+
import React5 from "react";
|
|
42
|
+
var ListItemRichTextNode = ({ children, node }) => {
|
|
43
|
+
const { value } = node;
|
|
44
|
+
return /* @__PURE__ */ React5.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/components/nodes/ListRichTextNode.tsx
|
|
48
|
+
import React6 from "react";
|
|
49
|
+
var ListRichTextNode = ({ children, node }) => {
|
|
50
|
+
const { tag, start } = node;
|
|
51
|
+
const ListTag = tag != null ? tag : "ul";
|
|
52
|
+
return /* @__PURE__ */ React6.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/components/nodes/ParagraphRichTextNode.tsx
|
|
56
|
+
import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
|
|
57
|
+
import React7 from "react";
|
|
58
|
+
var ParagraphRichTextNode = ({ children, node }) => {
|
|
59
|
+
const { format, direction } = node;
|
|
60
|
+
return /* @__PURE__ */ React7.createElement(
|
|
61
|
+
"p",
|
|
62
|
+
{
|
|
63
|
+
dir: isPureDirection(direction) ? direction : void 0,
|
|
64
|
+
style: isPureTextAlign(format) ? { textAlign: format } : void 0
|
|
65
|
+
},
|
|
66
|
+
children
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/components/nodes/TabRichTextNode.tsx
|
|
71
|
+
import React8 from "react";
|
|
72
|
+
var TabRichTextNode = () => {
|
|
73
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, " ");
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/components/nodes/TextRichTextNode.tsx
|
|
77
|
+
import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
|
|
78
|
+
import React9 from "react";
|
|
79
|
+
var TextRichTextNode = ({ node }) => {
|
|
80
|
+
const { text, format } = node;
|
|
81
|
+
const tags = getRichTextTagsFromTextFormat(format);
|
|
82
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React9.createElement(Tag, null, children), text) : text);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/components/UniformRichTextNode.tsx
|
|
86
|
+
function UniformRichTextNode({ node, ...props }) {
|
|
87
|
+
var _a;
|
|
88
|
+
if (!isRichTextNode(node))
|
|
89
|
+
return null;
|
|
90
|
+
let NodeRenderer = (_a = props.resolveRichTextRenderer) == null ? void 0 : _a.call(props, node);
|
|
91
|
+
if (typeof NodeRenderer === "undefined") {
|
|
92
|
+
NodeRenderer = resolveRichTextDefaultRenderer(node);
|
|
93
|
+
}
|
|
94
|
+
if (!NodeRenderer) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React10.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
98
|
+
return /* @__PURE__ */ React10.createElement(NodeRenderer, { node }, children);
|
|
99
|
+
}
|
|
100
|
+
var rendererMap = /* @__PURE__ */ new Map([
|
|
101
|
+
["heading", HeadingRichTextNode],
|
|
102
|
+
["linebreak", LinebreakRichTextNode],
|
|
103
|
+
["link", LinkRichTextNode],
|
|
104
|
+
["list", ListRichTextNode],
|
|
105
|
+
["listitem", ListItemRichTextNode],
|
|
106
|
+
["paragraph", ParagraphRichTextNode],
|
|
107
|
+
["quote", ({ children }) => /* @__PURE__ */ React10.createElement("blockquote", null, children)],
|
|
108
|
+
[
|
|
109
|
+
"code",
|
|
110
|
+
({ children }) => /* @__PURE__ */ React10.createElement("pre", null, /* @__PURE__ */ React10.createElement("code", null, children))
|
|
111
|
+
],
|
|
112
|
+
["root", ({ children }) => /* @__PURE__ */ React10.createElement(React10.Fragment, null, children)],
|
|
113
|
+
["text", TextRichTextNode],
|
|
114
|
+
["tab", TabRichTextNode]
|
|
115
|
+
]);
|
|
116
|
+
var resolveRichTextDefaultRenderer = (node) => {
|
|
117
|
+
return rendererMap.get(node.type);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/components/UniformRichText.tsx
|
|
121
|
+
var UniformRichText = React11.forwardRef(function UniformRichText2({ parameterId, component, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
122
|
+
var _a;
|
|
123
|
+
const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[parameterId];
|
|
124
|
+
const value = parameter == null ? void 0 : parameter.value;
|
|
125
|
+
if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
|
|
126
|
+
return null;
|
|
127
|
+
return Tag === null ? /* @__PURE__ */ React11.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React11.createElement(Tag, { ref, ...props }, /* @__PURE__ */ React11.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }));
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// src/components/UniformSlot.tsx
|
|
131
|
+
var UniformSlot = ({ data, slot, children }) => {
|
|
132
|
+
var _a;
|
|
133
|
+
const slotName = slot == null ? void 0 : slot.name;
|
|
134
|
+
const targetSlotData = slotName ? (_a = data == null ? void 0 : data.slots) == null ? void 0 : _a[slotName] : void 0;
|
|
135
|
+
const resolved = [];
|
|
136
|
+
if (slot) {
|
|
137
|
+
for (let i = 0; i < slot.items.length; i++) {
|
|
138
|
+
const child = slot.items[i];
|
|
139
|
+
if (!children) {
|
|
140
|
+
resolved.push(child);
|
|
141
|
+
} else {
|
|
142
|
+
const result = children({
|
|
143
|
+
child,
|
|
144
|
+
component: targetSlotData[i],
|
|
145
|
+
key: `inner-${i}`
|
|
146
|
+
});
|
|
147
|
+
resolved.push(result);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return resolved;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/components/UniformText.tsx
|
|
155
|
+
import { PureUniformText } from "@uniformdev/canvas-react/core";
|
|
156
|
+
import React12 from "react";
|
|
157
|
+
var UniformText = ({ context, ...rest }) => {
|
|
158
|
+
return /* @__PURE__ */ React12.createElement(
|
|
159
|
+
PureUniformText,
|
|
160
|
+
{
|
|
161
|
+
...rest,
|
|
162
|
+
isContextualEditing: context.isContextualEditing,
|
|
163
|
+
skipCustomRendering: context.isContextualEditing
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/component.ts
|
|
169
|
+
import {
|
|
170
|
+
createClientUniformContext,
|
|
171
|
+
useInitUniformContext,
|
|
172
|
+
useUniformContext
|
|
173
|
+
} from "@uniformdev/canvas-next-rsc-client";
|
|
174
|
+
export {
|
|
175
|
+
DefaultNotImplementedComponent,
|
|
176
|
+
UniformRichText,
|
|
177
|
+
UniformSlot,
|
|
178
|
+
UniformText,
|
|
179
|
+
createClientUniformContext,
|
|
180
|
+
useInitUniformContext,
|
|
181
|
+
useUniformContext
|
|
182
|
+
};
|
package/dist/config.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { NextConfig } from 'next';
|
|
2
|
+
export { UniformServerConfig } from '@uniformdev/canvas-next-rsc-shared';
|
|
3
|
+
|
|
4
|
+
declare const withUniformConfig: (nextConfig: NextConfig) => NextConfig;
|
|
5
|
+
|
|
6
|
+
export { withUniformConfig };
|
package/dist/config.js
CHANGED
|
@@ -1,31 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/* eslint-disable-next-line no-console */
|
|
20
|
-
console.log('Using Uniform config from', uniformConfigPath);
|
|
21
|
-
config.module.rules.push({
|
|
22
|
-
test: /uniform\.server\.config\.js$/,
|
|
23
|
-
include: uniformConfigPath,
|
|
24
|
-
use: context.defaultLoaders.babel,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return config;
|
|
29
|
-
},
|
|
30
|
-
});
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
19
|
|
|
20
|
+
// src/config.ts
|
|
21
|
+
var config_exports = {};
|
|
22
|
+
__export(config_exports, {
|
|
23
|
+
withUniformConfig: () => withUniformConfig
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(config_exports);
|
|
26
|
+
var { existsSync } = require("fs");
|
|
27
|
+
var { join } = require("path");
|
|
28
|
+
var getConfigPath = () => {
|
|
29
|
+
const configFilePath = join(process.cwd(), `uniform.server.config.js`);
|
|
30
|
+
if (!existsSync(configFilePath)) {
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
return configFilePath;
|
|
34
|
+
};
|
|
35
|
+
var withUniformConfig = (nextConfig) => ({
|
|
36
|
+
...nextConfig,
|
|
37
|
+
webpack: (config, context) => {
|
|
38
|
+
if (nextConfig.webpack) {
|
|
39
|
+
nextConfig.webpack(config, context);
|
|
40
|
+
}
|
|
41
|
+
if (context.isServer) {
|
|
42
|
+
const uniformConfigPath = getConfigPath();
|
|
43
|
+
if (uniformConfigPath) {
|
|
44
|
+
console.log("Using Uniform config from", uniformConfigPath);
|
|
45
|
+
config.module.rules.push({
|
|
46
|
+
test: /uniform\.server\.config\.js$/,
|
|
47
|
+
include: uniformConfigPath,
|
|
48
|
+
use: context.defaultLoaders.babel
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return config;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
withUniformConfig
|
|
58
|
+
});
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/config.ts
|
|
10
|
+
var { existsSync } = __require("fs");
|
|
11
|
+
var { join } = __require("path");
|
|
12
|
+
var getConfigPath = () => {
|
|
13
|
+
const configFilePath = join(process.cwd(), `uniform.server.config.js`);
|
|
14
|
+
if (!existsSync(configFilePath)) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
return configFilePath;
|
|
18
|
+
};
|
|
19
|
+
var withUniformConfig = (nextConfig) => ({
|
|
20
|
+
...nextConfig,
|
|
21
|
+
webpack: (config, context) => {
|
|
22
|
+
if (nextConfig.webpack) {
|
|
23
|
+
nextConfig.webpack(config, context);
|
|
24
|
+
}
|
|
25
|
+
if (context.isServer) {
|
|
26
|
+
const uniformConfigPath = getConfigPath();
|
|
27
|
+
if (uniformConfigPath) {
|
|
28
|
+
console.log("Using Uniform config from", uniformConfigPath);
|
|
29
|
+
config.module.rules.push({
|
|
30
|
+
test: /uniform\.server\.config\.js$/,
|
|
31
|
+
include: uniformConfigPath,
|
|
32
|
+
use: context.defaultLoaders.babel
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return config;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
withUniformConfig
|
|
41
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NextRequest } from 'next/server';
|
|
2
|
+
|
|
3
|
+
type CreatePreviewGETRouteHandlerOptions = {
|
|
4
|
+
playgroundPath?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const createPreviewGETRouteHandler: (options?: CreatePreviewGETRouteHandlerOptions) => (request: NextRequest) => Promise<Response>;
|
|
7
|
+
|
|
8
|
+
declare const createPreviewOPTIONSRouteHandler: () => () => Promise<Response>;
|
|
9
|
+
|
|
10
|
+
declare const createPreviewPOSTRouteHandler: () => (request: Request) => Promise<Response>;
|
|
11
|
+
|
|
12
|
+
export { CreatePreviewGETRouteHandlerOptions, createPreviewGETRouteHandler, createPreviewOPTIONSRouteHandler, createPreviewPOSTRouteHandler };
|
package/dist/handler.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { NextRequest } from 'next/server';
|
|
2
|
+
|
|
3
|
+
type CreatePreviewGETRouteHandlerOptions = {
|
|
4
|
+
playgroundPath?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const createPreviewGETRouteHandler: (options?: CreatePreviewGETRouteHandlerOptions) => (request: NextRequest) => Promise<Response>;
|
|
7
|
+
|
|
8
|
+
declare const createPreviewOPTIONSRouteHandler: () => () => Promise<Response>;
|
|
9
|
+
|
|
10
|
+
declare const createPreviewPOSTRouteHandler: () => (request: Request) => Promise<Response>;
|
|
11
|
+
|
|
12
|
+
export { CreatePreviewGETRouteHandlerOptions, createPreviewGETRouteHandler, createPreviewOPTIONSRouteHandler, createPreviewPOSTRouteHandler };
|