fontdue-js 3.0.0-alpha2 → 3.0.0-alpha4

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.
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { BuyButton_props } from './index.js';
3
+ export type { BuyButtonPreloadedQuery } from './index.js';
4
+ export declare function loadBuyButtonQuery(): never;
3
5
  export default function BuyButton({ collectionId, collectionSlug, ...rest }: BuyButton_props & {
4
6
  collectionId?: string | null;
5
7
  collectionSlug?: string | null;
@@ -4,6 +4,11 @@ import loadSerializableQuery from '../../relay/loadSerializableQuery.js';
4
4
  import { BuyButtonPreloadedIDQueryRenderer, BuyButtonPreloadedSlugQueryRenderer } from './index.js';
5
5
  import BuyButtonIDQueryNode from '../../__generated__/BuyButtonIDQuery.graphql.js';
6
6
  import BuyButtonSlugQueryNode from '../../__generated__/BuyButtonSlugQuery.graphql.js';
7
+ // Stub for the RSC export condition. See FontdueProvider/index.server.tsx
8
+ // for the rationale.
9
+ export function loadBuyButtonQuery() {
10
+ throw new Error("loadBuyButtonQuery isn't needed in React Server Components — " + 'the <BuyButton> server entrypoint awaits its query automatically. ' + 'Drop the manual call.');
11
+ }
7
12
 
8
13
  // Next RSC variant: awaits the query on the server and hands the response to
9
14
  // the client `*PreloadedQueryRenderer`. Lets pages just write
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface BuyingOptionsProps {
3
+ onPrecartOpen: () => void;
4
+ }
5
+ declare const _default: import("react-redux").ConnectedComponent<({ onPrecartOpen }: BuyingOptionsProps) => React.JSX.Element, {
6
+ context?: React.Context<import("react-redux").ReactReduxContextValue<any, import("redux").UnknownAction> | null> | undefined;
7
+ store?: import("redux").Store | undefined;
8
+ }>;
9
+ export default _default;
@@ -1,3 +1,5 @@
1
1
  import React from 'react';
2
2
  import { CartButton_props } from './index.js';
3
+ export type { CartButtonPreloadedQuery } from './index.js';
4
+ export declare function loadCartButtonQuery(): never;
3
5
  export default function CartButton(props: CartButton_props): Promise<React.JSX.Element>;
@@ -3,6 +3,14 @@ import React from 'react';
3
3
  import loadSerializableQuery from '../../relay/loadSerializableQuery.js';
4
4
  import { CartButtonPreloadedQueryRenderer } from './index.js';
5
5
  import CartButtonQueryNode from '../../__generated__/CartButtonQuery.graphql.js';
6
+ // Stub for the RSC export condition. `<CartButton>`'s server entrypoint awaits
7
+ // its query for consumers, so RSC users should never call `loadCartButtonQuery`
8
+ // manually. Re-exporting a throwing stub makes the mistake obvious — without
9
+ // it, importing the loader from `'fontdue-js/CartButton'` in a server
10
+ // component would fail at build time with `Named export not found`.
11
+ export function loadCartButtonQuery() {
12
+ throw new Error("loadCartButtonQuery isn't needed in React Server Components — " + 'the <CartButton> server entrypoint awaits its query automatically. ' + 'Drop the manual call.');
13
+ }
6
14
 
7
15
  // Next RSC variant: awaits the query on the server and hands the response to
8
16
  // the client `CartButtonPreloadedQueryRenderer`. Lets pages just write
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { CharacterViewer_props } from './index.js';
3
+ export type { CharacterViewerPreloadedQuery } from './index.js';
4
+ export declare function loadCharacterViewerQuery(): never;
3
5
  export default function CharacterViewer({ collectionId, collectionSlug, ...rest }: CharacterViewer_props & {
4
6
  collectionId?: string | null;
5
7
  collectionSlug?: string | null;
@@ -4,6 +4,11 @@ import loadSerializableQuery from '../../relay/loadSerializableQuery.js';
4
4
  import { CharacterViewerPreloadedIDQueryRenderer, CharacterViewerPreloadedSlugQueryRenderer } from './index.js';
5
5
  import CharacterViewerIDQueryNode from '../../__generated__/CharacterViewerIDQuery.graphql.js';
6
6
  import CharacterViewerSlugQueryNode from '../../__generated__/CharacterViewerSlugQuery.graphql.js';
7
+ // Stub for the RSC export condition. See FontdueProvider/index.server.tsx
8
+ // for the rationale.
9
+ export function loadCharacterViewerQuery() {
10
+ throw new Error("loadCharacterViewerQuery isn't needed in React Server Components — " + 'the <CharacterViewer> server entrypoint awaits its query automatically. ' + 'Drop the manual call.');
11
+ }
7
12
 
8
13
  // Next RSC variant: awaits the query on the server and hands the response to
9
14
  // the client `*PreloadedQueryRenderer`. Lets pages just write
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface CookieNotificationProps {
3
+ siteTitle?: string;
4
+ }
5
+ interface CookieNotificationState {
6
+ dismissed: boolean;
7
+ }
8
+ export default class CookieNotification extends React.Component<CookieNotificationProps, CookieNotificationState> {
9
+ constructor(props: CookieNotificationProps);
10
+ dismiss: () => void;
11
+ render(): React.JSX.Element | null;
12
+ }
13
+ export {};
@@ -1,5 +1,6 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React from 'react';
3
+ // @ts-ignore — `store` package has no published types
3
4
  import store from 'store';
4
5
  import ComponentsContext from '../ComponentsContext.js';
5
6
  const DefaultCookieNotification = _ref => {
@@ -29,7 +30,7 @@ const DefaultCookieNotification = _ref => {
29
30
  onClick: onDismiss
30
31
  }, "Got it"))));
31
32
  };
