@arcgis/core-adapter 4.32.0-next.5 → 4.32.0-next.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core-adapter",
3
- "version": "4.32.0-next.5",
3
+ "version": "4.32.0-next.50",
4
4
  "description": "ArcGIS Core Adapter",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -13,35 +13,11 @@
13
13
  "require": "./dist/index.cjs"
14
14
  }
15
15
  },
16
- "publishConfig": {
17
- "registry": "https://registry.npmjs.org/",
18
- "access": "public"
19
- },
20
16
  "license": "SEE LICENSE IN LICENSE.md",
21
- "scripts": {
22
- "build": "yarn pre:build && yarn build:generate && yarn build:tsup",
23
- "build:dev": "yarn build",
24
- "build:generate": "tsx ./scripts/generator.ts",
25
- "build:tsup": "tsup --silent",
26
- "pre:build": "rimraf ./src/index.ts",
27
- "clean": "rimraf .turbo ./dist",
28
- "update-types": "tsx ./scripts/update-adapter-typings"
29
- },
30
17
  "dependencies": {
31
18
  "tslib": "^2.7.0"
32
19
  },
33
- "devDependencies": {
34
- "@arcgis/typescript-config": "4.32.0-next.5",
35
- "@types/node": "^20.2.5",
36
- "resolve-pkg": "^2.0.0",
37
- "rimraf": "^5.0.0",
38
- "ts-morph": "^22.0.0",
39
- "tsup": "^8.3.0",
40
- "tsx": "^4.19.0",
41
- "typescript": "~5.4.0"
42
- },
43
20
  "peerDependencies": {
44
- "@arcgis/core": ">=4.31.0-next <4.32"
45
- },
46
- "gitHead": "e4e69443c65b6667007b81e8a05805bec146db56"
47
- }
21
+ "@arcgis/core": ">=4.32.0-next <4.33"
22
+ }
23
+ }
@@ -1,12 +1,12 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import ts from "typescript";
4
3
  import resolvePkg from "resolve-pkg";
5
4
  import type { SourceFile } from "ts-morph";
6
5
  import { Project } from "ts-morph";
7
- import { fileURLToPath } from "url";
6
+ import ts from "typescript";
7
+ import { publicModules } from "../support/publicModules";
8
8
 
9
- const dirname = path.dirname(fileURLToPath(import.meta.url));
9
+ const dirname = import.meta.dirname;
10
10
 
