@next-core/runtime 1.46.0 → 1.47.0
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.
|
@@ -32,7 +32,7 @@ function StoryboardFunctionRegistryFactory({
|
|
|
32
32
|
|
|
33
33
|
// Use `Proxy` with a frozen target, to make a readonly function registry.
|
|
34
34
|
const storyboardFunctions = new Proxy(Object.freeze({}), {
|
|
35
|
-
get(
|
|
35
|
+
get(_target, key) {
|
|
36
36
|
return getStoryboardFunction(key);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
@@ -89,7 +89,8 @@ function StoryboardFunctionRegistryFactory({
|
|
|
89
89
|
beforeEvaluate: collector.beforeEvaluate,
|
|
90
90
|
beforeCall: collector.beforeCall,
|
|
91
91
|
beforeBranch: collector.beforeBranch
|
|
92
|
-
}
|
|
92
|
+
},
|
|
93
|
+
debug: true
|
|
93
94
|
});
|
|
94
95
|
fn.processed = true;
|
|
95
96
|
return fn.cooked;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoryboardFunctionRegistry.js","names":["_cook","require","_supply","_storyboard","_getGeneralGlobals","StoryboardFunctionRegistryFactory","widgetId","widgetVersion","collectCoverage","registeredFunctions","Map","storyboardFunctions","Proxy","Object","freeze","get","
|
|
1
|
+
{"version":3,"file":"StoryboardFunctionRegistry.js","names":["_cook","require","_supply","_storyboard","_getGeneralGlobals","StoryboardFunctionRegistryFactory","widgetId","widgetVersion","collectCoverage","registeredFunctions","Map","storyboardFunctions","Proxy","Object","freeze","get","_target","key","getStoryboardFunction","currentApp","registerStoryboardFunctions","functions","app","clear","Array","isArray","fn","deps","collectMemberUsageInFunction","hasPermissionsCheck","has","set","name","source","typescript","undefined","processed","cooked","collector","createCollector","precooked","precookFunction","hooks","beforeVisit","cook","function","rules","noVar","globalVariables","supply","attemptToVisitGlobals","getGeneralGlobals","isStoryboardFunction","beforeEvaluate","beforeCall","beforeBranch","debug","updateStoryboardFunction","data","newFn","checkPermissionsUsage","functionNames","checkedFunctions","Set","add","some"],"sources":["../../src/StoryboardFunctionRegistry.ts"],"sourcesContent":["import type { MicroApp, StoryboardFunction } from \"@next-core/types\";\nimport { cook, precookFunction, EstreeNode } from \"@next-core/cook\";\nimport { supply } from \"@next-core/supply\";\nimport { collectMemberUsageInFunction } from \"@next-core/utils/storyboard\";\nimport { getGeneralGlobals } from \"./internal/compute/getGeneralGlobals.js\";\n\n/** @internal */\nexport type ReadonlyStoryboardFunctions = Readonly<Record<string, Function>>;\n\n/** @internal */\nexport type StoryboardFunctionPatch = Pick<\n StoryboardFunction,\n \"source\" | \"typescript\"\n>;\n\n/** @internal */\nexport interface StoryboardFunctionRegistry {\n /** A readonly proxy for accessing cooked storyboard functions. */\n storyboardFunctions: ReadonlyStoryboardFunctions;\n\n /** Register storyboard functions. */\n registerStoryboardFunctions(\n functions: StoryboardFunction[] | undefined,\n app?: PartialMicroApp\n ): void;\n\n /** Update a storyboard function during debugging. */\n updateStoryboardFunction(name: string, data: StoryboardFunctionPatch): void;\n\n checkPermissionsUsage(functionNames: string[]): boolean;\n}\n\n/** @internal */\nexport interface RuntimeStoryboardFunction {\n source: string;\n typescript?: boolean;\n processed?: boolean;\n cooked?: Function;\n deps: Set<string>;\n hasPermissionsCheck: boolean;\n}\n\n/** @internal */\nexport interface FunctionCoverageCollector {\n beforeVisit(node: EstreeNode): void;\n beforeEvaluate(node: EstreeNode): void;\n beforeCall(node: EstreeNode): void;\n beforeBranch(node: EstreeNode, branch: string): void;\n}\n\n/** @internal */\nexport interface FunctionCoverageSettings {\n createCollector(name: string): FunctionCoverageCollector;\n}\n\n/** @internal */\nexport type PartialMicroApp = Pick<MicroApp, \"id\" | \"isBuildPush\">;\n\n/** @internal */\nexport function StoryboardFunctionRegistryFactory({\n widgetId,\n widgetVersion,\n collectCoverage,\n}: {\n widgetId?: string;\n widgetVersion?: string;\n collectCoverage?: FunctionCoverageSettings;\n} = {}): StoryboardFunctionRegistry {\n const registeredFunctions = new Map<string, RuntimeStoryboardFunction>();\n\n // Use `Proxy` with a frozen target, to make a readonly function registry.\n const storyboardFunctions = new Proxy(Object.freeze({}), {\n get(_target, key) {\n return getStoryboardFunction(key as string);\n },\n }) as ReadonlyStoryboardFunctions;\n\n let currentApp: PartialMicroApp | undefined;\n\n function registerStoryboardFunctions(\n functions: StoryboardFunction[],\n app?: PartialMicroApp\n ): void {\n if (app) {\n currentApp = app;\n }\n registeredFunctions.clear();\n if (Array.isArray(functions)) {\n for (const fn of functions) {\n const deps = collectMemberUsageInFunction(fn, \"FN\", !!collectCoverage);\n const hasPermissionsCheck = collectMemberUsageInFunction(\n fn,\n \"PERMISSIONS\",\n !!collectCoverage\n ).has(\"check\");\n registeredFunctions.set(fn.name, {\n source: fn.source,\n typescript: fn.typescript,\n deps,\n hasPermissionsCheck,\n });\n }\n }\n }\n\n function getStoryboardFunction(name: string): Function | undefined {\n const fn = registeredFunctions.get(name);\n if (!fn) {\n return undefined;\n }\n if (fn.processed) {\n return fn.cooked;\n }\n let collector: FunctionCoverageCollector | undefined;\n if (collectCoverage) {\n collector = collectCoverage.createCollector(name);\n }\n const precooked = precookFunction(fn.source, {\n typescript: fn.typescript,\n hooks: collector && {\n beforeVisit: collector.beforeVisit,\n },\n });\n fn.cooked = cook(precooked.function, fn.source, {\n rules: {\n noVar: true,\n },\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n collectCoverage,\n widgetId,\n widgetVersion,\n app: currentApp,\n storyboardFunctions,\n isStoryboardFunction: true,\n }),\n !!collectCoverage\n ),\n hooks: collector && {\n beforeEvaluate: collector.beforeEvaluate,\n beforeCall: collector.beforeCall,\n beforeBranch: collector.beforeBranch,\n },\n debug: true,\n }) as Function;\n fn.processed = true;\n return fn.cooked;\n }\n\n return {\n storyboardFunctions,\n registerStoryboardFunctions,\n updateStoryboardFunction(\n name: string,\n data: StoryboardFunctionPatch\n ): void {\n const newFn = {\n ...data,\n name,\n };\n const deps = collectMemberUsageInFunction(newFn, \"FN\", true);\n const hasPermissionsCheck = collectMemberUsageInFunction(\n newFn,\n \"PERMISSIONS\",\n true\n ).has(\"check\");\n registeredFunctions.set(name, {\n source: data.source,\n typescript: data.typescript,\n deps,\n hasPermissionsCheck,\n });\n },\n /**\n * Check whether listed functions attempt to call `PERMISSIONS.check()`,\n * includes in nested `FN.*()` calls.\n */\n checkPermissionsUsage(functionNames) {\n const checkedFunctions = new Set<string>();\n const hasPermissionsCheck = (name: string): boolean => {\n if (!checkedFunctions.has(name)) {\n checkedFunctions.add(name);\n const fn = registeredFunctions.get(name);\n return (\n !!fn &&\n (fn.hasPermissionsCheck || [...fn.deps].some(hasPermissionsCheck))\n );\n }\n return false;\n };\n return functionNames.some(hasPermissionsCheck);\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AAEA;;AAGA;;AAMA;;AAiBA;;AAUA;;AAQA;;AAKA;;AAGA;AACO,SAASI,iCAAiCA,CAAC;EAChDC,QAAQ;EACRC,aAAa;EACbC;AAKF,CAAC,GAAG,CAAC,CAAC,EAA8B;EAClC,MAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAAoC,CAAC;;EAExE;EACA,MAAMC,mBAAmB,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;IACvDC,GAAGA,CAACC,OAAO,EAAEC,GAAG,EAAE;MAChB,OAAOC,qBAAqB,CAACD,GAAa,CAAC;IAC7C;EACF,CAAC,CAAgC;EAEjC,IAAIE,UAAuC;EAE3C,SAASC,2BAA2BA,CAClCC,SAA+B,EAC/BC,GAAqB,EACf;IACN,IAAIA,GAAG,EAAE;MACPH,UAAU,GAAGG,GAAG;IAClB;IACAb,mBAAmB,CAACc,KAAK,CAA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,IAAI,CAAC8B,gBAAgB,CAAChC,GAAG,CAACE,IAAI,CAAC,EAAE;UAC/B8B,gBAAgB,CAACE,GAAG,CAAChC,IAAI,CAAC;UAC1B,MAAMN,EAAE,GAAGjB,mBAAmB,CAACM,GAAG,CAACiB,IAAI,CAAC;UACxC,OACE,CAAC,CAACN,EAAE,KACHA,EAAE,CAACG,mBAAmB,IAAI,CAAC,GAAGH,EAAE,CAACC,IAAI,CAAC,CAACsC,IAAI,CAACpC,mBAAmB,CAAC,CAAC;QAEtE;QACA,OAAO,KAAK;MACd,CAAC;MACD,OAAOgC,aAAa,CAACI,IAAI,CAACpC,mBAAmB,CAAC;IAChD;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -28,7 +28,7 @@ export function StoryboardFunctionRegistryFactory() {
|
|
|
28
28
|
|
|
29
29
|
// Use `Proxy` with a frozen target, to make a readonly function registry.
|
|
30
30
|
const storyboardFunctions = new Proxy(Object.freeze({}), {
|
|
31
|
-
get(
|
|
31
|
+
get(_target, key) {
|
|
32
32
|
return getStoryboardFunction(key);
|
|
33
33
|
}
|
|
34
34
|
});
|
|
@@ -85,7 +85,8 @@ export function StoryboardFunctionRegistryFactory() {
|
|
|
85
85
|
beforeEvaluate: collector.beforeEvaluate,
|
|
86
86
|
beforeCall: collector.beforeCall,
|
|
87
87
|
beforeBranch: collector.beforeBranch
|
|
88
|
-
}
|
|
88
|
+
},
|
|
89
|
+
debug: true
|
|
89
90
|
});
|
|
90
91
|
fn.processed = true;
|
|
91
92
|
return fn.cooked;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoryboardFunctionRegistry.js","names":["cook","precookFunction","supply","collectMemberUsageInFunction","getGeneralGlobals","StoryboardFunctionRegistryFactory","widgetId","widgetVersion","collectCoverage","arguments","length","undefined","registeredFunctions","Map","storyboardFunctions","Proxy","Object","freeze","get","target","key","getStoryboardFunction","currentApp","registerStoryboardFunctions","functions","app","clear","Array","isArray","fn","deps","hasPermissionsCheck","has","set","name","source","typescript","processed","cooked","collector","createCollector","precooked","hooks","beforeVisit","function","rules","noVar","globalVariables","attemptToVisitGlobals","isStoryboardFunction","beforeEvaluate","beforeCall","beforeBranch","updateStoryboardFunction","data","newFn","checkPermissionsUsage","functionNames","checkedFunctions","Set","add","some"],"sources":["../../src/StoryboardFunctionRegistry.ts"],"sourcesContent":["import type { MicroApp, StoryboardFunction } from \"@next-core/types\";\nimport { cook, precookFunction, EstreeNode } from \"@next-core/cook\";\nimport { supply } from \"@next-core/supply\";\nimport { collectMemberUsageInFunction } from \"@next-core/utils/storyboard\";\nimport { getGeneralGlobals } from \"./internal/compute/getGeneralGlobals.js\";\n\n/** @internal */\nexport type ReadonlyStoryboardFunctions = Readonly<Record<string, Function>>;\n\n/** @internal */\nexport type StoryboardFunctionPatch = Pick<\n StoryboardFunction,\n \"source\" | \"typescript\"\n>;\n\n/** @internal */\nexport interface StoryboardFunctionRegistry {\n /** A readonly proxy for accessing cooked storyboard functions. */\n storyboardFunctions: ReadonlyStoryboardFunctions;\n\n /** Register storyboard functions. */\n registerStoryboardFunctions(\n functions: StoryboardFunction[] | undefined,\n app?: PartialMicroApp\n ): void;\n\n /** Update a storyboard function during debugging. */\n updateStoryboardFunction(name: string, data: StoryboardFunctionPatch): void;\n\n checkPermissionsUsage(functionNames: string[]): boolean;\n}\n\n/** @internal */\nexport interface RuntimeStoryboardFunction {\n source: string;\n typescript?: boolean;\n processed?: boolean;\n cooked?: Function;\n deps: Set<string>;\n hasPermissionsCheck: boolean;\n}\n\n/** @internal */\nexport interface FunctionCoverageCollector {\n beforeVisit(node: EstreeNode): void;\n beforeEvaluate(node: EstreeNode): void;\n beforeCall(node: EstreeNode): void;\n beforeBranch(node: EstreeNode, branch: string): void;\n}\n\n/** @internal */\nexport interface FunctionCoverageSettings {\n createCollector(name: string): FunctionCoverageCollector;\n}\n\n/** @internal */\nexport type PartialMicroApp = Pick<MicroApp, \"id\" | \"isBuildPush\">;\n\n/** @internal */\nexport function StoryboardFunctionRegistryFactory({\n widgetId,\n widgetVersion,\n collectCoverage,\n}: {\n widgetId?: string;\n widgetVersion?: string;\n collectCoverage?: FunctionCoverageSettings;\n} = {}): StoryboardFunctionRegistry {\n const registeredFunctions = new Map<string, RuntimeStoryboardFunction>();\n\n // Use `Proxy` with a frozen target, to make a readonly function registry.\n const storyboardFunctions = new Proxy(Object.freeze({}), {\n get(target, key) {\n return getStoryboardFunction(key as string);\n },\n }) as ReadonlyStoryboardFunctions;\n\n let currentApp: PartialMicroApp | undefined;\n\n function registerStoryboardFunctions(\n functions: StoryboardFunction[],\n app?: PartialMicroApp\n ): void {\n if (app) {\n currentApp = app;\n }\n registeredFunctions.clear();\n if (Array.isArray(functions)) {\n for (const fn of functions) {\n const deps = collectMemberUsageInFunction(fn, \"FN\", !!collectCoverage);\n const hasPermissionsCheck = collectMemberUsageInFunction(\n fn,\n \"PERMISSIONS\",\n !!collectCoverage\n ).has(\"check\");\n registeredFunctions.set(fn.name, {\n source: fn.source,\n typescript: fn.typescript,\n deps,\n hasPermissionsCheck,\n });\n }\n }\n }\n\n function getStoryboardFunction(name: string): Function | undefined {\n const fn = registeredFunctions.get(name);\n if (!fn) {\n return undefined;\n }\n if (fn.processed) {\n return fn.cooked;\n }\n let collector: FunctionCoverageCollector | undefined;\n if (collectCoverage) {\n collector = collectCoverage.createCollector(name);\n }\n const precooked = precookFunction(fn.source, {\n typescript: fn.typescript,\n hooks: collector && {\n beforeVisit: collector.beforeVisit,\n },\n });\n fn.cooked = cook(precooked.function, fn.source, {\n rules: {\n noVar: true,\n },\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n collectCoverage,\n widgetId,\n widgetVersion,\n app: currentApp,\n storyboardFunctions,\n isStoryboardFunction: true,\n }),\n !!collectCoverage\n ),\n hooks: collector && {\n beforeEvaluate: collector.beforeEvaluate,\n beforeCall: collector.beforeCall,\n beforeBranch: collector.beforeBranch,\n },\n }) as Function;\n fn.processed = true;\n return fn.cooked;\n }\n\n return {\n storyboardFunctions,\n registerStoryboardFunctions,\n updateStoryboardFunction(\n name: string,\n data: StoryboardFunctionPatch\n ): void {\n const newFn = {\n ...data,\n name,\n };\n const deps = collectMemberUsageInFunction(newFn, \"FN\", true);\n const hasPermissionsCheck = collectMemberUsageInFunction(\n newFn,\n \"PERMISSIONS\",\n true\n ).has(\"check\");\n registeredFunctions.set(name, {\n source: data.source,\n typescript: data.typescript,\n deps,\n hasPermissionsCheck,\n });\n },\n /**\n * Check whether listed functions attempt to call `PERMISSIONS.check()`,\n * includes in nested `FN.*()` calls.\n */\n checkPermissionsUsage(functionNames) {\n const checkedFunctions = new Set<string>();\n const hasPermissionsCheck = (name: string): boolean => {\n if (!checkedFunctions.has(name)) {\n checkedFunctions.add(name);\n const fn = registeredFunctions.get(name);\n return (\n !!fn &&\n (fn.hasPermissionsCheck || [...fn.deps].some(hasPermissionsCheck))\n );\n }\n return false;\n };\n return functionNames.some(hasPermissionsCheck);\n },\n };\n}\n"],"mappings":"AACA,SAASA,IAAI,EAAEC,eAAe,QAAoB,iBAAiB;AACnE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,4BAA4B,QAAQ,6BAA6B;AAC1E,SAASC,iBAAiB,QAAQ,yCAAyC;;AAE3E;;AAGA;;AAMA;;AAiBA;;AAUA;;AAQA;;AAKA;;AAGA;AACA,OAAO,SAASC,iCAAiCA,CAAA,EAQb;EAAA,IARc;IAChDC,QAAQ;IACRC,aAAa;IACbC;EAKF,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACJ,MAAMG,mBAAmB,GAAG,IAAIC,GAAG,CAAoC,CAAC;;EAExE;EACA,MAAMC,mBAAmB,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;IACvDC,GAAGA,CAACC,MAAM,EAAEC,GAA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CAAC;IACJ,CAAC;IACD;AACJ;AACA;AACA;IACIyB,qBAAqBA,CAACC,aAAa,EAAE;MACnC,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAAS,CAAC;MAC1C,MAAM5B,mBAAmB,GAAIG,IAAY,IAAc;QACrD,IAAI,CAACwB,gBAAgB,CAAC1B,GAAG,CAACE,IAAI,CAAC,EAAE;UAC/BwB,gBAAgB,CAACE,GAAG,CAAC1B,IAAI,CAAC;UAC1B,MAAML,EAAE,GAAGjB,mBAAmB,CAACM,GAAG,CAACgB,IAAI,CAAC;UACxC,OACE,CAAC,CAACL,EAAE,KACHA,EAAE,CAACE,mBAAmB,IAAI,CAAC,GAAGF,EAAE,CAACC,IAAI,CAAC,CAAC+B,IAAI,CAAC9B,mBAAmB,CAAC,CAAC;QAEtE;QACA,OAAO,KAAK;MACd,CAAC;MACD,OAAO0B,aAAa,CAACI,IAAI,CAAC9B,mBAAmB,CAAC;IAChD;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"StoryboardFunctionRegistry.js","names":["cook","precookFunction","supply","collectMemberUsageInFunction","getGeneralGlobals","StoryboardFunctionRegistryFactory","widgetId","widgetVersion","collectCoverage","arguments","length","undefined","registeredFunctions","Map","storyboardFunctions","Proxy","Object","freeze","get","_target","key","getStoryboardFunction","currentApp","registerStoryboardFunctions","functions","app","clear","Array","isArray","fn","deps","hasPermissionsCheck","has","set","name","source","typescript","processed","cooked","collector","createCollector","precooked","hooks","beforeVisit","function","rules","noVar","globalVariables","attemptToVisitGlobals","isStoryboardFunction","beforeEvaluate","beforeCall","beforeBranch","debug","updateStoryboardFunction","data","newFn","checkPermissionsUsage","functionNames","checkedFunctions","Set","add","some"],"sources":["../../src/StoryboardFunctionRegistry.ts"],"sourcesContent":["import type { MicroApp, StoryboardFunction } from \"@next-core/types\";\nimport { cook, precookFunction, EstreeNode } from \"@next-core/cook\";\nimport { supply } from \"@next-core/supply\";\nimport { collectMemberUsageInFunction } from \"@next-core/utils/storyboard\";\nimport { getGeneralGlobals } from \"./internal/compute/getGeneralGlobals.js\";\n\n/** @internal */\nexport type ReadonlyStoryboardFunctions = Readonly<Record<string, Function>>;\n\n/** @internal */\nexport type StoryboardFunctionPatch = Pick<\n StoryboardFunction,\n \"source\" | \"typescript\"\n>;\n\n/** @internal */\nexport interface StoryboardFunctionRegistry {\n /** A readonly proxy for accessing cooked storyboard functions. */\n storyboardFunctions: ReadonlyStoryboardFunctions;\n\n /** Register storyboard functions. */\n registerStoryboardFunctions(\n functions: StoryboardFunction[] | undefined,\n app?: PartialMicroApp\n ): void;\n\n /** Update a storyboard function during debugging. */\n updateStoryboardFunction(name: string, data: StoryboardFunctionPatch): void;\n\n checkPermissionsUsage(functionNames: string[]): boolean;\n}\n\n/** @internal */\nexport interface RuntimeStoryboardFunction {\n source: string;\n typescript?: boolean;\n processed?: boolean;\n cooked?: Function;\n deps: Set<string>;\n hasPermissionsCheck: boolean;\n}\n\n/** @internal */\nexport interface FunctionCoverageCollector {\n beforeVisit(node: EstreeNode): void;\n beforeEvaluate(node: EstreeNode): void;\n beforeCall(node: EstreeNode): void;\n beforeBranch(node: EstreeNode, branch: string): void;\n}\n\n/** @internal */\nexport interface FunctionCoverageSettings {\n createCollector(name: string): FunctionCoverageCollector;\n}\n\n/** @internal */\nexport type PartialMicroApp = Pick<MicroApp, \"id\" | \"isBuildPush\">;\n\n/** @internal */\nexport function StoryboardFunctionRegistryFactory({\n widgetId,\n widgetVersion,\n collectCoverage,\n}: {\n widgetId?: string;\n widgetVersion?: string;\n collectCoverage?: FunctionCoverageSettings;\n} = {}): StoryboardFunctionRegistry {\n const registeredFunctions = new Map<string, RuntimeStoryboardFunction>();\n\n // Use `Proxy` with a frozen target, to make a readonly function registry.\n const storyboardFunctions = new Proxy(Object.freeze({}), {\n get(_target, key) {\n return getStoryboardFunction(key as string);\n },\n }) as ReadonlyStoryboardFunctions;\n\n let currentApp: PartialMicroApp | undefined;\n\n function registerStoryboardFunctions(\n functions: StoryboardFunction[],\n app?: PartialMicroApp\n ): void {\n if (app) {\n currentApp = app;\n }\n registeredFunctions.clear();\n if (Array.isArray(functions)) {\n for (const fn of functions) {\n const deps = collectMemberUsageInFunction(fn, \"FN\", !!collectCoverage);\n const hasPermissionsCheck = collectMemberUsageInFunction(\n fn,\n \"PERMISSIONS\",\n !!collectCoverage\n ).has(\"check\");\n registeredFunctions.set(fn.name, {\n source: fn.source,\n typescript: fn.typescript,\n deps,\n hasPermissionsCheck,\n });\n }\n }\n }\n\n function getStoryboardFunction(name: string): Function | undefined {\n const fn = registeredFunctions.get(name);\n if (!fn) {\n return undefined;\n }\n if (fn.processed) {\n return fn.cooked;\n }\n let collector: FunctionCoverageCollector | undefined;\n if (collectCoverage) {\n collector = collectCoverage.createCollector(name);\n }\n const precooked = precookFunction(fn.source, {\n typescript: fn.typescript,\n hooks: collector && {\n beforeVisit: collector.beforeVisit,\n },\n });\n fn.cooked = cook(precooked.function, fn.source, {\n rules: {\n noVar: true,\n },\n globalVariables: supply(\n precooked.attemptToVisitGlobals,\n getGeneralGlobals(precooked.attemptToVisitGlobals, {\n collectCoverage,\n widgetId,\n widgetVersion,\n app: currentApp,\n storyboardFunctions,\n isStoryboardFunction: true,\n }),\n !!collectCoverage\n ),\n hooks: collector && {\n beforeEvaluate: collector.beforeEvaluate,\n beforeCall: collector.beforeCall,\n beforeBranch: collector.beforeBranch,\n },\n debug: true,\n }) as Function;\n fn.processed = true;\n return fn.cooked;\n }\n\n return {\n storyboardFunctions,\n registerStoryboardFunctions,\n updateStoryboardFunction(\n name: string,\n data: StoryboardFunctionPatch\n ): void {\n const newFn = {\n ...data,\n name,\n };\n const deps = collectMemberUsageInFunction(newFn, \"FN\", true);\n const hasPermissionsCheck = collectMemberUsageInFunction(\n newFn,\n \"PERMISSIONS\",\n true\n ).has(\"check\");\n registeredFunctions.set(name, {\n source: data.source,\n typescript: data.typescript,\n deps,\n hasPermissionsCheck,\n });\n },\n /**\n * Check whether listed functions attempt to call `PERMISSIONS.check()`,\n * includes in nested `FN.*()` calls.\n */\n checkPermissionsUsage(functionNames) {\n const checkedFunctions = new Set<string>();\n const hasPermissionsCheck = (name: string): boolean => {\n if (!checkedFunctions.has(name)) {\n checkedFunctions.add(name);\n const fn = registeredFunctions.get(name);\n return (\n !!fn &&\n (fn.hasPermissionsCheck || [...fn.deps].some(hasPermissionsCheck))\n );\n }\n return false;\n };\n return functionNames.some(hasPermissionsCheck);\n },\n };\n}\n"],"mappings":"AACA,SAASA,IAAI,EAAEC,eAAe,QAAoB,iBAAiB;AACnE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,4BAA4B,QAAQ,6BAA6B;AAC1E,SAASC,iBAAiB,QAAQ,yCAAyC;;AAE3E;;AAGA;;AAMA;;AAiBA;;AAUA;;AAQA;;AAKA;;AAGA;AACA,OAAO,SAASC,iCAAiCA,CAAA,EAQb;EAAA,IARc;IAChDC,QAAQ;IACRC,aAAa;IACbC;EAKF,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACJ,MAAMG,mBAAmB,GAAG,IAAIC,GAAG,CAAoC,CAAC;;EAExE;EACA,MAAMC,mBAAmB,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;IACvDC,GAAGA,CAACC,OAAO,EAAEC,GAAG,EAAE;MAChB,OAAOC,qBAAqB,CAACD,GAAa,CAAC;IAC7C;EACF,CAAC,CAAgC;EAEjC,IAAIE,UAAuC;EAE3C,SAASC,2BAA2BA,CAClCC,SAA+B,EAC/BC,GAAqB,EACf;IACN,IAAIA,GAAG,EAAE;MACPH,UAAU,GAAGG,GAAG;IAClB;IACAb,mBAAmB,CAACc,KAAK,CAAC,CAAC;IAC3B,IAAIC,KAAK,CAACC,OAAO,CAACJ,SAAS,CAAC,EAAE;MAC5B,KAAK,MAAMK,EAAE,IAAIL,S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mBAAmB,CAACM,GAAG,CAACgB,IAAI,CAAC;UACxC,OACE,CAAC,CAACL,EAAE,KACHA,EAAE,CAACE,mBAAmB,IAAI,CAAC,GAAGF,EAAE,CAACC,IAAI,CAAC,CAACgC,IAAI,CAAC/B,mBAAmB,CAAC,CAAC;QAEtE;QACA,OAAO,KAAK;MACd,CAAC;MACD,OAAO2B,aAAa,CAACI,IAAI,CAAC/B,mBAAmB,CAAC;IAChD;EACF,CAAC;AACH","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/runtime",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"repository": {
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@next-core/color-theme": "^0.4.8",
|
|
48
|
-
"@next-core/cook": "^2.
|
|
48
|
+
"@next-core/cook": "^2.3.0",
|
|
49
49
|
"@next-core/http": "^1.2.4",
|
|
50
|
-
"@next-core/i18n": "^1.0.
|
|
50
|
+
"@next-core/i18n": "^1.0.50",
|
|
51
51
|
"@next-core/inject": "^1.0.37",
|
|
52
52
|
"@next-core/loader": "^1.6.0",
|
|
53
|
-
"@next-core/supply": "^2.1.
|
|
53
|
+
"@next-core/supply": "^2.1.18",
|
|
54
54
|
"@next-core/types": "^1.11.1",
|
|
55
|
-
"@next-core/utils": "^1.7.
|
|
55
|
+
"@next-core/utils": "^1.7.8",
|
|
56
56
|
"@ungap/event-target": "^0.2.4",
|
|
57
57
|
"compare-versions": "^6.1.0",
|
|
58
58
|
"history": "^4.10.1",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"@next-core/build-next-libs": "^1.0.17",
|
|
68
68
|
"@next-core/test-next": "^1.1.3"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "a143984961ebb50532250cad45a7dbdfd23d8728"
|
|
71
71
|
}
|