@xrift/world-components 0.1.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.
@@ -0,0 +1,36 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface XRiftContextValue {
3
+ /**
4
+ * ワールドのベースURL(CDNのディレクトリパス)
5
+ * 例: 'https://assets.xrift.net/users/xxx/worlds/yyy/hash123/'
6
+ */
7
+ baseUrl: string;
8
+ }
9
+ /**
10
+ * XRift ワールドの情報を提供するContext
11
+ * ワールド側でこのContextを直接参照して情報を取得できる
12
+ */
13
+ export declare const XRiftContext: import("react").Context<XRiftContextValue | null>;
14
+ interface Props {
15
+ baseUrl: string;
16
+ children: ReactNode;
17
+ }
18
+ /**
19
+ * XRift ワールドの情報を提供するContextProvider
20
+ * Module Federationで動的にロードされたワールドコンポーネントに
21
+ * 必要な情報を注入するために使用
22
+ */
23
+ export declare const XRiftProvider: ({ baseUrl, children }: Props) => import("react/jsx-runtime").JSX.Element;
24
+ /**
25
+ * XRift ワールドの情報を取得するhook
26
+ * ワールドプロジェクト側でアセットの相対パスを絶対パスに変換する際に使用
27
+ *
28
+ * @example
29
+ * const { baseUrl } = useXRift()
30
+ * const gltf = useGLTF(baseUrl + 'assets/model.glb')
31
+ *
32
+ * @throws {Error} XRiftProvider の外で呼び出された場合
33
+ */
34
+ export declare const useXRift: () => XRiftContextValue;
35
+ export {};
36
+ //# sourceMappingURL=XRiftContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XRiftContext.d.ts","sourceRoot":"","sources":["../../src/contexts/XRiftContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAA;AAEjE,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;CAKhB;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,mDAAgD,CAAA;AAEzE,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,uBAAuB,KAAK,4CAMzD,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,QAAO,iBAQ3B,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from 'react';
3
+ /**
4
+ * XRift ワールドの情報を提供するContext
5
+ * ワールド側でこのContextを直接参照して情報を取得できる
6
+ */
7
+ export const XRiftContext = createContext(null);
8
+ /**
9
+ * XRift ワールドの情報を提供するContextProvider
10
+ * Module Federationで動的にロードされたワールドコンポーネントに
11
+ * 必要な情報を注入するために使用
12
+ */
13
+ export const XRiftProvider = ({ baseUrl, children }) => {
14
+ return (_jsx(XRiftContext.Provider, { value: { baseUrl }, children: children }));
15
+ };
16
+ /**
17
+ * XRift ワールドの情報を取得するhook
18
+ * ワールドプロジェクト側でアセットの相対パスを絶対パスに変換する際に使用
19
+ *
20
+ * @example
21
+ * const { baseUrl } = useXRift()
22
+ * const gltf = useGLTF(baseUrl + 'assets/model.glb')
23
+ *
24
+ * @throws {Error} XRiftProvider の外で呼び出された場合
25
+ */
26
+ export const useXRift = () => {
27
+ const context = useContext(XRiftContext);
28
+ if (!context) {
29
+ throw new Error('useXRift must be used within XRiftProvider');
30
+ }
31
+ return context;
32
+ };
33
+ //# sourceMappingURL=XRiftContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XRiftContext.js","sourceRoot":"","sources":["../../src/contexts/XRiftContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAA;AAcjE;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAA2B,IAAI,CAAC,CAAA;AAOzE;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAS,EAAE,EAAE;IAC5D,OAAO,CACL,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,OAAO,EAAE,YACtC,QAAQ,GACa,CACzB,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAsB,EAAE;IAC9C,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAA;IAExC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;IAC/D,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { XRiftContext, XRiftProvider, useXRift, type XRiftContextValue, } from './contexts/XRiftContext';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,KAAK,iBAAiB,GACvB,MAAM,yBAAyB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ // Contexts
2
+ export { XRiftContext, XRiftProvider, useXRift, } from './contexts/XRiftContext';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,EACL,YAAY,EACZ,aAAa,EACb,QAAQ,GAET,MAAM,yBAAyB,CAAA"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@xrift/world-components",
3
+ "version": "0.1.0",
4
+ "description": "Shared components and utilities for Xrift worlds",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc --watch",
13
+ "prepublishOnly": "npm run build"
14
+ },
15
+ "keywords": [
16
+ "xrift",
17
+ "react",
18
+ "three",
19
+ "webxr"
20
+ ],
21
+ "author": "WebXR-JP",
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/WebXR-JP/xrift-world-components.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/WebXR-JP/xrift-world-components/issues"
29
+ },
30
+ "homepage": "https://github.com/WebXR-JP/xrift-world-components#readme",
31
+ "peerDependencies": {
32
+ "react": "^18.0.0 || ^19.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/react": "^18.3.12",
36
+ "typescript": "^5.6.3"
37
+ }
38
+ }