@roxyapi/ui-react 0.1.1 → 0.1.3
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/AGENTS.md +2 -2
- package/LICENSE +21 -0
- package/README.md +499 -0
- package/dist/components/biorhythm-chart.d.ts +8 -5
- package/dist/components/biorhythm-chart.d.ts.map +1 -1
- package/dist/components/biorhythm-chart.js +35 -9
- package/dist/components/biorhythm-chart.js.map +2 -2
- package/dist/components/compatibility-card.d.ts +8 -5
- package/dist/components/compatibility-card.d.ts.map +1 -1
- package/dist/components/compatibility-card.js +35 -9
- package/dist/components/compatibility-card.js.map +2 -2
- package/dist/components/dasha-timeline.d.ts +8 -5
- package/dist/components/dasha-timeline.d.ts.map +1 -1
- package/dist/components/dasha-timeline.js +35 -9
- package/dist/components/dasha-timeline.js.map +2 -2
- package/dist/components/data.d.ts +6 -4
- package/dist/components/data.d.ts.map +1 -1
- package/dist/components/data.js +35 -9
- package/dist/components/data.js.map +2 -2
- package/dist/components/dosha-card.d.ts +8 -5
- package/dist/components/dosha-card.d.ts.map +1 -1
- package/dist/components/dosha-card.js +35 -9
- package/dist/components/dosha-card.js.map +2 -2
- package/dist/components/endpoint-form.d.ts +20 -4
- package/dist/components/endpoint-form.d.ts.map +1 -1
- package/dist/components/endpoint-form.js +59 -9
- package/dist/components/endpoint-form.js.map +2 -2
- package/dist/components/guna-milan.d.ts +8 -5
- package/dist/components/guna-milan.d.ts.map +1 -1
- package/dist/components/guna-milan.js +35 -9
- package/dist/components/guna-milan.js.map +2 -2
- package/dist/components/hexagram.d.ts +8 -5
- package/dist/components/hexagram.d.ts.map +1 -1
- package/dist/components/hexagram.js +35 -9
- package/dist/components/hexagram.js.map +2 -2
- package/dist/components/horoscope-card.d.ts +8 -5
- package/dist/components/horoscope-card.d.ts.map +1 -1
- package/dist/components/horoscope-card.js +35 -9
- package/dist/components/horoscope-card.js.map +2 -2
- package/dist/components/kp-planets-table.d.ts +8 -5
- package/dist/components/kp-planets-table.d.ts.map +1 -1
- package/dist/components/kp-planets-table.js +35 -9
- package/dist/components/kp-planets-table.js.map +2 -2
- package/dist/components/location-search.d.ts +22 -4
- package/dist/components/location-search.d.ts.map +1 -1
- package/dist/components/location-search.js +51 -9
- package/dist/components/location-search.js.map +2 -2
- package/dist/components/moon-phase.d.ts +8 -5
- package/dist/components/moon-phase.d.ts.map +1 -1
- package/dist/components/moon-phase.js +35 -9
- package/dist/components/moon-phase.js.map +2 -2
- package/dist/components/natal-chart.d.ts +8 -5
- package/dist/components/natal-chart.d.ts.map +1 -1
- package/dist/components/natal-chart.js +35 -9
- package/dist/components/natal-chart.js.map +2 -2
- package/dist/components/numerology-card.d.ts +8 -5
- package/dist/components/numerology-card.d.ts.map +1 -1
- package/dist/components/numerology-card.js +35 -9
- package/dist/components/numerology-card.js.map +2 -2
- package/dist/components/panchang-table.d.ts +8 -5
- package/dist/components/panchang-table.d.ts.map +1 -1
- package/dist/components/panchang-table.js +35 -9
- package/dist/components/panchang-table.js.map +2 -2
- package/dist/components/synastry-chart.d.ts +15 -5
- package/dist/components/synastry-chart.d.ts.map +1 -1
- package/dist/components/synastry-chart.js +35 -9
- package/dist/components/synastry-chart.js.map +2 -2
- package/dist/components/tarot-card.d.ts +8 -5
- package/dist/components/tarot-card.d.ts.map +1 -1
- package/dist/components/tarot-card.js +35 -9
- package/dist/components/tarot-card.js.map +2 -2
- package/dist/components/tarot-spread.d.ts +8 -5
- package/dist/components/tarot-spread.d.ts.map +1 -1
- package/dist/components/tarot-spread.js +35 -9
- package/dist/components/tarot-spread.js.map +2 -2
- package/dist/components/vedic-kundli.d.ts +8 -5
- package/dist/components/vedic-kundli.d.ts.map +1 -1
- package/dist/components/vedic-kundli.js +35 -9
- package/dist/components/vedic-kundli.js.map +2 -2
- package/dist/index.cjs +545 -99
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +20 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +545 -99
- package/dist/index.js.map +2 -2
- package/dist/load-ui.d.ts +2 -0
- package/dist/load-ui.d.ts.map +1 -1
- package/dist/load-ui.js +13 -4
- package/dist/load-ui.js.map +2 -2
- package/package.json +29 -7
- package/src/components/biorhythm-chart.d.ts +0 -12
- package/src/components/biorhythm-chart.d.ts.map +0 -1
- package/src/components/biorhythm-chart.tsx +0 -35
- package/src/components/compatibility-card.d.ts +0 -12
- package/src/components/compatibility-card.d.ts.map +0 -1
- package/src/components/compatibility-card.tsx +0 -35
- package/src/components/dasha-timeline.d.ts +0 -12
- package/src/components/dasha-timeline.d.ts.map +0 -1
- package/src/components/dasha-timeline.tsx +0 -35
- package/src/components/data.d.ts +0 -11
- package/src/components/data.d.ts.map +0 -1
- package/src/components/data.tsx +0 -35
- package/src/components/dosha-card.d.ts +0 -12
- package/src/components/dosha-card.d.ts.map +0 -1
- package/src/components/dosha-card.tsx +0 -35
- package/src/components/endpoint-form.d.ts +0 -12
- package/src/components/endpoint-form.d.ts.map +0 -1
- package/src/components/endpoint-form.tsx +0 -35
- package/src/components/guna-milan.d.ts +0 -12
- package/src/components/guna-milan.d.ts.map +0 -1
- package/src/components/guna-milan.tsx +0 -35
- package/src/components/hexagram.d.ts +0 -12
- package/src/components/hexagram.d.ts.map +0 -1
- package/src/components/hexagram.tsx +0 -35
- package/src/components/horoscope-card.d.ts +0 -12
- package/src/components/horoscope-card.d.ts.map +0 -1
- package/src/components/horoscope-card.tsx +0 -35
- package/src/components/kp-planets-table.d.ts +0 -12
- package/src/components/kp-planets-table.d.ts.map +0 -1
- package/src/components/kp-planets-table.tsx +0 -35
- package/src/components/location-search.d.ts +0 -12
- package/src/components/location-search.d.ts.map +0 -1
- package/src/components/location-search.tsx +0 -35
- package/src/components/moon-phase.d.ts +0 -12
- package/src/components/moon-phase.d.ts.map +0 -1
- package/src/components/moon-phase.tsx +0 -35
- package/src/components/natal-chart.d.ts +0 -12
- package/src/components/natal-chart.d.ts.map +0 -1
- package/src/components/natal-chart.tsx +0 -35
- package/src/components/numerology-card.d.ts +0 -12
- package/src/components/numerology-card.d.ts.map +0 -1
- package/src/components/numerology-card.tsx +0 -35
- package/src/components/panchang-table.d.ts +0 -12
- package/src/components/panchang-table.d.ts.map +0 -1
- package/src/components/panchang-table.tsx +0 -35
- package/src/components/synastry-chart.d.ts +0 -12
- package/src/components/synastry-chart.d.ts.map +0 -1
- package/src/components/synastry-chart.tsx +0 -35
- package/src/components/tarot-card.d.ts +0 -12
- package/src/components/tarot-card.d.ts.map +0 -1
- package/src/components/tarot-card.tsx +0 -35
- package/src/components/tarot-spread.d.ts +0 -12
- package/src/components/tarot-spread.d.ts.map +0 -1
- package/src/components/tarot-spread.tsx +0 -35
- package/src/components/vedic-kundli.d.ts +0 -12
- package/src/components/vedic-kundli.d.ts.map +0 -1
- package/src/components/vedic-kundli.tsx +0 -35
- package/src/index.d.ts +0 -21
- package/src/index.d.ts.map +0 -1
- package/src/index.ts +0 -20
- package/src/load-ui.d.ts +0 -2
- package/src/load-ui.d.ts.map +0 -1
- package/src/load-ui.ts +0 -41
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ensureScriptLoaded } from '../load-ui.js';
|
|
3
|
-
|
|
4
|
-
type DivAttrs = React.HTMLAttributes<HTMLElement>;
|
|
5
|
-
|
|
6
|
-
export interface RoxyTarotCardProps extends Omit<DivAttrs, 'children' | 'onSelect'> {
|
|
7
|
-
data?: unknown;
|
|
8
|
-
[attr: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const RoxyTarotCard = React.forwardRef<HTMLElement, RoxyTarotCardProps>(
|
|
12
|
-
function RoxyTarotCard({ data, ...rest }, ref) {
|
|
13
|
-
const internal = React.useRef<HTMLElement | null>(null);
|
|
14
|
-
React.useImperativeHandle(ref, () => internal.current as HTMLElement);
|
|
15
|
-
const [loaded, setLoaded] = React.useState(false);
|
|
16
|
-
|
|
17
|
-
React.useEffect(() => {
|
|
18
|
-
let active = true;
|
|
19
|
-
ensureScriptLoaded().then(() => {
|
|
20
|
-
if (active) setLoaded(true);
|
|
21
|
-
});
|
|
22
|
-
return () => {
|
|
23
|
-
active = false;
|
|
24
|
-
};
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
if (internal.current && data !== undefined) {
|
|
29
|
-
(internal.current as unknown as { data: unknown }).data = data;
|
|
30
|
-
}
|
|
31
|
-
}, [data, loaded]);
|
|
32
|
-
|
|
33
|
-
return React.createElement('roxy-tarot-card', { ref: internal, ...rest });
|
|
34
|
-
},
|
|
35
|
-
);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
type DivAttrs = React.HTMLAttributes<HTMLElement>;
|
|
4
|
-
export interface RoxyTarotSpreadProps
|
|
5
|
-
extends Omit<DivAttrs, 'children' | 'onSelect'> {
|
|
6
|
-
data?: unknown;
|
|
7
|
-
[attr: string]: unknown;
|
|
8
|
-
}
|
|
9
|
-
export declare const RoxyTarotSpread: React.ForwardRefExoticComponent<
|
|
10
|
-
Omit<RoxyTarotSpreadProps, 'ref'> & React.RefAttributes<HTMLElement>
|
|
11
|
-
>;
|
|
12
|
-
//# sourceMappingURL=tarot-spread.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tarot-spread.d.ts","sourceRoot":"","sources":["tarot-spread.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,KAAK,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;AAElD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAAC;IACpF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,eAAe,uGAwB3B,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ensureScriptLoaded } from '../load-ui.js';
|
|
3
|
-
|
|
4
|
-
type DivAttrs = React.HTMLAttributes<HTMLElement>;
|
|
5
|
-
|
|
6
|
-
export interface RoxyTarotSpreadProps extends Omit<DivAttrs, 'children' | 'onSelect'> {
|
|
7
|
-
data?: unknown;
|
|
8
|
-
[attr: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const RoxyTarotSpread = React.forwardRef<HTMLElement, RoxyTarotSpreadProps>(
|
|
12
|
-
function RoxyTarotSpread({ data, ...rest }, ref) {
|
|
13
|
-
const internal = React.useRef<HTMLElement | null>(null);
|
|
14
|
-
React.useImperativeHandle(ref, () => internal.current as HTMLElement);
|
|
15
|
-
const [loaded, setLoaded] = React.useState(false);
|
|
16
|
-
|
|
17
|
-
React.useEffect(() => {
|
|
18
|
-
let active = true;
|
|
19
|
-
ensureScriptLoaded().then(() => {
|
|
20
|
-
if (active) setLoaded(true);
|
|
21
|
-
});
|
|
22
|
-
return () => {
|
|
23
|
-
active = false;
|
|
24
|
-
};
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
if (internal.current && data !== undefined) {
|
|
29
|
-
(internal.current as unknown as { data: unknown }).data = data;
|
|
30
|
-
}
|
|
31
|
-
}, [data, loaded]);
|
|
32
|
-
|
|
33
|
-
return React.createElement('roxy-tarot-spread', { ref: internal, ...rest });
|
|
34
|
-
},
|
|
35
|
-
);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
type DivAttrs = React.HTMLAttributes<HTMLElement>;
|
|
4
|
-
export interface RoxyVedicKundliProps
|
|
5
|
-
extends Omit<DivAttrs, 'children' | 'onSelect'> {
|
|
6
|
-
data?: unknown;
|
|
7
|
-
[attr: string]: unknown;
|
|
8
|
-
}
|
|
9
|
-
export declare const RoxyVedicKundli: React.ForwardRefExoticComponent<
|
|
10
|
-
Omit<RoxyVedicKundliProps, 'ref'> & React.RefAttributes<HTMLElement>
|
|
11
|
-
>;
|
|
12
|
-
//# sourceMappingURL=vedic-kundli.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vedic-kundli.d.ts","sourceRoot":"","sources":["vedic-kundli.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,KAAK,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;AAElD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,UAAU,CAAC;IACpF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,eAAe,uGAwB3B,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ensureScriptLoaded } from '../load-ui.js';
|
|
3
|
-
|
|
4
|
-
type DivAttrs = React.HTMLAttributes<HTMLElement>;
|
|
5
|
-
|
|
6
|
-
export interface RoxyVedicKundliProps extends Omit<DivAttrs, 'children' | 'onSelect'> {
|
|
7
|
-
data?: unknown;
|
|
8
|
-
[attr: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const RoxyVedicKundli = React.forwardRef<HTMLElement, RoxyVedicKundliProps>(
|
|
12
|
-
function RoxyVedicKundli({ data, ...rest }, ref) {
|
|
13
|
-
const internal = React.useRef<HTMLElement | null>(null);
|
|
14
|
-
React.useImperativeHandle(ref, () => internal.current as HTMLElement);
|
|
15
|
-
const [loaded, setLoaded] = React.useState(false);
|
|
16
|
-
|
|
17
|
-
React.useEffect(() => {
|
|
18
|
-
let active = true;
|
|
19
|
-
ensureScriptLoaded().then(() => {
|
|
20
|
-
if (active) setLoaded(true);
|
|
21
|
-
});
|
|
22
|
-
return () => {
|
|
23
|
-
active = false;
|
|
24
|
-
};
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
if (internal.current && data !== undefined) {
|
|
29
|
-
(internal.current as unknown as { data: unknown }).data = data;
|
|
30
|
-
}
|
|
31
|
-
}, [data, loaded]);
|
|
32
|
-
|
|
33
|
-
return React.createElement('roxy-vedic-kundli', { ref: internal, ...rest });
|
|
34
|
-
},
|
|
35
|
-
);
|
package/src/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export { RoxyBiorhythmChart } from './components/biorhythm-chart.js';
|
|
2
|
-
export { RoxyCompatibilityCard } from './components/compatibility-card.js';
|
|
3
|
-
export { RoxyDashaTimeline } from './components/dasha-timeline.js';
|
|
4
|
-
export { RoxyData } from './components/data.js';
|
|
5
|
-
export { RoxyDoshaCard } from './components/dosha-card.js';
|
|
6
|
-
export { RoxyEndpointForm } from './components/endpoint-form.js';
|
|
7
|
-
export { RoxyGunaMilan } from './components/guna-milan.js';
|
|
8
|
-
export { RoxyHexagram } from './components/hexagram.js';
|
|
9
|
-
export { RoxyHoroscopeCard } from './components/horoscope-card.js';
|
|
10
|
-
export { RoxyKpPlanetsTable } from './components/kp-planets-table.js';
|
|
11
|
-
export { RoxyLocationSearch } from './components/location-search.js';
|
|
12
|
-
export { RoxyMoonPhase } from './components/moon-phase.js';
|
|
13
|
-
export { RoxyNatalChart } from './components/natal-chart.js';
|
|
14
|
-
export { RoxyNumerologyCard } from './components/numerology-card.js';
|
|
15
|
-
export { RoxyPanchangTable } from './components/panchang-table.js';
|
|
16
|
-
export { RoxySynastryChart } from './components/synastry-chart.js';
|
|
17
|
-
export { RoxyTarotCard } from './components/tarot-card.js';
|
|
18
|
-
export { RoxyTarotSpread } from './components/tarot-spread.js';
|
|
19
|
-
export { RoxyVedicKundli } from './components/vedic-kundli.js';
|
|
20
|
-
export { ensureScriptLoaded } from './load-ui.js';
|
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
package/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
|
package/src/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export { ensureScriptLoaded } from './load-ui.js';
|
|
2
|
-
export { RoxyNatalChart } from './components/natal-chart.js';
|
|
3
|
-
export { RoxyHoroscopeCard } from './components/horoscope-card.js';
|
|
4
|
-
export { RoxySynastryChart } from './components/synastry-chart.js';
|
|
5
|
-
export { RoxyCompatibilityCard } from './components/compatibility-card.js';
|
|
6
|
-
export { RoxyMoonPhase } from './components/moon-phase.js';
|
|
7
|
-
export { RoxyVedicKundli } from './components/vedic-kundli.js';
|
|
8
|
-
export { RoxyPanchangTable } from './components/panchang-table.js';
|
|
9
|
-
export { RoxyDashaTimeline } from './components/dasha-timeline.js';
|
|
10
|
-
export { RoxyDoshaCard } from './components/dosha-card.js';
|
|
11
|
-
export { RoxyGunaMilan } from './components/guna-milan.js';
|
|
12
|
-
export { RoxyKpPlanetsTable } from './components/kp-planets-table.js';
|
|
13
|
-
export { RoxyNumerologyCard } from './components/numerology-card.js';
|
|
14
|
-
export { RoxyTarotCard } from './components/tarot-card.js';
|
|
15
|
-
export { RoxyTarotSpread } from './components/tarot-spread.js';
|
|
16
|
-
export { RoxyBiorhythmChart } from './components/biorhythm-chart.js';
|
|
17
|
-
export { RoxyHexagram } from './components/hexagram.js';
|
|
18
|
-
export { RoxyEndpointForm } from './components/endpoint-form.js';
|
|
19
|
-
export { RoxyLocationSearch } from './components/location-search.js';
|
|
20
|
-
export { RoxyData } from './components/data.js';
|
package/src/load-ui.d.ts
DELETED
package/src/load-ui.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load-ui.d.ts","sourceRoot":"","sources":["load-ui.ts"],"names":[],"mappings":"AAUA,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,MAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B3E"}
|
package/src/load-ui.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loads the matching component bundle on first mount. Idempotent across
|
|
3
|
-
* many components on the same page. Skips on the server (no document) so
|
|
4
|
-
* React server components and Next.js SSR work without a flash.
|
|
5
|
-
*/
|
|
6
|
-
const SCRIPT_ID = 'roxyapi-ui-loader';
|
|
7
|
-
const CDN_BASE = "https://cdn.jsdelivr.net/npm/@roxyapi/ui@0/dist/cdn";
|
|
8
|
-
|
|
9
|
-
let loaded: Promise<void> | null = null;
|
|
10
|
-
|
|
11
|
-
export function ensureScriptLoaded(version: string = '0.1.0'): Promise<void> {
|
|
12
|
-
if (typeof document === 'undefined') return Promise.resolve();
|
|
13
|
-
if (loaded) return loaded;
|
|
14
|
-
|
|
15
|
-
loaded = new Promise<void>((resolve, reject) => {
|
|
16
|
-
const major = version.split('.')[0];
|
|
17
|
-
const url = `${CDN_BASE.replace('@0', '@' + major)}/roxy-ui.js`;
|
|
18
|
-
let existing = document.getElementById(SCRIPT_ID) as HTMLScriptElement | null;
|
|
19
|
-
if (existing) {
|
|
20
|
-
if (existing.dataset.loaded === 'true') {
|
|
21
|
-
resolve();
|
|
22
|
-
} else {
|
|
23
|
-
existing.addEventListener('load', () => resolve());
|
|
24
|
-
existing.addEventListener('error', () => reject(new Error('roxy-ui load failed')));
|
|
25
|
-
}
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
existing = document.createElement('script');
|
|
29
|
-
existing.id = SCRIPT_ID;
|
|
30
|
-
existing.src = url;
|
|
31
|
-
existing.async = true;
|
|
32
|
-
existing.crossOrigin = 'anonymous';
|
|
33
|
-
existing.addEventListener('load', () => {
|
|
34
|
-
existing!.dataset.loaded = 'true';
|
|
35
|
-
resolve();
|
|
36
|
-
});
|
|
37
|
-
existing.addEventListener('error', () => reject(new Error('roxy-ui load failed')));
|
|
38
|
-
document.head.appendChild(existing);
|
|
39
|
-
});
|
|
40
|
-
return loaded;
|
|
41
|
-
}
|