@gringow/gringow-react 0.0.6 → 0.0.7

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
@@ -20,13 +20,15 @@ pnpm add @gringow/gringow @gringow/gringow-react
20
20
  - A cache produced by the core Gringow tooling (CLI, Vite plugin, or direct API usage)
21
21
 
22
22
  ## Quick start
23
- Configure the store once when your application boots and then render translated strings with the `g` helper.
23
+ Register the custom element once on the client, configure the store, and then render translated strings with the `g`
24
+ helper.
24
25
 
25
26
  ```tsx
26
- // app-bootstrap.ts
27
- import { GringowStore } from '@gringow/gringow-react'
27
+ // app-bootstrap.ts (client-only)
28
+ import '@gringow/gringow-react/browser'
29
+ import { GringowStore } from '@gringow/gringow-react/store'
28
30
 
29
- GringowStore.defaultLanguage = 'en-US'
31
+ GringowStore.language = 'en-US'
30
32
  GringowStore.cacheUrl = '/gringow/gringow.json'
31
33
  await GringowStore.fetchCache()
32
34
  ```
@@ -42,8 +44,13 @@ export function Welcome({ name }: { name: string }) {
42
44
 
43
45
  The helper flattens the template string, looks up the cached translation by ID, and renders a `<g-gringow>` custom element wrapped in `React.Suspense`. Until the cache is available the original template literal is used as a fallback.
44
46
 
47
+ > The `browser` entry registers the `<g-gringow>` element and wires it to `GringowStore`. Import it once per
48
+ > application (typically in your client bootstrap).
49
+
45
50
  ## Managing the translation cache
46
- The store can be fed from a static file or from the hosted Gringow IO endpoint.
51
+ The store can be fed from a static file or from a hosted endpoint. When not set programmatically, `cacheUrl` falls back
52
+ to `<meta name="gringow-cache-url">` or `data-gringow-cache-url` on `<html>`, and `language` defaults to
53
+ `document.documentElement.lang`.
47
54
 
48
55
  ```tsx
49
56
  import { GringowStore } from '@gringow/gringow-react'
@@ -69,13 +76,15 @@ function changeLanguage(lang: string) {
69
76
  ```
70
77
 
71
78
  ## API reference
72
- - `g(strings, ...values)` returns a `React.ReactNode` bound to the Gringow cache
79
+ - `g(strings, ...values)` returns a `<g-gringow>` element keyed by the flattened template string.
73
80
  - `GringowStore` singleton exposes:
74
- - `defaultLanguage` getter/setter
75
- - `cacheUrl` and `gringowIoToken` setters (auto trigger cache fetch)
76
- - `fetchCache(force?: boolean)` to load or refresh the cache
81
+ - `language` getter/setter (defaults to `<html lang>`)
82
+ - `cacheUrl` setter (fallback to `<meta name="gringow-cache-url">` or `data-gringow-cache-url`)
83
+ - `fetchCache()` to load the cache once (throws if URL or language are missing)
84
+ - `getCacheItem(cacheId)` to resolve a translation for the current language, falling back to the original string
77
85
  - `cache` getter with the resolved cache object (`Record<cacheId, GringowCacheItem>`)
78
86
  - `LanguageChangeEvent` class with `EVENT_NAME` constant and `create(lang)` helper
87
+ - `changeLanguage(lang)` dispatches the language change event for convenience
79
88
 
80
89
  ## Development scripts
81
90
  ```bash
@@ -0,0 +1,2 @@
1
+ import '@gringow/gringow-shadow/event';
2
+ import '@gringow/gringow-shadow/store';
@@ -0,0 +1,9 @@
1
+ import { GringowComponent } from '@gringow/gringow-shadow/component';
2
+ import { GringowStore } from '@gringow/gringow-shadow/store';
3
+
4
+ // src/browser.tsx
5
+ GringowComponent.defaults = { store: GringowStore };
6
+ var elementClass = window.customElements.get(GringowComponent.GRINGOW_ELEMENT_NAME);
7
+ if (!elementClass) {
8
+ window.customElements.define(GringowComponent.GRINGOW_ELEMENT_NAME, GringowComponent);
9
+ }
@@ -0,0 +1,3 @@
1
+ declare function changeLanguage(lang: string): void;
2
+
3
+ export { changeLanguage };
@@ -0,0 +1,10 @@
1
+ import { LanguageChangeEvent } from '@gringow/gringow-shadow/event';
2
+
3
+ // src/event.ts
4
+
5
+ // src/change-language.ts
6
+ function changeLanguage(lang) {
7
+ window.dispatchEvent(LanguageChangeEvent.create(lang));
8
+ }
9
+
10
+ export { changeLanguage };
@@ -0,0 +1 @@
1
+ export { LanguageChangeEvent } from '@gringow/gringow-shadow/event';
package/dist/event.mjs ADDED
@@ -0,0 +1 @@
1
+ export { LanguageChangeEvent } from '@gringow/gringow-shadow/event';
package/dist/g.d.mts ADDED
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+
3
+ declare function g(strings: TemplateStringsArray, ...replacements: Array<unknown>): React.ReactNode;
4
+
5
+ export { g };
package/dist/g.mjs ADDED
@@ -0,0 +1,18 @@
1
+ import { flatTemplateString, createCacheId } from '@gringow/gringow/browser';
2
+ import React from 'react';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ // src/g.tsx
6
+ var isServer = typeof window === "undefined";
7
+ function moduleName(isServer2) {
8
+ return !isServer2 ? "./browser.mjs" : ".";
9
+ }
10
+ function g(strings, ...replacements) {
11
+ import(moduleName(isServer));
12
+ const reactId = React.useId();
13
+ const flatten = flatTemplateString(strings, replacements);
14
+ const cacheId = createCacheId(flatten);
15
+ return /* @__PURE__ */ jsx("g-gringow", { id: reactId, "data-cache-id": cacheId, "data-flatten": flatten }, reactId);
16
+ }
17
+
18
+ export { g };
@@ -0,0 +1,22 @@
1
+ import { DetailedHTMLProps, HTMLAttributes, ReactNode } from 'react';
2
+
3
+ type GGringowProps = DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> & {
4
+ id?: string
5
+ cacheId?: string
6
+ 'data-cache-id'?: string
7
+ cache?: unknown
8
+ lang?: string
9
+ flatten?: string
10
+ replacements?: Array<unknown>
11
+ children?: ReactNode
12
+ }
13
+
14
+ declare global {
15
+ namespace React {
16
+ namespace JSX {
17
+ interface IntrinsicElements {
18
+ 'g-gringow': GGringowProps
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1 @@
1
+
package/dist/index.d.mts CHANGED
@@ -1,11 +1,3 @@
1
- import React from 'react';
2
- export { GringowComponent } from './gringow-component.mjs';
3
- export { LanguageChangeEvent, LanguageChangeEventDetail } from './gringow-event.mjs';
4
- export { GringowStore } from './gringow-store.mjs';
5
- import '@gringow/gringow';
6
-
7
- declare function g(strings: TemplateStringsArray, ...values: Array<unknown>): React.ReactNode;
8
-
9
- declare const gringowReact: {};
10
-
11
- export { gringowReact as default, g };
1
+ export { changeLanguage } from './change-language.mjs';
2
+ export { g } from './g.mjs';
3
+ import 'react';
package/dist/index.mjs CHANGED
@@ -1,161 +1,24 @@
1
- import { GRINGOW_IO_URL, flatTemplateString, createCacheId } from '@gringow/gringow/browser';
1
+ import { LanguageChangeEvent } from '@gringow/gringow-shadow/event';
2
+ import { flatTemplateString, createCacheId } from '@gringow/gringow/browser';
2
3
  import React from 'react';
3
4
  import { jsx } from 'react/jsx-runtime';
4
5
 
5
- // src/g.tsx
6
+ // src/event.ts
6
7
 
7
- // src/gringow-event.ts
8
- var LanguageChangeEvent = class _LanguageChangeEvent extends CustomEvent {
9
- static EVENT_NAME = "language-change";
10
- constructor(detail) {
11
- super(_LanguageChangeEvent.EVENT_NAME, {
12
- detail: {
13
- lang: detail.lang ?? "en-US",
14
- timestamp: detail.timestamp || Date.now()
15
- },
16
- bubbles: true,
17
- cancelable: true
18
- });
19
- }
20
- static create(lang) {
21
- return new _LanguageChangeEvent({ lang });
22
- }
23
- };
24
- var GringowStoreSingleton = class _GringowStoreSingleton {
25
- static instance = null;
26
- #cache = null;
27
- #cacheUrl;
28
- #gringowIoToken;
29
- #defaultLanguage;
30
- constructor() {
31
- }
32
- static getInstance() {
33
- if (!_GringowStoreSingleton.instance) {
34
- _GringowStoreSingleton.instance = new _GringowStoreSingleton();
35
- }
36
- return _GringowStoreSingleton.instance;
37
- }
38
- set defaultLanguage(value) {
39
- this.#defaultLanguage = value ?? "en-US";
40
- }
41
- get defaultLanguage() {
42
- return this.#defaultLanguage;
43
- }
44
- set cacheUrl(value) {
45
- this.#cacheUrl = value;
46
- this.fetchCache();
47
- }
48
- get cacheUrl() {
49
- if (!this.#cacheUrl) {
50
- throw new Error("Cache URL is not set");
51
- }
52
- return this.#cacheUrl;
53
- }
54
- set gringowIoToken(value) {
55
- this.#gringowIoToken = value;
56
- this.#cacheUrl = `${GRINGOW_IO_URL}?token=${this.#gringowIoToken}`;
57
- this.fetchCache();
58
- }
59
- get gringowIoToken() {
60
- return this.#gringowIoToken;
61
- }
62
- get cache() {
63
- return this.#cache;
64
- }
65
- set cache(value) {
66
- this.#cache = value;
67
- }
68
- async fetchCache(force = false) {
69
- if (!this.#cacheUrl) {
70
- throw new Error("Cache URL is not set");
71
- }
72
- if (!this.cache || force) {
73
- try {
74
- const response = await fetch(this.#cacheUrl);
75
- if (!response.ok) {
76
- throw new Error("Failed to fetch gringow cache");
77
- }
78
- this.cache = await response.json();
79
- } catch (error) {
80
- throw new Error("Failed to fetch gringow cache", { cause: error });
81
- }
82
- }
83
- return this.cache;
84
- }
85
- };
86
- var GringowStore = GringowStoreSingleton.getInstance();
87
-
88
- // src/gringow-component.ts
89
- var GringowComponent = class extends HTMLElement {
90
- shadowRoot;
91
- cacheId;
92
- cache;
93
- flatten;
94
- message;
95
- gringowElement;
96
- _lang = GringowStore.defaultLanguage;
97
- get lang() {
98
- return this._lang;
99
- }
100
- set lang(value) {
101
- this._lang = value ?? GringowStore.defaultLanguage;
102
- this.updateMessage(this._lang);
103
- }
104
- constructor() {
105
- super();
106
- this.initializeShadowRoot();
107
- window.addEventListener(LanguageChangeEvent.EVENT_NAME, this.languageChangedListener.bind(this));
108
- }
109
- languageChangedListener(event) {
110
- if (this.lang !== event.detail.lang) {
111
- this.lang = event.detail.lang;
112
- }
113
- this.updateMessage(event.detail.lang);
114
- }
115
- updateMessage(lang) {
116
- this.gringowElement = this.shadowRoot.host;
117
- this.cacheId = this.gringowElement.cacheId;
118
- this.cache = this.gringowElement.cache;
119
- this.message = this.cache?.translation?.[lang] ?? this.cache?.original ?? this.flatten;
120
- this.shadowRoot.innerHTML = `<slot>${this.message}</slot>`;
121
- }
122
- initializeShadowRoot() {
123
- this.shadowRoot = this.attachShadow({ mode: "open" });
124
- this.updateMessage(this.lang);
125
- }
126
- };
127
- var ELEMENT_NAME = "g-gringow";
128
- function g(strings, ...values) {
129
- const [elementShow, setElementShow] = React.useState(false);
130
- const [cache, setCache] = React.useState();
131
- const ref = React.useRef(null);
132
- const flatten = flatTemplateString(strings, values);
8
+ // src/change-language.ts
9
+ function changeLanguage(lang) {
10
+ window.dispatchEvent(LanguageChangeEvent.create(lang));
11
+ }
12
+ var isServer = typeof window === "undefined";
13
+ function moduleName(isServer2) {
14
+ return !isServer2 ? "./browser.mjs" : ".";
15
+ }
16
+ function g(strings, ...replacements) {
17
+ import(moduleName(isServer));
18
+ const reactId = React.useId();
19
+ const flatten = flatTemplateString(strings, replacements);
133
20
  const cacheId = createCacheId(flatten);
134
- React.useEffect(() => {
135
- React.startTransition(async () => {
136
- await GringowStore.fetchCache();
137
- setCache(GringowStore.cache);
138
- });
139
- }, []);
140
- React.useEffect(() => {
141
- if (!window.customElements.get(ELEMENT_NAME)) {
142
- window.customElements.define(ELEMENT_NAME, GringowComponent);
143
- }
144
- });
145
- React.useEffect(() => {
146
- if (ref.current && cache[cacheId]) {
147
- ref.current.lang = ref.current.lang ?? GringowStore.defaultLanguage;
148
- ref.current.cacheId = cacheId;
149
- ref.current.cache = cache[cacheId];
150
- ref.current.flatten = flatten;
151
- if (!elementShow) setElementShow(true);
152
- }
153
- });
154
- return /* @__PURE__ */ jsx(React.Suspense, { fallback: flatten, children: Boolean(cache) && /* @__PURE__ */ jsx("g-gringow", { ref, id: cacheId, children: /* @__PURE__ */ jsx("g-outlet", { slot: cacheId, children: flatten }) }) });
21
+ return /* @__PURE__ */ jsx("g-gringow", { id: reactId, "data-cache-id": cacheId, "data-flatten": flatten }, reactId);
155
22
  }
156
23
 
157
- // src/index.ts
158
- var gringowReact = {};
159
- var index_default = gringowReact;
160
-
161
- export { GringowComponent, GringowStore, LanguageChangeEvent, index_default as default, g };
24
+ export { changeLanguage, g };
@@ -0,0 +1 @@
1
+ export { GringowStore, GringowStoreType } from '@gringow/gringow-shadow/store';
package/dist/store.mjs ADDED
@@ -0,0 +1 @@
1
+ export { GringowStore } from '@gringow/gringow-shadow/store';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gringow/gringow-react",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "React bindings for Gringow AI-powered translation tool",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -11,8 +11,14 @@
11
11
  ],
12
12
  "exports": {
13
13
  ".": {
14
+ "types": "./dist/index.d.mts",
14
15
  "import": "./dist/index.mjs",
15
- "require": "./dist/index.js"
16
+ "require": "./dist/index.mjs"
17
+ },
18
+ "./store": {
19
+ "types": "./dist/store.d.mts",
20
+ "import": "./dist/store.mjs",
21
+ "require": "./dist/store.mjs"
16
22
  }
17
23
  },
18
24
  "author": "Renato Gaspar <rntgspr@gmail.com>",
@@ -21,13 +27,16 @@
21
27
  "access": "public"
22
28
  },
