drupal-decoupled 0.2.2 → 0.3.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Drupal Decoupled
2
2
 
3
- Using Drupal as a headless CMS with a Decoupled front-end implementation is a great way to get an enterprise-quality CMS, paired with a great modern development experience using Remix, Next.js, Astro and/or others.
3
+ Using Drupal as a headless CMS with a Decoupled front-end implementation is a great way to get an enterprise-quality CMS, paired with a great modern development experience using React Router, Next.js, Astro and/or others.
4
4
 
5
5
  Unlock the full potential of Drupal as an API-first CMS. Our quick-start guides and ready-to-use examples help you get started in no time!
6
6
 
@@ -11,12 +11,12 @@ Visit the [docs](https://drupal-decoupled.octahedroid.com/) to see how to use th
11
11
 
12
12
  ### Quickstart
13
13
  - [Drupal](https://drupal-decoupled.octahedroid.com/docs/getting-started/quick-start/drupal/)
14
- - [Remix](https://drupal-decoupled.octahedroid.com/docs/getting-started/quick-start/remix)
14
+ - [React Router](https://drupal-decoupled.octahedroid.com/docs/getting-started/quick-start/react-router)
15
15
  - [Next.js](https://drupal-decoupled.octahedroid.com/docs/getting-started/quick-start/next)
16
16
 
17
17
  ### Step by step
18
18
  - [Drupal](https://drupal-decoupled.octahedroid.com/docs/getting-started/step-by-step/drupal/install/)
19
- - [Remix](https://drupal-decoupled.octahedroid.com/docs/01-getting-started/02-step-by-step/02-starters/01-remix/)
19
+ - [React Router](https://drupal-decoupled.octahedroid.com/docs/01-getting-started/02-step-by-step/02-starters/01-react-router/)
20
20
  - [Next.js](https://drupal-decoupled.octahedroid.com/docs/01-getting-started/02-step-by-step/02-starters/02-next/)
21
21
 
22
22
  ## Supporting organizations
@@ -0,0 +1 @@
1
+ var g=(a,l)=>typeof a=="string"?a:(Array.isArray(a)||(a=[a]),a.reduce((p,{pattern:t,replacement:i})=>p?.replace(t,i),l));var T={"og:title":"title","og:description":"description","og:url":"url","og:site_name":"siteName","og:locale":"locale","og:type":"type"},d={"twitter:card":"card","twitter:title":"title","twitter:description":"description","twitter:site":"site","twitter:creator":"creator"},u=new Set(["twitter:card","twitter:title","twitter:description","twitter:site","twitter:creator","twitter:url"]),f=({tags:a,defaultTags:l={},metaTagOverrides:p})=>{let t={...l};for(let i of a){let c=p?.[i.__typename];if(i.__typename==="MetaTagLink"){let{rel:e,href:n}=i.attributes,s=c?.[e??""],r=s?g(s,n):n;e==="canonical"&&r&&(t.alternates={...t.alternates,canonical:r})}if(i.__typename==="MetaTagProperty"){let{property:e,content:n}=i.attributes,s=c?.[e??""],r=s?g(s,n):n;if(e&&r){let o=T[e];o?t.openGraph={...t.openGraph,[o]:r}:e==="og:image"?t.openGraph={...t.openGraph,images:[{url:r}]}:t.other={...t.other,[e]:r}}}if(i.__typename==="MetaTagValue"){let{name:e,content:n}=i.attributes,s=c?.[e??""],r=s?g(s,n):n;if(e&&r)if(e==="title")t.title=r;else if(e==="description")t.description=r;else if(e==="keywords")t.keywords=r.split(",").map(o=>o.trim());else if(e==="robots")t.robots=r;else if(u.has(e)){let o=d[e];o?t.twitter={...t.twitter,[o]:r}:e==="twitter:url"&&(t.other={...t.other,[e]:r})}else e==="twitter:image"?t.twitter={...t.twitter,images:[{url:r}]}:t.other={...t.other,[e]:r}}}return t};export{f as metaTags};
@@ -0,0 +1,38 @@
1
+ import type { MetaTag, MetaTagOverrides } from "../shared/metatag-types";
2
+ export type { MetaTag };
3
+ type NextMetadata = {
4
+ title?: string | null;
5
+ description?: string | null;
6
+ keywords?: string[];
7
+ robots?: string;
8
+ openGraph?: {
9
+ title?: string;
10
+ description?: string;
11
+ url?: string;
12
+ siteName?: string;
13
+ images?: Array<{
14
+ url: string;
15
+ }>;
16
+ locale?: string;
17
+ type?: string;
18
+ };
19
+ twitter?: {
20
+ card?: string;
21
+ title?: string;
22
+ description?: string;
23
+ images?: Array<{
24
+ url: string;
25
+ }>;
26
+ site?: string;
27
+ creator?: string;
28
+ };
29
+ alternates?: {
30
+ canonical?: string;
31
+ };
32
+ other?: Record<string, string>;
33
+ };
34
+ export declare const metaTags: ({ tags, defaultTags, metaTagOverrides, }: {
35
+ tags: MetaTag[];
36
+ defaultTags?: NextMetadata;
37
+ metaTagOverrides?: MetaTagOverrides;
38
+ }) => NextMetadata;
@@ -0,0 +1 @@
1
+ var g=(a,l)=>typeof a=="string"?a:(Array.isArray(a)||(a=[a]),a.reduce((p,{pattern:t,replacement:i})=>p?.replace(t,i),l));var T={"og:title":"title","og:description":"description","og:url":"url","og:site_name":"siteName","og:locale":"locale","og:type":"type"},d={"twitter:card":"card","twitter:title":"title","twitter:description":"description","twitter:site":"site","twitter:creator":"creator"},u=new Set(["twitter:card","twitter:title","twitter:description","twitter:site","twitter:creator","twitter:url"]),f=({tags:a,defaultTags:l={},metaTagOverrides:p})=>{let t={...l};for(let i of a){let c=p?.[i.__typename];if(i.__typename==="MetaTagLink"){let{rel:e,href:n}=i.attributes,s=c?.[e??""],r=s?g(s,n):n;e==="canonical"&&r&&(t.alternates={...t.alternates,canonical:r})}if(i.__typename==="MetaTagProperty"){let{property:e,content:n}=i.attributes,s=c?.[e??""],r=s?g(s,n):n;if(e&&r){let o=T[e];o?t.openGraph={...t.openGraph,[o]:r}:e==="og:image"?t.openGraph={...t.openGraph,images:[{url:r}]}:t.other={...t.other,[e]:r}}}if(i.__typename==="MetaTagValue"){let{name:e,content:n}=i.attributes,s=c?.[e??""],r=s?g(s,n):n;if(e&&r)if(e==="title")t.title=r;else if(e==="description")t.description=r;else if(e==="keywords")t.keywords=r.split(",").map(o=>o.trim());else if(e==="robots")t.robots=r;else if(u.has(e)){let o=d[e];o?t.twitter={...t.twitter,[o]:r}:e==="twitter:url"&&(t.other={...t.other,[e]:r})}else e==="twitter:image"?t.twitter={...t.twitter,images:[{url:r}]}:t.other={...t.other,[e]:r}}}return t};export{f as metaTags};
@@ -0,0 +1 @@
1
+ export * from "./seo";
@@ -0,0 +1 @@
1
+ var o=(e,g)=>typeof e=="string"?e:(Array.isArray(e)||(e=[e]),e.reduce((p,{pattern:s,replacement:u})=>p?.replace(s,u),g));var T=[{charSet:"utf-8"},{name:"viewport",content:"width=device-width,initial-scale=1"}],y=({tags:e,defaultTags:g=[],metaTagOverrides:p})=>{let s=e.find(t=>t.__typename==="MetaTagValue"&&t.attributes.name==="title"),u=e.map(t=>{let l=p?.[t.__typename];if(t.__typename==="MetaTagLink"){let{rel:r,href:a}=t.attributes,n=l?.[r??""];if(!n)return{tagName:"link",rel:r,href:a};let i=o(n,a);return{tagName:"link",rel:r,href:i}}if(t.__typename==="MetaTagProperty"){let{property:r,content:a}=t.attributes,n=l?.[r??""];if(!n)return{property:t.attributes.property,content:t.attributes.content};let i=o(n,a);return{property:r,content:i}}if(t.__typename==="MetaTagValue"){let{name:r,content:a}=t.attributes,n=l?.[r??""];if(!n)return{name:t.attributes.name??"",content:t.attributes.content??""};let i=o(n,a);return{name:r,content:i}}return{}});return[...T,...g,s?{title:s.attributes.content}:{},...u]};export{y as metaTags};
@@ -0,0 +1,28 @@
1
+ import type { MetaTag, MetaTagOverrides } from "../shared/metatag-types";
2
+ export type { MetaTag };
3
+ type MetaDescriptor = {
4
+ charSet: "utf-8";
5
+ } | {
6
+ title: string;
7
+ } | {
8
+ name: string;
9
+ content: string;
10
+ } | {
11
+ property: string;
12
+ content: string;
13
+ } | {
14
+ httpEquiv: string;
15
+ content: string;
16
+ } | {
17
+ [name: string]: string;
18
+ tagName: "meta" | "link";
19
+ } | {
20
+ [name: string]: unknown;
21
+ };
22
+ export declare const metaTags: ({ tags, defaultTags, metaTagOverrides, }: {
23
+ tags: MetaTag[];
24
+ defaultTags?: Array<{
25
+ [key: string]: string | undefined;
26
+ }>;
27
+ metaTagOverrides?: MetaTagOverrides;
28
+ }) => Array<MetaDescriptor>;
@@ -0,0 +1 @@
1
+ var g=(e,o)=>typeof e=="string"?e:(Array.isArray(e)||(e=[e]),e.reduce((p,{pattern:s,replacement:u})=>p?.replace(s,u),o));var T=[{charSet:"utf-8"},{name:"viewport",content:"width=device-width,initial-scale=1"}],y=({tags:e,defaultTags:o=[],metaTagOverrides:p})=>{let s=e.find(t=>t.__typename==="MetaTagValue"&&t.attributes.name==="title"),u=e.map(t=>{let l=p?.[t.__typename];if(t.__typename==="MetaTagLink"){let{rel:r,href:a}=t.attributes,n=l?.[r??""];if(!n)return{tagName:"link",rel:r,href:a};let i=g(n,a);return{tagName:"link",rel:r,href:i}}if(t.__typename==="MetaTagProperty"){let{property:r,content:a}=t.attributes,n=l?.[r??""];if(!n)return{property:t.attributes.property,content:t.attributes.content};let i=g(n,a);return{property:r,content:i}}if(t.__typename==="MetaTagValue"){let{name:r,content:a}=t.attributes,n=l?.[r??""];if(!n)return{name:t.attributes.name??"",content:t.attributes.content??""};let i=g(n,a);return{name:r,content:i}}return{}});return[...T,...o,s?{title:s.attributes.content}:{},...u]};export{y as metaTags};
@@ -1,22 +1,3 @@
1
- type MetaDescriptor = {
2
- charSet: "utf-8";
3
- } | {
4
- title: string;
5
- } | {
6
- name: string;
7
- content: string;
8
- } | {
9
- property: string;
10
- content: string;
11
- } | {
12
- httpEquiv: string;
13
- content: string;
14
- } | {
15
- [name: string]: string;
16
- tagName: "meta" | "link";
17
- } | {
18
- [name: string]: unknown;
19
- };
20
1
  type MetaTagUnion = (MetaTagLink | MetaTagValue | MetaTagProperty) & {
21
2
  __isUnion?: true;
22
3
  };
@@ -24,7 +5,7 @@ interface MetaTagLink {
24
5
  attributes: MetaTagLinkAttributes;
25
6
  __typename: "MetaTagLink";
26
7
  }
27
- export type MetaTag = MetaTagLink | MetaTagValue | MetaTagProperty;
8
+ type MetaTag = MetaTagLink | MetaTagValue | MetaTagProperty;
28
9
  interface MetaTagLinkAttributes {
29
10
  rel?: string | null;
30
11
  href?: string | null;
@@ -45,22 +26,17 @@ interface MetaTagPropertyAttributes {
45
26
  property?: string | null;
46
27
  content?: string | null;
47
28
  }
48
- type OverrideOptionsReplace = {
29
+ type OverrideOptionsSingle = {
49
30
  kind: string;
50
31
  pattern: string;
51
32
  replacement: string;
52
- }[];
53
- type OverrideOptions = string | OverrideOptionsReplace;
33
+ };
34
+ type OverrideOptions = string | OverrideOptionsSingle | OverrideOptionsSingle[];
54
35
  type MetaTagOverrides = {
55
36
  [key in MetaTagUnion["__typename"]]?: {
56
37
  [key: string]: OverrideOptions;
57
38
  };
58
39
  };
59
- export declare const metaTags: ({ tags, defaultTags, metaTagOverrides, }: {
60
- tags: MetaTag[];
61
- defaultTags?: {
62
- [key: string]: string | undefined;
63
- }[] | undefined;
64
- metaTagOverrides?: MetaTagOverrides | undefined;
65
- }) => Array<MetaDescriptor>;
66
- export {};
40
+ declare const applyOverrides: (overrides: OverrideOptions, initial: string | null | undefined) => string | null | undefined;
41
+ export type { MetaTag, MetaTagLink, MetaTagValue, MetaTagProperty, MetaTagUnion, MetaTagOverrides, OverrideOptions, OverrideOptionsSingle, };
42
+ export { applyOverrides };
@@ -0,0 +1 @@
1
+ var i=(e,t)=>typeof e=="string"?e:(Array.isArray(e)||(e=[e]),e.reduce((a,{pattern:r,replacement:n})=>a?.replace(r,n),t));export{i as applyOverrides};
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "drupal-decoupled",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Drupal utils for Decoupled integrations",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "graphql",
8
8
  "drupal",
9
9
  "decoupled",
10
- "remix",
10
+ "react-router",
11
11
  "next.js"
12
12
  ],
13
13
  "main": "dist/index.js",
@@ -15,39 +15,32 @@
15
15
  "files": [
16
16
  "dist"
17
17
  ],
18
- "bundlesize": [
19
- {
20
- "path": "./dist/index.js"
21
- }
22
- ],
23
18
  "scripts": {
24
- "prepublish": "yarn build",
25
- "ts-types": " tsc --emitDeclarationOnly --outDir dist",
26
- "build": "rimraf dist && node ./esbuild.js && yarn ts-types"
19
+ "ts-types": "tsc --emitDeclarationOnly --outDir dist",
20
+ "build": "node ./esbuild.js && pnpm ts-types"
27
21
  },
28
22
  "author": "Octahedroid <opensource@octahedroid.com>",
29
23
  "repository": {
30
24
  "url": "https://github.com/octahedroid/drupal-decoupled/tree/main/packages/drupal-decoupled"
31
25
  },
32
26
  "exports": {
33
- ".": "./dist/index.js",
34
- "./remix": "./dist/remix/index.js"
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ },
31
+ "./react-router": {
32
+ "types": "./dist/react-router/index.d.ts",
33
+ "import": "./dist/react-router/index.js"
34
+ },
35
+ "./next": {
36
+ "types": "./dist/next/index.d.ts",
37
+ "import": "./dist/next/index.js"
38
+ }
35
39
  },
36
40
  "license": "MIT",
37
- "dependencies": {
38
- "@measured/puck": "^0.18.1",
39
- "immutable-json-patch": "^6.0.1",
40
- "jmespath": "^0.16.0",
41
- "react": "^18.2.0",
42
- "react-dom": "^18.2.0"
43
- },
44
41
  "devDependencies": {
45
- "@types/jmespath": "^0.15.2",
46
- "@types/node": "^18.11.3",
47
- "@types/react": "^18.2.20",
48
- "@types/react-dom": "^18.2.7",
49
- "esbuild": "^0.17.18",
50
- "rimraf": "^5.0.0",
51
- "typescript": "^4.8.4"
42
+ "@types/node": "catalog:",
43
+ "esbuild": "catalog:",
44
+ "typescript": "catalog:"
52
45
  }
53
46
  }
@@ -1 +0,0 @@
1
- var l=[{charSet:"utf-8"},{name:"viewport",content:"width=device-width,initial-scale=1"}],c=(e,o)=>typeof e=="string"?e:(Array.isArray(e)||(e=[e]),e.reduce((g,{pattern:s,replacement:p})=>g?.replace(s,p),o)),T=({tags:e,defaultTags:o=[],metaTagOverrides:g})=>{let s=e.find(t=>t.__typename==="MetaTagValue"&&t.attributes.name==="title"),p=e.map(t=>{let u=g?.[t.__typename];if(t.__typename==="MetaTagLink"){let{rel:n,href:a}=t.attributes,r=u?.[n];if(!r)return{tagName:"link",rel:n,href:a};let i=c(r,a);return{tagName:"link",rel:n,href:i}}if(t.__typename==="MetaTagProperty"){let{property:n,content:a}=t.attributes,r=u?.[n];if(!r)return{property:t.attributes.property,content:t.attributes.content};let i=c(r,a);return{property:n,content:i}}if(t.__typename==="MetaTagValue"){let{name:n,content:a}=t.attributes,r=u?.[n];if(!r)return{name:t.attributes.name,content:t.attributes.content};let i=c(r,a);return{name:n,content:i}}});return[...l,...o,s?{title:s.attributes.content}:{},...p]};export{T as metaTags};
package/dist/remix/seo.js DELETED
@@ -1 +0,0 @@
1
- var l=[{charSet:"utf-8"},{name:"viewport",content:"width=device-width,initial-scale=1"}],c=(e,o)=>typeof e=="string"?e:(Array.isArray(e)||(e=[e]),e.reduce((g,{pattern:s,replacement:p})=>g?.replace(s,p),o)),T=({tags:e,defaultTags:o=[],metaTagOverrides:g})=>{let s=e.find(t=>t.__typename==="MetaTagValue"&&t.attributes.name==="title"),p=e.map(t=>{let u=g?.[t.__typename];if(t.__typename==="MetaTagLink"){let{rel:n,href:a}=t.attributes,r=u?.[n];if(!r)return{tagName:"link",rel:n,href:a};let i=c(r,a);return{tagName:"link",rel:n,href:i}}if(t.__typename==="MetaTagProperty"){let{property:n,content:a}=t.attributes,r=u?.[n];if(!r)return{property:t.attributes.property,content:t.attributes.content};let i=c(r,a);return{property:n,content:i}}if(t.__typename==="MetaTagValue"){let{name:n,content:a}=t.attributes,r=u?.[n];if(!r)return{name:t.attributes.name,content:t.attributes.content};let i=c(r,a);return{name:n,content:i}}});return[...l,...o,s?{title:s.attributes.content}:{},...p]};export{T as metaTags};
File without changes