@markw65/monkeyc-optimizer 1.0.38 → 1.0.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.
@@ -1,9 +1,10 @@
1
1
  import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
2
  import { hasProperty, traverseAst } from "./ast";
3
- import { LookupDefinition, ProgramState, ProgramStateLive, ProgramStateNode, StateNode, StateNodeDecl, ProgramStateStack, FunctionInfo, FunctionStateNode } from "./optimizer-types";
4
- export { visitReferences } from "./visitor";
3
+ import { JungleResourceMap } from "./jungles";
4
+ import { FunctionInfo, FunctionStateNode, LookupDefinition, ProgramState, ProgramStateLive, ProgramStateNode, ProgramStateStack, StateNode, StateNodeDecl } from "./optimizer-types";
5
+ export { visitorNode, visitReferences } from "./visitor";
5
6
  export { traverseAst, hasProperty };
6
- export declare function getApiMapping(state?: ProgramState, barrelList?: string[]): Promise<ProgramStateNode | null>;
7
+ export declare function getApiMapping(state?: ProgramState, resourcesMap?: Record<string, JungleResourceMap>): Promise<ProgramStateNode | null>;
7
8
  export declare function isStateNode(node: StateNodeDecl): node is StateNode;
8
9
  export declare function variableDeclarationName(node: mctree.TypedIdentifier | mctree.InstanceofIdentifier): string;
9
10
  export declare function sameLookupResult(a: LookupDefinition[], b: LookupDefinition[]): boolean;
@@ -1,5 +1,6 @@
1
1
  import { ManifestXML } from "./manifest";
2
2
  import { BuildConfig } from "./optimizer-types.js";
