@shwfed/nuxt 0.1.37 → 0.1.39

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.mts CHANGED
@@ -6,9 +6,6 @@ interface ModuleOptions {
6
6
  * DSL
7
7
  */
8
8
  headers?: string;
9
- /**
10
- * DSL
11
- */
12
9
  baseURL: string;
13
10
  }>;
14
11
  }
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
3
  "configKey": "shwfed",
4
- "version": "0.1.37",
4
+ "version": "0.1.39",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,23 +1,16 @@
1
- import { defineNuxtPlugin, useNuxtApp } from "#app";
1
+ import { defineNuxtPlugin, useNuxtApp, useRuntimeConfig } from "#app";
2
2
  import z from "zod";
3
3
  export default defineNuxtPlugin({
4
4
  name: "shwfed-nuxt:api",
5
5
  dependsOn: ["shwfed-nuxt:cel"],
6
6
  setup: (nuxt) => {
7
+ const config = useRuntimeConfig().public.shwfed;
7
8
  const { $dsl } = useNuxtApp();
8
9
  const api = $fetch.create({
10
+ baseURL: config.apis.baseURL,
9
11
  onRequest: ({
10
12
  options
11
13
  }) => {
12
- if (options.baseURL === "/") {
13
- try {
14
- const baseURL = $dsl.evaluate`${nuxt.$config.public.shwfed.apis.baseURL}`();
15
- if (typeof baseURL === "string") {
16
- options.baseURL = baseURL;
17
- }
18
- } catch {
19
- }
20
- }
21
14
  if (nuxt.$config.public.shwfed.apis.headers) {
22
15
  try {
23
16
  const headers = $dsl.evaluate`${nuxt.$config.public.shwfed.apis.headers}`();
@@ -88,6 +88,10 @@ export function createEnvironment() {
88
88
  return number.toLocaleString(navigator.language, options);
89
89
  }).registerFunction("parseJSON(string): dyn", (string) => {
90
90
  return JSON.parse(string);
91
+ }).registerFunction("string.slice(int): string", (s, start) => {
92
+ return s.slice(Number(start));
93
+ }).registerFunction("string.slice(int, int): string", (s, start, end) => {
94
+ return s.slice(Number(start), Number(end));
91
95
  }).registerFunction("session(string): optional<string>", (key) => {
92
96
  if (typeof window === "undefined") return Optional.none();
93
97
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",