Explorar el Código

fix: infer props for newly created script

tophf hace 2 semanas
padre
commit
8bcddf7e8c
Se han modificado 3 ficheros con 4 adiciones y 1 borrados
  1. 1 0
      src/background/utils/db.js
  2. 2 1
      src/options/views/edit/index.vue
  3. 1 0
      src/types.d.ts

+ 1 - 0
src/background/utils/db.js

@@ -688,6 +688,7 @@ export async function parseScript(src) {
     [S_SCRIPT_PRE + id]: script,
     ...codeChanged && { [S_CODE_PRE + id]: code },
   });
+  if (src[INFERRED]) inferScriptProps(script);
   Object.assign(update, script, srcUpdate);
   result.where = { id };
   result[S_CODE] = src[S_CODE];

+ 2 - 1
src/options/views/edit/index.vue

@@ -96,7 +96,7 @@ import {
   debounce, formatByteLength, getScriptName, getScriptUpdateUrl, i18n, isEmpty,
   nullBool2string, sendCmdDirectly, trueJoin,
 } from '@/common';
-import { ERR_BAD_PATTERN, VM_DOCS_MATCHING, VM_HOME } from '@/common/consts';
+import { ERR_BAD_PATTERN, INFERRED, VM_DOCS_MATCHING, VM_HOME } from '@/common/consts';
 import { deepCopy, deepEqual, objectPick } from '@/common/object';
 import { externalEditorInfoUrl, focusMe, getActiveElement, showMessage } from '@/common/ui';
 import { keyboardService } from '@/common/keyboard';
@@ -337,6 +337,7 @@ async function save() {
       isNew: !id,
       message: '',
       bumpDate: true,
+      [INFERRED]: true,
     });
     const newId = res?.where?.id;
     CM.markClean();

+ 1 - 0
src/types.d.ts

@@ -242,6 +242,7 @@ declare interface VMScriptSourceOptions extends DeepPartial<Omit<VMScript, 'infe
 
   bumpDate?: boolean;
   fetchOpts?: object;
+  inferred?: boolean;
   message?: string;
   portId?: string;
   reloadTab?: boolean;