Skip to content

Commit 019e945

Browse files
committed
Revert extraneous changes
1 parent a4e892d commit 019e945

File tree

7 files changed

+33
-292
lines changed

7 files changed

+33
-292
lines changed

common/api-review/functions-exp.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
```ts
66

7-
import { FirebaseApp } from '@firebase/app';
7+
import { FirebaseApp } from '@firebase/app-exp';
88
import { FirebaseError } from '@firebase/util';
99

1010
// @public

packages-exp/functions-compat/src/index.ts

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,22 @@
1515
* limitations under the License.
1616
*/
1717

18-
import firebase, {
19-
FirebaseApp as FirebaseAppCompat
20-
} from '@firebase/app-compat';
18+
import firebase from '@firebase/app-compat';
2119
import { name, version } from '../package.json';
2220
import { registerFunctions } from './register';
23-
import { FirebaseFunctions as FunctionsCompat } from '@firebase/functions-types';
24-
import { Functions as FirebaseFunctionsExp } from '@firebase/functions-exp';
21+
import * as types from '@firebase/functions-types';
2522

26-
declare module '@firebase/functions-exp' {
27-
export function getFunctions(
28-
app: FirebaseAppCompat,
29-
regionOrCustomDomain?: string
30-
): FirebaseFunctionsExp;
31-
32-
export function httpsCallable<RequestData = unknown, ResponseData = unknown>(
33-
functionsInstance: FunctionsCompat,
34-
name: string,
35-
options?: HttpsCallableOptions
36-
): HttpsCallable<RequestData, ResponseData>;
37-
38-
export function useFunctionsEmulator(
39-
functionsInstance: FunctionsCompat,
40-
host: string,
41-
port: number
42-
): void;
43-
}
4423
registerFunctions();
4524
firebase.registerVersion(name, version);
4625

4726
declare module '@firebase/app-compat' {
4827
interface FirebaseNamespace {
4928
functions?: {
50-
(app?: FirebaseApp): FunctionsCompat;
51-
Functions: typeof FunctionsCompat;
29+
(app?: FirebaseApp): types.FirebaseFunctions;
30+
Functions: typeof types.FirebaseFunctions;
5231
};
5332
}
5433
interface FirebaseApp {
55-
functions?(regionOrCustomDomain?: string): FunctionsCompat;
34+
functions?(regionOrCustomDomain?: string): types.FirebaseFunctions;
5635
}
5736
}

packages-exp/functions-compat/test/interop.test.ts

Lines changed: 0 additions & 157 deletions
This file was deleted.

packages/util/index.node.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@ export * from './src/utf8';
3838
export * from './src/exponential_backoff';
3939
export * from './src/formatters';
4040
export * from './src/compat';
41-
export * from './src/exp';

packages/util/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ export * from './src/utf8';
3333
export * from './src/exponential_backoff';
3434
export * from './src/formatters';
3535
export * from './src/compat';
36-
export * from './src/exp';

packages/util/src/exp.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

scripts/exp/ts-transform-import-path.js

Lines changed: 27 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -34,111 +34,62 @@ export function getImportPathTransformer({ pattern, template }) {
3434
export const importPathTransformer = () => ({
3535
before: [
3636
transformImportPath({
37-
pattern: /^(@firebase.*)-exp(.*)$/,
37+
pattern: /^(@firebase.*)-exp(.*)$/g,
3838
template: [1, 2]
3939
})
4040
],
4141
after: [],
4242
afterDeclarations: [
4343
transformImportPath({
44-
pattern: /^(@firebase.*)-exp(.*)$/,
44+
pattern: /^(@firebase.*)-exp(.*)$/g,
4545
template: [1, 2]
4646
})
4747
]
4848
});
4949

5050
function transformImportPath({ pattern, template }) {
5151
return context => file => {
52-
return visitNodeAndChildren(
53-
file,
54-
context,
55-
{ pattern, template },
56-
transformNode
57-
);
52+
return visitNodeAndChildren(file, context, { pattern, template });
5853
};
5954
}
6055

61-
function visitNodeAndChildren(
62-
node,
63-
context,
64-
{ pattern, template },
65-
nodeTransformer
66-
) {
56+
function visitNodeAndChildren(node, context, { pattern, template }) {
6757
return ts.visitEachChild(
68-
nodeTransformer(node, { pattern, template }),
58+
visitNode(node, { pattern, template }),
6959
childNode =>
70-
visitNodeAndChildren(
71-
childNode,
72-
context,
73-
{ pattern, template },
74-
nodeTransformer
75-
),
60+
visitNodeAndChildren(childNode, context, { pattern, template }),
7661
context
7762
);
7863
}
7964

80-
function replacePath(pathString, pattern, template) {
81-
const pathStringWithoutQuotes = pathString.substr(1, pathString.length - 2);
82-
83-
const captures = pattern.exec(pathStringWithoutQuotes);
84-
85-
if (captures) {
86-
const newNameFragments = [];
87-
for (const fragment of template) {
88-
if (typeof fragment === 'number') {
89-
newNameFragments.push(captures[fragment]);
90-
} else if (typeof fragment === 'string') {
91-
newNameFragments.push(fragment);
92-
} else {
93-
throw Error(`unrecognized fragment: ${fragment}`);
94-
}
95-
}
96-
return newNameFragments.join('');
97-
}
98-
99-
return null;
100-
}
101-
102-
function transformNode(node, { pattern, template }) {
65+
function visitNode(node, { pattern, template }) {
66+
let importPath;
10367
if (
10468
(ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) &&
10569
node.moduleSpecifier
10670
) {
10771
const importPathWithQuotes = node.moduleSpecifier.getText();
108-
const newName = replacePath(importPathWithQuotes, pattern, template);
72+
importPath = importPathWithQuotes.substr(
73+
1,
74+
importPathWithQuotes.length - 2
75+
);
76+
77+
const captures = pattern.exec(importPath);
10978

110-
if (newName) {
111-
if (ts.isImportDeclaration(node)) {
112-
return ts.factory.updateImportDeclaration(
113-
node,
114-
node.decorators,
115-
node.modifiers,
116-
node.importClause,
117-
ts.factory.createStringLiteral(newName) // moduleSpecifier
118-
);
119-
} else if (ts.isExportDeclaration(node)) {
120-
return ts.factory.updateExportDeclaration(
121-
node,
122-
node.decorators,
123-
node.modifiers,
124-
node.isTypeOnly,
125-
node.exportClause,
126-
ts.factory.createStringLiteral(newName) // moduleSpecifier
127-
);
79+
if (captures) {
80+
const newNameFragments = [];
81+
for (const fragment of template) {
82+
if (typeof fragment === 'number') {
83+
newNameFragments.push(captures[fragment]);
84+
} else if (typeof fragment === 'string') {
85+
newNameFragments.push(fragment);
86+
} else {
87+
throw Error(`unrecognized fragment: ${fragment}`);
88+
}
12889
}
129-
// Just in case.
130-
return node;
131-
}
132-
} else if (ts.isModuleDeclaration(node) && node.name) {
133-
const importPathWithQuotes = node.name.getText();
134-
const newName = replacePath(importPathWithQuotes, pattern, template);
135-
if (newName) {
136-
const newNode = ts.factory.updateModuleDeclaration(
137-
node,
138-
node.decorators,
139-
node.modifiers,
140-
ts.factory.createStringLiteral(newName) // name
141-
);
90+
const newName = newNameFragments.join('');
91+
const newNode = ts.getMutableClone(node);
92+
newNode.moduleSpecifier = ts.createLiteral(newName);
14293
return newNode;
14394
}
14495
}

0 commit comments

Comments
 (0)