pdfjs-serverless 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/index.mjs +236 -200
  2. package/package.json +5 -2
package/dist/index.mjs CHANGED
@@ -1,195 +1,3 @@
1
- const process$1 = {};
2
- let cachedSetTimeout;
3
- let cachedClearTimeout;
4
- function defaultSetTimeout() {
5
- throw new Error("setTimeout has not been defined");
6
- }
7
- function defaultClearTimeout() {
8
- throw new Error("clearTimeout has not been defined");
9
- }
10
- (function() {
11
- try {
12
- cachedSetTimeout = typeof setTimeout === "function" ? setTimeout : defaultSetTimeout;
13
- } catch {
14
- cachedSetTimeout = defaultSetTimeout;
15
- }
16
- try {
17
- cachedClearTimeout = typeof clearTimeout === "function" ? clearTimeout : defaultClearTimeout;
18
- } catch {
19
- cachedClearTimeout = defaultClearTimeout;
20
- }
21
- })();
22
- function runTimeout(fun) {
23
- if (cachedSetTimeout === setTimeout) {
24
- return setTimeout(fun, 0);
25
- }
26
- if ((cachedSetTimeout === defaultSetTimeout || !cachedSetTimeout) && setTimeout) {
27
- cachedSetTimeout = setTimeout;
28
- return setTimeout(fun, 0);
29
- }
30
- try {
31
- return cachedSetTimeout(fun, 0);
32
- } catch {
33
- try {
34
- return cachedSetTimeout.call(null, fun, 0);
35
- } catch {
36
- return cachedSetTimeout.call(this, fun, 0);
37
- }
38
- }
39
- }
40
- function runClearTimeout(marker) {
41
- if (cachedClearTimeout === clearTimeout) {
42
- return clearTimeout(marker);
43
- }
44
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
45
- cachedClearTimeout = clearTimeout;
46
- return clearTimeout(marker);
47
- }
48
- try {
49
- return cachedClearTimeout(marker);
50
- } catch {
51
- try {
52
- return cachedClearTimeout.call(null, marker);
53
- } catch {
54
- return cachedClearTimeout.call(this, marker);
55
- }
56
- }
57
- }
58
- let queue = [];
59
- let draining = false;
60
- let currentQueue;
61
- let queueIndex = -1;
62
- function cleanUpNextTick() {
63
- if (!draining || !currentQueue) {
64
- return;
65
- }
66
- draining = false;
67
- if (currentQueue.length > 0) {
68
- queue = [...currentQueue, ...queue];
69
- } else {
70
- queueIndex = -1;
71
- }
72
- if (queue.length > 0) {
73
- drainQueue();
74
- }
75
- }
76
- function drainQueue() {
77
- if (draining) {
78
- return;
79
- }
80
- const timeout = runTimeout(cleanUpNextTick);
81
- draining = true;
82
- let len = queue.length;
83
- while (len) {
84
- currentQueue = queue;
85
- queue = [];
86
- while (++queueIndex < len) {
87
- if (currentQueue) {
88
- currentQueue[queueIndex].run();
89
- }
90
- }
91
- queueIndex = -1;
92
- len = queue.length;
93
- }
94
- currentQueue = null;
95
- draining = false;
96
- runClearTimeout(timeout);
97
- }
98
- process$1.nextTick = function(fun) {
99
- const args = Array.from({ length: arguments.length - 1 });
100
- if (arguments.length > 1) {
101
- for (let i = 1; i < arguments.length; i++) {
102
- args[i - 1] = arguments[i];
103
- }
104
- }
105
- queue.push(new Item(fun, args));
106
- if (queue.length === 1 && !draining) {
107
- runTimeout(drainQueue);
108
- }
109
- };
110
- function Item(fun, array) {
111
- this.fun = fun;
112
- this.array = array;
113
- }
114
- Item.prototype.run = function() {
115
- this.fun.apply(null, this.array);
116
- };
117
- process$1.title = "unenv";
118
- const _envShim = /* @__PURE__ */ Object.create(null);
119
- const _processEnv = globalThis.process?.env;
120
- const _getEnv = (useShim) => _processEnv || globalThis.__env__ || (useShim ? _envShim : globalThis);
121
- process$1.env = new Proxy(_envShim, {
122
- get(_, prop) {
123
- const env = _getEnv();
124
- return env[prop] ?? _envShim[prop];
125
- },
126
- has(_, prop) {
127
- const env = _getEnv();
128
- return prop in env || prop in _envShim;
129
- },
130
- set(_, prop, value) {
131
- const env = _getEnv(true);
132
- env[prop] = value;
133
- return true;
134
- },
135
- deleteProperty(_, prop) {
136
- const env = _getEnv(true);
137
- delete env[prop];
138
- },
139
- ownKeys() {
140
- const env = _getEnv();
141
- return Object.keys(env);
142
- }
143
- });
144
- process$1.argv = [];
145
- process$1.version = "";
146
- process$1.versions = {};
147
- function noop() {
148
- return process$1;
149
- }
150
- process$1.on = noop;
151
- process$1.addListener = noop;
152
- process$1.once = noop;
153
- process$1.off = noop;
154
- process$1.removeListener = noop;
155
- process$1.removeAllListeners = noop;
156
- process$1.emit = noop;
157
- process$1.prependListener = noop;
158
- process$1.prependOnceListener = noop;
159
- process$1.listeners = function(name) {
160
- return [];
161
- };
162
- process$1.binding = function(name) {
163
- throw new Error("[unenv] process.binding is not supported");
164
- };
165
- let cwd = "/";
166
- process$1.cwd = function() {
167
- return cwd;
168
- };
169
- process$1.chdir = function(dir) {
170
- cwd = dir;
171
- };
172
- process$1.umask = function() {
173
- return 0;
174
- };
175
-
176
- function getGlobal() {
177
- if (typeof globalThis !== "undefined") {
178
- return globalThis;
179
- }
180
- if (typeof self !== "undefined") {
181
- return self;
182
- }
183
- if (typeof global !== "undefined") {
184
- return global;
185
- }
186
- return {};
187
- }
188
- const _global = getGlobal();
189
-
190
- _global.process = _global.process || process$1;
191
- const process = _global.process;
192
-
193
1
  function createNotImplementedError(name) {
194
2
  throw new Error(`[unenv] ${name} is not implemented yet!`);
195
3
  }
