@teambit/renaming 0.0.2 → 0.0.9
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.
- package/dist/rename.cmd.js +2 -2
- package/dist/rename.cmd.js.map +1 -1
- package/dist/renaming.graphql.d.ts +3 -0
- package/dist/renaming.graphql.js +44 -0
- package/dist/renaming.graphql.js.map +1 -0
- package/dist/renaming.main.runtime.d.ts +4 -2
- package/dist/renaming.main.runtime.js +34 -6
- package/dist/renaming.main.runtime.js.map +1 -1
- package/package-tar/teambit-renaming-0.0.9.tgz +0 -0
- package/package.json +11 -9
- package/package-tar/teambit-renaming-0.0.2.tgz +0 -0
package/dist/rename.cmd.js
CHANGED
|
@@ -35,11 +35,11 @@ class RenameCmd {
|
|
|
35
35
|
constructor(renaming) {
|
|
36
36
|
this.renaming = renaming;
|
|
37
37
|
(0, _defineProperty2().default)(this, "name", 'rename <source-id> <target-id>');
|
|
38
|
-
(0, _defineProperty2().default)(this, "description", 'EXPERIMENTAL. create a new
|
|
38
|
+
(0, _defineProperty2().default)(this, "description", 'EXPERIMENTAL. rename component. if tagged/exported, create a new component and deprecate the source-component');
|
|
39
39
|
(0, _defineProperty2().default)(this, "group", 'collaborate');
|
|
40
40
|
(0, _defineProperty2().default)(this, "skipWorkspace", true);
|
|
41
41
|
(0, _defineProperty2().default)(this, "alias", '');
|
|
42
|
-
(0, _defineProperty2().default)(this, "options", [['s', 'scope', 'default scope for the newly created component'], ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`']]);
|
|
42
|
+
(0, _defineProperty2().default)(this, "options", [['s', 'scope <string>', 'default scope for the newly created component'], ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`']]);
|
|
43
43
|
(0, _defineProperty2().default)(this, "loader", true);
|
|
44
44
|
(0, _defineProperty2().default)(this, "migration", true);
|
|
45
45
|
(0, _defineProperty2().default)(this, "remoteOp", true);
|
package/dist/rename.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["rename.cmd.ts"],"names":["RenameCmd","constructor","renaming","report","sourceId","targetId","options","results","rename","chalk","green","bold","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AASO,MAAMA,SAAN,CAAmC;
|
|
1
|
+
{"version":3,"sources":["rename.cmd.ts"],"names":["RenameCmd","constructor","renaming","report","sourceId","targetId","options","results","rename","chalk","green","bold","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AASO,MAAMA,SAAN,CAAmC;AAexCC,EAAAA,WAAW,CAASC,QAAT,EAAiC;AAAA,SAAxBA,QAAwB,GAAxBA,QAAwB;AAAA,kDAdrC,gCAcqC;AAAA,yDAZ1C,+GAY0C;AAAA,mDAXpC,aAWoC;AAAA,2DAV5B,IAU4B;AAAA,mDATpC,EASoC;AAAA,qDARlC,CACR,CAAC,GAAD,EAAM,gBAAN,EAAwB,+CAAxB,CADQ,EAER,CAAC,GAAD,EAAM,eAAN,EAAuB,qFAAvB,CAFQ,CAQkC;AAAA,oDAJnC,IAImC;AAAA,uDAHhC,IAGgC;AAAA,sDAFjC,IAEiC;AAAE;;AAElC,QAANC,MAAM,CAAC,CAACC,QAAD,EAAWC,QAAX,CAAD,EAAyCC,OAAzC,EAAkF;AAC5F,UAAMC,OAAO,GAAG,MAAM,KAAKL,QAAL,CAAcM,MAAd,CAAqBJ,QAArB,EAA+BC,QAA/B,EAAyCC,OAAzC,CAAtB;AACA,WAAOG,iBAAMC,KAAN,CACJ,wBAAuBD,iBAAME,IAAN,CAAWJ,OAAO,CAACH,QAAR,CAAiBQ,QAAjB,EAAX,CAAwC,OAAMH,iBAAME,IAAN,CAAWJ,OAAO,CAACF,QAAR,CAAiBO,QAAjB,EAAX,CAAwC,EADzG,CAAP;AAGD;;AAtBuC","sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { RenamingMain } from '.';\n\nexport type RenameOptions = {\n scope?: string;\n path?: string;\n};\n\nexport class RenameCmd implements Command {\n name = 'rename <source-id> <target-id>';\n description =\n 'EXPERIMENTAL. rename component. if tagged/exported, create a new component and deprecate the source-component';\n group = 'collaborate';\n skipWorkspace = true;\n alias = '';\n options = [\n ['s', 'scope <string>', 'default scope for the newly created component'],\n ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ] as CommandOptions;\n loader = true;\n migration = true;\n remoteOp = true;\n\n constructor(private renaming: RenamingMain) {}\n\n async report([sourceId, targetId]: [string, string], options: RenameOptions): Promise<string> {\n const results = await this.renaming.rename(sourceId, targetId, options);\n return chalk.green(\n `successfully renamed ${chalk.bold(results.sourceId.toString())} to ${chalk.bold(results.targetId.toString())}`\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.renamingSchema = renamingSchema;
|
|
9
|
+
|
|
10
|
+
function _graphqlTag() {
|
|
11
|
+
const data = _interopRequireDefault(require("graphql-tag"));
|
|
12
|
+
|
|
13
|
+
_graphqlTag = function () {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function renamingSchema(renaming) {
|
|
21
|
+
return {
|
|
22
|
+
typeDefs: (0, _graphqlTag().default)`
|
|
23
|
+
extend type Component {
|
|
24
|
+
renaming: RenamingInfo
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type RenamingInfo {
|
|
28
|
+
renamedFrom: String
|
|
29
|
+
}
|
|
30
|
+
`,
|
|
31
|
+
resolvers: {
|
|
32
|
+
Component: {
|
|
33
|
+
renaming: component => {
|
|
34
|
+
const renamingInfo = renaming.getRenamingInfo(component);
|
|
35
|
+
return {
|
|
36
|
+
renamedFrom: renamingInfo === null || renamingInfo === void 0 ? void 0 : renamingInfo.renamedFrom.toString()
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=renaming.graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renaming.graphql.ts"],"names":["renamingSchema","renaming","typeDefs","resolvers","Component","component","renamingInfo","getRenamingInfo","renamedFrom","toString"],"mappings":";;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,SAASA,cAAT,CAAwBC,QAAxB,EAAwD;AAC7D,SAAO;AACLC,IAAAA,QAAQ,EAAE,0BAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KATS;AAULC,IAAAA,SAAS,EAAE;AACTC,MAAAA,SAAS,EAAE;AACTH,QAAAA,QAAQ,EAAGI,SAAD,IAA0B;AAClC,gBAAMC,YAAY,GAAGL,QAAQ,CAACM,eAAT,CAAyBF,SAAzB,CAArB;AACA,iBAAO;AACLG,YAAAA,WAAW,EAAEF,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEE,WAAd,CAA0BC,QAA1B;AADR,WAAP;AAGD;AANQ;AADF;AAVN,GAAP;AAqBD","sourcesContent":["import { Component } from '@teambit/component';\nimport { Schema } from '@teambit/graphql';\nimport gql from 'graphql-tag';\nimport { RenamingMain } from './renaming.main.runtime';\n\nexport function renamingSchema(renaming: RenamingMain): Schema {\n return {\n typeDefs: gql`\n extend type Component {\n renaming: RenamingInfo\n }\n\n type RenamingInfo {\n renamedFrom: String\n }\n `,\n resolvers: {\n Component: {\n renaming: (component: Component) => {\n const renamingInfo = renaming.getRenamingInfo(component);\n return {\n renamedFrom: renamingInfo?.renamedFrom.toString(),\n };\n },\n },\n },\n };\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CLIMain } from '@teambit/cli';
|
|
2
2
|
import { Component, ComponentID, ComponentMain } from '@teambit/component';
|
|
3
3
|
import { DeprecationMain } from '@teambit/deprecation';
|
|
4
|
+
import { GraphqlMain } from '@teambit/graphql';
|
|
4
5
|
import { NewComponentHelperMain } from '@teambit/new-component-helper';
|
|
5
6
|
import { Workspace } from '@teambit/workspace';
|
|
6
7
|
import { RenameOptions } from './rename.cmd';
|
|
@@ -15,12 +16,13 @@ export declare class RenamingMain {
|
|
|
15
16
|
static slots: never[];
|
|
16
17
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
17
18
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
18
|
-
static provider([cli, workspace, deprecation, newComponentHelper, componentMain]: [
|
|
19
|
+
static provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql]: [
|
|
19
20
|
CLIMain,
|
|
20
21
|
Workspace,
|
|
21
22
|
DeprecationMain,
|
|
22
23
|
NewComponentHelperMain,
|
|
23
|
-
ComponentMain
|
|
24
|
+
ComponentMain,
|
|
25
|
+
GraphqlMain
|
|
24
26
|
]): Promise<RenamingMain>;
|
|
25
27
|
}
|
|
26
28
|
export declare type RenameResult = {
|
|
@@ -51,6 +51,16 @@ function _deprecation() {
|
|
|
51
51
|
return data;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
function _graphql() {
|
|
55
|
+
const data = _interopRequireDefault(require("@teambit/graphql"));
|
|
56
|
+
|
|
57
|
+
_graphql = function () {
|
|
58
|
+
return data;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
|
|
54
64
|
function _newComponentHelper() {
|
|
55
65
|
const data = _interopRequireDefault(require("@teambit/new-component-helper"));
|
|
56
66
|
|
|
@@ -101,6 +111,16 @@ function _renaming2() {
|
|
|
101
111
|
return data;
|
|
102
112
|
}
|
|
103
113
|
|
|
114
|
+
function _renaming3() {
|
|
115
|
+
const data = require("./renaming.graphql");
|
|
116
|
+
|
|
117
|
+
_renaming3 = function () {
|
|
118
|
+
return data;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return data;
|
|
122
|
+
}
|
|
123
|
+
|
|
104
124
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
105
125
|
|
|
106
126
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -118,12 +138,19 @@ class RenamingMain {
|
|
|
118
138
|
|
|
119
139
|
async rename(sourceIdStr, targetIdStr, options) {
|
|
120
140
|
const sourceId = await this.workspace.resolveComponentId(sourceIdStr);
|
|
141
|
+
const isTagged = sourceId.hasVersion();
|
|
121
142
|
const sourceComp = await this.workspace.get(sourceId);
|
|
122
143
|
const targetId = this.newComponentHelper.getNewComponentId(targetIdStr, undefined, options === null || options === void 0 ? void 0 : options.scope);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
144
|
+
|
|
145
|
+
if (isTagged) {
|
|
146
|
+
const config = await this.getConfig(sourceComp);
|
|
147
|
+
await this.newComponentHelper.writeAndAddNewComp(sourceComp, targetId, options, config);
|
|
148
|
+
await this.deprecation.deprecate(sourceId, targetId);
|
|
149
|
+
} else {
|
|
150
|
+
this.workspace.bitMap.renameNewComponent(sourceId, targetId);
|
|
151
|
+
await this.workspace.bitMap.write();
|
|
152
|
+
}
|
|
153
|
+
|
|
127
154
|
return {
|
|
128
155
|
sourceId,
|
|
129
156
|
targetId
|
|
@@ -149,9 +176,10 @@ class RenamingMain {
|
|
|
149
176
|
});
|
|
150
177
|
}
|
|
151
178
|
|
|
152
|
-
static async provider([cli, workspace, deprecation, newComponentHelper, componentMain]) {
|
|
179
|
+
static async provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql]) {
|
|
153
180
|
const renaming = new RenamingMain(workspace, newComponentHelper, deprecation);
|
|
154
181
|
cli.register(new (_rename().RenameCmd)(renaming));
|
|
182
|
+
graphql.register((0, _renaming3().renamingSchema)(renaming));
|
|
155
183
|
componentMain.registerShowFragments([new (_renaming2().RenamingFragment)(renaming)]);
|
|
156
184
|
return renaming;
|
|
157
185
|
}
|
|
@@ -160,7 +188,7 @@ class RenamingMain {
|
|
|
160
188
|
|
|
161
189
|
exports.RenamingMain = RenamingMain;
|
|
162
190
|
(0, _defineProperty2().default)(RenamingMain, "slots", []);
|
|
163
|
-
(0, _defineProperty2().default)(RenamingMain, "dependencies", [_cli().CLIAspect, _workspace().default, _deprecation().DeprecationAspect, _newComponentHelper().default, _component().default]);
|
|
191
|
+
(0, _defineProperty2().default)(RenamingMain, "dependencies", [_cli().CLIAspect, _workspace().default, _deprecation().DeprecationAspect, _newComponentHelper().default, _component().default, _graphql().default]);
|
|
164
192
|
(0, _defineProperty2().default)(RenamingMain, "runtime", _cli().MainRuntime);
|
|
165
193
|
|
|
166
194
|
_renaming().RenamingAspect.addRuntime(RenamingMain);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["renaming.main.runtime.ts"],"names":["RenamingMain","constructor","workspace","newComponentHelper","deprecation","rename","sourceIdStr","targetIdStr","options","sourceId","resolveComponentId","sourceComp","get","targetId","getNewComponentId","undefined","scope","
|
|
1
|
+
{"version":3,"sources":["renaming.main.runtime.ts"],"names":["RenamingMain","constructor","workspace","newComponentHelper","deprecation","rename","sourceIdStr","targetIdStr","options","sourceId","resolveComponentId","isTagged","hasVersion","sourceComp","get","targetId","getNewComponentId","undefined","scope","config","getConfig","writeAndAddNewComp","deprecate","bitMap","renameNewComponent","write","getRenamingInfo","component","renameConfig","state","aspects","RenamingAspect","id","renamedFrom","ComponentID","fromObject","comp","fromExisting","getConfigFromExistingToNewComponent","toObject","provider","cli","componentMain","graphql","renaming","register","RenameCmd","registerShowFragments","RenamingFragment","CLIAspect","WorkspaceAspect","DeprecationAspect","NewComponentHelperAspect","ComponentAspect","GraphqlAspect","MainRuntime","addRuntime"],"mappings":"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","sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport ComponentAspect, { Component, ComponentID, ComponentMain } from '@teambit/component';\nimport { DeprecationAspect, DeprecationMain } from '@teambit/deprecation';\nimport GraphqlAspect, { GraphqlMain } from '@teambit/graphql';\nimport NewComponentHelperAspect, { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { RenameCmd, RenameOptions } from './rename.cmd';\nimport { RenamingAspect } from './renaming.aspect';\nimport { RenamingFragment } from './renaming.fragment';\nimport { renamingSchema } from './renaming.graphql';\n\nexport class RenamingMain {\n constructor(\n private workspace: Workspace,\n private newComponentHelper: NewComponentHelperMain,\n private deprecation: DeprecationMain\n ) {}\n\n async rename(sourceIdStr: string, targetIdStr: string, options: RenameOptions): Promise<RenameResult> {\n const sourceId = await this.workspace.resolveComponentId(sourceIdStr);\n const isTagged = sourceId.hasVersion();\n const sourceComp = await this.workspace.get(sourceId);\n const targetId = this.newComponentHelper.getNewComponentId(targetIdStr, undefined, options?.scope);\n if (isTagged) {\n const config = await this.getConfig(sourceComp);\n await this.newComponentHelper.writeAndAddNewComp(sourceComp, targetId, options, config);\n await this.deprecation.deprecate(sourceId, targetId);\n } else {\n this.workspace.bitMap.renameNewComponent(sourceId, targetId);\n await this.workspace.bitMap.write();\n }\n\n return {\n sourceId,\n targetId,\n };\n }\n\n getRenamingInfo(component: Component): RenamingInfo | null {\n const renameConfig = component.state.aspects.get(RenamingAspect.id)?.config as RenamingInfo | undefined;\n if (!renameConfig) return null;\n return {\n renamedFrom: ComponentID.fromObject(renameConfig.renamedFrom),\n };\n }\n\n private async getConfig(comp: Component) {\n const fromExisting = await this.newComponentHelper.getConfigFromExistingToNewComponent(comp);\n return {\n ...fromExisting,\n [RenamingAspect.id]: {\n renamedFrom: comp.id.toObject(),\n },\n };\n }\n\n static slots = [];\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n DeprecationAspect,\n NewComponentHelperAspect,\n ComponentAspect,\n GraphqlAspect,\n ];\n static runtime = MainRuntime;\n static async provider([cli, workspace, deprecation, newComponentHelper, componentMain, graphql]: [\n CLIMain,\n Workspace,\n DeprecationMain,\n NewComponentHelperMain,\n ComponentMain,\n GraphqlMain\n ]) {\n const renaming = new RenamingMain(workspace, newComponentHelper, deprecation);\n cli.register(new RenameCmd(renaming));\n graphql.register(renamingSchema(renaming));\n componentMain.registerShowFragments([new RenamingFragment(renaming)]);\n return renaming;\n }\n}\n\nRenamingAspect.addRuntime(RenamingMain);\n\nexport type RenameResult = { sourceId: ComponentID; targetId: ComponentID };\n\nexport type RenamingInfo = {\n renamedFrom: ComponentID;\n};\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/renaming",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/component/renaming",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "renaming",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.9"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
13
13
|
"@teambit/harmony": "0.2.11",
|
|
14
|
+
"graphql-tag": "2.12.1",
|
|
14
15
|
"@babel/runtime": "7.12.18",
|
|
15
16
|
"core-js": "^3.0.0",
|
|
16
|
-
"@teambit/cli": "0.0.
|
|
17
|
-
"@teambit/component": "0.0.
|
|
18
|
-
"@teambit/
|
|
19
|
-
"@teambit/
|
|
20
|
-
"@teambit/
|
|
17
|
+
"@teambit/cli": "0.0.417",
|
|
18
|
+
"@teambit/component": "0.0.605",
|
|
19
|
+
"@teambit/graphql": "0.0.605",
|
|
20
|
+
"@teambit/deprecation": "0.0.605",
|
|
21
|
+
"@teambit/new-component-helper": "0.0.9",
|
|
22
|
+
"@teambit/workspace": "0.0.605"
|
|
21
23
|
},
|
|
22
24
|
"devDependencies": {
|
|
23
25
|
"@types/mocha": "5.2.7",
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
"@types/node": "12.20.4"
|
|
29
31
|
},
|
|
30
32
|
"peerDependencies": {
|
|
31
|
-
"@teambit/legacy": "1.0.
|
|
33
|
+
"@teambit/legacy": "1.0.201",
|
|
32
34
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
33
35
|
"react": "^16.8.0 || ^17.0.0"
|
|
34
36
|
},
|
|
@@ -56,7 +58,7 @@
|
|
|
56
58
|
"react": "-"
|
|
57
59
|
},
|
|
58
60
|
"peerDependencies": {
|
|
59
|
-
"@teambit/legacy": "1.0.
|
|
61
|
+
"@teambit/legacy": "1.0.201",
|
|
60
62
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
61
63
|
"react": "^16.8.0 || ^17.0.0"
|
|
62
64
|
}
|
|
Binary file
|