3
+ import { xmlUtil } from "./sdk-util";
3
4
  export declare type Target = {
4
5
  product: string;
5
6
  qualifier: JungleQualifier;
@@ -35,13 +36,16 @@ export declare type JungleQualifier = {
35
36
  annotations?: BarrelAnnotations;
36
37
  barrelMap?: BarrelMap;
37
38
  optBarrels?: OptBarrelMap;
39
+ resourceMap?: JungleResourceMap;
38
40
  };
39
41
  declare type JungleInfoBase = {
40
42
  jungles: string[];
41
43
  manifest: string;
42
44
  xml: ManifestXML;
43
45
  annotations?: string[];
46
+ resources: JungleResourceMap;
44
47
  };
48
+ export declare type JungleResourceMap = Record<string, xmlUtil.Document | Error>;
45
49
  export declare type ResolvedJungle = JungleInfoBase & {
46
50
  targets: Target[];
47
51
  };
@@ -1,5 +1,5 @@
1
1
  import { LineHandler } from "./util";
2
- export declare function launchSimulator(): Promise<void>;
2
+ export declare function launchSimulator(force?: boolean): Promise<void>;
3
3
  export declare function checkIfSimulatorRunning(): Promise<boolean>;
4
4
  export declare function checkIfSimulatorRunningOn(port: number): Promise<boolean>;
5
5
  export declare function simulateProgram(prg: string, device: string, test?: boolean, logger?: LineHandler | LineHandler[]): Promise<void>;
@@ -1,65 +1,5 @@
1
- declare type iqApplication = {
2
- $: {
3
- id: string;
4
- entry: string;
5
- launcherIcon: string;
6
- minSdkVersion: string;
7
- name: string;
8
- type: string;
9
- version: string;
10
- };
11
- "iq:products"?: Array<{
12
- "iq:product"?: Array<{
13
- $: {
14
- id: string;
15
- };
16
- }>;
17
- }>;
18
- "iq:barrels"?: Array<{
19
- "iq:depends"?: Array<{
20
- $: {
21
- name: string;
22
- version: string;
23
- };
24
- }>;
25
- }>;
26
- "iq:permissions"?: Array<{
27
- "iq:uses-permission"?: Array<{
28
- $: {
29
- id: string;
30
- };
31
- }>;
32
- }>;
33
- "iq:languages"?: Array<{
34
- "iq:language"?: Array<string>;
35
- }>;
36
- };
37
- declare type iqBarrel = {
38
- $: {
39
- id: string;
40
- module: string;
41
- version: string;
42
- };
43
- "iq:products"?: Array<{
44
- "iq:product"?: Array<{
45
- $: {
46
- id: string;
47
- };
48
- }>;
49
- }>;
50
- "iq:annotations"?: Array<{
51
- "iq:annotation"?: Array<string>;
52
- }>;
53
- };
54
- export declare type ManifestXML = {
55
- "iq:manifest": {
56
- $: {
57
- "xmlns:iq": string;
58
- };
59
- "iq:application"?: Array<iqApplication>;
60
- "iq:barrel"?: Array<iqBarrel>;
61
- };
62
- };
1
+ import { xmlUtil } from "./sdk-util";
2
+ export declare type ManifestXML = xmlUtil.Document;
63
3
  export declare function readManifest(manifest: string): Promise<ManifestXML>;
64
4
  export declare function writeManifest(filename: string, xml: ManifestXML): Promise<void>;
65
5
  export declare function manifestProducts(manifest: ManifestXML): string[];
@@ -68,4 +8,3 @@ export declare function manifestDropBarrels(manifest: ManifestXML): void;
68
8
  export declare function manifestBarrelName(manifestName: string, manifest: ManifestXML): string;
69
9
  export declare function manifestAnnotations(manifest: ManifestXML): string[] | undefined;
70
10
  export declare function checkManifest(manifest: ManifestXML, products: string[]): Promise<boolean>;
71
- export {};
@@ -1,11 +1,13 @@
1
1
  import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
+ import { JungleResourceMap } from "./jungles";
2
3
  import { BuildConfig, FilesToOptimizeMap, LookupDefinition, ProgramStateAnalysis } from "./optimizer-types";
3
4
  export declare function getFileSources(fnMap: FilesToOptimizeMap): Promise<void>;
4
5
  export declare function getFileASTs(fnMap: FilesToOptimizeMap): Promise<boolean>;
5
- export declare function analyze(fnMap: FilesToOptimizeMap, barrelList?: string[], config?: BuildConfig): Promise<ProgramStateAnalysis>;
6
+ export declare function analyze(fnMap: FilesToOptimizeMap, resourcesMap?: Record<string, JungleResourceMap>, config?: BuildConfig): Promise<ProgramStateAnalysis>;
7
+ export declare function reportMissingSymbols(state: ProgramStateAnalysis, config?: BuildConfig): void;
6
8
  export declare function getLiteralFromDecls(lookupDefns: LookupDefinition[]): mctree.Literal | mctree.AsExpression | null;
7
9
  export declare function getLiteralNode(node: mctree.Node | null | undefined): null | mctree.Literal | mctree.AsExpression;
8
- export declare function optimizeMonkeyC(fnMap: FilesToOptimizeMap, barrelList?: string[], config?: BuildConfig): Promise<Record<string, {
10
+ export declare function optimizeMonkeyC(fnMap: FilesToOptimizeMap, resourcesMap?: Record<string, JungleResourceMap>, config?: BuildConfig): Promise<Record<string, {
9
11
  type: import("./optimizer-types").DiagnosticType;
10
12
  loc: {
11
13
  start: mctree.Position;
@@ -1,5 +1,4 @@
1
1
  import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
- import { ResolvedJungle } from "./jungles";
3
2
  export declare type DiagnosticType = "ERROR" | "WARNING" | "INFO";
4
3
  export declare type BuildConfig = {
5
4
  workspace?: string;
@@ -27,10 +26,6 @@ export declare type BuildConfig = {
27
26
  sizeBasedPRE?: boolean | string;
28
27
  prettier?: Record<string, unknown>;
29
28
  extensionVersion?: string;
30
- _cache?: {
31
- barrels?: Record<string, ResolvedJungle>;
32
- barrelMap?: Record<string, Record<string, ResolvedJungle>>;
33
- };
34
29
  };
35
30
  export declare type StateNodeDecl = StateNode | mctree.EnumStringMember | mctree.TypedIdentifier | mctree.EnumDeclaration;
36
31
  export declare type StateNodeDecls = {
@@ -2,8 +2,8 @@ import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
2
  import { get_jungle, ResolvedJungle, Target } from "./jungles";
3
3
  import { launchSimulator, simulateProgram } from "./launch";
4
4
  import { manifestProducts } from "./manifest";
5
- import { copyRecursiveAsNeeded } from "./util";
6
5
  import { BuildConfig, FilesToOptimizeMap, ProgramStateAnalysis } from "./optimizer-types";
6
+ import { copyRecursiveAsNeeded } from "./util";
7
7
  export * from "./optimizer-types";
8
8
  export { copyRecursiveAsNeeded, get_jungle, launchSimulator, manifestProducts, mctree, ResolvedJungle, simulateProgram, };
9
9
  export declare const defaultConfig: {
@@ -18,6 +18,19 @@ declare global {
18
18
  var lastModifiedSource: number;
19
19
  }
20
20
  /**
21
+ *
22
+ * WARNING WARNING WARNING WARNING WARNING WARNING
23
+ *
24
+ * prettier-extension-monkeyc can dynamically import this
25
+ * function from a local copy of @markw65/monkeyc-optimizer,
26
+ * rather than using the version that ships with the
27
+ * extension.
28
+ *
29
+ * For this to work, buildOptimizedProject's signature cannot
30
+ * change (or at least, can only change in a backward compatible
31
+ * way).
32
+ *
33
+ * DON'T CHANGE THIS FUNCTION's SIGNATURE
21
34
  *
22
35
  * @param {string | null} product
23
36
  * @param {BuildConfig} options
@@ -40,13 +53,13 @@ export declare function buildOptimizedProject(product: string | null, options: B
40
53
  }>;
41
54
  export declare function generateOptimizedProject(options: BuildConfig): Promise<{
42
55
  jungleFiles: string | undefined;
43
- xml: import("./manifest").ManifestXML;
56
+ xml: import("./xml-util").Document;
44
57
  program: string;
45
58
  hasTests: boolean;
46
59
  diagnostics?: undefined;
47
60
  } | {
48
61
  jungleFiles: string;
49
- xml: import("./manifest").ManifestXML;
62
+ xml: import("./xml-util").Document;
50
63
  program: string;
51
64
  hasTests: boolean;
52
65
  diagnostics: Record<string, {
@@ -0,0 +1,5 @@
1
+ import { Program } from "@markw65/prettier-plugin-monkeyc/build/src/estree-types";
2
+ import { JungleResourceMap } from "./jungles";
3
+ import { xmlUtil } from "./sdk-util";
4
+ export declare function visit_resources(elements: xmlUtil.Element[], parent: string | null, visitor: (e: xmlUtil.Element, module: string | null) => void, error: (e: xmlUtil.Element, parent: string | null) => void): void;
5
+ export declare function add_resources_to_ast(ast: Program, resources: Record<string, JungleResourceMap>): void;
@@ -1,4 +1,5 @@
1
1
  export { readPrg, SectionKinds } from "./readprg";
2
+ export * as xmlUtil from "./xml-util";
2
3
  export declare const isWin: boolean;
3
4
  export declare const appSupport: string;
4
5
  export declare const connectiq: string;
@@ -15,4 +16,7 @@ export declare type DeviceInfo = {
15
16
  };
16
17
  };
17
18
  export declare function getDeviceInfo(): Promise<DeviceInfo>;
18
- export declare function getLanguages(): Promise<any>;
19
+ export declare function getLanguages(): Promise<{
20
+ id: string;
21
+ name: string;
22
+ }[]>;
@@ -1,3 +1,4 @@
1
1
  import { mctree } from "@markw65/prettier-plugin-monkeyc";
2
2
  import { LookupDefinition, ProgramStateAnalysis } from "./optimizer-types";
3
+ export declare function visitorNode(node: mctree.Node): mctree.Node;
3
4
  export declare function visitReferences(state: ProgramStateAnalysis, ast: mctree.Program, name: string | null, defn: LookupDefinition[] | null | false, callback: (node: mctree.Node, results: LookupDefinition[], error: boolean) => undefined | false): void;
@@ -0,0 +1,139 @@
1
+ export interface Position {
2
+ /** >= 0 */
3
+ offset: number;
4
+ /** >= 1 */
5
+ line: number;
6
+ /** >= 0 */
7
+ column: number;
8
+ }
9
+ export interface SourceLocation {
10
+ source?: string | null | undefined;
11
+ start: Position;
12
+ end: Position;
13
+ }
14
+ interface BaseNode {
15
+ type: string;
16
+ loc?: SourceLocation | null | undefined;
17
+ start?: number;
18
+ end?: number;
19
+ range?: [number, number] | undefined;
20
+ }
21
+ interface CharData extends BaseNode {
22
+ type: "chardata";
23
+ value: string;
24
+ }
25
+ interface CharRef extends BaseNode {
26
+ type: "charref";
27
+ value: number;
28
+ base: 10 | 16;
29
+ }
30
+ interface Comment extends BaseNode {
31
+ type: "comment";
32
+ value: string;
33
+ }
34
+ interface DocTypeDecl extends BaseNode {
35
+ type: "doctypedecl";
36
+ name: string;
37
+ externalID?: ExternalID;
38
+ intSubset?: Array<MarkupDecl | PEReference>;
39
+ }
40
+ interface EntityDecl extends BaseNode {
41
+ type: "entitydecl";
42
+ name: string;
43
+ def: XValue;
44
+ kind: "&" | "%";
45
+ }
46
+ interface XValue extends BaseNode {
47
+ type: "entityvalue";
48
+ value?: Array<string | Reference | PEReference>;
49
+ extid?: System;
50
+ ndecl?: NData;
51
+ }
52
+ declare type Reference = CharRef | EntityRef;
53
+ declare type PEReference = PERef;
54
+ declare type SystemLiteral = string;
55
+ interface EntityRef extends BaseNode {
56
+ type: "entityref";
57
+ name: string;
58
+ }
59
+ interface PERef extends BaseNode {
60
+ type: "peref";
61
+ name: string;
62
+ }
63
+ interface NotationDecl extends BaseNode {
64
+ type: "notationdecl";
65
+ name: string;
66
+ id: ExternalID | PublicID;
67
+ }
68
+ interface PublicID extends BaseNode {
69
+ type: "publicid";
70
+ value: string;
71
+ }
72
+ interface NData extends BaseNode {
73
+ type: "ndata";
74
+ value: string;
75
+ }
76
+ declare type ExternalID = System | Public;
77
+ declare type MarkupDecl = EntityDecl | NotationDecl | PI | Comment;
78
+ interface System extends BaseNode {
79
+ type: "system";
80
+ value: SystemLiteral;
81
+ }
82
+ interface Public extends BaseNode {
83
+ type: "public";
84
+ value: SystemLiteral;
85
+ pubid: string;
86
+ }
87
+ declare type Misc = Comment | PI | CharData;
88
+ declare type Content = Element | Reference | CData | Misc;
89
+ export interface CData extends BaseNode {
90
+ type: "cdata";
91
+ value: string;
92
+ }
93
+ export interface PI extends BaseNode {
94
+ type: "pi";
95
+ name: string;
96
+ value: string | null;
97
+ }
98
+ export interface Element extends BaseNode {
99
+ type: "element";
100
+ name: string;
101
+ attr: Record<string, string>;
102
+ children?: Array<Content> | undefined;
103
+ }
104
+ export interface Prolog extends BaseNode {
105
+ type: "prolog";
106
+ xmldecl?: XmlDecl;
107
+ misc1: Misc[];
108
+ doctypedecl?: DocTypeDecl;
109
+ misc2: Misc[];
110
+ }
111
+ interface XmlDecl extends BaseNode {
112
+ type: "xmldecl";
113
+ version: "1.0";
114
+ encoding?: string[];
115
+ standalone?: string[];
116
+ }
117
+ export declare class Document {
118
+ prolog: Prolog;
119
+ body: Nodes;
120
+ misc: Array<Misc>;
121
+ constructor(prolog: Prolog, body: Nodes, misc: Array<Misc>);
122
+ }
123
+ export declare function elementKids(e: Element): Element[];
124
+ declare type ElementMatcher = string | ((c: Element) => boolean);
125
+ export declare class Nodes {
126
+ elements: Array<Element>;
127
+ constructor(elements: Element | Element[]);
128
+ length(): number;
129
+ deleteChildren(arg: ElementMatcher): void;
130
+ addChildren(elements: Element[]): void;
131
+ filter(arg: ElementMatcher): Nodes;
132
+ skip(name: string): Nodes;
133
+ children(name?: string): Nodes;
134
+ text(): string[];
135
+ attrs(): Record<string, string>[];
136
+ }
137
+ export declare function parseXml(content: string, fileName?: string | null): Document;
138
+ export declare function writeXml(doc: Document): string;
139
+ export {};