@@ -2217,6 +2025,202 @@ notImplemented("buffer.transcode");
2217
2025
  notImplemented("buffer.isUtf8");
2218
2026
  notImplemented("buffer.isAscii");
2219
2027
 
2028
+ const process$1 = {};
2029
+ let cachedSetTimeout;
2030
+ let cachedClearTimeout;
2031
+ function defaultSetTimeout() {
2032
+ throw new Error("setTimeout has not been defined");
2033
+ }
2034
+ function defaultClearTimeout() {
2035
+ throw new Error("clearTimeout has not been defined");
2036
+ }
2037
+ (function() {
2038
+ try {
2039
+ cachedSetTimeout = typeof setTimeout === "function" ? setTimeout : defaultSetTimeout;
2040
+ } catch {
2041
+ cachedSetTimeout = defaultSetTimeout;
2042
+ }
2043
+ try {
2044
+ cachedClearTimeout = typeof clearTimeout === "function" ? clearTimeout : defaultClearTimeout;
2045
+ } catch {
2046
+ cachedClearTimeout = defaultClearTimeout;
2047
+ }
2048
+ })();
2049
+ function runTimeout(fun) {
2050
+ if (cachedSetTimeout === setTimeout) {
2051
+ return setTimeout(fun, 0);
2052
+ }
2053
+ if ((cachedSetTimeout === defaultSetTimeout || !cachedSetTimeout) && setTimeout) {
2054
+ cachedSetTimeout = setTimeout;
2055
+ return setTimeout(fun, 0);
2056
+ }
2057
+ try {
2058
+ return cachedSetTimeout(fun, 0);
2059
+ } catch {
2060
+ try {
2061
+ return cachedSetTimeout.call(null, fun, 0);
2062
+ } catch {
2063
+ return cachedSetTimeout.call(this, fun, 0);
2064
+ }
2065
+ }
2066
+ }
2067
+ function runClearTimeout(marker) {
2068
+ if (cachedClearTimeout === clearTimeout) {
2069
+ return clearTimeout(marker);
2070
+ }
2071
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
2072
+ cachedClearTimeout = clearTimeout;
2073
+ return clearTimeout(marker);
2074
+ }
2075
+ try {
2076
+ return cachedClearTimeout(marker);
2077
+ } catch {
2078
+ try {
2079
+ return cachedClearTimeout.call(null, marker);
2080
+ } catch {
2081
+ return cachedClearTimeout.call(this, marker);
2082
+ }
2083
+ }
2084
+ }
2085
+ let queue = [];
2086
+ let draining = false;
2087
+ let currentQueue;
2088
+ let queueIndex = -1;
2089
+ function cleanUpNextTick() {
2090
+ if (!draining || !currentQueue) {
2091
+ return;
2092
+ }
2093
+ draining = false;
2094
+ if (currentQueue.length > 0) {
2095
+ queue = [...currentQueue, ...queue];
2096
+ } else {
2097
+ queueIndex = -1;
2098
+ }
2099
+ if (queue.length > 0) {
2100
+ drainQueue();
2101
+ }
2102
+ }
2103
+ function drainQueue() {
2104
+ if (draining) {
2105
+ return;
2106
+ }
2107
+ const timeout = runTimeout(cleanUpNextTick);
2108
+ draining = true;
2109
+ let len = queue.length;
2110
+ while (len) {
2111
+ currentQueue = queue;
2112
+ queue = [];
2113
+ while (++queueIndex < len) {
2114
+ if (currentQueue) {
2115
+ currentQueue[queueIndex].run();
2116
+ }
2117
+ }
2118
+ queueIndex = -1;
2119
+ len = queue.length;
2120
+ }
2121
+ currentQueue = null;
2122
+ draining = false;
2123
+ runClearTimeout(timeout);
2124
+ }
2125
+ process$1.nextTick = function(fun) {
2126
+ const args = Array.from({ length: arguments.length - 1 });
2127
+ if (arguments.length > 1) {
2128
+ for (let i = 1; i < arguments.length; i++) {
2129
+ args[i - 1] = arguments[i];
2130
+ }
2131
+ }
2132
+ queue.push(new Item(fun, args));
2133
+ if (queue.length === 1 && !draining) {
2134
+ runTimeout(drainQueue);
2135
+ }
2136
+ };
2137
+ function Item(fun, array) {
2138
+ this.fun = fun;
2139
+ this.array = array;
2140
+ }
2141
+ Item.prototype.run = function() {
2142
+ this.fun.apply(null, this.array);
2143
+ };
2144
+ process$1.title = "unenv";
2145
+ const _envShim = /* @__PURE__ */ Object.create(null);
2146
+ const _processEnv = globalThis.process?.env;
2147
+ const _getEnv = (useShim) => _processEnv || globalThis.__env__ || (useShim ? _envShim : globalThis);
2148
+ process$1.env = new Proxy(_envShim, {
2149
+ get(_, prop) {
2150
+ const env = _getEnv();
2151
+ return env[prop] ?? _envShim[prop];
2152
+ },
2153
+ has(_, prop) {
2154
+ const env = _getEnv();
2155
+ return prop in env || prop in _envShim;
2156
+ },
2157
+ set(_, prop, value) {
2158
+ const env = _getEnv(true);
2159
+ env[prop] = value;
2160
+ return true;
2161
+ },
2162
+ deleteProperty(_, prop) {
2163
+ const env = _getEnv(true);
2164
+ delete env[prop];
2165
+ },
2166
+ ownKeys() {
2167
+ const env = _getEnv();
2168
+ return Object.keys(env);
2169
+ }
2170
+ });
2171
+ process$1.argv = [];
2172
+ process$1.version = "";
2173
+ process$1.versions = {};
2174
+ function noop() {
2175
+ return process$1;
2176
+ }
2177
+ process$1.on = noop;
2178
+ process$1.addListener = noop;
2179
+ process$1.once = noop;
2180
+ process$1.off = noop;
2181
+ process$1.removeListener = noop;
2182
+ process$1.removeAllListeners = noop;
2183
+ process$1.emit = noop;
2184
+ process$1.prependListener = noop;
2185
+ process$1.prependOnceListener = noop;
2186
+ process$1.listeners = function(name) {
2187
+ return [];
2188
+ };
2189
+ process$1.binding = function(name) {
2190
+ throw new Error("[unenv] process.binding is not supported");
2191
+ };
2192
+ let cwd = "/";
2193
+ process$1.cwd = function() {
2194
+ return cwd;
2195
+ };
2196
+ process$1.chdir = function(dir) {
2197
+ cwd = dir;
2198
+ };
2199
+ process$1.umask = function() {
2200
+ return 0;
2201
+ };
2202
+
2203
+ function getGlobal() {
2204
+ if (typeof globalThis !== "undefined") {
2205
+ return globalThis;
2206
+ }
2207
+ if (typeof self !== "undefined") {
2208
+ return self;
2209
+ }
2210
+ if (typeof global !== "undefined") {
2211
+ return global;
2212
+ }
2213
+ return {};
2214
+ }
2215
+ const _global = getGlobal();
2216
+
2217
+ _global.process = _global.process || process$1;
2218
+ const process = _global.process;
2219
+
2220
+ function getDefaultExportFromNamespaceIfNotNamed (n) {
2221
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
2222
+ }
2223
+
2220
2224
  function commonjsRequire(path) {
2221
2225
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
2222
2226
  }
