@unmap/nuxt 0.0.1
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/dist/module.d.ts +45 -0
- package/dist/module.js +37 -0
- package/dist/module.js.map +1 -0
- package/package.json +38 -0
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/** unmap publishable key (um_live_... / um_test_...). */
|
|
5
|
+
key?: string;
|
|
6
|
+
/** Gateway base URL. Defaults to the public unmap gateway. */
|
|
7
|
+
gateway?: string;
|
|
8
|
+
}
|
|
9
|
+
interface NormalizedOptions {
|
|
10
|
+
key: string;
|
|
11
|
+
gateway: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Fold module options into the public runtime-config shape, applying the default
|
|
15
|
+
* gateway and trimming trailing slashes. Pure and Nuxt-free, so it can be unit
|
|
16
|
+
* tested without booting a Nuxt app.
|
|
17
|
+
*/
|
|
18
|
+
declare function normalizeOptions(options?: ModuleOptions): NormalizedOptions;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Nuxt 3 module for unmap. Adds public runtime config `unmap: { key, gateway }`
|
|
22
|
+
* (overridable via `NUXT_PUBLIC_UNMAP_KEY` / `NUXT_PUBLIC_UNMAP_GATEWAY`) and
|
|
23
|
+
* auto-imports the `@unmap/vue` composables.
|
|
24
|
+
*
|
|
25
|
+
* // nuxt.config.ts
|
|
26
|
+
* export default defineNuxtConfig({
|
|
27
|
+
* modules: ["@unmap/nuxt"],
|
|
28
|
+
* unmap: { key: "um_live_..." },
|
|
29
|
+
* });
|
|
30
|
+
*/
|
|
31
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
32
|
+
|
|
33
|
+
declare module "@nuxt/schema" {
|
|
34
|
+
interface PublicRuntimeConfig {
|
|
35
|
+
unmap: {
|
|
36
|
+
key: string;
|
|
37
|
+
gateway: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface ConfigSchema {
|
|
41
|
+
unmap?: ModuleOptions;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { type ModuleOptions, type NormalizedOptions, _default as default, normalizeOptions };
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/module.ts
|
|
2
|
+
import { defineNuxtModule, addImportsSources } from "@nuxt/kit";
|
|
3
|
+
|
|
4
|
+
// src/options.ts
|
|
5
|
+
import { DEFAULT_GATEWAY } from "@unmap/core";
|
|
6
|
+
function normalizeOptions(options = {}) {
|
|
7
|
+
const gateway = (options.gateway?.trim() || DEFAULT_GATEWAY).replace(/\/+$/, "");
|
|
8
|
+
return { key: options.key?.trim() ?? "", gateway };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/module.ts
|
|
12
|
+
var UNMAP_VUE_IMPORTS = ["useUnmap", "useGeocoder", "useDirections"];
|
|
13
|
+
var module_default = defineNuxtModule({
|
|
14
|
+
meta: {
|
|
15
|
+
name: "@unmap/nuxt",
|
|
16
|
+
configKey: "unmap",
|
|
17
|
+
compatibility: { nuxt: ">=3.13.0" }
|
|
18
|
+
},
|
|
19
|
+
defaults: {},
|
|
20
|
+
setup(options, nuxt) {
|
|
21
|
+
const normalized = normalizeOptions(options);
|
|
22
|
+
nuxt.options.runtimeConfig.public.unmap = {
|
|
23
|
+
...nuxt.options.runtimeConfig.public.unmap,
|
|
24
|
+
key: normalized.key,
|
|
25
|
+
gateway: normalized.gateway
|
|
26
|
+
};
|
|
27
|
+
addImportsSources({
|
|
28
|
+
from: "@unmap/vue",
|
|
29
|
+
imports: [...UNMAP_VUE_IMPORTS]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
export {
|
|
34
|
+
module_default as default,
|
|
35
|
+
normalizeOptions
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/module.ts","../src/options.ts"],"sourcesContent":["import { defineNuxtModule, addImportsSources } from \"@nuxt/kit\";\nimport { normalizeOptions, type ModuleOptions } from \"./options\";\n\nexport type { ModuleOptions, NormalizedOptions } from \"./options\";\nexport { normalizeOptions } from \"./options\";\n\n/** Composables re-exported from `@unmap/vue`, auto-imported into every component. */\nconst UNMAP_VUE_IMPORTS = [\"useUnmap\", \"useGeocoder\", \"useDirections\"] as const;\n\n/**\n * Nuxt 3 module for unmap. Adds public runtime config `unmap: { key, gateway }`\n * (overridable via `NUXT_PUBLIC_UNMAP_KEY` / `NUXT_PUBLIC_UNMAP_GATEWAY`) and\n * auto-imports the `@unmap/vue` composables.\n *\n * // nuxt.config.ts\n * export default defineNuxtConfig({\n * modules: [\"@unmap/nuxt\"],\n * unmap: { key: \"um_live_...\" },\n * });\n */\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: \"@unmap/nuxt\",\n configKey: \"unmap\",\n compatibility: { nuxt: \">=3.13.0\" },\n },\n defaults: {},\n setup(options, nuxt) {\n const normalized = normalizeOptions(options);\n\n // Publish to public runtime config so the key/gateway reach the client.\n nuxt.options.runtimeConfig.public.unmap = {\n ...(nuxt.options.runtimeConfig.public.unmap as Record<string, unknown> | undefined),\n key: normalized.key,\n gateway: normalized.gateway,\n };\n\n // Auto-import the Vue composables from the published package.\n addImportsSources({\n from: \"@unmap/vue\",\n imports: [...UNMAP_VUE_IMPORTS],\n });\n },\n});\n\ndeclare module \"@nuxt/schema\" {\n interface PublicRuntimeConfig {\n unmap: { key: string; gateway: string };\n }\n interface ConfigSchema {\n unmap?: ModuleOptions;\n }\n}\n","import { DEFAULT_GATEWAY } from \"@unmap/core\";\n\nexport interface ModuleOptions {\n /** unmap publishable key (um_live_... / um_test_...). */\n key?: string;\n /** Gateway base URL. Defaults to the public unmap gateway. */\n gateway?: string;\n}\n\nexport interface NormalizedOptions {\n key: string;\n gateway: string;\n}\n\n/**\n * Fold module options into the public runtime-config shape, applying the default\n * gateway and trimming trailing slashes. Pure and Nuxt-free, so it can be unit\n * tested without booting a Nuxt app.\n */\nexport function normalizeOptions(options: ModuleOptions = {}): NormalizedOptions {\n const gateway = (options.gateway?.trim() || DEFAULT_GATEWAY).replace(/\\/+$/, \"\");\n return { key: options.key?.trim() ?? \"\", gateway };\n}\n"],"mappings":";AAAA,SAAS,kBAAkB,yBAAyB;;;ACApD,SAAS,uBAAuB;AAmBzB,SAAS,iBAAiB,UAAyB,CAAC,GAAsB;AAC/E,QAAM,WAAW,QAAQ,SAAS,KAAK,KAAK,iBAAiB,QAAQ,QAAQ,EAAE;AAC/E,SAAO,EAAE,KAAK,QAAQ,KAAK,KAAK,KAAK,IAAI,QAAQ;AACnD;;;ADfA,IAAM,oBAAoB,CAAC,YAAY,eAAe,eAAe;AAarE,IAAO,iBAAQ,iBAAgC;AAAA,EAC7C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,WAAW;AAAA,IACX,eAAe,EAAE,MAAM,WAAW;AAAA,EACpC;AAAA,EACA,UAAU,CAAC;AAAA,EACX,MAAM,SAAS,MAAM;AACnB,UAAM,aAAa,iBAAiB,OAAO;AAG3C,SAAK,QAAQ,cAAc,OAAO,QAAQ;AAAA,MACxC,GAAI,KAAK,QAAQ,cAAc,OAAO;AAAA,MACtC,KAAK,WAAW;AAAA,MAChB,SAAS,WAAW;AAAA,IACtB;AAGA,sBAAkB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS,CAAC,GAAG,iBAAiB;AAAA,IAChC,CAAC;AAAA,EACH;AACF,CAAC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unmap/nuxt",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Nuxt 3 module for unmap: runtime config + auto-imported @unmap/vue composables",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/module.js",
|
|
7
|
+
"module": "./dist/module.js",
|
|
8
|
+
"types": "./dist/module.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/module.d.ts",
|
|
12
|
+
"import": "./dist/module.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@nuxt/kit": "^3.13.0",
|
|
24
|
+
"@unmap/core": "0.0.1",
|
|
25
|
+
"@unmap/vue": "0.0.1"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@nuxt/schema": "^3.13.0",
|
|
29
|
+
"tsup": "^8.3.0",
|
|
30
|
+
"typescript": "^5.6.0",
|
|
31
|
+
"vitest": "^2.1.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"typecheck": "tsc --noEmit"
|
|
37
|
+
}
|
|
38
|
+
}
|