Unverified Commit 925bb3b0 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Upgrade React (#48589)

Second try for #48561

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------
Co-authored-by: 's avatarSophie Alpert <git@sophiebits.com>
Co-authored-by: 's avatarShu Ding <g@shud.in>
parent 864f0653
......@@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "13.3.1-canary.16"
"version": "13.3.1-canary.15"
}
......@@ -196,11 +196,11 @@
"random-seed": "0.3.0",
"react": "18.2.0",
"react-17": "npm:react@17.0.2",
"react-builtin": "npm:react@18.3.0-next-85de6fde5-20230328",
"react-builtin": "npm:react@18.3.0-next-1f248bdd7-20230419",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
"react-dom-builtin": "npm:react-dom@18.3.0-next-85de6fde5-20230328",
"react-server-dom-webpack": "18.3.0-next-85de6fde5-20230328",
"react-dom-builtin": "npm:react-dom@18.3.0-next-1f248bdd7-20230419",
"react-server-dom-webpack": "18.3.0-next-1f248bdd7-20230419",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
......
{
"name": "create-next-app",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"keywords": [
"react",
"next",
......
{
"name": "eslint-config-next",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
......@@ -9,7 +9,7 @@
"directory": "packages/eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "13.3.1-canary.16",
"@next/eslint-plugin-next": "13.3.1-canary.15",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.42.0",
"eslint-import-resolver-node": "^0.3.6",
......
{
"name": "@next/eslint-plugin-next",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"description": "ESLint plugin for NextJS.",
"main": "dist/index.js",
"license": "MIT",
......
{
"name": "@next/font",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
......
{
"name": "@next/bundle-analyzer",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
......
{
"name": "@next/codemod",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"license": "MIT",
"repository": {
"type": "git",
......
{
"name": "@next/env",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"keywords": [
"react",
"next",
......
{
"name": "@next/mdx",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"main": "index.js",
"license": "MIT",
"repository": {
......
{
"name": "@next/plugin-storybook",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
......
{
"name": "@next/polyfill-module",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
......
{
"name": "@next/polyfill-nomodule",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
......
{
"name": "@next/swc",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"private": true,
"scripts": {
"clean": "rm -rf ./native/*",
......
{
"name": "next",
"version": "13.3.1-canary.16",
"version": "13.3.1-canary.15",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
......@@ -81,7 +81,7 @@
]
},
"dependencies": {
"@next/env": "13.3.1-canary.16",
"@next/env": "13.3.1-canary.15",
"@swc/helpers": "0.5.0",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
......@@ -140,11 +140,11 @@
"@jest/types": "29.5.0",
"@napi-rs/cli": "2.14.7",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "13.3.1-canary.16",
"@next/polyfill-nomodule": "13.3.1-canary.16",
"@next/react-dev-overlay": "13.3.1-canary.16",
"@next/react-refresh-utils": "13.3.1-canary.16",
"@next/swc": "13.3.1-canary.16",
"@next/polyfill-module": "13.3.1-canary.15",
"@next/polyfill-nomodule": "13.3.1-canary.15",
"@next/react-dev-overlay": "13.3.1-canary.15",
"@next/react-refresh-utils": "13.3.1-canary.15",
"@next/swc": "13.3.1-canary.15",
"@opentelemetry/api": "1.4.1",
"@segment/ajv-human-errors": "2.1.2",
"@taskr/clear": "1.1.0",
......
......@@ -135,6 +135,7 @@ export class ClientReferenceManifestPlugin {
cssFiles: {},
clientModules: {},
}
const dev = this.dev
const clientRequestsSet = new Set()
......@@ -255,18 +256,13 @@ export class ClientReferenceManifestPlugin {
return null
}
// Get the actual chunk file names from the chunk file list.
// It's possible that the chunk is generated via `import()`, in
// that case the chunk file name will be '[name].[contenthash]'
// instead of '[name]-[chunkhash]'.
return [...requiredChunk.files].map((file) => {
// It's possible that a chunk also emits CSS files, that will
// be handled separatedly.
if (!file.endsWith('.js')) return null
return requiredChunk.id + ':' + file
})
return (
requiredChunk.id +
':' +
(requiredChunk.name || requiredChunk.id) +
(dev ? '' : '-' + requiredChunk.hash)
)
})
.flat()
.filter(nonNullable)
}
const requiredChunks = getAppPathRequiredChunks()
......
......@@ -69,8 +69,8 @@ self.__next_require__ =
// eslint-disable-next-line no-undef
;(self as any).__next_chunk_load__ = (chunk: string) => {
if (!chunk) return Promise.resolve()
const [chunkId, chunkFilePath] = chunk.split(':')
chunkFilenameMap[chunkId] = chunkFilePath
const [chunkId, chunkFileName] = chunk.split(':')
chunkFilenameMap[chunkId] = `static/chunks/${chunkFileName}.js`
// @ts-ignore
// eslint-disable-next-line no-undef
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
var ReactVersion = '18.3.0-next-85de6fde5-20230328';
var ReactVersion = '18.3.0-next-1f248bdd7-20230419';
var Internals = {
usingClientEntryPoint: false,
......
......@@ -8,4 +8,4 @@
* LICENSE file in the root directory of this source tree.
*/
'use strict';var b={usingClientEntryPoint:!1,Events:null,Dispatcher:{current:null}};function d(a){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)e+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+a+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=b;
exports.createPortal=function(){throw Error(d(448));};exports.flushSync=function(){throw Error(d(449));};exports.preconnect=function(){var a=b.Dispatcher.current;a&&a.preconnect.apply(this,arguments)};exports.prefetchDNS=function(){var a=b.Dispatcher.current;a&&a.prefetchDNS.apply(this,arguments)};exports.preinit=function(){var a=b.Dispatcher.current;a&&a.preinit.apply(this,arguments)};exports.preload=function(){var a=b.Dispatcher.current;a&&a.preload.apply(this,arguments)};exports.version="18.3.0-next-85de6fde5-20230328";
exports.createPortal=function(){throw Error(d(448));};exports.flushSync=function(){throw Error(d(449));};exports.preconnect=function(){var a=b.Dispatcher.current;a&&a.preconnect.apply(this,arguments)};exports.prefetchDNS=function(){var a=b.Dispatcher.current;a&&a.prefetchDNS.apply(this,arguments)};exports.preinit=function(){var a=b.Dispatcher.current;a&&a.preinit.apply(this,arguments)};exports.preload=function(){var a=b.Dispatcher.current;a&&a.preload.apply(this,arguments)};exports.version="18.3.0-next-1f248bdd7-20230419";
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "react-dom",
"version": "18.3.0-next-85de6fde5-20230328",
"version": "18.3.0-next-1f248bdd7-20230419",
"description": "React package for working with the DOM.",
"main": "index.js",
"repository": {
......@@ -18,10 +18,10 @@
"homepage": "https://reactjs.org/",
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "0.24.0-next-85de6fde5-20230328"
"scheduler": "0.24.0-next-1f248bdd7-20230419"
},
"peerDependencies": {
"react": "18.3.0-next-85de6fde5-20230328"
"react": "18.3.0-next-1f248bdd7-20230419"
},
"files": [
"LICENSE",
......
......@@ -36,18 +36,30 @@ function parseModel(response, json) {
// eslint-disable-next-line no-unused-vars
function resolveClientReference(bundlerConfig, metadata) {
if (bundlerConfig) {
var resolvedModuleData = bundlerConfig[metadata.id][metadata.name];
if (metadata.async) {
return {
id: resolvedModuleData.id,
chunks: resolvedModuleData.chunks,
name: resolvedModuleData.name,
async: true
};
var moduleExports = bundlerConfig[metadata.id];
var resolvedModuleData = moduleExports[metadata.name];
var name;
if (resolvedModuleData) {
// The potentially aliased name.
name = resolvedModuleData.name;
} else {
return resolvedModuleData;
// If we don't have this specific name, we might have the full module.
resolvedModuleData = moduleExports['*'];
if (!resolvedModuleData) {
throw new Error('Could not find the module "' + metadata.id + '" in the React SSR Manifest. ' + 'This is probably a bug in the React Server Components bundler.');
}
name = metadata.name;
}
return {
id: resolvedModuleData.id,
chunks: resolvedModuleData.chunks,
name: name,
async: !!metadata.async
};
}
return metadata;
......@@ -151,6 +163,19 @@ function requireModule(metadata) {
}
var knownServerReferences = new WeakMap();
function createServerReference(id, callServer) {
var proxy = function () {
// $FlowFixMe[method-unbinding]
var args = Array.prototype.slice.call(arguments);
return callServer(id, args);
};
knownServerReferences.set(proxy, {
id: id,
bound: null
});
return proxy;
}
// ATTENTION
// When adding new symbols to this file,
......@@ -662,6 +687,28 @@ function parseModelString(response, parentObject, key, value) {
}
}
case 'I':
{
// $Infinity
return Infinity;
}
case '-':
{
// $-0 or $-Infinity
if (value === '$-0') {
return -0;
} else {
return -Infinity;
}
}
case 'N':
{
// $NaN
return NaN;
}
case 'u':
{
// matches "$undefined"
......@@ -669,6 +716,18 @@ function parseModelString(response, parentObject, key, value) {
return undefined;
}
case 'D':
{
// Date
return new Date(Date.parse(value.substring(2)));
}
case 'n':
{
// BigInt
return BigInt(value.substring(2));
}
default:
{
// We assume that anything else is a reference ID.
......@@ -1281,10 +1340,43 @@ function serializeSymbolReference(name) {
return '$S' + name;
}
function serializeFormDataReference(id) {
// Why K? F is "Function". D is "Date". What else?
return '$K' + id.toString(16);
}
function serializeNumber(number) {
if (Number.isFinite(number)) {
if (number === 0 && 1 / number === -Infinity) {
return '$-0';
} else {
return number;
}
} else {
if (number === Infinity) {
return '$Infinity';
} else if (number === -Infinity) {
return '$-Infinity';
} else {
return '$NaN';
}
}
}
function serializeUndefined() {
return '$undefined';
}
function serializeDateFromDateJSON(dateJSON) {
// JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString.
// We need only tack on a $D prefix.
return '$D' + dateJSON;
}
function serializeBigInt(n) {
return '$n' + n.toString(10);
}
function escapeStringValue(value) {
if (value[0] === '$') {
// We need to escape $ prefixed strings since we use those to encode
......@@ -1295,19 +1387,19 @@ function escapeStringValue(value) {
}
}
function processReply(root, resolve, reject) {
function processReply(root, formFieldPrefix, resolve, reject) {
var nextPartId = 1;
var pendingParts = 0;
var formData = null;
function resolveToJSON(key, value) {
var parent = this;
var parent = this; // Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
{
// $FlowFixMe[incompatible-use]
var originalValue = this[key];
var originalValue = parent[key];
if (typeof originalValue === 'object' && originalValue !== value) {
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
if (objectName(originalValue) !== 'Object') {
error('Only plain objects can be passed to Server Functions from the Client. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
} else {
......@@ -1338,7 +1430,7 @@ function processReply(root, resolve, reject) {
var data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
data.append('' + promiseId, partJSON);
data.append(formFieldPrefix + promiseId, partJSON);
pendingParts--;
if (pendingParts === 0) {
......@@ -1350,6 +1442,26 @@ function processReply(root, resolve, reject) {
reject(reason);
});
return serializePromiseID(promiseId);
} // TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
if (value instanceof FormData) {
if (formData === null) {
// Upgrade to use FormData to allow us to use rich objects as its values.
formData = new FormData();
}
var data = formData;
var refId = nextPartId++; // Copy all the form fields with a prefix for this reference.
// These must come first in the form order because we assume that all the
// fields are available before this is referenced.
var prefix = formFieldPrefix + refId + '_'; // $FlowFixMe[prop-missing]: FormData has forEach.
value.forEach(function (originalValue, originalKey) {
data.append(prefix + originalKey, originalValue);
});
return serializeFormDataReference(refId);
}
if (!isArray(value)) {
......@@ -1388,13 +1500,28 @@ function processReply(root, resolve, reject) {
}
if (typeof value === 'string') {
// TODO: Maybe too clever. If we support URL there's no similar trick.
if (value[value.length - 1] === 'Z') {
// Possibly a Date, whose toJSON automatically calls toISOString
// $FlowFixMe[incompatible-use]
var _originalValue = parent[key]; // $FlowFixMe[method-unbinding]
if (_originalValue instanceof Date) {
return serializeDateFromDateJSON(value);
}
}
return escapeStringValue(value);
}
if (typeof value === 'boolean' || typeof value === 'number') {
if (typeof value === 'boolean') {
return value;
}
if (typeof value === 'number') {
return serializeNumber(value);
}
if (typeof value === 'undefined') {
return serializeUndefined();
}
......@@ -1411,10 +1538,11 @@ function processReply(root, resolve, reject) {
} // The reference to this function came from the same client so we can pass it back.
var refId = nextPartId++; // eslint-disable-next-line react-internal/safe-string-coercion
var _refId = nextPartId++; // eslint-disable-next-line react-internal/safe-string-coercion
formData.set('' + refId, metaDataJSON);
return serializeServerReferenceID(refId);
formData.set(formFieldPrefix + _refId, metaDataJSON);
return serializeServerReferenceID(_refId);
}
throw new Error('Client Functions cannot be passed directly to Server Functions. ' + 'Only Functions passed from the Server can be passed back again.');
......@@ -1433,7 +1561,7 @@ function processReply(root, resolve, reject) {
}
if (typeof value === 'bigint') {
throw new Error("BigInt (" + value + ") is not yet supported as an argument to a Server Function.");
return serializeBigInt(value);
}
throw new Error("Type " + typeof value + " is not supported as an argument to a Server Function.");
......@@ -1447,7 +1575,7 @@ function processReply(root, resolve, reject) {
resolve(json);
} else {
// Otherwise, we use FormData to let us stream in the result.
formData.set('0', json);
formData.set(formFieldPrefix + '0', json);
if (pendingParts === 0) {
// $FlowFixMe[incompatible-call] this has already been refined.
......@@ -1531,13 +1659,14 @@ function encodeReply(value)
/* We don't use URLSearchParams yet but maybe */
{
return new Promise(function (resolve, reject) {
processReply(value, resolve, reject);
processReply(value, '', resolve, reject);
});
}
exports.createFromFetch = createFromFetch;
exports.createFromReadableStream = createFromReadableStream;
exports.createFromXHR = createFromXHR;
exports.createServerReference = createServerReference;
exports.encodeReply = encodeReply;
})();
}
......@@ -36,18 +36,30 @@ function parseModel(response, json) {
// eslint-disable-next-line no-unused-vars
function resolveClientReference(bundlerConfig, metadata) {
if (bundlerConfig) {
var resolvedModuleData = bundlerConfig[metadata.id][metadata.name];
if (metadata.async) {
return {
id: resolvedModuleData.id,
chunks: resolvedModuleData.chunks,
name: resolvedModuleData.name,
async: true
};
var moduleExports = bundlerConfig[metadata.id];
var resolvedModuleData = moduleExports[metadata.name];
var name;
if (resolvedModuleData) {
// The potentially aliased name.
name = resolvedModuleData.name;
} else {
return resolvedModuleData;
// If we don't have this specific name, we might have the full module.
resolvedModuleData = moduleExports['*'];
if (!resolvedModuleData) {
throw new Error('Could not find the module "' + metadata.id + '" in the React SSR Manifest. ' + 'This is probably a bug in the React Server Components bundler.');
}
name = metadata.name;
}
return {
id: resolvedModuleData.id,
chunks: resolvedModuleData.chunks,
name: name,
async: !!metadata.async
};
}
return metadata;
......@@ -642,6 +654,28 @@ function parseModelString(response, parentObject, key, value) {
}
}
case 'I':
{
// $Infinity
return Infinity;
}
case '-':
{
// $-0 or $-Infinity
if (value === '$-0') {
return -0;
} else {
return -Infinity;
}
}
case 'N':
{
// $NaN
return NaN;
}
case 'u':
{
// matches "$undefined"
......@@ -649,6 +683,18 @@ function parseModelString(response, parentObject, key, value) {
return undefined;
}
case 'D':
{
// Date
return new Date(Date.parse(value.substring(2)));
}
case 'n':
{
// BigInt
return BigInt(value.substring(2));
}
default:
{
// We assume that anything else is a reference ID.
......@@ -877,6 +923,10 @@ function noServerCall() {
throw new Error('Server Functions cannot be called during initial render. ' + 'This would create a fetch waterfall. Try to use a Server Component ' + 'to pass data to Client Components instead.');
}
function createServerReference(id, callServer) {
return noServerCall;
}
function createResponseFromOptions(options) {
return createResponse(options && options.moduleMap ? options.moduleMap : null, noServerCall);
}
......@@ -923,5 +973,6 @@ function createFromFetch(promiseForResponse, options) {
exports.createFromFetch = createFromFetch;
exports.createFromReadableStream = createFromReadableStream;
exports.createServerReference = createServerReference;
})();
}
......@@ -7,7 +7,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var p=require("react"),q={stream:!0};function r(a,b){return a?(a=a[b.id][b.name],b.async?{id:a.id,chunks:a.chunks,name:a.name,async:!0}:a):b}var t=new Map,u=new Map;function v(){}
'use strict';var p=require("react"),q={stream:!0};function r(a,b){if(a){var c=a[b.id];if(a=c[b.name])c=a.name;else{a=c["*"];if(!a)throw Error('Could not find the module "'+b.id+'" in the React SSR Manifest. This is probably a bug in the React Server Components bundler.');c=b.name}return{id:a.id,chunks:a.chunks,name:c,async:!!b.async}}return b}var t=new Map,u=new Map;function v(){}
function w(a){for(var b=a.chunks,c=[],d=0;d<b.length;d++){var f=b[d],e=t.get(f);if(void 0===e){e=globalThis.__next_chunk_load__(f);c.push(e);var l=t.set.bind(t,f,null);e.then(l,v);t.set(f,e)}else null!==e&&c.push(e)}if(a.async){if(b=u.get(a.id))return"fulfilled"===b.status?null:b;var m=Promise.all(c).then(function(){return globalThis.__next_require__(a.id)});m.then(function(g){m.status="fulfilled";m.value=g},function(g){m.status="rejected";m.reason=g});u.set(a.id,m);return m}return 0<c.length?Promise.all(c):null}
var x=new WeakMap,y=Symbol.for("react.element"),A=Symbol.for("react.lazy"),B=Symbol.for("react.default_value"),C=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function D(a,b,c,d){this.status=a;this.value=b;this.reason=c;this._response=d}D.prototype=Object.create(Promise.prototype);
D.prototype.then=function(a,b){switch(this.status){case "resolved_model":E(this);break;case "resolved_module":F(this)}switch(this.status){case "fulfilled":a(this.value);break;case "pending":case "blocked":a&&(null===this.value&&(this.value=[]),this.value.push(a));b&&(null===this.reason&&(this.reason=[]),this.reason.push(b));break;default:b(this.reason)}};
......@@ -18,9 +18,10 @@ function F(a){try{var b=a.value;if(b.async){var c=u.get(b.id);if("fulfilled"===c
function P(a,b,c){if(M){var d=M;d.deps++}else d=M={deps:1,value:null};return function(f){b[c]=f;d.deps--;0===d.deps&&"blocked"===a.status&&(f=a.value,a.status="fulfilled",a.value=d.value,null!==f&&H(f,d.value))}}function Q(a){return function(b){return J(a,b)}}
function R(a,b){function c(){var f=Array.prototype.slice.call(arguments),e=b.bound;return e?"fulfilled"===e.status?d(b.id,e.value.concat(f)):Promise.resolve(e).then(function(l){return d(b.id,l.concat(f))}):d(b.id,f)}var d=a._callServer;x.set(c,b);return c}
function S(a,b,c,d){if("$"===d[0]){if("$"===d)return y;switch(d[1]){case "$":return d.substring(1);case "L":return b=parseInt(d.substring(2),16),a=O(a,b),{$$typeof:A,_payload:a,_init:G};case "@":return b=parseInt(d.substring(2),16),O(a,b);case "S":return Symbol.for(d.substring(2));case "P":return a=d.substring(2),C[a]||(C[a]=p.createServerContext(a,B)),C[a].Provider;case "F":b=parseInt(d.substring(2),16);b=O(a,b);switch(b.status){case "resolved_model":E(b)}switch(b.status){case "fulfilled":return R(a,
b.value);default:throw b.reason;}case "u":return;default:d=parseInt(d.substring(1),16);a=O(a,d);switch(a.status){case "resolved_model":E(a);break;case "resolved_module":F(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":return d=L,a.then(P(d,b,c),Q(d)),null;default:throw a.reason;}}}return d}function T(){throw Error('Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.');}
function U(a,b,c){var d=a._chunks,f=d.get(b);c=JSON.parse(c,a._fromJSON);var e=r(a._bundlerConfig,c);if(c=w(e)){if(f){var l=f;l.status="blocked"}else l=new D("blocked",null,null,a),d.set(b,l);c.then(function(){return K(l,e)},function(m){return J(l,m)})}else f?K(f,e):d.set(b,new D("resolved_module",e,null,a))}function V(a){return function(b,c){return"string"===typeof c?S(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===y?{$$typeof:y,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}
function W(a,b){var c=new TextDecoder,d=new Map;a={_bundlerConfig:a,_callServer:void 0!==b?b:T,_chunks:d,_partialRow:"",_stringDecoder:c};a._fromJSON=V(a);return a}function X(){throw Error("Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.");}
b.value);default:throw b.reason;}case "I":return Infinity;case "-":return"$-0"===d?-0:-Infinity;case "N":return NaN;case "u":return;case "D":return new Date(Date.parse(d.substring(2)));case "n":return BigInt(d.substring(2));default:d=parseInt(d.substring(1),16);a=O(a,d);switch(a.status){case "resolved_model":E(a);break;case "resolved_module":F(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":return d=L,a.then(P(d,b,c),Q(d)),null;default:throw a.reason;}}}return d}
function T(){throw Error('Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.');}function U(a,b,c){var d=a._chunks,f=d.get(b);c=JSON.parse(c,a._fromJSON);var e=r(a._bundlerConfig,c);if(c=w(e)){if(f){var l=f;l.status="blocked"}else l=new D("blocked",null,null,a),d.set(b,l);c.then(function(){return K(l,e)},function(m){return J(l,m)})}else f?K(f,e):d.set(b,new D("resolved_module",e,null,a))}
function V(a){return function(b,c){return"string"===typeof c?S(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===y?{$$typeof:y,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}function W(a,b){var c=new TextDecoder,d=new Map;a={_bundlerConfig:a,_callServer:void 0!==b?b:T,_chunks:d,_partialRow:"",_stringDecoder:c};a._fromJSON=V(a);return a}
function X(){throw Error("Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.");}
function Y(a,b){function c(e){var l=e.value;if(e.done)N(a,Error("Connection closed."));else{e=l;l=a._stringDecoder;for(var m=e.indexOf(10);-1<m;){var g=a._partialRow;var n=e.subarray(0,m);n=l.decode(n);var h=g+n;g=a;if(""!==h){var k=h.indexOf(":",0);n=parseInt(h.substring(0,k),16);switch(h[k+1]){case "I":U(g,n,h.substring(k+2));break;case "E":k=JSON.parse(h.substring(k+2)).digest;h=Error("An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.");
h.stack="Error: "+h.message;h.digest=k;k=g._chunks;var z=k.get(n);z?J(z,h):k.set(n,new D("rejected",null,h,g));break;default:h=h.substring(k+1),k=g._chunks,(z=k.get(n))?(g=z,n=h,"pending"===g.status&&(h=g.value,k=g.reason,g.status="resolved_model",g.value=n,null!==h&&(E(g),I(g,h,k)))):k.set(n,new D("resolved_model",h,null,g))}}a._partialRow="";e=e.subarray(m+1);m=e.indexOf(10)}a._partialRow+=l.decode(e,q);return f.read().then(c).catch(d)}}function d(e){N(a,e)}var f=b.getReader();f.read().then(c).catch(d)}
exports.createFromFetch=function(a,b){var c=W(b&&b.moduleMap?b.moduleMap:null,X);a.then(function(d){Y(c,d.body)},function(d){N(c,d)});return O(c,0)};exports.createFromReadableStream=function(a,b){b=W(b&&b.moduleMap?b.moduleMap:null,X);Y(b,a);return O(b,0)};
exports.createFromFetch=function(a,b){var c=W(b&&b.moduleMap?b.moduleMap:null,X);a.then(function(d){Y(c,d.body)},function(d){N(c,d)});return O(c,0)};exports.createFromReadableStream=function(a,b){b=W(b&&b.moduleMap?b.moduleMap:null,X);Y(b,a);return O(b,0)};exports.createServerReference=function(){return X};
......@@ -37,18 +37,30 @@ function parseModel(response, json) {
// eslint-disable-next-line no-unused-vars
function resolveClientReference(bundlerConfig, metadata) {
if (bundlerConfig) {
var resolvedModuleData = bundlerConfig[metadata.id][metadata.name];
if (metadata.async) {
return {
id: resolvedModuleData.id,
chunks: resolvedModuleData.chunks,
name: resolvedModuleData.name,
async: true
};
var moduleExports = bundlerConfig[metadata.id];
var resolvedModuleData = moduleExports[metadata.name];
var name;
if (resolvedModuleData) {
// The potentially aliased name.
name = resolvedModuleData.name;
} else {
return resolvedModuleData;
// If we don't have this specific name, we might have the full module.
resolvedModuleData = moduleExports['*'];
if (!resolvedModuleData) {
throw new Error('Could not find the module "' + metadata.id + '" in the React SSR Manifest. ' + 'This is probably a bug in the React Server Components bundler.');
}
name = metadata.name;
}
return {
id: resolvedModuleData.id,
chunks: resolvedModuleData.chunks,
name: name,
async: !!metadata.async
};
}
return metadata;
......@@ -643,6 +655,28 @@ function parseModelString(response, parentObject, key, value) {
}
}
case 'I':
{
// $Infinity
return Infinity;
}
case '-':
{
// $-0 or $-Infinity
if (value === '$-0') {
return -0;
} else {
return -Infinity;
}
}
case 'N':
{
// $NaN
return NaN;
}
case 'u':
{
// matches "$undefined"
......@@ -650,6 +684,18 @@ function parseModelString(response, parentObject, key, value) {
return undefined;
}
case 'D':
{
// Date
return new Date(Date.parse(value.substring(2)));
}
case 'n':
{
// BigInt
return BigInt(value.substring(2));
}
default:
{
// We assume that anything else is a reference ID.
......@@ -892,6 +938,10 @@ function noServerCall() {
throw new Error('Server Functions cannot be called during initial render. ' + 'This would create a fetch waterfall. Try to use a Server Component ' + 'to pass data to Client Components instead.');
}
function createServerReference(id, callServer) {
return noServerCall;
}
function createFromNodeStream(stream, moduleMap) {
var response = createResponse(moduleMap, noServerCall);
stream.on('data', function (chunk) {
......@@ -911,5 +961,6 @@ function createFromNodeStream(stream, moduleMap) {
}
exports.createFromNodeStream = createFromNodeStream;
exports.createServerReference = createServerReference;
})();
}
......@@ -36,8 +36,28 @@ function parseModel(response, json) {
// eslint-disable-next-line no-unused-vars
function resolveClientReference(bundlerConfig, metadata) {
var resolvedModuleData = bundlerConfig[metadata.id][metadata.name];
return resolvedModuleData;
var moduleExports = bundlerConfig[metadata.id];
var resolvedModuleData = moduleExports[metadata.name];
var name;
if (resolvedModuleData) {
// The potentially aliased name.
name = resolvedModuleData.name;
} else {
// If we don't have this specific name, we might have the full module.
resolvedModuleData = moduleExports['*'];
if (!resolvedModuleData) {
throw new Error('Could not find the module "' + metadata.id + '" in the React SSR Manifest. ' + 'This is probably a bug in the React Server Components bundler.');
}
name = metadata.name;
}
return {
specifier: resolvedModuleData.specifier,
name: name
};
}
var asyncModuleCache = new Map();
function preloadModule(metadata) {
......@@ -584,6 +604,28 @@ function parseModelString(response, parentObject, key, value) {
}
}
case 'I':
{
// $Infinity
return Infinity;
}
case '-':
{
// $-0 or $-Infinity
if (value === '$-0') {
return -0;
} else {
return -Infinity;
}
}
case 'N':
{
// $NaN
return NaN;
}
case 'u':
{
// matches "$undefined"
......@@ -591,6 +633,18 @@ function parseModelString(response, parentObject, key, value) {
return undefined;
}
case 'D':
{
// Date
return new Date(Date.parse(value.substring(2)));
}
case 'n':
{
// BigInt
return BigInt(value.substring(2));
}
default:
{
// We assume that anything else is a reference ID.
......@@ -833,6 +887,10 @@ function noServerCall() {
throw new Error('Server Functions cannot be called during initial render. ' + 'This would create a fetch waterfall. Try to use a Server Component ' + 'to pass data to Client Components instead.');
}
function createServerReference(id, callServer) {
return noServerCall;
}
function createFromNodeStream(stream, moduleMap) {
var response = createResponse(moduleMap, noServerCall);
stream.on('data', function (chunk) {
......@@ -852,5 +910,6 @@ function createFromNodeStream(stream, moduleMap) {
}
exports.createFromNodeStream = createFromNodeStream;
exports.createServerReference = createServerReference;
})();
}
......@@ -10,7 +10,7 @@
'use strict';
'use strict';const n=require("acorn"),p=require("url"),r=require("module");
'use strict';const n=require("acorn-loose"),p=require("url"),r=require("module");
module.exports=function(){const h=Symbol.for("react.client.reference"),k=Symbol.for("react.server.reference"),t=Promise.prototype,u=Function.prototype.bind;Function.prototype.bind=function(a){const c=u.apply(this,arguments);if(this.$$typeof===k){const b=Array.prototype.slice.call(arguments,1);c.$$typeof=k;c.$$id=this.$$id;c.$$bound=this.$$bound?this.$$bound.concat(b):b}return c};const v={get:function(a,c){switch(c){case "$$typeof":return a.$$typeof;case "$$id":return a.$$id;case "$$async":return a.$$async;
case "name":return a.name;case "displayName":return;case "defaultProps":return;case "toJSON":return;case Symbol.toPrimitive:return Object.prototype[Symbol.toPrimitive];case "Provider":throw Error("Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider.");}throw Error("Cannot access "+(String(a.name)+"."+String(c))+" on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.");
},set:function(){throw Error("Cannot assign to a client module from a server module.");}},q={get:function(a,c){switch(c){case "$$typeof":return a.$$typeof;case "$$id":return a.$$id;case "$$async":return a.$$async;case "name":return a.name;case "defaultProps":return;case "toJSON":return;case Symbol.toPrimitive:return Object.prototype[Symbol.toPrimitive];case "__esModule":const d=a.$$id;a.default=Object.defineProperties(function(){throw Error("Attempted to call the default export of "+d+" from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");
......
......@@ -10,11 +10,12 @@
'use strict';
'use strict';var q=require("path"),t=require("url"),x=require("neo-async"),y=require("webpack/lib/dependencies/ModuleDependency"),z=require("webpack/lib/dependencies/NullDependency"),A=require("webpack/lib/Template"),B=require("webpack");const C=Array.isArray;class D extends y{constructor(b){super(b)}get type(){return"client-reference"}}const E=require.resolve("../client.browser.js");
class F{constructor(b){this.ssrManifestFilename=this.clientManifestFilename=this.chunkName=this.clientReferences=void 0;if(!b||"boolean"!==typeof b.isServer)throw Error("React Server Plugin: You must specify the isServer option as a boolean.");if(b.isServer)throw Error("TODO: Implement the server compiler.");b.clientReferences?"string"!==typeof b.clientReferences&&C(b.clientReferences)?this.clientReferences=b.clientReferences:this.clientReferences=[b.clientReferences]:this.clientReferences=[{directory:".",
recursive:!0,include:/\.(js|ts|jsx|tsx)$/}];"string"===typeof b.chunkName?(this.chunkName=b.chunkName,/\[(index|request)\]/.test(this.chunkName)||(this.chunkName+="[index]")):this.chunkName="client[index]";this.clientManifestFilename=b.clientManifestFilename||"react-client-manifest.json";this.ssrManifestFilename=b.ssrManifestFilename||"react-ssr-manifest.json"}apply(b){const n=this;let p,u=!1;b.hooks.beforeCompile.tapAsync("React Server Plugin",(c,a)=>{c=c.contextModuleFactory;const e=b.resolverFactory.get("context",
{});n.resolveAllClientFiles(b.context,e,b.inputFileSystem,c,function(d,h){d?a(d):(p=h,a())})});b.hooks.thisCompilation.tap("React Server Plugin",(c,a)=>{a=a.normalModuleFactory;c.dependencyFactories.set(D,a);c.dependencyTemplates.set(D,new z.Template);c=e=>{e.hooks.program.tap("React Server Plugin",()=>{const d=e.state.module;if(d.resource===E&&(u=!0,p))for(let k=0;k<p.length;k++){const l=p[k];var h=n.chunkName.replace(/\[index\]/g,""+k).replace(/\[request\]/g,A.toPath(l.userRequest));h=new B.AsyncDependenciesBlock({name:h},
null,l.request);h.addDependency(l);d.addBlock(h)}})};a.hooks.parser.for("javascript/auto").tap("HarmonyModulesPlugin",c);a.hooks.parser.for("javascript/esm").tap("HarmonyModulesPlugin",c);a.hooks.parser.for("javascript/dynamic").tap("HarmonyModulesPlugin",c)});b.hooks.make.tap("React Server Plugin",c=>{c.hooks.processAssets.tap({name:"React Server Plugin",stage:B.Compilation.PROCESS_ASSETS_STAGE_REPORT},function(){if(!1===u)c.warnings.push(new B.WebpackError("Client runtime at react-server-dom-webpack/client was not found. React Server Components module map file "+
n.clientManifestFilename+" was not created."));else{var a={},e={};c.chunkGroups.forEach(function(h){function k(f,g){if(/\.(js|ts)x?$/.test(g.resource)){var r=c.moduleGraph.getExportsInfo(g).getProvidedExports(),m=t.pathToFileURL(g.resource).href;if(void 0!==m){const v={};a[m]={id:f,chunks:l,name:"*"};v["*"]={specifier:m,name:"*"};a[m+"#"]={id:f,chunks:l,name:""};v[""]={specifier:m,name:""};Array.isArray(r)&&r.forEach(function(w){a[m+"#"+w]={id:f,chunks:l,name:w};v[w]={specifier:m,name:w}});e[f]=v}}}
const l=h.chunks.map(function(f){return f.id});h.chunks.forEach(function(f){f=c.chunkGraph.getChunkModulesIterable(f);Array.from(f).forEach(function(g){const r=c.chunkGraph.getModuleId(g);k(r,g);g.modules&&g.modules.forEach(m=>{k(r,m)})})})});var d=JSON.stringify(a,null,2);c.emitAsset(n.clientManifestFilename,new B.sources.RawSource(d,!1));d=JSON.stringify(e,null,2);c.emitAsset(n.ssrManifestFilename,new B.sources.RawSource(d,!1))}})})}resolveAllClientFiles(b,n,p,u,c){x.map(this.clientReferences,(a,
e)=>{"string"===typeof a?e(null,[new D(a)]):n.resolve({},b,a.directory,{},(d,h)=>{if(d)return e(d);u.resolveDependencies(p,{resource:h,resourceQuery:"",recursive:void 0===a.recursive?!0:a.recursive,regExp:a.include,include:void 0,exclude:a.exclude},(k,l)=>{if(k)return e(k);k=l.map(f=>{var g=q.join(h,f.userRequest);g=new D(g);g.userRequest=f.userRequest;return g});e(null,k)})})},(a,e)=>{if(a)return c(a);a=[];for(let d=0;d<e.length;d++)a.push.apply(a,e[d]);c(null,a)})}}module.exports=F;
'use strict';var r=require("path"),u=require("url"),x=require("neo-async"),A=require("acorn-loose"),B=require("webpack/lib/dependencies/ModuleDependency"),C=require("webpack/lib/dependencies/NullDependency"),D=require("webpack/lib/Template"),E=require("webpack");const F=Array.isArray;class G extends B{constructor(b){super(b)}get type(){return"client-reference"}}const H=require.resolve("../client.browser.js");
class I{constructor(b){this.ssrManifestFilename=this.clientManifestFilename=this.chunkName=this.clientReferences=void 0;if(!b||"boolean"!==typeof b.isServer)throw Error("React Server Plugin: You must specify the isServer option as a boolean.");if(b.isServer)throw Error("TODO: Implement the server compiler.");b.clientReferences?"string"!==typeof b.clientReferences&&F(b.clientReferences)?this.clientReferences=b.clientReferences:this.clientReferences=[b.clientReferences]:this.clientReferences=[{directory:".",
recursive:!0,include:/\.(js|ts|jsx|tsx)$/}];"string"===typeof b.chunkName?(this.chunkName=b.chunkName,/\[(index|request)\]/.test(this.chunkName)||(this.chunkName+="[index]")):this.chunkName="client[index]";this.clientManifestFilename=b.clientManifestFilename||"react-client-manifest.json";this.ssrManifestFilename=b.ssrManifestFilename||"react-ssr-manifest.json"}apply(b){const n=this;let p,t=!1;b.hooks.beforeCompile.tapAsync("React Server Plugin",(e,g)=>{e=e.contextModuleFactory;const l=b.resolverFactory.get("context",
{}),a=b.resolverFactory.get("normal");n.resolveAllClientFiles(b.context,l,a,b.inputFileSystem,e,function(c,d){c?g(c):(p=d,g())})});b.hooks.thisCompilation.tap("React Server Plugin",(e,g)=>{g=g.normalModuleFactory;e.dependencyFactories.set(G,g);e.dependencyTemplates.set(G,new C.Template);e=l=>{l.hooks.program.tap("React Server Plugin",()=>{const a=l.state.module;if(a.resource===H&&(t=!0,p))for(let d=0;d<p.length;d++){const m=p[d];var c=n.chunkName.replace(/\[index\]/g,""+d).replace(/\[request\]/g,
D.toPath(m.userRequest));c=new E.AsyncDependenciesBlock({name:c},null,m.request);c.addDependency(m);a.addBlock(c)}})};g.hooks.parser.for("javascript/auto").tap("HarmonyModulesPlugin",e);g.hooks.parser.for("javascript/esm").tap("HarmonyModulesPlugin",e);g.hooks.parser.for("javascript/dynamic").tap("HarmonyModulesPlugin",e)});b.hooks.make.tap("React Server Plugin",e=>{e.hooks.processAssets.tap({name:"React Server Plugin",stage:E.Compilation.PROCESS_ASSETS_STAGE_REPORT},function(){if(!1===t)e.warnings.push(new E.WebpackError("Client runtime at react-server-dom-webpack/client was not found. React Server Components module map file "+
n.clientManifestFilename+" was not created."));else{var g=new Set((p||[]).map(d=>d.request)),l={},a={};e.chunkGroups.forEach(function(d){function m(k,f){if(g.has(f.resource)&&(f=u.pathToFileURL(f.resource).href,void 0!==f)){const h={};l[f]={id:k,chunks:q,name:"*"};h["*"]={specifier:f,name:"*"};a[k]=h}}const q=d.chunks.map(function(k){return k.id});d.chunks.forEach(function(k){k=e.chunkGraph.getChunkModulesIterable(k);Array.from(k).forEach(function(f){const h=e.chunkGraph.getModuleId(f);m(h,f);f.modules&&
f.modules.forEach(v=>{m(h,v)})})})});var c=JSON.stringify(l,null,2);e.emitAsset(n.clientManifestFilename,new E.sources.RawSource(c,!1));c=JSON.stringify(a,null,2);e.emitAsset(n.ssrManifestFilename,new E.sources.RawSource(c,!1))}})})}resolveAllClientFiles(b,n,p,t,e,g){function l(a){if(-1===a.indexOf("use client"))return!1;let c;try{c=A.parse(a,{ecmaVersion:"2024",sourceType:"module"}).body}catch(d){return!1}for(a=0;a<c.length;a++){const d=c[a];if("ExpressionStatement"!==d.type||!d.directive)break;
if("use client"===d.directive)return!0}return!1}x.map(this.clientReferences,(a,c)=>{"string"===typeof a?c(null,[new G(a)]):n.resolve({},b,a.directory,{},(d,m)=>{if(d)return c(d);e.resolveDependencies(t,{resource:m,resourceQuery:"",recursive:void 0===a.recursive?!0:a.recursive,regExp:a.include,include:void 0,exclude:a.exclude},(q,k)=>{if(q)return c(q);q=k.map(f=>{var h=r.join(m,f.userRequest);h=new G(h);h.userRequest=f.userRequest;return h});x.filter(q,(f,h)=>{p.resolve({},b,f.request,{},(v,y)=>{if(v||
"string"!==typeof y)return h(null,!1);t.readFile(y,"utf-8",(w,z)=>{if(w||"string"!==typeof z)return h(null,!1);w=l(z);h(null,w)})})},c)})})},(a,c)=>{if(a)return g(a);a=[];for(let d=0;d<c.length;d++)a.push.apply(a,c[d]);g(null,a)})}}module.exports=I;
{
"name": "react-server-dom-webpack",
"description": "React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.",
"version": "18.3.0-next-85de6fde5-20230328",
"version": "18.3.0-next-1f248bdd7-20230419",
"keywords": [
"react"
],
......@@ -78,12 +78,12 @@
"node": ">=0.10.0"
},
"peerDependencies": {
"react": "18.3.0-next-85de6fde5-20230328",
"react-dom": "18.3.0-next-85de6fde5-20230328",
"react": "18.3.0-next-1f248bdd7-20230419",
"react-dom": "18.3.0-next-1f248bdd7-20230419",
"webpack": "^5.59.0"
},
"dependencies": {
"acorn": "^6.2.1",
"acorn-loose": "^8.3.0",
"neo-async": "^2.6.1",
"loose-envify": "^1.1.0"
},
......
......@@ -230,7 +230,6 @@ function getComponentNameFromType(type) {
return (context2.displayName || context2._globalName) + '.Provider';
}
// eslint-disable-next-line no-fallthrough
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment