piclaw 0.0.20 → 0.0.21
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/.output/nitro.json +1 -1
- package/.output/public/assets/defult-D5RLDUrI.js +1 -0
- package/.output/public/assets/{dist-D-Hc5HbQ.js → dist-BH_oa-kv.js} +1 -1
- package/.output/public/assets/index-7JvURuHy.js +204 -0
- package/.output/public/assets/index-K43slwjJ.css +1 -0
- package/.output/public/index.html +11 -2
- package/.output/server/_chunks/app.mjs +138 -104
- package/.output/server/_chunks/config.mjs +4 -0
- package/.output/server/_chunks/dummy.mjs +1 -1
- package/.output/server/_chunks/logger.mjs +1 -1
- package/.output/server/_chunks/notes.mjs +1 -3
- package/.output/server/_chunks/renderer-template.mjs +1 -1
- package/.output/server/_chunks/sandbox.mjs +217 -0
- package/.output/server/_chunks/server.mjs +411 -291
- package/.output/server/_chunks/terminal.mjs +47 -8
- package/.output/server/_chunks/virtual.mjs +192 -54
- package/.output/server/_id_.delete.mjs +5 -2
- package/.output/server/_id_2.delete.mjs +8 -0
- package/.output/server/_jid_.delete.mjs +0 -1
- package/.output/server/_jid_.patch.mjs +21 -3
- package/.output/server/_jid_2.delete.mjs +0 -1
- package/.output/server/_libs/@acemir/cssom+[...].mjs +2269 -1137
- package/.output/server/_libs/@google/genai.mjs +348 -284
- package/.output/server/_libs/@mariozechner/pi-agent-core+[...].mjs +381 -2073
- package/.output/server/_libs/@mariozechner/pi-coding-agent+[...].mjs +236 -136
- package/.output/server/_libs/_.mjs +3 -2
- package/.output/server/_libs/_10.mjs +2 -4
- package/.output/server/_libs/_11.mjs +2 -4
- package/.output/server/_libs/_12.mjs +2 -3
- package/.output/server/_libs/_13.mjs +2 -3
- package/.output/server/_libs/_14.mjs +2 -4
- package/.output/server/_libs/_15.mjs +2 -4
- package/.output/server/_libs/_16.mjs +2 -3
- package/.output/server/_libs/_17.mjs +2 -4
- package/.output/server/_libs/_18.mjs +2 -2
- package/.output/server/_libs/_19.mjs +2 -2
- package/.output/server/_libs/_2.mjs +3 -3
- package/.output/server/_libs/_20.mjs +2 -2
- package/.output/server/_libs/_21.mjs +2 -2
- package/.output/server/_libs/_22.mjs +2 -2
- package/.output/server/_libs/_23.mjs +2 -2
- package/.output/server/_libs/_24.mjs +2 -2
- package/.output/server/_libs/_25.mjs +2 -2
- package/.output/server/_libs/_26.mjs +2 -2
- package/.output/server/_libs/_27.mjs +2 -2
- package/.output/server/_libs/_28.mjs +2 -2
- package/.output/server/_libs/_29.mjs +2 -2
- package/.output/server/_libs/_3.mjs +3 -3
- package/.output/server/_libs/_30.mjs +2 -2
- package/.output/server/_libs/_31.mjs +2 -2
- package/.output/server/_libs/_32.mjs +2 -2
- package/.output/server/_libs/_33.mjs +2 -2
- package/.output/server/_libs/_34.mjs +2 -2
- package/.output/server/_libs/_35.mjs +2 -2
- package/.output/server/_libs/_36.mjs +2 -2
- package/.output/server/_libs/_37.mjs +2 -2
- package/.output/server/_libs/_38.mjs +2 -2
- package/.output/server/_libs/_39.mjs +2 -2
- package/.output/server/_libs/_4.mjs +4 -3
- package/.output/server/_libs/_40.mjs +2 -2
- package/.output/server/_libs/_41.mjs +2 -2
- package/.output/server/_libs/_42.mjs +2 -2
- package/.output/server/_libs/_43.mjs +2 -2
- package/.output/server/_libs/_44.mjs +2 -2
- package/.output/server/_libs/_45.mjs +2 -2
- package/.output/server/_libs/_46.mjs +2 -2
- package/.output/server/_libs/_47.mjs +2 -2
- package/.output/server/_libs/_48.mjs +2 -2
- package/.output/server/_libs/_49.mjs +2 -2
- package/.output/server/_libs/_5.mjs +2 -3
- package/.output/server/_libs/_50.mjs +2 -2
- package/.output/server/_libs/_51.mjs +2 -2
- package/.output/server/_libs/_52.mjs +2 -2
- package/.output/server/_libs/_53.mjs +2 -2
- package/.output/server/_libs/_54.mjs +2 -2
- package/.output/server/_libs/_55.mjs +2 -2
- package/.output/server/_libs/_56.mjs +2 -2
- package/.output/server/_libs/_57.mjs +2 -2
- package/.output/server/_libs/_58.mjs +2 -2
- package/.output/server/_libs/_59.mjs +2 -2
- package/.output/server/_libs/_6.mjs +2 -3
- package/.output/server/_libs/_60.mjs +2 -2
- package/.output/server/_libs/_61.mjs +2 -2
- package/.output/server/_libs/_62.mjs +2 -2
- package/.output/server/_libs/_63.mjs +2 -2
- package/.output/server/_libs/_64.mjs +2 -2
- package/.output/server/_libs/_65.mjs +2 -2
- package/.output/server/_libs/_66.mjs +2 -2
- package/.output/server/_libs/_67.mjs +2 -2
- package/.output/server/_libs/_68.mjs +2 -2
- package/.output/server/_libs/_69.mjs +2 -2
- package/.output/server/_libs/_7.mjs +2 -5
- package/.output/server/_libs/_70.mjs +2 -2
- package/.output/server/_libs/_71.mjs +2 -2
- package/.output/server/_libs/_72.mjs +2 -2
- package/.output/server/_libs/_73.mjs +2 -2
- package/.output/server/_libs/_74.mjs +2 -2
- package/.output/server/_libs/_75.mjs +2 -2
- package/.output/server/_libs/_76.mjs +2 -2
- package/.output/server/_libs/_77.mjs +2 -2
- package/.output/server/_libs/_78.mjs +2 -2
- package/.output/server/_libs/_79.mjs +2 -2
- package/.output/server/_libs/_8.mjs +2 -3
- package/.output/server/_libs/_80.mjs +2 -2
- package/.output/server/_libs/_81.mjs +2 -2
- package/.output/server/_libs/_82.mjs +2 -2
- package/.output/server/_libs/_83.mjs +2 -2
- package/.output/server/_libs/_84.mjs +2 -2
- package/.output/server/_libs/_85.mjs +2 -2
- package/.output/server/_libs/_86.mjs +2 -2
- package/.output/server/_libs/_87.mjs +2 -2
- package/.output/server/_libs/_88.mjs +2 -2
- package/.output/server/_libs/_89.mjs +2 -2
- package/.output/server/_libs/_9.mjs +2 -4
- package/.output/server/_libs/_90.mjs +5 -2
- package/.output/server/_libs/_91.mjs +3 -2
- package/.output/server/_libs/_92.mjs +2 -2
- package/.output/server/_libs/_93.mjs +2 -2
- package/.output/server/_libs/_94.mjs +2 -2
- package/.output/server/_libs/agent-base.mjs +1 -1
- package/.output/server/_libs/cheerio+[...].mjs +1 -1
- package/.output/server/_libs/data-uri-to-buffer.mjs +2 -67
- package/.output/server/_libs/data-urls+[...].mjs +1 -1
- package/.output/server/_libs/diff.mjs +1 -1
- package/.output/server/_libs/exodus__bytes.mjs +99 -81
- package/.output/server/_libs/fetch-blob+node-domexception.mjs +1 -1
- package/.output/server/_libs/h3+rou3+srvx.mjs +34 -4
- package/.output/server/_libs/html-encoding-sniffer.mjs +1 -1
- package/.output/server/_libs/https-proxy-agent.mjs +2 -2
- package/.output/server/_libs/jsdom.mjs +1 -1
- package/.output/server/_libs/just-bash+[...].mjs +4676 -3916
- package/.output/server/_libs/mariozechner__jiti.mjs +1 -1
- package/.output/server/_libs/mariozechner__pi-ai.mjs +1472 -0
- package/.output/server/_libs/md4x.mjs +1 -1
- package/.output/server/_libs/node-fetch.mjs +14 -14
- package/.output/server/_libs/node-liblzma.mjs +1 -1
- package/.output/server/_libs/silvia-odwyer__photon-node.mjs +1 -1
- package/.output/server/_routes/api/auth/status.mjs +25 -6
- package/.output/server/_routes/api/config2.mjs +2 -0
- package/.output/server/_routes/api/files/groups.mjs +0 -1
- package/.output/server/_routes/api/groups.mjs +4 -2
- package/.output/server/_routes/api/groups2.mjs +14 -5
- package/.output/server/_routes/api/health.mjs +0 -1
- package/.output/server/_routes/api/pi/apikey.mjs +0 -1
- package/.output/server/_routes/api/pi/apikey_providers.mjs +0 -1
- package/.output/server/_routes/api/pi/commands.mjs +1 -2
- package/.output/server/_routes/api/pi/login/events.mjs +0 -1
- package/.output/server/_routes/api/pi/login/respond.mjs +0 -1
- package/.output/server/_routes/api/pi/login.mjs +0 -1
- package/.output/server/_routes/api/pi/logout.mjs +0 -1
- package/.output/server/_routes/api/pi/models.mjs +0 -1
- package/.output/server/_routes/api/pi/status.mjs +0 -1
- package/.output/server/_routes/api/sandbox.mjs +26 -0
- package/.output/server/_routes/api/sandbox2.mjs +17 -0
- package/.output/server/_routes/api/send.mjs +12 -12
- package/.output/server/_routes/api/status.mjs +0 -1
- package/.output/server/_routes/api/stop.mjs +0 -1
- package/.output/server/_routes/api/tasks2.mjs +0 -1
- package/.output/server/_routes/api/telegram/setup.mjs +0 -1
- package/.output/server/_routes/api/telegram/status.mjs +0 -1
- package/.output/server/_routes/api/terminal2.mjs +2 -1
- package/.output/server/_routes/api/tunnel/setup.mjs +0 -1
- package/.output/server/_runtime.mjs +1 -2
- package/.output/server/index.mjs +1 -1
- package/.output/server/node_modules/amdefine/amdefine.js +301 -0
- package/.output/server/node_modules/amdefine/package.json +16 -0
- package/.output/server/node_modules/compressjs/lib/BWT.js +420 -0
- package/.output/server/node_modules/compressjs/lib/BWTC.js +234 -0
- package/.output/server/node_modules/compressjs/lib/BitStream.js +108 -0
- package/.output/server/node_modules/compressjs/lib/Bzip2.js +936 -0
- package/.output/server/node_modules/compressjs/lib/CRC32.js +105 -0
- package/.output/server/node_modules/compressjs/lib/Context1Model.js +56 -0
- package/.output/server/node_modules/compressjs/lib/DefSumModel.js +152 -0
- package/.output/server/node_modules/compressjs/lib/DeflateDistanceModel.js +55 -0
- package/.output/server/node_modules/compressjs/lib/Dmc.js +197 -0
- package/.output/server/node_modules/compressjs/lib/DummyRangeCoder.js +81 -0
- package/.output/server/node_modules/compressjs/lib/FenwickModel.js +194 -0
- package/.output/server/node_modules/compressjs/lib/Huffman.js +514 -0
- package/.output/server/node_modules/compressjs/lib/HuffmanAllocator.js +227 -0
- package/.output/server/node_modules/compressjs/lib/LogDistanceModel.js +46 -0
- package/.output/server/node_modules/compressjs/lib/Lzjb.js +300 -0
- package/.output/server/node_modules/compressjs/lib/LzjbR.js +241 -0
- package/.output/server/node_modules/compressjs/lib/Lzp3.js +273 -0
- package/.output/server/node_modules/compressjs/lib/MTFModel.js +208 -0
- package/.output/server/node_modules/compressjs/lib/NoModel.js +46 -0
- package/.output/server/node_modules/compressjs/lib/PPM.js +343 -0
- package/.output/server/node_modules/compressjs/lib/RangeCoder.js +238 -0
- package/.output/server/node_modules/compressjs/lib/Simple.js +111 -0
- package/.output/server/node_modules/compressjs/lib/Stream.js +53 -0
- package/.output/server/node_modules/compressjs/lib/Util.js +324 -0
- package/.output/server/node_modules/compressjs/lib/freeze.js +14 -0
- package/.output/server/node_modules/compressjs/main.js +29 -0
- package/.output/server/node_modules/compressjs/package.json +35 -0
- package/.output/server/package.json +2 -1
- package/README.md +10 -1
- package/lib/index.d.mts +1 -0
- package/lib/index.mjs +1 -0
- package/lib/piclaw.mjs +100 -0
- package/lib/utils.mjs +96 -0
- package/package.json +16 -11
- package/.output/public/assets/defult-DtwgaiMA.js +0 -1
- package/.output/public/assets/index-B5n0eraW.css +0 -1
- package/.output/public/assets/index-DUbn6fuj.js +0 -205
- package/.output/server/_libs/@aws-crypto/crc32+[...].mjs +0 -299
- package/.output/server/_libs/@aws-sdk/client-bedrock-runtime+[...].mjs +0 -17828
- package/.output/server/_libs/@aws-sdk/credential-provider-http+[...].mjs +0 -122
- package/.output/server/_libs/@aws-sdk/credential-provider-ini+[...].mjs +0 -417
- package/.output/server/_libs/@aws-sdk/credential-provider-process+[...].mjs +0 -54
- package/.output/server/_libs/@aws-sdk/credential-provider-sso+[...].mjs +0 -1151
- package/.output/server/_libs/@aws-sdk/credential-provider-web-identity+[...].mjs +0 -50
- package/.output/server/_libs/@smithy/credential-provider-imds+[...].mjs +0 -369
- package/.output/server/_libs/@tootallnate/quickjs-emscripten+[...].mjs +0 -3011
- package/.output/server/_libs/_100.mjs +0 -2
- package/.output/server/_libs/_101.mjs +0 -2
- package/.output/server/_libs/_102.mjs +0 -2
- package/.output/server/_libs/_103.mjs +0 -5
- package/.output/server/_libs/_104.mjs +0 -3
- package/.output/server/_libs/_105.mjs +0 -2
- package/.output/server/_libs/_106.mjs +0 -3
- package/.output/server/_libs/_107.mjs +0 -2
- package/.output/server/_libs/_108.mjs +0 -2
- package/.output/server/_libs/_95.mjs +0 -2
- package/.output/server/_libs/_96.mjs +0 -2
- package/.output/server/_libs/_97.mjs +0 -2
- package/.output/server/_libs/_98.mjs +0 -2
- package/.output/server/_libs/_99.mjs +0 -2
- package/.output/server/_libs/amdefine.mjs +0 -188
- package/.output/server/_libs/ast-types.mjs +0 -2270
- package/.output/server/_libs/aws-sdk__nested-clients.mjs +0 -3141
- package/.output/server/_libs/basic-ftp.mjs +0 -1906
- package/.output/server/_libs/compressjs.mjs +0 -50
- package/.output/server/_libs/degenerator+[...].mjs +0 -9964
- package/.output/server/_libs/get-uri.mjs +0 -413
- package/.output/server/_libs/http-proxy-agent.mjs +0 -123
- package/.output/server/_libs/ip-address.mjs +0 -1423
- package/.output/server/_libs/lru-cache.mjs +0 -732
- package/.output/server/_libs/netmask.mjs +0 -139
- package/.output/server/_libs/pac-proxy-agent+[...].mjs +0 -3104
- package/.output/server/_libs/proxy-agent+proxy-from-env.mjs +0 -204
- package/.output/server/_libs/smithy__core.mjs +0 -192
- package/.output/server/node_modules/tslib/modules/index.js +0 -70
- package/.output/server/node_modules/tslib/modules/package.json +0 -3
- package/.output/server/node_modules/tslib/package.json +0 -47
- package/.output/server/node_modules/tslib/tslib.js +0 -484
- package/bin/piclaw.mjs +0 -195
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/** vim: et:ts=4:sw=4:sts=4
|
|
2
|
+
* @license amdefine 1.0.1 Copyright (c) 2011-2016, The Dojo Foundation All Rights Reserved.
|
|
3
|
+
* Available via the MIT or new BSD license.
|
|
4
|
+
* see: http://github.com/jrburke/amdefine for details
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*jslint node: true */
|
|
8
|
+
/*global module, process */
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates a define for node.
|
|
13
|
+
* @param {Object} module the "module" object that is defined by Node for the
|
|
14
|
+
* current module.
|
|
15
|
+
* @param {Function} [requireFn]. Node's require function for the current module.
|
|
16
|
+
* It only needs to be passed in Node versions before 0.5, when module.require
|
|
17
|
+
* did not exist.
|
|
18
|
+
* @returns {Function} a define function that is usable for the current node
|
|
19
|
+
* module.
|
|
20
|
+
*/
|
|
21
|
+
function amdefine(module, requireFn) {
|
|
22
|
+
'use strict';
|
|
23
|
+
var defineCache = {},
|
|
24
|
+
loaderCache = {},
|
|
25
|
+
alreadyCalled = false,
|
|
26
|
+
path = require('path'),
|
|
27
|
+
makeRequire, stringRequire;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Trims the . and .. from an array of path segments.
|
|
31
|
+
* It will keep a leading path segment if a .. will become
|
|
32
|
+
* the first path segment, to help with module name lookups,
|
|
33
|
+
* which act like paths, but can be remapped. But the end result,
|
|
34
|
+
* all paths that use this function should look normalized.
|
|
35
|
+
* NOTE: this method MODIFIES the input array.
|
|
36
|
+
* @param {Array} ary the array of path segments.
|
|
37
|
+
*/
|
|
38
|
+
function trimDots(ary) {
|
|
39
|
+
var i, part;
|
|
40
|
+
for (i = 0; ary[i]; i+= 1) {
|
|
41
|
+
part = ary[i];
|
|
42
|
+
if (part === '.') {
|
|
43
|
+
ary.splice(i, 1);
|
|
44
|
+
i -= 1;
|
|
45
|
+
} else if (part === '..') {
|
|
46
|
+
if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
|
|
47
|
+
//End of the line. Keep at least one non-dot
|
|
48
|
+
//path segment at the front so it can be mapped
|
|
49
|
+
//correctly to disk. Otherwise, there is likely
|
|
50
|
+
//no path mapping for a path starting with '..'.
|
|
51
|
+
//This can still fail, but catches the most reasonable
|
|
52
|
+
//uses of ..
|
|
53
|
+
break;
|
|
54
|
+
} else if (i > 0) {
|
|
55
|
+
ary.splice(i - 1, 2);
|
|
56
|
+
i -= 2;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function normalize(name, baseName) {
|
|
63
|
+
var baseParts;
|
|
64
|
+
|
|
65
|
+
//Adjust any relative paths.
|
|
66
|
+
if (name && name.charAt(0) === '.') {
|
|
67
|
+
//If have a base name, try to normalize against it,
|
|
68
|
+
//otherwise, assume it is a top-level require that will
|
|
69
|
+
//be relative to baseUrl in the end.
|
|
70
|
+
if (baseName) {
|
|
71
|
+
baseParts = baseName.split('/');
|
|
72
|
+
baseParts = baseParts.slice(0, baseParts.length - 1);
|
|
73
|
+
baseParts = baseParts.concat(name.split('/'));
|
|
74
|
+
trimDots(baseParts);
|
|
75
|
+
name = baseParts.join('/');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return name;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Create the normalize() function passed to a loader plugin's
|
|
84
|
+
* normalize method.
|
|
85
|
+
*/
|
|
86
|
+
function makeNormalize(relName) {
|
|
87
|
+
return function (name) {
|
|
88
|
+
return normalize(name, relName);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function makeLoad(id) {
|
|
93
|
+
function load(value) {
|
|
94
|
+
loaderCache[id] = value;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
load.fromText = function (id, text) {
|
|
98
|
+
//This one is difficult because the text can/probably uses
|
|
99
|
+
//define, and any relative paths and requires should be relative
|
|
100
|
+
//to that id was it would be found on disk. But this would require
|
|
101
|
+
//bootstrapping a module/require fairly deeply from node core.
|
|
102
|
+
//Not sure how best to go about that yet.
|
|
103
|
+
throw new Error('amdefine does not implement load.fromText');
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return load;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
makeRequire = function (systemRequire, exports, module, relId) {
|
|
110
|
+
function amdRequire(deps, callback) {
|
|
111
|
+
if (typeof deps === 'string') {
|
|
112
|
+
//Synchronous, single module require('')
|
|
113
|
+
return stringRequire(systemRequire, exports, module, deps, relId);
|
|
114
|
+
} else {
|
|
115
|
+
//Array of dependencies with a callback.
|
|
116
|
+
|
|
117
|
+
//Convert the dependencies to modules.
|
|
118
|
+
deps = deps.map(function (depName) {
|
|
119
|
+
return stringRequire(systemRequire, exports, module, depName, relId);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
//Wait for next tick to call back the require call.
|
|
123
|
+
if (callback) {
|
|
124
|
+
process.nextTick(function () {
|
|
125
|
+
callback.apply(null, deps);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
amdRequire.toUrl = function (filePath) {
|
|
132
|
+
if (filePath.indexOf('.') === 0) {
|
|
133
|
+
return normalize(filePath, path.dirname(module.filename));
|
|
134
|
+
} else {
|
|
135
|
+
return filePath;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return amdRequire;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
//Favor explicit value, passed in if the module wants to support Node 0.4.
|
|
143
|
+
requireFn = requireFn || function req() {
|
|
144
|
+
return module.require.apply(module, arguments);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
function runFactory(id, deps, factory) {
|
|
148
|
+
var r, e, m, result;
|
|
149
|
+
|
|
150
|
+
if (id) {
|
|
151
|
+
e = loaderCache[id] = {};
|
|
152
|
+
m = {
|
|
153
|
+
id: id,
|
|
154
|
+
uri: __filename,
|
|
155
|
+
exports: e
|
|
156
|
+
};
|
|
157
|
+
r = makeRequire(requireFn, e, m, id);
|
|
158
|
+
} else {
|
|
159
|
+
//Only support one define call per file
|
|
160
|
+
if (alreadyCalled) {
|
|
161
|
+
throw new Error('amdefine with no module ID cannot be called more than once per file.');
|
|
162
|
+
}
|
|
163
|
+
alreadyCalled = true;
|
|
164
|
+
|
|
165
|
+
//Use the real variables from node
|
|
166
|
+
//Use module.exports for exports, since
|
|
167
|
+
//the exports in here is amdefine exports.
|
|
168
|
+
e = module.exports;
|
|
169
|
+
m = module;
|
|
170
|
+
r = makeRequire(requireFn, e, m, module.id);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
//If there are dependencies, they are strings, so need
|
|
174
|
+
//to convert them to dependency values.
|
|
175
|
+
if (deps) {
|
|
176
|
+
deps = deps.map(function (depName) {
|
|
177
|
+
return r(depName);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
//Call the factory with the right dependencies.
|
|
182
|
+
if (typeof factory === 'function') {
|
|
183
|
+
result = factory.apply(m.exports, deps);
|
|
184
|
+
} else {
|
|
185
|
+
result = factory;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (result !== undefined) {
|
|
189
|
+
m.exports = result;
|
|
190
|
+
if (id) {
|
|
191
|
+
loaderCache[id] = m.exports;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
stringRequire = function (systemRequire, exports, module, id, relId) {
|
|
197
|
+
//Split the ID by a ! so that
|
|
198
|
+
var index = id.indexOf('!'),
|
|
199
|
+
originalId = id,
|
|
200
|
+
prefix, plugin;
|
|
201
|
+
|
|
202
|
+
if (index === -1) {
|
|
203
|
+
id = normalize(id, relId);
|
|
204
|
+
|
|
205
|
+
//Straight module lookup. If it is one of the special dependencies,
|
|
206
|
+
//deal with it, otherwise, delegate to node.
|
|
207
|
+
if (id === 'require') {
|
|
208
|
+
return makeRequire(systemRequire, exports, module, relId);
|
|
209
|
+
} else if (id === 'exports') {
|
|
210
|
+
return exports;
|
|
211
|
+
} else if (id === 'module') {
|
|
212
|
+
return module;
|
|
213
|
+
} else if (loaderCache.hasOwnProperty(id)) {
|
|
214
|
+
return loaderCache[id];
|
|
215
|
+
} else if (defineCache[id]) {
|
|
216
|
+
runFactory.apply(null, defineCache[id]);
|
|
217
|
+
return loaderCache[id];
|
|
218
|
+
} else {
|
|
219
|
+
if(systemRequire) {
|
|
220
|
+
return systemRequire(originalId);
|
|
221
|
+
} else {
|
|
222
|
+
throw new Error('No module with ID: ' + id);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
//There is a plugin in play.
|
|
227
|
+
prefix = id.substring(0, index);
|
|
228
|
+
id = id.substring(index + 1, id.length);
|
|
229
|
+
|
|
230
|
+
plugin = stringRequire(systemRequire, exports, module, prefix, relId);
|
|
231
|
+
|
|
232
|
+
if (plugin.normalize) {
|
|
233
|
+
id = plugin.normalize(id, makeNormalize(relId));
|
|
234
|
+
} else {
|
|
235
|
+
//Normalize the ID normally.
|
|
236
|
+
id = normalize(id, relId);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (loaderCache[id]) {
|
|
240
|
+
return loaderCache[id];
|
|
241
|
+
} else {
|
|
242
|
+
plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
|
|
243
|
+
|
|
244
|
+
return loaderCache[id];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
//Create a define function specific to the module asking for amdefine.
|
|
250
|
+
function define(id, deps, factory) {
|
|
251
|
+
if (Array.isArray(id)) {
|
|
252
|
+
factory = deps;
|
|
253
|
+
deps = id;
|
|
254
|
+
id = undefined;
|
|
255
|
+
} else if (typeof id !== 'string') {
|
|
256
|
+
factory = id;
|
|
257
|
+
id = deps = undefined;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (deps && !Array.isArray(deps)) {
|
|
261
|
+
factory = deps;
|
|
262
|
+
deps = undefined;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (!deps) {
|
|
266
|
+
deps = ['require', 'exports', 'module'];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
//Set up properties for this module. If an ID, then use
|
|
270
|
+
//internal cache. If no ID, then use the external variables
|
|
271
|
+
//for this node module.
|
|
272
|
+
if (id) {
|
|
273
|
+
//Put the module in deep freeze until there is a
|
|
274
|
+
//require call for it.
|
|
275
|
+
defineCache[id] = [id, deps, factory];
|
|
276
|
+
} else {
|
|
277
|
+
runFactory(id, deps, factory);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
//define.require, which has access to all the values in the
|
|
282
|
+
//cache. Useful for AMD modules that all have IDs in the file,
|
|
283
|
+
//but need to finally export a value to node based on one of those
|
|
284
|
+
//IDs.
|
|
285
|
+
define.require = function (id) {
|
|
286
|
+
if (loaderCache[id]) {
|
|
287
|
+
return loaderCache[id];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (defineCache[id]) {
|
|
291
|
+
runFactory.apply(null, defineCache[id]);
|
|
292
|
+
return loaderCache[id];
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
define.amd = {};
|
|
297
|
+
|
|
298
|
+
return define;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
module.exports = amdefine;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "amdefine",
|
|
3
|
+
"description": "Provide AMD's define() API for declaring modules in the AMD format",
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"homepage": "http://github.com/jrburke/amdefine",
|
|
6
|
+
"author": "James Burke <jrburke@gmail.com> (http://github.com/jrburke)",
|
|
7
|
+
"license": "BSD-3-Clause OR MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/jrburke/amdefine.git"
|
|
11
|
+
},
|
|
12
|
+
"main": "./amdefine.js",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=0.4.2"
|
|
15
|
+
}
|
|
16
|
+
}
|