23
29
  "devDependencies": {
30
+ "@types/node": "^24.10.0",
24
31
  "tsup": "8.5.0",
25
32
  "typescript": "5.8.3"
26
33
  },
27
34
  "dependencies": {
35
+ "@types/react": "^19.2.7",
28
36
  "react": "19.1.0",
29
37
  "react-dom": "19.1.0",
30
- "@gringow/gringow": "0.1.2"
38
+ "@gringow/gringow": "0.1.3",
39
+ "@gringow/gringow-shadow": "0.0.2"
31
40
  },
32
41
  "scripts": {
33
42
  "build": "rm -rf ./dist/* ./tsconfig.tsbuildinfo && tsup",
@@ -1,17 +0,0 @@
1
- declare class GringowComponent extends HTMLElement {
2
- shadowRoot: ShadowRoot;
3
- private cacheId;
4
- private cache;
5
- private flatten;
6
- private message;
7
- private gringowElement;
8
- private _lang;
9
- get lang(): string;
10
- set lang(value: string);
11
- constructor();
12
- private languageChangedListener;
13
- private updateMessage;
14
- private initializeShadowRoot;
15
- }
16
-
17
- export { GringowComponent };
@@ -1,124 +0,0 @@
1
- import { GRINGOW_IO_URL } from '@gringow/gringow/browser';
2
-
3
- // src/gringow-event.ts
4
- var LanguageChangeEvent = class _LanguageChangeEvent extends CustomEvent {
5
- static EVENT_NAME = "language-change";
6
- constructor(detail) {
7
- super(_LanguageChangeEvent.EVENT_NAME, {
8
- detail: {
9
- lang: detail.lang ?? "en-US",
10
- timestamp: detail.timestamp || Date.now()
11
- },
12
- bubbles: true,
13
- cancelable: true
14
- });
15
- }
16
- static create(lang) {
17
- return new _LanguageChangeEvent({ lang });
18
- }
19
- };
20
- var GringowStoreSingleton = class _GringowStoreSingleton {
21
- static instance = null;
22
- #cache = null;
23
- #cacheUrl;
24
- #gringowIoToken;
25
- #defaultLanguage;
26
- constructor() {
27
- }
28
- static getInstance() {
29
- if (!_GringowStoreSingleton.instance) {
30
- _GringowStoreSingleton.instance = new _GringowStoreSingleton();
31
- }
32
- return _GringowStoreSingleton.instance;
33
- }
34
- set defaultLanguage(value) {
35
- this.#defaultLanguage = value ?? "en-US";
36
- }
37
- get defaultLanguage() {
38
- return this.#defaultLanguage;
39
- }
40
- set cacheUrl(value) {
41
- this.#cacheUrl = value;
42
- this.fetchCache();
43
- }
44
- get cacheUrl() {
45
- if (!this.#cacheUrl) {
46
- throw new Error("Cache URL is not set");
47
- }
48
- return this.#cacheUrl;
49
- }
50
- set gringowIoToken(value) {
51
- this.#gringowIoToken = value;
52
- this.#cacheUrl = `${GRINGOW_IO_URL}?token=${this.#gringowIoToken}`;
53
- this.fetchCache();
54
- }
55
- get gringowIoToken() {
56
- return this.#gringowIoToken;
57
- }
58
- get cache() {
59
- return this.#cache;
60
- }
61
- set cache(value) {
62
- this.#cache = value;
63
- }
64
- async fetchCache(force = false) {
65
- if (!this.#cacheUrl) {
66
- throw new Error("Cache URL is not set");
67
- }
68
- if (!this.cache || force) {
69
- try {
70
- const response = await fetch(this.#cacheUrl);
71
- if (!response.ok) {
72
- throw new Error("Failed to fetch gringow cache");
73
- }
74
- this.cache = await response.json();
75
- } catch (error) {
76
- throw new Error("Failed to fetch gringow cache", { cause: error });
77
- }
78
- }
79
- return this.cache;
80
- }
81
- };
82
- var GringowStore = GringowStoreSingleton.getInstance();
83
-
84
- // src/gringow-component.ts
85
- var GringowComponent = class extends HTMLElement {
86
- shadowRoot;
87
- cacheId;
88
- cache;
89
- flatten;
90
- message;
91
- gringowElement;
92
- _lang = GringowStore.defaultLanguage;
93
- get lang() {
94
- return this._lang;
95
- }
96
- set lang(value) {
97
- this._lang = value ?? GringowStore.defaultLanguage;
98
- this.updateMessage(this._lang);
99
- }
100
- constructor() {
101
- super();
102
- this.initializeShadowRoot();
103
- window.addEventListener(LanguageChangeEvent.EVENT_NAME, this.languageChangedListener.bind(this));
104
- }
105
- languageChangedListener(event) {
106
- if (this.lang !== event.detail.lang) {
107
- this.lang = event.detail.lang;
108
- }
109
- this.updateMessage(event.detail.lang);
110
- }
111
- updateMessage(lang) {
112
- this.gringowElement = this.shadowRoot.host;
113
- this.cacheId = this.gringowElement.cacheId;
114
- this.cache = this.gringowElement.cache;
115
- this.message = this.cache?.translation?.[lang] ?? this.cache?.original ?? this.flatten;
116
- this.shadowRoot.innerHTML = `<slot>${this.message}</slot>`;
117
- }
118
- initializeShadowRoot() {
119
- this.shadowRoot = this.attachShadow({ mode: "open" });
120
- this.updateMessage(this.lang);
121
- }
122
- };
123
-
124
- export { GringowComponent };
@@ -1,11 +0,0 @@
1
- interface LanguageChangeEventDetail {
2
- lang: string;
3
- timestamp?: number;
4
- }
5
- declare class LanguageChangeEvent extends CustomEvent<LanguageChangeEventDetail> {
6
- static readonly EVENT_NAME = "language-change";
7
- constructor(detail: LanguageChangeEventDetail);
8
- static create(lang: string): LanguageChangeEvent;
9
- }
10
-
11
- export { LanguageChangeEvent, type LanguageChangeEventDetail };
@@ -1,19 +0,0 @@
1
- // src/gringow-event.ts
2
- var LanguageChangeEvent = class _LanguageChangeEvent extends CustomEvent {
3
- static EVENT_NAME = "language-change";
4
- constructor(detail) {
5
- super(_LanguageChangeEvent.EVENT_NAME, {
6
- detail: {
7
- lang: detail.lang ?? "en-US",
8
- timestamp: detail.timestamp || Date.now()
9
- },
10
- bubbles: true,
11
- cancelable: true
12
- });
13
- }
14
- static create(lang) {
15
- return new _LanguageChangeEvent({ lang });
16
- }
17
- };
18
-
19
- export { LanguageChangeEvent };
@@ -1,20 +0,0 @@
1
- import { GringowCache } from '@gringow/gringow';
2
-
3
- declare class GringowStoreSingleton {
4
- #private;
5
- private static instance;
6
- private constructor();
7
- static getInstance(): GringowStoreSingleton;
8
- set defaultLanguage(value: string);
9
- get defaultLanguage(): string;
10
- set cacheUrl(value: string);
11
- get cacheUrl(): string;
12
- set gringowIoToken(value: string);
13
- get gringowIoToken(): string;
14
- get cache(): GringowCache;
15
- set cache(value: GringowCache);
16
- fetchCache(force?: boolean): Promise<GringowCache>;
17
- }
18
- declare const GringowStore: GringowStoreSingleton;
19
-
20
- export { GringowStore };
@@ -1,68 +0,0 @@
1
- import { GRINGOW_IO_URL } from '@gringow/gringow/browser';
2
-
3
- // src/gringow-store.ts
4
- var GringowStoreSingleton = class _GringowStoreSingleton {
5
- static instance = null;
6
- #cache = null;
7
- #cacheUrl;
8
- #gringowIoToken;
9
- #defaultLanguage;
10
- constructor() {
11
- }
12
- static getInstance() {
13
- if (!_GringowStoreSingleton.instance) {
14
- _GringowStoreSingleton.instance = new _GringowStoreSingleton();
15
- }
16
- return _GringowStoreSingleton.instance;
17
- }
18
- set defaultLanguage(value) {
19
- this.#defaultLanguage = value ?? "en-US";
20
- }
21
- get defaultLanguage() {
22
- return this.#defaultLanguage;
23
- }
24
- set cacheUrl(value) {
25
- this.#cacheUrl = value;
26
- this.fetchCache();
27
- }
28
- get cacheUrl() {
29
- if (!this.#cacheUrl) {
30
- throw new Error("Cache URL is not set");
31
- }
32
- return this.#cacheUrl;
33
- }
34
- set gringowIoToken(value) {
35
- this.#gringowIoToken = value;
36
- this.#cacheUrl = `${GRINGOW_IO_URL}?token=${this.#gringowIoToken}`;
37
- this.fetchCache();
38
- }
39
- get gringowIoToken() {
40
- return this.#gringowIoToken;
41
- }
42
- get cache() {
43
- return this.#cache;
44
- }
45
- set cache(value) {
46
- this.#cache = value;
47
- }
48
- async fetchCache(force = false) {
49
- if (!this.#cacheUrl) {
50
- throw new Error("Cache URL is not set");
51
- }
52
- if (!this.cache || force) {
53
- try {
54
- const response = await fetch(this.#cacheUrl);
55
- if (!response.ok) {
56
- throw new Error("Failed to fetch gringow cache");
57
- }
58
- this.cache = await response.json();
59
- } catch (error) {
60
- throw new Error("Failed to fetch gringow cache", { cause: error });
61
- }
62
- }
63
- return this.cache;
64
- }
65
- };
66
- var GringowStore = GringowStoreSingleton.getInstance();
67
-
68
- export { GringowStore };