@@ -2225,6 +2229,28 @@ var pdf = {exports: {}};
2225
2229
 
2226
2230
  var pdf_worker = {exports: {}};
2227
2231
 
2232
+ /**
2233
+ * @licstart The following is the entire license notice for the
2234
+ * JavaScript code in this page
2235
+ *
2236
+ * Copyright 2023 Mozilla Foundation
2237
+ *
2238
+ * Licensed under the Apache License, Version 2.0 (the "License");
2239
+ * you may not use this file except in compliance with the License.
2240
+ * You may obtain a copy of the License at
2241
+ *
2242
+ * http://www.apache.org/licenses/LICENSE-2.0
2243
+ *
2244
+ * Unless required by applicable law or agreed to in writing, software
2245
+ * distributed under the License is distributed on an "AS IS" BASIS,
2246
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2247
+ * See the License for the specific language governing permissions and
2248
+ * limitations under the License.
2249
+ *
2250
+ * @licend The above is the entire license notice for the
2251
+ * JavaScript code in this page
2252
+ */
2253
+
2228
2254
  var hasRequiredPdf_worker;
2229
2255
 
2230
2256
  function requirePdf_worker () {
@@ -2861,7 +2887,7 @@ function requirePdf_worker () {
2861
2887
  exports.unreachable = unreachable;
2862
2888
  exports.utf8StringToString = utf8StringToString;
2863
2889
  exports.warn = warn;
2864
- const isNodeJS = "undefined" === "object" ;
2890
+ const isNodeJS = true; // typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
2865
2891
  exports.isNodeJS = isNodeJS;
2866
2892
  const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
2867
2893
  exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
@@ -61217,6 +61243,21 @@ function requireFs () {
61217
61243
  return fs.exports;
61218
61244
  }
61219
61245
 
61246
+ const canvas = new Proxy({}, {
61247
+ get(target, prop) {
61248
+ return () => {
61249
+ throw new Error(`[pdfjs-serverless] canvas.${prop} is not implemented`)
61250
+ }
61251
+ },
61252
+ });
61253
+
61254
+ const canvas$1 = /*#__PURE__*/Object.freeze({
61255
+ __proto__: null,
61256
+ default: canvas
61257
+ });
61258
+
61259
+ const require$$2 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(canvas$1);
61260
+
61220
61261
  var url = {exports: {}};
61221
61262
 
61222
61263
  var hasRequiredUrl;
@@ -62340,7 +62381,7 @@ function requireHttp () {
62340
62381
  exports.unreachable = unreachable;
62341
62382
  exports.utf8StringToString = utf8StringToString;
62342
62383
  exports.warn = warn;
62343
- const isNodeJS = "undefined" === "object" ;
62384
+ const isNodeJS = true; // typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
62344
62385
  exports.isNodeJS = isNodeJS;
62345
62386
  const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
62346
62387
  exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
@@ -68019,12 +68060,7 @@ function requireHttp () {
68019
68060
  exports.NodeFilterFactory = NodeFilterFactory;
68020
68061
  class NodeCanvasFactory extends _base_factory.BaseCanvasFactory {
68021
68062
  _createCanvas(width, height) {
68022
- const Canvas = new Proxy({}, {
68023
- get(target, prop) {
68024
- return () => undefined
68025
- }
68026
- })
68027
- ;
68063
+ const Canvas = require$$2;
68028
68064
  return Canvas.createCanvas(width, height);
68029
68065
  }
68030
68066
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pdfjs-serverless",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "packageManager": "pnpm@8.6.12",
6
6
  "description": "Serverless build of PDF.js",
7
7
  "author": "Johann Schopplich <pkg@johannschopplich.com>",
@@ -34,7 +34,9 @@
34
34
  "dist"
35
35
  ],
36
36
  "scripts": {
37
- "build": "rollup -c rollup.config.js && cp -R node_modules/pdfjs-dist/types dist",
37
+ "build:pre": "rollup --config rollup.config.ts --configPlugin typescript",
38
+ "build:post": "cp -R node_modules/pdfjs-dist/types dist",
39
+ "build": "pnpm run build:pre && pnpm run build:post",
38
40
  "lint": "eslint .",
39
41
  "lint:fix": "eslint . --fix",
40
42
  "release": "bumpp --commit --push --tag"
@@ -46,6 +48,7 @@
46
48
  "@rollup/plugin-inject": "^5.0.3",
47
49
  "@rollup/plugin-node-resolve": "^15.2.1",
48
50
  "@rollup/plugin-replace": "^5.0.2",
51
+ "@rollup/plugin-typescript": "^11.1.3",
49
52
  "@types/node": "^20.5.6",
50
53
  "bumpp": "^9.2.0",
51
54
  "eslint": "^8.48.0",