@djangocfg/ext-base 1.0.0 → 1.0.2
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 +140 -176
- package/package.json +28 -12
- package/preview.png +0 -0
- package/src/cli/index.ts +274 -0
- package/src/config.ts +17 -0
- package/src/index.ts +2 -1
- package/src/metadata.ts +73 -0
- package/src/types/context.ts +124 -3
- package/src/utils/createExtensionConfig.ts +139 -0
- package/src/utils/index.ts +5 -0
- package/templates/extension-template/README.md.template +62 -0
- package/templates/extension-template/package.json.template +73 -0
- package/templates/extension-template/preview.png +0 -0
- package/templates/extension-template/src/components/.gitkeep +0 -0
- package/templates/extension-template/src/config.ts +35 -0
- package/templates/extension-template/src/contexts/__PROVIDER_NAME__Context.tsx +41 -0
- package/templates/extension-template/src/contexts/__PROVIDER_NAME__ExtensionProvider.tsx +36 -0
- package/templates/extension-template/src/hooks/index.ts +27 -0
- package/templates/extension-template/src/index.ts +17 -0
- package/templates/extension-template/src/types.ts +7 -0
- package/templates/extension-template/tsconfig.json +8 -0
- package/templates/extension-template/tsup.config.ts +26 -0
- package/dist/api.cjs +0 -41
- package/dist/api.d.cts +0 -35
- package/dist/api.d.ts +0 -35
- package/dist/api.js +0 -2
- package/dist/auth.cjs +0 -10
- package/dist/auth.d.cts +0 -1
- package/dist/auth.d.ts +0 -1
- package/dist/auth.js +0 -2
- package/dist/chunk-3RG5ZIWI.js +0 -8
- package/dist/chunk-MECBWZG4.js +0 -44
- package/dist/chunk-YQGNYUBX.js +0 -67
- package/dist/hooks.cjs +0 -190
- package/dist/hooks.d.cts +0 -96
- package/dist/hooks.d.ts +0 -96
- package/dist/hooks.js +0 -65
- package/dist/index.cjs +0 -131
- package/dist/index.d.cts +0 -246
- package/dist/index.d.ts +0 -246
- package/dist/index.js +0 -3
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
# @djangocfg/ext-__NAME__
|
|
8
|
+
|
|
9
|
+
__DESCRIPTION__
|
|
10
|
+
|
|
11
|
+
**Part of [DjangoCFG](https://djangocfg.com)** — modern Django framework for production-ready SaaS applications.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Feature 1
|
|
16
|
+
- Feature 2
|
|
17
|
+
- Feature 3
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @djangocfg/ext-__NAME__
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Provider Setup
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { __PROVIDER_NAME__ExtensionProvider } from '@djangocfg/ext-__NAME__/hooks';
|
|
31
|
+
|
|
32
|
+
export default function RootLayout({ children }) {
|
|
33
|
+
return (
|
|
34
|
+
<__PROVIDER_NAME__ExtensionProvider>
|
|
35
|
+
{children}
|
|
36
|
+
</__PROVIDER_NAME__ExtensionProvider>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Using Hooks
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
'use client';
|
|
45
|
+
|
|
46
|
+
import { use__PROVIDER_NAME__ } from '@djangocfg/ext-__NAME__/hooks';
|
|
47
|
+
|
|
48
|
+
export function MyComponent() {
|
|
49
|
+
const context = use__PROVIDER_NAME__();
|
|
50
|
+
|
|
51
|
+
return <div>Your component</div>;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
|
58
|
+
|
|
59
|
+
## Links
|
|
60
|
+
|
|
61
|
+
- [DjangoCFG Documentation](https://djangocfg.com)
|
|
62
|
+
- [GitHub](https://github.com/markolofsen/django-cfg)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@djangocfg/ext-__NAME__",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "__DESCRIPTION__",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"django",
|
|
7
|
+
"djangocfg",
|
|
8
|
+
"extension",
|
|
9
|
+
"__NAME__",
|
|
10
|
+
"typescript",
|
|
11
|
+
"react"
|
|
12
|
+
],
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "DjangoCFG",
|
|
15
|
+
"url": "https://djangocfg.com"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://djangocfg.com",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/markolofsen/django-cfg.git",
|
|
21
|
+
"directory": "extensions/__NAME__"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/markolofsen/django-cfg/issues"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.cjs",
|
|
29
|
+
"module": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./hooks": {
|
|
38
|
+
"types": "./dist/hooks.d.ts",
|
|
39
|
+
"import": "./dist/hooks.js",
|
|
40
|
+
"require": "./dist/hooks.cjs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"src",
|
|
46
|
+
"preview.png"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup",
|
|
50
|
+
"dev": "tsup --watch",
|
|
51
|
+
"check": "tsc --noEmit"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@djangocfg/ext-base": "latest",
|
|
55
|
+
"@djangocfg/ui-core": "latest",
|
|
56
|
+
"@djangocfg/ui-nextjs": "latest",
|
|
57
|
+
"consola": "^3.4.2",
|
|
58
|
+
"lucide-react": "^0.545.0",
|
|
59
|
+
"next": "^15.5.7",
|
|
60
|
+
"react": "^18 || ^19",
|
|
61
|
+
"swr": "^2.3.7"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@djangocfg/ext-base": "latest",
|
|
65
|
+
"@djangocfg/typescript-config": "latest",
|
|
66
|
+
"@types/node": "^24.7.2",
|
|
67
|
+
"@types/react": "^19.0.0",
|
|
68
|
+
"consola": "^3.4.2",
|
|
69
|
+
"swr": "^2.3.7",
|
|
70
|
+
"tsup": "^8.5.0",
|
|
71
|
+
"typescript": "^5.9.3"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* __DISPLAY_NAME__ extension configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createExtensionConfig } from '@djangocfg/ext-base';
|
|
6
|
+
import packageJson from '../package.json';
|
|
7
|
+
|
|
8
|
+
export const extensionConfig = createExtensionConfig(packageJson, {
|
|
9
|
+
name: '__NAME__',
|
|
10
|
+
displayName: '__DISPLAY_NAME__',
|
|
11
|
+
icon: '__ICON__',
|
|
12
|
+
category: '__CATEGORY__',
|
|
13
|
+
features: [
|
|
14
|
+
'Feature 1',
|
|
15
|
+
'Feature 2',
|
|
16
|
+
'Feature 3',
|
|
17
|
+
],
|
|
18
|
+
minVersion: '2.0.0',
|
|
19
|
+
examples: [
|
|
20
|
+
{
|
|
21
|
+
title: 'Basic Usage',
|
|
22
|
+
description: 'How to use this extension',
|
|
23
|
+
code: `import { __PROVIDER_NAME__ExtensionProvider } from '@djangocfg/ext-__NAME__/hooks';
|
|
24
|
+
|
|
25
|
+
export default function RootLayout({ children }) {
|
|
26
|
+
return (
|
|
27
|
+
<__PROVIDER_NAME__ExtensionProvider>
|
|
28
|
+
{children}
|
|
29
|
+
</__PROVIDER_NAME__ExtensionProvider>
|
|
30
|
+
);
|
|
31
|
+
}`,
|
|
32
|
+
language: 'tsx',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Main __DISPLAY_NAME__ Context
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { createContext, useContext, type ReactNode } from 'react';
|
|
8
|
+
|
|
9
|
+
interface __PROVIDER_NAME__ContextValue {
|
|
10
|
+
// Add your context values here
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const __PROVIDER_NAME__Context = createContext<__PROVIDER_NAME__ContextValue | undefined>(undefined);
|
|
14
|
+
|
|
15
|
+
export interface __PROVIDER_NAME__ProviderProps {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function __PROVIDER_NAME__Provider({ children }: __PROVIDER_NAME__ProviderProps) {
|
|
20
|
+
const value: __PROVIDER_NAME__ContextValue = {
|
|
21
|
+
// Implement your context logic here
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<__PROVIDER_NAME__Context.Provider value={value}>
|
|
26
|
+
{children}
|
|
27
|
+
</__PROVIDER_NAME__Context.Provider>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function use__PROVIDER_NAME__() {
|
|
32
|
+
const context = useContext(__PROVIDER_NAME__Context);
|
|
33
|
+
if (context === undefined) {
|
|
34
|
+
throw new Error('use__PROVIDER_NAME__ must be used within __PROVIDER_NAME__Provider');
|
|
35
|
+
}
|
|
36
|
+
return context;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function use__PROVIDER_NAME__Optional() {
|
|
40
|
+
return useContext(__PROVIDER_NAME__Context);
|
|
41
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main __DISPLAY_NAME__ Extension Provider
|
|
3
|
+
*
|
|
4
|
+
* Wraps all contexts with ExtensionProvider for proper registration
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use client';
|
|
8
|
+
|
|
9
|
+
import type { ReactNode } from 'react';
|
|
10
|
+
import { ExtensionProvider } from '@djangocfg/ext-base/hooks';
|
|
11
|
+
import { extensionConfig } from '../config';
|
|
12
|
+
import { __PROVIDER_NAME__Provider } from './__PROVIDER_NAME__Context';
|
|
13
|
+
|
|
14
|
+
interface __PROVIDER_NAME__ExtensionProviderProps {
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Main provider for __DISPLAY_NAME__ extension
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <__PROVIDER_NAME__ExtensionProvider>
|
|
24
|
+
* <YourApp />
|
|
25
|
+
* </__PROVIDER_NAME__ExtensionProvider>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function __PROVIDER_NAME__ExtensionProvider({ children }: __PROVIDER_NAME__ExtensionProviderProps) {
|
|
29
|
+
return (
|
|
30
|
+
<ExtensionProvider metadata={extensionConfig}>
|
|
31
|
+
<__PROVIDER_NAME__Provider>
|
|
32
|
+
{children}
|
|
33
|
+
</__PROVIDER_NAME__Provider>
|
|
34
|
+
</ExtensionProvider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @djangocfg/ext-__NAME__/hooks
|
|
5
|
+
* React hooks and client-only components
|
|
6
|
+
*
|
|
7
|
+
* This entry point includes React components, hooks, and SWR functionality.
|
|
8
|
+
* NOT safe for Server Components.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Re-export everything from main entry (types, constants)
|
|
13
|
+
// ============================================================================
|
|
14
|
+
export * from '../index';
|
|
15
|
+
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Contexts & Hooks
|
|
18
|
+
// ============================================================================
|
|
19
|
+
export {
|
|
20
|
+
__PROVIDER_NAME__ExtensionProvider,
|
|
21
|
+
} from '../contexts/__PROVIDER_NAME__ExtensionProvider';
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
__PROVIDER_NAME__Provider,
|
|
25
|
+
use__PROVIDER_NAME__,
|
|
26
|
+
use__PROVIDER_NAME__Optional,
|
|
27
|
+
} from '../contexts/__PROVIDER_NAME__Context';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @djangocfg/ext-__NAME__
|
|
3
|
+
* Server-safe entry point (no client-only code)
|
|
4
|
+
*
|
|
5
|
+
* Contains types and server-safe exports only.
|
|
6
|
+
* For React hooks and SWR, use '@djangocfg/ext-__NAME__/hooks'
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Config
|
|
11
|
+
// ============================================================================
|
|
12
|
+
export { extensionConfig } from './config';
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Types
|
|
16
|
+
// ============================================================================
|
|
17
|
+
export type * from './types';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: {
|
|
5
|
+
index: 'src/index.ts',
|
|
6
|
+
hooks: 'src/hooks/index.ts',
|
|
7
|
+
},
|
|
8
|
+
format: ['esm', 'cjs'],
|
|
9
|
+
dts: true,
|
|
10
|
+
splitting: false,
|
|
11
|
+
sourcemap: true,
|
|
12
|
+
clean: true,
|
|
13
|
+
external: [
|
|
14
|
+
'react',
|
|
15
|
+
'react-dom',
|
|
16
|
+
'next',
|
|
17
|
+
'lucide-react',
|
|
18
|
+
'@djangocfg/ext-base',
|
|
19
|
+
'@djangocfg/ui-nextjs',
|
|
20
|
+
'swr',
|
|
21
|
+
'consola',
|
|
22
|
+
],
|
|
23
|
+
banner: {
|
|
24
|
+
js: "'use client';",
|
|
25
|
+
},
|
|
26
|
+
});
|
package/dist/api.cjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
|
-
}) : x)(function(x) {
|
|
6
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
// src/config/env.ts
|
|
11
|
-
process.env.NODE_ENV === "development";
|
|
12
|
-
process.env.NODE_ENV === "production";
|
|
13
|
-
process.env.NODE_ENV === "test";
|
|
14
|
-
var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
|
|
15
|
-
var getApiUrl = () => {
|
|
16
|
-
return process.env.NEXT_PUBLIC_API_URL || "";
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// src/api/createExtensionAPI.ts
|
|
20
|
-
function createExtensionAPI(APIClass) {
|
|
21
|
-
let storage;
|
|
22
|
-
try {
|
|
23
|
-
const { api: accountsApi } = __require("@djangocfg/api");
|
|
24
|
-
storage = accountsApi._storage;
|
|
25
|
-
} catch (error) {
|
|
26
|
-
storage = void 0;
|
|
27
|
-
}
|
|
28
|
-
const apiUrl = isStaticBuild ? "" : getApiUrl();
|
|
29
|
-
return new APIClass(apiUrl, storage ? { storage } : void 0);
|
|
30
|
-
}
|
|
31
|
-
function getSharedAuthStorage() {
|
|
32
|
-
try {
|
|
33
|
-
const { api: accountsApi } = __require("@djangocfg/api");
|
|
34
|
-
return accountsApi._storage;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
return void 0;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.createExtensionAPI = createExtensionAPI;
|
|
41
|
-
exports.getSharedAuthStorage = getSharedAuthStorage;
|
package/dist/api.d.cts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Factory for creating extension API instances
|
|
3
|
-
*
|
|
4
|
-
* Provides consistent API setup across all extensions with shared authentication
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Creates an extension API instance with shared authentication storage
|
|
8
|
-
*
|
|
9
|
-
* @param APIClass - The generated API class from your extension
|
|
10
|
-
* @returns Configured API instance with shared auth storage
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // In your extension's api/index.ts
|
|
15
|
-
* import { API } from './generated/ext_newsletter';
|
|
16
|
-
* import { createExtensionAPI } from '@djangocfg/ext-base/api';
|
|
17
|
-
*
|
|
18
|
-
* export const apiNewsletter = createExtensionAPI(API);
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
declare function createExtensionAPI<T>(APIClass: new (url: string, options?: any) => T): T;
|
|
22
|
-
/**
|
|
23
|
-
* Get shared authentication storage from accounts API
|
|
24
|
-
*
|
|
25
|
-
* @returns Storage instance or undefined if not available
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const storage = getSharedAuthStorage();
|
|
30
|
-
* const api = new API(apiUrl, { storage });
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare function getSharedAuthStorage(): any | undefined;
|
|
34
|
-
|
|
35
|
-
export { createExtensionAPI, getSharedAuthStorage };
|
package/dist/api.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Factory for creating extension API instances
|
|
3
|
-
*
|
|
4
|
-
* Provides consistent API setup across all extensions with shared authentication
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Creates an extension API instance with shared authentication storage
|
|
8
|
-
*
|
|
9
|
-
* @param APIClass - The generated API class from your extension
|
|
10
|
-
* @returns Configured API instance with shared auth storage
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // In your extension's api/index.ts
|
|
15
|
-
* import { API } from './generated/ext_newsletter';
|
|
16
|
-
* import { createExtensionAPI } from '@djangocfg/ext-base/api';
|
|
17
|
-
*
|
|
18
|
-
* export const apiNewsletter = createExtensionAPI(API);
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
declare function createExtensionAPI<T>(APIClass: new (url: string, options?: any) => T): T;
|
|
22
|
-
/**
|
|
23
|
-
* Get shared authentication storage from accounts API
|
|
24
|
-
*
|
|
25
|
-
* @returns Storage instance or undefined if not available
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const storage = getSharedAuthStorage();
|
|
30
|
-
* const api = new API(apiUrl, { storage });
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare function getSharedAuthStorage(): any | undefined;
|
|
34
|
-
|
|
35
|
-
export { createExtensionAPI, getSharedAuthStorage };
|
package/dist/api.js
DELETED
package/dist/auth.cjs
DELETED
package/dist/auth.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AuthContextType, UserProfile, useAuth } from '@djangocfg/api/auth';
|
package/dist/auth.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { AuthContextType, UserProfile, useAuth } from '@djangocfg/api/auth';
|
package/dist/auth.js
DELETED
package/dist/chunk-3RG5ZIWI.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export { __require };
|
package/dist/chunk-MECBWZG4.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { __require } from './chunk-3RG5ZIWI.js';
|
|
2
|
-
|
|
3
|
-
// src/config/env.ts
|
|
4
|
-
var isDevelopment = process.env.NODE_ENV === "development";
|
|
5
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
6
|
-
var isTest = process.env.NODE_ENV === "test";
|
|
7
|
-
var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
|
|
8
|
-
var isClient = typeof window !== "undefined";
|
|
9
|
-
var isServer = !isClient;
|
|
10
|
-
var getApiUrl = () => {
|
|
11
|
-
return process.env.NEXT_PUBLIC_API_URL || "";
|
|
12
|
-
};
|
|
13
|
-
var env = {
|
|
14
|
-
isDevelopment,
|
|
15
|
-
isProduction,
|
|
16
|
-
isTest,
|
|
17
|
-
isStaticBuild,
|
|
18
|
-
isClient,
|
|
19
|
-
isServer,
|
|
20
|
-
getApiUrl
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// src/api/createExtensionAPI.ts
|
|
24
|
-
function createExtensionAPI(APIClass) {
|
|
25
|
-
let storage;
|
|
26
|
-
try {
|
|
27
|
-
const { api: accountsApi } = __require("@djangocfg/api");
|
|
28
|
-
storage = accountsApi._storage;
|
|
29
|
-
} catch (error) {
|
|
30
|
-
storage = void 0;
|
|
31
|
-
}
|
|
32
|
-
const apiUrl = isStaticBuild ? "" : getApiUrl();
|
|
33
|
-
return new APIClass(apiUrl, storage ? { storage } : void 0);
|
|
34
|
-
}
|
|
35
|
-
function getSharedAuthStorage() {
|
|
36
|
-
try {
|
|
37
|
-
const { api: accountsApi } = __require("@djangocfg/api");
|
|
38
|
-
return accountsApi._storage;
|
|
39
|
-
} catch (error) {
|
|
40
|
-
return void 0;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { createExtensionAPI, env, getApiUrl, getSharedAuthStorage, isClient, isDevelopment, isProduction, isServer, isStaticBuild, isTest };
|
package/dist/chunk-YQGNYUBX.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { createConsola } from 'consola';
|
|
2
|
-
|
|
3
|
-
// src/utils/errors.ts
|
|
4
|
-
function isExtensionError(error) {
|
|
5
|
-
return typeof error === "object" && error !== null && "message" in error && "timestamp" in error;
|
|
6
|
-
}
|
|
7
|
-
function createExtensionError(error, code, details) {
|
|
8
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
9
|
-
return {
|
|
10
|
-
message,
|
|
11
|
-
code,
|
|
12
|
-
details,
|
|
13
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function formatErrorMessage(error) {
|
|
17
|
-
if (isExtensionError(error)) {
|
|
18
|
-
return error.code ? `[${error.code}] ${error.message}` : error.message;
|
|
19
|
-
}
|
|
20
|
-
if (error instanceof Error) {
|
|
21
|
-
return error.message;
|
|
22
|
-
}
|
|
23
|
-
return String(error);
|
|
24
|
-
}
|
|
25
|
-
function handleExtensionError(error, logger, callback) {
|
|
26
|
-
const extensionError = isExtensionError(error) ? error : createExtensionError(error);
|
|
27
|
-
if (logger) {
|
|
28
|
-
logger.error("Extension error:", extensionError);
|
|
29
|
-
}
|
|
30
|
-
if (callback) {
|
|
31
|
-
callback(extensionError);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
var isDevelopment = process.env.NODE_ENV === "development";
|
|
35
|
-
var LEVEL_MAP = {
|
|
36
|
-
debug: 4,
|
|
37
|
-
info: 3,
|
|
38
|
-
warn: 2,
|
|
39
|
-
error: 1
|
|
40
|
-
};
|
|
41
|
-
function createExtensionLogger(options) {
|
|
42
|
-
const { tag, level = "info", enabled = true } = options;
|
|
43
|
-
if (!enabled) {
|
|
44
|
-
const noop = () => {
|
|
45
|
-
};
|
|
46
|
-
return {
|
|
47
|
-
info: noop,
|
|
48
|
-
warn: noop,
|
|
49
|
-
error: noop,
|
|
50
|
-
debug: noop,
|
|
51
|
-
success: noop
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const logLevel = isDevelopment ? LEVEL_MAP[level] : LEVEL_MAP.error;
|
|
55
|
-
const consola = createConsola({
|
|
56
|
-
level: logLevel
|
|
57
|
-
}).withTag(tag);
|
|
58
|
-
return {
|
|
59
|
-
info: (...args) => consola.info(...args),
|
|
60
|
-
warn: (...args) => consola.warn(...args),
|
|
61
|
-
error: (...args) => consola.error(...args),
|
|
62
|
-
debug: (...args) => consola.debug(...args),
|
|
63
|
-
success: (...args) => consola.success(...args)
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export { createExtensionError, createExtensionLogger, formatErrorMessage, handleExtensionError, isExtensionError };
|