11
11
  /**
12
12
  * Collect the details of a type we are interested in
@@ -53,8 +53,9 @@ const nativeGenericTypes = nativeTypes.map((x) => `<${x}>`);
53
53
 
54
54
  // Modules to ignore
55
55
  const ignoreExports: string[] = [
56
- // declared as a namespace
56
+ // virtual
57
57
  "esri/core/units",
58
+ "esri/core/quantity",
58
59
  ];
59
60
 
60
61
  // Module that returns an instance of a class
@@ -165,6 +166,8 @@ function generate(): void {
165
166
 
166
167
  const publicTypeValidator = new PublicTypeValidator();
167
168
 
169
+ const visitedModules = new Set<string>();
170
+
168
171
  // We will visit the typings and extract the symbols we need
169
172
  // Add the singletons to the typeInfos array
170
173
  const typeInfos: TypeInfo[] = [...singletons.entries()].map(([amdModulePath, typeName]) => ({
@@ -189,10 +192,24 @@ function generate(): void {
189
192
  // Only include imports that are in the import dictionary
190
193
  // or are part of "esri/applications" modules
191
194
  const amdModulePath = node.name.text;
195
+ if (visitedModules.has(amdModulePath)) {
196
+ console.log("\x1b[33m", "WARNING: Skipping duplicate module: ", amdModulePath);
197
+ return node;
198
+ }
199
+ visitedModules.add(amdModulePath);
192
200
  if (!amdImportReferencesKeys.includes(amdModulePath) && !amdModulePath.includes("esri/applications")) {
193
201
  return node;
194
202
  }
195
203
 
204
+ if (amdModulePath.includes("esri/applications") && !publicModules.includes(amdModulePath)) {
205
+ console.log(
206
+ "\x1b[33m",
207
+ "WARNING: Skipping, application module not in publicModules file in js-api repo: ",
208
+ amdModulePath,
209
+ );
210
+ return node;
211
+ }
212
+
196
213
  // Ignore modules that are in the ignore list and the singletons that are already in the typeInfos array
197
214
  if (ignoreModule(amdModulePath) || singletons.has(amdModulePath)) {
198
215
  return node;
@@ -377,7 +394,22 @@ function processUnionType(parameterInfo: ParameterInfo): string {
377
394
  function generateImportFunction(entry: TypeInfo): string {
378
395
  const { amdModulePath, esmModulePath, typeName, instanceType = false } = entry;
379
396
  const functionNameSuffix = convertToPascalCase(amdModulePath);
380
- const promiseType = instanceType ? typeName : `typeof ${typeName}`;
397
+ const resolvedTypeName = [
398
+ "__esri.CollectionFlattener",
399
+ "__esri.SelectionOperation",
400
+ "__esri.SketchTooltipControls",
401
+ ].includes(typeName)
402
+ ? "any"
403
+ : typeName;
404
+
405
+ let promiseType: string;
406
+ if (resolvedTypeName === "any") {
407
+ promiseType = "any";
408
+ } else if (instanceType) {
409
+ promiseType = resolvedTypeName;
410
+ } else {
411
+ promiseType = `typeof ${resolvedTypeName}`;
412
+ }
381
413
 
382
414
  return `
383
415
  export async function import${functionNameSuffix}(): Promise<${promiseType}> {
@@ -1,5 +1,5 @@
1
- import fs from "fs";
2
- import https from "https";
1
+ import fs from "node:fs";
2
+ import https from "node:https";
3
3
  import resolvePkg from "resolve-pkg";
4
4
 
5
5
  // Get the @arcgis/core installed version
@@ -22,37 +22,71 @@ const files = [
22
22
  source: `https://jsapi.esri.com/typings/api-reference-esm-imports-${coreVersion}.json`,
23
23
  destination: `${process.cwd()}/support/api-reference-esm-imports.json`,
24
24
  },
25
+ {
26
+ source: "https://raw.devtopia.esri.com/WebGIS/arcgis-js-api/4master/build/publicModules.mjs",
27
+ destination: `${process.cwd()}/support/publicModules.ts`,
28
+ },
25
29
  ];
26
30
 
31
+ const HttpOK = 200;
32
+
27
33
  // Download the typings and support files.
28
34
  async function downloadSupportFiles(source: string, destination: string): Promise<void> {
29
- try {
30
- fs.unlinkSync(destination);
31
- } catch {
32
- console.log("Error in deleting typings files, continue...");
33
- }
34
-
35
- const file = fs.createWriteStream(destination);
36
-
37
35
  await new Promise((resolve, reject) => {
38
- https.get(source, (resp) => {
36
+ const isPublicModules = source.includes("publicModules.mjs");
37
+ const options: {
38
+ headers?: {
39
+ Authorization: string;
40
+ };
41
+ } = {};
42
+ if (isPublicModules) {
43
+ options.headers = {
44
+ Authorization: `Token ${process.env.DEVTOPIA_TOKEN}`,
45
+ };
46
+ }
47
+ https.get(source, options, (resp) => {
48
+ const file = resp.statusCode === HttpOK ? fs.createWriteStream(destination) : undefined;
39
49
  console.log("Downloaded:", source);
40
50
  console.log(`Response type: ${resp.headers["content-type"]}`);
41
51
 
42
- resp.pipe(file);
52
+ if (resp.statusCode !== HttpOK) {
53
+ console.error(`Request failed for ${source}:`, resp.statusMessage);
54
+ console.error(`Skipping: ${destination}`);
55
+ file?.close();
56
+ resolve(undefined);
57
+ }
58
+
59
+ if (isPublicModules) {
60
+ let body = "";
61
+ resp.on("data", (chunk) => {
62
+ body += chunk;
63
+ });
64
+
65
+ resp.on("end", () => {
66
+ const regex = /const\s+publicModules\s*=\s*\[(.*?)\];/su;
67
+ const match = body.match(regex);
68
+ if (match) {
69
+ const publicModules = match[1];
70
+ body = `export const publicModules = [${publicModules}];`;
71
+ file?.write(body);
72
+ }
73
+ });
74
+ } else {
75
+ resp.pipe(file!);
76
+ }
43
77
 
44
78
  resp.on("error", (err) => {
45
79
  console.error(`Request error for ${source}:`, err);
46
80
  reject(err);
47
81
  });
48
82
 
49
- file.on("error", (err) => {
83
+ file?.on("error", (err) => {
50
84
  console.error(`Writing error for ${destination}:`, err);
51
85
  reject(err);
52
86
  });
53
87
 
54
- file.on("finish", () => {
55
- file.close();
88
+ file?.on("finish", () => {
89
+ file?.close();
56
90
  resolve(undefined);
57
91
  });
58
92
  });