@monkeyplus/flow 5.0.0-rc.106 → 5.0.0-rc.108

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.
@@ -17,7 +17,7 @@ export default async (runtimeConfig) => {
17
17
  });
18
18
  };
19
19
  } catch (err) {
20
- console.log(err);
20
+ console.error(err);
21
21
  }
22
22
  return flow;
23
23
  };
@@ -44,6 +44,7 @@ export interface FlowApp {
44
44
  render: (view: Record<string, string>, data: any) => Promise<string> | void | string;
45
45
  provide: (name: string, value: any) => void;
46
46
  setUtil: (name: string, value: any) => void;
47
+ $config: RuntimeConfig;
47
48
  [key: string]: any;
48
49
  }
49
50
  export declare const FlowPluginIndicator = "__flow_plugin";
@@ -6,12 +6,42 @@ import { genObjectFromRawEntries, genDynamicImport } from 'knitwork';
6
6
  import fse from 'fs-extra';
7
7
  import { debounce } from 'perfect-debounce';
8
8
  import { isIgnoredFlow, logger } from '@monkeyplus/flow-kit';
9
- import { h as hashId, c as createIsExternal, u as uniq, i as isCSS } from './external.mjs';
9
+ import { hash } from 'ohash';
10
+ import { ExternalsDefaults, isExternal } from 'externality';
10
11
  import { withTrailingSlash, withoutLeadingSlash } from 'ufo';
11
12
  import escapeRE from 'escape-string-regexp';
12
13
  import { normalizeViteManifest } from 'vue-bundle-renderer';
13
- import 'ohash';
14
- import 'externality';
14
+
15
+ function uniq(arr) {
16
+ return Array.from(new Set(arr));
17
+ }
18
+ const IS_CSS_RE = /\.(?:css|scss|sass|postcss|less|stylus|styl)(\?[^.]+)?$/;
19
+ function isCSS(file) {
20
+ return IS_CSS_RE.test(file);
21
+ }
22
+ function hashId(id) {
23
+ return `$id_${hash(id)}`;
24
+ }
25
+
26
+ function createIsExternal(viteServer, rootDir) {
27
+ const externalOpts = {
28
+ inline: [
29
+ /virtual:/,
30
+ /\.ts$/,
31
+ ...ExternalsDefaults.inline || [],
32
+ ...viteServer.config.ssr.noExternal
33
+ ],
34
+ external: [
35
+ ...viteServer.config.ssr.external || [],
36
+ /node_modules/
37
+ ],
38
+ resolve: {
39
+ type: "module",
40
+ extensions: [".ts", ".js", ".json", ".vue", ".mjs", ".jsx", ".tsx", ".wasm"]
41
+ }
42
+ };
43
+ return (id) => isExternal(id, rootDir, externalOpts);
44
+ }
15
45
 
16
46
  async function writeManifest(ctx, css = []) {
17
47
  const clientDist = resolve(ctx.nuxt.options.buildDir, "dist/client");
@@ -1,3 +1,4 @@
1
1
  import 'node-fetch-native/polyfill';
2
+ export declare const getFlowRenderer: () => Promise<any>;
2
3
  declare const _default: import("h3").EventHandler<void>;
3
4
  export default _default;
@@ -1,18 +1,18 @@
1
1
  import "node-fetch-native/polyfill";
2
- import { defineEventHandler } from "h3";
2
+ import { eventHandler } from "h3";
3
3
  import { defineCachedFunction, useRuntimeConfig } from "#internal/nitro";
4
4
  const getServerApp = cachedImport(() => import("#server"));
5
- const getFlowRenderer = cachedResult(async () => {
5
+ export const getFlowRenderer = cachedResult(async () => {
6
6
  const createFlowApp = await getServerApp();
7
7
  if (!createFlowApp)
8
8
  throw new Error("Server bundle is not available");
9
9
  return createFlowApp(useRuntimeConfig());
10
10
  });
11
- export default defineEventHandler(async ({ context }) => {
11
+ export default eventHandler(async (event) => {
12
12
  const flow = await getFlowRenderer();
13
- context.flow = flow;
14
- context.render = flow.render;
15
- context.defineCachedFunction = defineCachedFunction;
13
+ event.context.flow = flow;
14
+ event.context.render = flow.render;
15
+ event.context.defineCachedFunction = defineCachedFunction;
16
16
  });
17
17
  function _interopDefault(e) {
18
18
  return e && typeof e === "object" && "default" in e ? e.default : e;
@@ -1,4 +1,4 @@
1
- import { eventHandler, useQuery } from "h3";
1
+ import { eventHandler, getQuery } from "h3";
2
2
  import { joinURL } from "ufo";
3
3
  const normalizeCall = async (seo, ctx) => {
4
4
  if (typeof seo === "function")
@@ -98,7 +98,7 @@ export default eventHandler(async (event) => {
98
98
  templateContext.getInjectContext = () => {
99
99
  return `<script id="__FLOW_DATA__" type="application/json">${JSON.stringify(contextInject)}<\/script>`;
100
100
  };
101
- const query = useQuery(event);
101
+ const query = getQuery(event);
102
102
  if (query?.context)
103
103
  return { ...templateContext, utils: Object.keys(utils) };
104
104
  let html;