msgpackr-extract 2.0.0 → 2.1.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.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { dirname } from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ process.chdir(fileURLToPath(dirname(dirname(import.meta.url))));
6
+ process.argv[2] = 'download';
7
+ import('prebuildify-ci');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "msgpackr-extract",
3
3
  "author": "Kris Zyp",
4
- "version": "2.0.0",
4
+ "version": "2.1.0",
5
5
  "description": "Node addon for string extraction for msgpackr",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -11,32 +11,39 @@
11
11
  "scripts": {
12
12
  "install": "node-gyp-build-optional-packages",
13
13
  "recompile": "node-gyp rebuild",
14
- "before-publish": "prebuildify-ci download && prebuildify --target 16.14.2 && set ENABLE_V8_FUNCTIONS=false&& prebuildify --platform-packages --napi --target 16.14.2 && node set-optional-deps.cjs",
15
- "prebuild": "prebuildify --target 16.14.2",
16
- "prebuild-libc": "prebuildify --tag-libc --target 16.14.2 && ENABLE_V8_FUNCTIONS=false prebuildify --platform-packages --napi --tag-libc --target 16.14.2",
14
+ "before-publish": "prebuildify-ci download && node set-optional-deps.cjs",
15
+ "prebuild": "prebuildify-platform-packages --target 16.14.2",
16
+ "prebuild-win32": "prebuildify-platform-packages --target 16.14.2 && set ENABLE_V8_FUNCTIONS=false&& prebuildify-platform-packages --platform-packages --napi --target 16.14.2",
17
+ "prebuild-libc": "prebuildify-platform-packages --tag-libc --target 16.14.2 && ENABLE_V8_FUNCTIONS=false prebuildify-platform-packages --platform-packages --napi --tag-libc --target 16.14.2",
18
+ "prebuild-libc-alpine": "prebuildify-cross --image alpine --tag-libc --target 16.14.2",
17
19
  "publish-all": "cd prebuilds/win32-x64 && npm publish --access public && cd ../darwin-x64 && npm publish --access public && cd ../darwin-arm64 && npm publish --access public && cd ../linux-x64 && npm publish --access public && cd ../linux-arm64 && npm publish --access public && cd ../linux-arm && npm publish --access public && cd ../.. && npm publish --access public",
18
20
  "test": "node ./index.js"
19
21
  },
20
22
  "main": "./index.js",
21
23
  "gypfile": true,
22
24
  "dependencies": {
23
- "node-gyp-build-optional-packages": "5.0.1"
25
+ "node-gyp-build-optional-packages": "5.0.3"
24
26
  },
25
27
  "files": [
26
28
  "index.js",
27
29
  "/src",
28
- "/*.gyp"
30
+ "/*.gyp",
31
+ "/bin"
29
32
  ],
33
+ "bin": {
34
+ "download-msgpackr-prebuilds": "./bin/download-prebuilds.js"
35
+ },
30
36
  "optionalDependencies": {
31
- "@msgpackr-extract/msgpackr-extract-darwin-arm64": "2.0.0",
32
- "@msgpackr-extract/msgpackr-extract-darwin-x64": "2.0.0",
33
- "@msgpackr-extract/msgpackr-extract-linux-arm": "2.0.0",
34
- "@msgpackr-extract/msgpackr-extract-linux-arm64": "2.0.0",
35
- "@msgpackr-extract/msgpackr-extract-linux-x64": "2.0.0",
36
- "@msgpackr-extract/msgpackr-extract-win32-x64": "2.0.0"
37
+ "@msgpackr-extract/msgpackr-extract-darwin-arm64": "2.1.0",
38
+ "@msgpackr-extract/msgpackr-extract-darwin-x64": "2.1.0",
39
+ "@msgpackr-extract/msgpackr-extract-linux-arm": "2.1.0",
40
+ "@msgpackr-extract/msgpackr-extract-linux-arm64": "2.1.0",
41
+ "@msgpackr-extract/msgpackr-extract-linux-x64": "2.1.0",
42
+ "@msgpackr-extract/msgpackr-extract-win32-x64": "2.1.0"
37
43
  },
38
44
  "devDependencies": {
39
- "prebuildify": "kriszyp/prebuildify#optional-packages",
40
- "prebuildify-ci": "^1.0.5"
45
+ "prebuildify-platform-packages": "5.0.0",
46
+ "prebuildify-ci": "^1.0.5",
47
+ "prebuildify-cross": "5.0.0"
41
48
  }
42
- }
49
+ }
package/src/extract.cpp CHANGED
@@ -34,7 +34,6 @@ napi_value unexpectedEnd(napi_env env) {
34
34
 
35
35
  class Extractor {
36
36
  public:
37
- napi_value target[MAX_TARGET_SIZE + 1]; // leave one for the queued string
38
37
  // napi_ref targetArray; // could consider reenabling this optimization for napi
39
38
  bool hasTargetArray = false;
40
39
  uint8_t* source;
@@ -43,7 +42,7 @@ public:
43
42
  int stringStart = 0;
44
43
  int lastStringEnd = 0;
45
44
 
46
- void readString(napi_env env, int length, bool allowStringBlocks) {
45
+ void readString(napi_env env, int length, bool allowStringBlocks, napi_value* target) {
47
46
  int start = position;
48
47
  int end = position + length;
49
48
  if (allowStringBlocks) { // for larger strings, we don't bother to check every character for being latin, and just go right to creating a new string
@@ -85,6 +84,7 @@ public:
85
84
  }
86
85
 
87
86
  napi_value extractStrings(napi_env env, int startingPosition, int size, uint8_t* inputSource) {
87
+ napi_value target[MAX_TARGET_SIZE + 1]; // leave one for the queued string
88
88
  writePosition = 0;
89
89
  lastStringEnd = 0;
90
90
  position = startingPosition;
@@ -99,7 +99,7 @@ public:
99
99
  if (token + position > size) {
100
100
  return unexpectedEnd(env);
101
101
  }
102
- readString(env,token, true);
102
+ readString(env, token, true, target);
103
103
  if (writePosition >= MAX_TARGET_SIZE)
104
104
  break;
105
105
  } else if (token <= 0xdb && token >= 0xd9) {
@@ -111,7 +111,7 @@ public:
111
111
  if (length + position > size) {
112
112
  return unexpectedEnd(env);
113
113
  }
114
- readString(env,length, true);
114
+ readString(env,length, true, target);
115
115
  } else if (token == 0xda) { //str 16
116
116
  if (2 + position > size) {
117
117
  return unexpectedEnd(env);
@@ -121,7 +121,7 @@ public:
121
121
  if (length + position > size) {
122
122
  return unexpectedEnd(env);
123
123
  }
124
- readString(env,length, false);
124
+ readString(env,length, false, target);
125
125
  } else { //str 32
126
126
  if (4 + position > size) {
127
127
  return unexpectedEnd(env);
@@ -133,7 +133,7 @@ public:
133
133
  if (length + position > size) {
134
134
  return unexpectedEnd(env);
135
135
  }
136
- readString(env, length, false);
136
+ readString(env, length, false, target);
137
137
  }
138
138
  if (writePosition >= MAX_TARGET_SIZE)
139
139
  break;
@@ -269,4 +269,4 @@ NAPI_MODULE_INIT() {
269
269
  setupTokenTable();
270
270
  EXPORT_NAPI_FUNCTION("extractStrings", extractStrings);
271
271
  return exports;
272
- }
272
+ }