32
- const GetComponent = _ref2 => {
33
+ function GetComponent(_ref2) {
33
34
  let {
34
35
  name,
35
36
  fallback,
@@ -39,7 +40,7 @@ const GetComponent = _ref2 => {
39
40
  const Component = components[name] || fallback;
40
41
  return children(Component);
41
42
  });
42
- };
43
+ }
43
44
  const CookieNotificationBase = _ref3 => {
44
45
  let {
45
46
  siteTitle,
@@ -48,8 +49,7 @@ const CookieNotificationBase = _ref3 => {
48
49
  } = _ref3;
49
50
  return /*#__PURE__*/React.createElement(GetComponent, {
50
51
  name: "CookieNotification",
51
- fallback: DefaultCookieNotification,
52
- open: open
52
+ fallback: DefaultCookieNotification
53
53
  }, Component => /*#__PURE__*/React.createElement(Component, {
54
54
  onDismiss: dismiss,
55
55
  siteTitle: siteTitle,
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ export { default as loadFontdueProviderQuery } from '../../loadFontdueProviderQuery.js';
2
3
  import type { FontdueContextProvider_props } from '../FontdueContextProvider/index.js';
3
4
  import { SerializablePreloadedQuery } from '../../relay/loadSerializableQuery.js';
4
5
  import { FontdueProviderQuery } from '../../__generated__/FontdueProviderQuery.graphql.js';
@@ -2,6 +2,7 @@
2
2
 
3
3
  import _FontdueProviderQuery from "../../__generated__/FontdueProviderQuery.graphql.js";
4
4
  import React, { Suspense, lazy } from 'react';
5
+ export { default as loadFontdueProviderQuery } from '../../loadFontdueProviderQuery.js';
5
6
  import { ErrorBoundary } from 'react-error-boundary';
6
7
  import { graphql, useLazyLoadQuery, usePreloadedQuery } from 'react-relay';
7
8
  import TestModeBanner from '../TestModeBanner/index.js';
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { FontdueProvider_props } from './index.js';
3
3
  export type { FontdueProvider_props } from './index.js';
4
+ export type { FontdueProviderPreloadedQuery } from '../../loadFontdueProviderQuery.js';
5
+ export declare function loadFontdueProviderQuery(): never;
4
6
  export default function FontdueProviderServer({ preloadedQuery, ...rest }: FontdueProvider_props): Promise<React.JSX.Element>;
@@ -1,7 +1,17 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React from 'react';
3
3
  import FontdueProvider from './index.js';
4
- import loadFontdueProviderQuery from '../../loadFontdueProviderQuery.js';
4
+ import loadFontdueProviderQueryImpl from '../../loadFontdueProviderQuery.js';
5
+ // Stub for the RSC export condition. The default `<FontdueProvider>` server
6
+ // entrypoint (this file) awaits the query for consumers, so RSC users should
7
+ // never call it manually. Re-exporting a throwing stub makes the mistake
8
+ // obvious — without it, importing `loadFontdueProviderQuery` from
9
+ // `'fontdue-js/FontdueProvider'` in a server component would fail at build
10
+ // time with the unhelpful `Named export 'loadFontdueProviderQuery' not found`.
11
+ export function loadFontdueProviderQuery() {
12
+ throw new Error("loadFontdueProviderQuery isn't needed in React Server Components — " + 'the <FontdueProvider> server entrypoint awaits its query automatically. ' + 'Drop the manual call.');
13
+ }
14
+
5
15
  // RSC entry. When no preloadedQuery is passed, fetch one server-side so the
6
16
  // Next.js App Router path stays "drop the provider in your layout, done."
7
17
  export default async function FontdueProviderServer(_ref) {
@@ -9,7 +19,7 @@ export default async function FontdueProviderServer(_ref) {
9
19
  preloadedQuery,
10
20
  ...rest
11
21
  } = _ref;
12
- const resolved = preloadedQuery ?? (await loadFontdueProviderQuery({
22
+ const resolved = preloadedQuery ?? (await loadFontdueProviderQueryImpl({
13
23
  url: rest.url
14
24
  }));
15
25
  return /*#__PURE__*/React.createElement(FontdueProvider, _extends({}, rest, {
@@ -1,3 +1,5 @@
1
1
  import React from 'react';
2
2
  import { NewsletterSignup_props } from './index.js';
3
+ export type { NewsletterSignupPreloadedQuery } from './index.js';
4
+ export declare function loadNewsletterSignupQuery(): never;
3
5
  export default function NewsletterSignup(props: NewsletterSignup_props): Promise<React.JSX.Element>;
@@ -3,6 +3,11 @@ import React from 'react';
3
3
  import loadSerializableQuery from '../../relay/loadSerializableQuery.js';
4
4
  import { NewsletterSignupPreloadedQueryRenderer } from './index.js';
5
5
  import NewsletterSignupQueryNode from '../../__generated__/NewsletterSignupQuery.graphql.js';
6
+ // Stub for the RSC export condition. See FontdueProvider/index.server.tsx
7
+ // for the rationale.
8
+ export function loadNewsletterSignupQuery() {
9
+ throw new Error("loadNewsletterSignupQuery isn't needed in React Server Components — " + 'the <NewsletterSignup> server entrypoint awaits its query automatically. ' + 'Drop the manual call.');
10
+ }
6
11
 
7
12
  // Next RSC variant: awaits the query on the server and hands the response to
8
13
  // the client `NewsletterSignupPreloadedQueryRenderer`. Lets pages just write
@@ -1,3 +1,5 @@
1
1
  import React from 'react';
2
2
  import { TestFontsForm_props } from './index.js';
3
+ export type { TestFontsFormPreloadedQuery } from './index.js';
4
+ export declare function loadTestFontsFormQuery(): never;
3
5
  export default function TestFontsForm(props: TestFontsForm_props): Promise<React.JSX.Element>;
@@ -3,6 +3,11 @@ import React from 'react';
3
3
  import loadSerializableQuery from '../../relay/loadSerializableQuery.js';
4
4
  import { TestFontsFormPreloadedQueryRenderer } from './index.js';
5
5
  import TestFontsFormQueryNode from '../../__generated__/TestFontsForm_Query.graphql.js';
6
+ // Stub for the RSC export condition. See FontdueProvider/index.server.tsx
7
+ // for the rationale.
8
+ export function loadTestFontsFormQuery() {
9
+ throw new Error("loadTestFontsFormQuery isn't needed in React Server Components — " + 'the <TestFontsForm> server entrypoint awaits its query automatically. ' + 'Drop the manual call.');
10
+ }
6
11
 
7
12
  // Next RSC variant: awaits the query on the server and hands the response to
8
13
  // the client `TestFontsFormPreloadedQueryRenderer`. Lets pages just write
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { TypeTesterStandalone_props } from './TypeTesterStandalone.js';
3
+ export type { TypeTesterPreloadedQuery } from './TypeTesterStandalone.js';
4
+ export declare function loadTypeTesterQuery(): never;
3
5
  export default function TypeTesterStandalone(props: Extract<TypeTesterStandalone_props, {
4
6
  familyName: string;
5
7
  }>): Promise<React.JSX.Element>;
@@ -3,6 +3,11 @@ import React from 'react';
3
3
  import loadSerializableQuery from '../../relay/loadSerializableQuery.js';
4
4
  import { TypeTesterStandalonePreloadedQueryRenderer } from './TypeTesterStandalone.js';
5
5
  import TypeTesterStandaloneQueryNode from '../../__generated__/TypeTesterStandaloneQuery.graphql.js';
6
+ // Stub for the RSC export condition. See FontdueProvider/index.server.tsx
7
+ // for the rationale.
8
+ export function loadTypeTesterQuery() {
9
+ throw new Error("loadTypeTesterQuery isn't needed in React Server Components — " + 'the <TypeTester> server entrypoint awaits its query automatically. ' + 'Drop the manual call.');
10
+ }
6
11
 
7
12
  // Next RSC variant: awaits the query on the server and hands the response to
8
13
  // the client `TypeTesterStandalonePreloadedQueryRenderer`. Lets pages just
@@ -1,3 +1,5 @@
1
1
  import React from 'react';
2
2
  import { TypeTesters_props } from './index.js';
3
+ export type { TypeTestersPreloadedQuery } from './index.js';
4
+ export declare function loadTypeTestersQuery(): never;
3
5
  export default function TypeTesters({ collectionId, collectionSlug, tags, excludeTags, ...rest }: TypeTesters_props): Promise<React.JSX.Element | null>;
@@ -4,6 +4,11 @@ import loadSerializableQuery from '../../relay/loadSerializableQuery.js';
4
4
  import { TypeTestersPreloadedIDQueryRenderer, TypeTestersPreloadedSlugQueryRenderer } from './index.js';
5
5
  import TypeTestersIDQueryNode from '../../__generated__/TypeTestersIDQuery.graphql.js';
6
6
  import TypeTestersSlugQueryNode from '../../__generated__/TypeTestersSlugQuery.graphql.js';
7
+ // Stub for the RSC export condition. See FontdueProvider/index.server.tsx
8
+ // for the rationale.
9
+ export function loadTypeTestersQuery() {
10
+ throw new Error("loadTypeTestersQuery isn't needed in React Server Components — " + 'the <TypeTesters> server entrypoint awaits its query automatically. ' + 'Drop the manual call.');
11
+ }
7
12
 
8
13
  // Next RSC variant: awaits the query on the server and hands the response to
9
14
  // the client `*PreloadedQueryRenderer`. Lets pages just write
@@ -3,7 +3,7 @@ import { handlePossibleCorsError } from '../corsError.js';
3
3
 
4
4
  // `__FONTDUE_JS_VERSION__` is replaced by an inline babel plugin
5
5
  // (defineVersionPlugin in .babelrc.cjs) with the literal package.json#version.
6
- const version = "3.0.0-alpha2";
6
+ const version = "3.0.0-alpha4";
7
7
  const IS_SERVER = typeof window === typeof undefined;
8
8
 
9
9
  // Read env from either process.env (Node/Next.js) or import.meta.env (Vite/Astro).
package/dist/vite.js CHANGED
@@ -68,16 +68,32 @@ export default function fontdueJs() {
68
68
  // and SSR paths.
69
69
  define: {
70
70
  global: 'globalThis'
71
- },
72
- ssr: {
73
- // Run fontdue-js source through Vite's transform pipeline so
74
- // cjsInterop sees its imports of CJS-shaped Relay/draft-js/fbjs
75
- // and rewrites them. Otherwise Node externalizes fontdue-js and
76
- // its `import { graphql } from 'react-relay'` fails — cjs-module-
77
- // lexer can't extract names from `module.exports = require('./lib')`.
78
- noExternal: ['fontdue-js']
79
71
  }
80
72
  };
73
+ },
74
+ // Apply `noExternal` to every server-side Vite environment so
75
+ // fontdue-js source flows through Vite's transform pipeline and
76
+ // cjsInterop can rewrite its imports of CJS-shaped Relay/draft-js/
77
+ // fbjs. The legacy `ssr.noExternal` only covered the default `ssr`
78
+ // environment, so Astro 6's separate `prerender` build externalized
79
+ // fontdue-js and `import { graphql } from 'react-relay'` ran against
80
+ // unrewritten CJS at prerender time.
81
+ //
82
+ // `config.consumer` would be the principled check, but at
83
+ // `configEnvironment` time Vite hasn't populated it yet (undefined
84
+ // for ssr/prerender/client alike). Match by name instead:
85
+ // - 'ssr': default Vite SSR env (plain Vite SSR, RR7)
86
+ // - 'prerender': Astro 6's static-prerender env
87
+ // The `consumer` fallback is kept as future-proofing if a framework
88
+ // ever names its server env something else but does populate consumer.
89
+ configEnvironment(name, config) {
90
+ if (name === 'ssr' || name === 'prerender' || config.consumer === 'server') {
91
+ return {
92
+ resolve: {
93
+ noExternal: ['fontdue-js']
94
+ }
95
+ };
96
+ }
81
97
  }
82
98
  }];
83
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fontdue-js",
3
- "version": "3.0.0-alpha2",
3
+ "version": "3.0.0-alpha4",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "npm run relay && run-p build-js build-css build-ts",
@@ -81,7 +81,6 @@
81
81
  "@types/react": "19.0.0"
82
82
  },
83
83
  "exports": {
84
- ".": "./dist/index.js",
85
84
  "./fontdue.css": "./dist/fontdue.css",
86
85
  "./BuyButton": {
87
86
  "react-server": "./dist/components/BuyButton/index.server.js",
@@ -100,7 +99,6 @@
100
99
  "react-server": "./dist/components/FontdueProvider/index.server.js",
101
100
  "default": "./dist/components/FontdueProvider/index.js"
102
101
  },
103
- "./loadFontdueProviderQuery": "./dist/loadFontdueProviderQuery.js",
104
102
  "./NewsletterSignup": {
105
103
  "react-server": "./dist/components/NewsletterSignup/index.server.js",
106
104
  "default": "./dist/components/NewsletterSignup/index.js"