@use-voltra/expo-plugin 2.1.1 → 2.3.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.
- package/build/cjs/constants.js +1 -3
- package/build/cjs/constants.js.map +1 -1
- package/build/cjs/dynamic-live-activity.js +6 -0
- package/build/cjs/dynamic-live-activity.js.map +1 -0
- package/build/cjs/index.js +15 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/serverUpdate.js +119 -0
- package/build/cjs/serverUpdate.js.map +1 -0
- package/build/cjs/utils/packageVersion.js +49 -0
- package/build/cjs/utils/packageVersion.js.map +1 -0
- package/build/cjs/utils/prerender.js +25 -159
- package/build/cjs/utils/prerender.js.map +1 -1
- package/build/cjs/widgetServerUpdate.js +63 -0
- package/build/cjs/widgetServerUpdate.js.map +1 -0
- package/build/esm/constants.js +0 -2
- package/build/esm/constants.js.map +1 -1
- package/build/esm/dynamic-live-activity.js +2 -0
- package/build/esm/dynamic-live-activity.js.map +1 -0
- package/build/esm/index.js +6 -2
- package/build/esm/index.js.map +1 -1
- package/build/esm/serverUpdate.js +112 -0
- package/build/esm/serverUpdate.js.map +1 -0
- package/build/esm/utils/packageVersion.js +13 -0
- package/build/esm/utils/packageVersion.js.map +1 -0
- package/build/esm/utils/prerender.js +24 -126
- package/build/esm/utils/prerender.js.map +1 -1
- package/build/esm/widgetServerUpdate.js +59 -0
- package/build/esm/widgetServerUpdate.js.map +1 -0
- package/build/types/constants.d.ts +0 -2
- package/build/types/constants.d.ts.map +1 -1
- package/build/types/dynamic-live-activity.d.ts +2 -0
- package/build/types/dynamic-live-activity.d.ts.map +1 -0
- package/build/types/index.d.ts +11 -4
- package/build/types/index.d.ts.map +1 -1
- package/build/types/serverUpdate.d.ts +80 -0
- package/build/types/serverUpdate.d.ts.map +1 -0
- package/build/types/types.d.ts +22 -0
- package/build/types/types.d.ts.map +1 -1
- package/build/types/utils/packageVersion.d.ts +2 -0
- package/build/types/utils/packageVersion.d.ts.map +1 -0
- package/build/types/utils/prerender.d.ts +22 -8
- package/build/types/utils/prerender.d.ts.map +1 -1
- package/build/types/widgetServerUpdate.d.ts +34 -0
- package/build/types/widgetServerUpdate.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/constants.ts +0 -3
- package/src/dynamic-live-activity.node.test.ts +18 -0
- package/src/dynamic-live-activity.ts +1 -0
- package/src/index.ts +33 -3
- package/src/serverUpdate.node.test.ts +126 -0
- package/src/serverUpdate.ts +160 -0
- package/src/types.ts +25 -0
- package/src/utils/packageVersion.node.test.ts +24 -0
- package/src/utils/packageVersion.ts +19 -0
- package/src/utils/prerender.node.test.ts +2 -1
- package/src/utils/prerender.ts +34 -155
- package/src/widgetServerUpdate.ts +109 -0
package/build/cjs/constants.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_IMAGE_SIZE_BYTES =
|
|
4
|
-
/** Extensions to try when resolving module paths for pre-rendering */
|
|
5
|
-
exports.MODULE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', ''];
|
|
3
|
+
exports.MAX_IMAGE_SIZE_BYTES = void 0;
|
|
6
4
|
/** Maximum image size in bytes for widget / Live Activity assets (4KB limit) */
|
|
7
5
|
exports.MAX_IMAGE_SIZE_BYTES = 4096;
|
|
8
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,gFAAgF;AACnE,QAAA,oBAAoB,GAAG,IAAI,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDynamicLiveActivityAttributesType = void 0;
|
|
4
|
+
var dynamic_live_activity_1 = require("@use-voltra/core/dynamic-live-activity");
|
|
5
|
+
Object.defineProperty(exports, "getDynamicLiveActivityAttributesType", { enumerable: true, get: function () { return dynamic_live_activity_1.getDynamicLiveActivityAttributesType; } });
|
|
6
|
+
//# sourceMappingURL=dynamic-live-activity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-live-activity.js","sourceRoot":"","sources":["../../src/dynamic-live-activity.ts"],"names":[],"mappings":";;;AAAA,gFAA6F;AAApF,6IAAA,oCAAoC,OAAA"}
|
package/build/cjs/index.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.widgetLabelEnglish = exports.isWidgetLocalizedMap = exports.prerenderWidgetState = exports.evaluateWidgetModuleExports = exports.evaluateWidgetModule = exports.logger = exports.pickLocalizedValue = exports.normalizeLocaleTag = exports.resolveFontPaths = exports.addApplicationGroupsEntitlement = exports.validateWidgetLabel = exports.validateWidgetEntry = exports.validateInitialStatePath = exports.validateHomeScreenWidgetId = exports.normalizeWidgetEntryPath = exports.assertValidLocaleKey = exports.
|
|
3
|
+
exports.widgetLabelEnglish = exports.isWidgetLocalizedMap = exports.prerenderWidgetState = exports.evaluateWidgetModuleExports = exports.evaluateWidgetModule = exports.createPrerenderWidgetModuleLoader = exports.resolveInstalledPackageVersion = exports.logger = exports.pickLocalizedValue = exports.normalizeLocaleTag = exports.resolveFontPaths = exports.addApplicationGroupsEntitlement = exports.validateWidgetLabel = exports.validateWidgetEntry = exports.validateInitialStatePath = exports.validateHomeScreenWidgetId = exports.normalizeWidgetEntryPath = exports.assertValidLocaleKey = exports.validateWidgetServerUpdate = exports.resolveWidgetServerUpdate = exports.validateServerUpdateRefresh = exports.resolveServerUpdateUrl = exports.resolveServerUpdateInterval = exports.isLocalHttpHost = exports.DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES = exports.getDynamicLiveActivityAttributesType = exports.MAX_IMAGE_SIZE_BYTES = void 0;
|
|
4
4
|
var constants_1 = require("./constants");
|
|
5
5
|
Object.defineProperty(exports, "MAX_IMAGE_SIZE_BYTES", { enumerable: true, get: function () { return constants_1.MAX_IMAGE_SIZE_BYTES; } });
|
|
6
|
-
|
|
6
|
+
var dynamic_live_activity_1 = require("./dynamic-live-activity");
|
|
7
|
+
Object.defineProperty(exports, "getDynamicLiveActivityAttributesType", { enumerable: true, get: function () { return dynamic_live_activity_1.getDynamicLiveActivityAttributesType; } });
|
|
8
|
+
var serverUpdate_1 = require("./serverUpdate");
|
|
9
|
+
Object.defineProperty(exports, "DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES", { enumerable: true, get: function () { return serverUpdate_1.DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES; } });
|
|
10
|
+
Object.defineProperty(exports, "isLocalHttpHost", { enumerable: true, get: function () { return serverUpdate_1.isLocalHttpHost; } });
|
|
11
|
+
Object.defineProperty(exports, "resolveServerUpdateInterval", { enumerable: true, get: function () { return serverUpdate_1.resolveServerUpdateInterval; } });
|
|
12
|
+
Object.defineProperty(exports, "resolveServerUpdateUrl", { enumerable: true, get: function () { return serverUpdate_1.resolveServerUpdateUrl; } });
|
|
13
|
+
Object.defineProperty(exports, "validateServerUpdateRefresh", { enumerable: true, get: function () { return serverUpdate_1.validateServerUpdateRefresh; } });
|
|
14
|
+
var widgetServerUpdate_1 = require("./widgetServerUpdate");
|
|
15
|
+
Object.defineProperty(exports, "resolveWidgetServerUpdate", { enumerable: true, get: function () { return widgetServerUpdate_1.resolveWidgetServerUpdate; } });
|
|
16
|
+
Object.defineProperty(exports, "validateWidgetServerUpdate", { enumerable: true, get: function () { return widgetServerUpdate_1.validateWidgetServerUpdate; } });
|
|
7
17
|
var validation_1 = require("./validation");
|
|
8
18
|
Object.defineProperty(exports, "assertValidLocaleKey", { enumerable: true, get: function () { return validation_1.assertValidLocaleKey; } });
|
|
9
19
|
Object.defineProperty(exports, "normalizeWidgetEntryPath", { enumerable: true, get: function () { return validation_1.normalizeWidgetEntryPath; } });
|
|
@@ -20,7 +30,10 @@ Object.defineProperty(exports, "normalizeLocaleTag", { enumerable: true, get: fu
|
|
|
20
30
|
Object.defineProperty(exports, "pickLocalizedValue", { enumerable: true, get: function () { return localePick_1.pickLocalizedValue; } });
|
|
21
31
|
var logger_1 = require("./utils/logger");
|
|
22
32
|
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
|
33
|
+
var packageVersion_1 = require("./utils/packageVersion");
|
|
34
|
+
Object.defineProperty(exports, "resolveInstalledPackageVersion", { enumerable: true, get: function () { return packageVersion_1.resolveInstalledPackageVersion; } });
|
|
23
35
|
var prerender_1 = require("./utils/prerender");
|
|
36
|
+
Object.defineProperty(exports, "createPrerenderWidgetModuleLoader", { enumerable: true, get: function () { return prerender_1.createPrerenderWidgetModuleLoader; } });
|
|
24
37
|
Object.defineProperty(exports, "evaluateWidgetModule", { enumerable: true, get: function () { return prerender_1.evaluateWidgetModule; } });
|
|
25
38
|
Object.defineProperty(exports, "evaluateWidgetModuleExports", { enumerable: true, get: function () { return prerender_1.evaluateWidgetModuleExports; } });
|
|
26
39
|
Object.defineProperty(exports, "prerenderWidgetState", { enumerable: true, get: function () { return prerender_1.prerenderWidgetState; } });
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAkD;AAAzC,iHAAA,oBAAoB,OAAA;AAC7B,iEAA8E;AAArE,6IAAA,oCAAoC,OAAA;AAc7C,+CAMuB;AALrB,6IAAA,6CAA6C,OAAA;AAC7C,+GAAA,eAAe,OAAA;AACf,2HAAA,2BAA2B,OAAA;AAC3B,sHAAA,sBAAsB,OAAA;AACtB,2HAAA,2BAA2B,OAAA;AAO7B,2DAA4F;AAAnF,+HAAA,yBAAyB,OAAA;AAAE,gIAAA,0BAA0B,OAAA;AAC9D,2CAOqB;AANnB,kHAAA,oBAAoB,OAAA;AACpB,sHAAA,wBAAwB,OAAA;AACxB,wHAAA,0BAA0B,OAAA;AAC1B,sHAAA,wBAAwB,OAAA;AACxB,iHAAA,mBAAmB,OAAA;AACnB,iHAAA,mBAAmB,OAAA;AAErB,qDAAsE;AAA7D,+HAAA,+BAA+B,OAAA;AACxC,uCAAgD;AAAvC,yGAAA,gBAAgB,OAAA;AACzB,iDAA2E;AAAlE,gHAAA,kBAAkB,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AAC/C,yCAAuC;AAA9B,gGAAA,MAAM,OAAA;AACf,yDAAuE;AAA9D,gIAAA,8BAA8B,OAAA;AAOvC,+CAK0B;AAJxB,8HAAA,iCAAiC,OAAA;AACjC,iHAAA,oBAAoB,OAAA;AACpB,wHAAA,2BAA2B,OAAA;AAC3B,iHAAA,oBAAoB,OAAA;AAGtB,mDAA8E;AAArE,mHAAA,oBAAoB,OAAA;AAAE,iHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Config rules for `serverUpdate`, shared by the Expo plugins and the `voltra` CLI.
|
|
4
|
+
*
|
|
5
|
+
* `serverUpdate` marks a widget as server-driven for both render engines. On a widget with
|
|
6
|
+
* `entry` the device fetches a JSON object and hands it to the bundled JS as props; without
|
|
7
|
+
* `entry` the server returns a full Voltra payload. Widgets without `entry` keep exactly the
|
|
8
|
+
* rules they had before ADR 0002, so no existing config breaks.
|
|
9
|
+
*
|
|
10
|
+
* `url` is optional. `serverUpdate: {}` means "server-driven, URL supplied at runtime" through
|
|
11
|
+
* `setWidgetServerUpdate`, which covers per-tenant backends whose URL is only known after login.
|
|
12
|
+
*
|
|
13
|
+
* These helpers report problems instead of throwing so each caller can raise its own error type.
|
|
14
|
+
*
|
|
15
|
+
* The `voltra` CLI validates `serverUpdate` from its own copy of this module; keep the two in
|
|
16
|
+
* sync.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES = void 0;
|
|
20
|
+
exports.resolveServerUpdateInterval = resolveServerUpdateInterval;
|
|
21
|
+
exports.resolveServerUpdateUrl = resolveServerUpdateUrl;
|
|
22
|
+
exports.isLocalHttpHost = isLocalHttpHost;
|
|
23
|
+
exports.validateServerUpdateRefresh = validateServerUpdateRefresh;
|
|
24
|
+
/**
|
|
25
|
+
* Interval floor and default for a widget with `entry`. WorkManager cannot run periodic work
|
|
26
|
+
* more often than every 15 minutes, and WidgetKit stretches timelines requested closer together
|
|
27
|
+
* than five minutes, so a smaller number would only mislead.
|
|
28
|
+
*/
|
|
29
|
+
exports.DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES = 15;
|
|
30
|
+
/** Hosts allowed over plain `http`, for talking to a dev server from a simulator or emulator. */
|
|
31
|
+
const LOCAL_HTTP_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '10.0.2.2', '10.0.3.2']);
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the interval a widget should be scheduled on.
|
|
34
|
+
*
|
|
35
|
+
* A widget with `entry` is clamped up to {@link DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES}
|
|
36
|
+
* with a warning, because a shorter interval is not something either platform can honour. A
|
|
37
|
+
* payload widget keeps the platform's existing rule and is rejected below the floor.
|
|
38
|
+
*/
|
|
39
|
+
function resolveServerUpdateInterval(options) {
|
|
40
|
+
const { intervalMinutes, context, hasEntry, defaultIntervalMinutes, minimumIntervalMinutes } = options;
|
|
41
|
+
const fallback = hasEntry ? exports.DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES : defaultIntervalMinutes;
|
|
42
|
+
if (intervalMinutes === undefined) {
|
|
43
|
+
return { kind: 'ok', intervalMinutes: fallback };
|
|
44
|
+
}
|
|
45
|
+
if (typeof intervalMinutes !== 'number' || !Number.isFinite(intervalMinutes)) {
|
|
46
|
+
return { kind: 'invalid', error: `${context}.intervalMinutes must be a number` };
|
|
47
|
+
}
|
|
48
|
+
if (!Number.isInteger(intervalMinutes)) {
|
|
49
|
+
return { kind: 'invalid', error: `${context}.intervalMinutes must be an integer` };
|
|
50
|
+
}
|
|
51
|
+
if (hasEntry) {
|
|
52
|
+
if (intervalMinutes < exports.DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES) {
|
|
53
|
+
return {
|
|
54
|
+
kind: 'clamped',
|
|
55
|
+
intervalMinutes: exports.DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES,
|
|
56
|
+
warning: `${context}.intervalMinutes is ${intervalMinutes}, below the ` +
|
|
57
|
+
`${exports.DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES} minute floor for widgets with an entry. ` +
|
|
58
|
+
`Using ${exports.DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES}.`,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return { kind: 'ok', intervalMinutes };
|
|
62
|
+
}
|
|
63
|
+
if (intervalMinutes < minimumIntervalMinutes) {
|
|
64
|
+
return { kind: 'invalid', error: `${context}.intervalMinutes must be at least ${minimumIntervalMinutes}` };
|
|
65
|
+
}
|
|
66
|
+
return { kind: 'ok', intervalMinutes };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks `serverUpdate.url`. An absent URL is fine — the app supplies it at runtime through
|
|
70
|
+
* `setWidgetServerUpdate`.
|
|
71
|
+
*
|
|
72
|
+
* A URL that is not an absolute `http`/`https` URL is rejected: no platform HTTP stack here
|
|
73
|
+
* accepts one, so such a config could only ever have failed to fetch. Plain `http` to a
|
|
74
|
+
* non-local host is reported as insecure rather than rejected — App Transport Security and
|
|
75
|
+
* Android's cleartext policy already block it in a release build, and rejecting it outright
|
|
76
|
+
* would break configs that point at a LAN dev server.
|
|
77
|
+
*/
|
|
78
|
+
function resolveServerUpdateUrl(url, context) {
|
|
79
|
+
if (url === undefined) {
|
|
80
|
+
return { kind: 'ok' };
|
|
81
|
+
}
|
|
82
|
+
if (typeof url !== 'string' || !url.trim()) {
|
|
83
|
+
return { kind: 'invalid', error: `${context}.url must be a non-empty string` };
|
|
84
|
+
}
|
|
85
|
+
let parsed;
|
|
86
|
+
try {
|
|
87
|
+
parsed = new URL(url);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return { kind: 'invalid', error: `${context}.url must be an absolute http(s) URL, received '${url}'` };
|
|
91
|
+
}
|
|
92
|
+
if (parsed.protocol === 'https:') {
|
|
93
|
+
return { kind: 'ok' };
|
|
94
|
+
}
|
|
95
|
+
if (parsed.protocol !== 'http:') {
|
|
96
|
+
return { kind: 'invalid', error: `${context}.url must be an absolute http(s) URL, received '${url}'` };
|
|
97
|
+
}
|
|
98
|
+
if (isLocalHttpHost(parsed.hostname)) {
|
|
99
|
+
return { kind: 'ok' };
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
kind: 'insecure',
|
|
103
|
+
warning: `${context}.url uses plain http ('${url}'). Release builds block cleartext traffic, so the ` +
|
|
104
|
+
'widget will not fetch outside a development build. Use https, or a local dev host ' +
|
|
105
|
+
`(${[...LOCAL_HTTP_HOSTS].join(', ')}).`,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** True for the hosts Voltra allows over plain `http` — dev servers reachable from a simulator. */
|
|
109
|
+
function isLocalHttpHost(hostname) {
|
|
110
|
+
return LOCAL_HTTP_HOSTS.has(hostname.replace(/^\[|\]$/g, ''));
|
|
111
|
+
}
|
|
112
|
+
/** Validates `serverUpdate.refresh`. Returns an error message, or `undefined` when it is fine. */
|
|
113
|
+
function validateServerUpdateRefresh(refresh, context) {
|
|
114
|
+
if (refresh !== undefined && typeof refresh !== 'boolean') {
|
|
115
|
+
return `${context}.refresh must be a boolean`;
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=serverUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverUpdate.js","sourceRoot":"","sources":["../../src/serverUpdate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAsCH,kEAsCC;AAkBD,wDAoCC;AAGD,0CAEC;AAGD,kEAMC;AA9ID;;;;GAIG;AACU,QAAA,6CAA6C,GAAG,EAAE,CAAA;AAE/D,iGAAiG;AACjG,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAA;AAqB3F;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,OAA2C;IAE3C,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAA;IACtG,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,qDAA6C,CAAC,CAAC,CAAC,sBAAsB,CAAA;IAElG,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAA;IAClD,CAAC;IAED,IAAI,OAAO,eAAe,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QAC7E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,OAAO,mCAAmC,EAAE,CAAA;IAClF,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;Q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AAE,CAAA;IACxG,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IACvB,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,OAAO,mDAAmD,GAAG,GAAG,EAAE,CAAA;IACxG,CAAC;IAED,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IACvB,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,OAAO,EACL,GAAG,OAAO,0BAA0B,GAAG,qDAAqD;YAC5F,oFAAoF;YACpF,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;KAC3C,CAAA;AACH,CAAC;AAED,mGAAmG;AACnG,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAA;AAC/D,CAAC;AAED,kGAAkG;AAClG,SAAgB,2BAA2B,CAAC,OAAgB,EAAE,OAAe;IAC3E,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1D,OAAO,GAAG,OAAO,4BAA4B,CAAA;IAC/C,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.resolveInstalledPackageVersion = resolveInstalledPackageVersion;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const node_module_1 = require("node:module");
|
|
40
|
+
function resolveInstalledPackageVersion(projectRoot, packageName) {
|
|
41
|
+
const projectRequire = (0, node_module_1.createRequire)(path.join(projectRoot, 'package.json'));
|
|
42
|
+
const packageJsonPath = projectRequire.resolve(`${packageName}/package.json`);
|
|
43
|
+
const manifest = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
44
|
+
if (typeof manifest.version !== 'string' || manifest.version.length === 0) {
|
|
45
|
+
throw new Error(`Package ${packageName} does not declare a valid version in ${packageJsonPath}.`);
|
|
46
|
+
}
|
|
47
|
+
return manifest.version;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../../../src/utils/packageVersion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,wEAUC;AAlBD,4CAA6B;AAC7B,gDAAiC;AACjC,6CAA2C;AAM3C,SAAgB,8BAA8B,CAAC,WAAmB,EAAE,WAAmB;IACrF,MAAM,cAAc,GAAG,IAAA,2BAAa,EAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAA;IAC5E,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,WAAW,eAAe,CAAC,CAAA;IAC7E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAoB,CAAA;IAExF,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1E,MAAM,IAAI,KAAK,CAAC,WAAW,WAAW,wCAAwC,eAAe,GAAG,CAAC,CAAA;IACnG,CAAC;IAED,OAAO,QAAQ,CAAC,OAAO,CAAA;AACzB,CAAC"}
|
|
@@ -1,182 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createPrerenderWidgetModuleLoader = createPrerenderWidgetModuleLoader;
|
|
39
7
|
exports.evaluateWidgetModuleExports = evaluateWidgetModuleExports;
|
|
40
8
|
exports.evaluateWidgetModule = evaluateWidgetModule;
|
|
41
9
|
exports.prerenderWidgetState = prerenderWidgetState;
|
|
42
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
43
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
44
|
-
const
|
|
45
|
-
const node_vm_1 = __importDefault(require("node:vm"));
|
|
46
|
-
const babel = __importStar(require("@babel/core"));
|
|
47
|
-
const constants_1 = require("../constants");
|
|
11
|
+
const compiler_1 = require("@use-voltra/compiler");
|
|
48
12
|
const logger_1 = require("./logger");
|
|
49
13
|
const widgetLabel_1 = require("./widgetLabel");
|
|
50
|
-
const PRERENDER_PACKAGE_REDIRECTS = {
|
|
51
|
-
'@use-voltra/ios-client': '@use-voltra/ios',
|
|
52
|
-
'@use-voltra/android-client': '@use-voltra/android',
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Check if a module specifier is a relative or absolute path (local file)
|
|
56
|
-
*/
|
|
57
|
-
function isLocalModule(moduleSpecifier) {
|
|
58
|
-
return moduleSpecifier.startsWith('.') || moduleSpecifier.startsWith('/');
|
|
59
|
-
}
|
|
60
14
|
/**
|
|
61
|
-
*
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
for (const ext of constants_1.MODULE_EXTENSIONS) {
|
|
66
|
-
const fullPath = basePath + ext;
|
|
67
|
-
if (node_fs_1.default.existsSync(fullPath) && node_fs_1.default.statSync(fullPath).isFile()) {
|
|
68
|
-
return fullPath;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// Try index files if it's a directory
|
|
72
|
-
if (node_fs_1.default.existsSync(basePath) && node_fs_1.default.statSync(basePath).isDirectory()) {
|
|
73
|
-
for (const ext of constants_1.MODULE_EXTENSIONS) {
|
|
74
|
-
const indexPath = node_path_1.default.join(basePath, 'index' + ext);
|
|
75
|
-
if (node_fs_1.default.existsSync(indexPath)) {
|
|
76
|
-
return indexPath;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
function getProjectBabelConfigPath(projectRoot) {
|
|
83
|
-
const configPath = node_path_1.default.join(projectRoot, 'babel.config.js');
|
|
84
|
-
return node_fs_1.default.existsSync(configPath) ? configPath : null;
|
|
85
|
-
}
|
|
86
|
-
function getFallbackExpoPreset(projectRoot) {
|
|
87
|
-
return require.resolve('babel-preset-expo', { paths: [projectRoot] });
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Transpile a file with Babel
|
|
15
|
+
* Create the loader used to evaluate widget source during prebuild.
|
|
16
|
+
*
|
|
17
|
+
* Evaluation rules live in `@use-voltra/compiler` so that prebuild, `voltra apply`, and
|
|
18
|
+
* the Metro widget bundler agree on what widget code may import.
|
|
91
19
|
*/
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
filename: filePath,
|
|
98
|
-
...(projectBabelConfigPath
|
|
99
|
-
? { configFile: projectBabelConfigPath }
|
|
100
|
-
: {
|
|
101
|
-
babelrc: false,
|
|
102
|
-
configFile: false,
|
|
103
|
-
presets: [getFallbackExpoPreset(projectRoot)],
|
|
104
|
-
}),
|
|
20
|
+
function createPrerenderWidgetModuleLoader(projectRoot, platform) {
|
|
21
|
+
return (0, compiler_1.createWidgetModuleLoader)({
|
|
22
|
+
projectRoot,
|
|
23
|
+
platform,
|
|
24
|
+
onWarning: (message) => logger_1.logger.warn(message),
|
|
105
25
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return result.code;
|
|
26
|
+
}
|
|
27
|
+
function resolveLoader({ projectRoot, platform, loader }) {
|
|
28
|
+
return loader ?? createPrerenderWidgetModuleLoader(projectRoot, platform);
|
|
110
29
|
}
|
|
111
30
|
/**
|
|
112
|
-
* Evaluate a widget module
|
|
113
|
-
* This allows executing widget code that uses JSX and React components.
|
|
114
|
-
* Local module dependencies are also transpiled with the same Babel settings.
|
|
31
|
+
* Evaluate a widget module and return its exports object.
|
|
115
32
|
*
|
|
116
33
|
* Exported so platform-specific prerender flows can reuse the same module loader rather
|
|
117
|
-
* than duplicating the Babel + VM scaffolding.
|
|
118
|
-
*
|
|
34
|
+
* than duplicating the Babel + VM scaffolding. Callers decide whether to read `.default`,
|
|
35
|
+
* a named export, etc.
|
|
119
36
|
*/
|
|
120
|
-
function evaluateWidgetModuleExports(
|
|
121
|
-
|
|
122
|
-
const moduleCache = new Map();
|
|
123
|
-
const projectRequire = (0, node_module_1.createRequire)(node_path_1.default.join(projectRoot, 'package.json'));
|
|
124
|
-
/**
|
|
125
|
-
* Custom require that transpiles local modules with Babel
|
|
126
|
-
*/
|
|
127
|
-
function customRequire(moduleSpecifier, currentDir) {
|
|
128
|
-
// For non-local modules (npm packages), use native require
|
|
129
|
-
if (!isLocalModule(moduleSpecifier)) {
|
|
130
|
-
const redirectedSpecifier = PRERENDER_PACKAGE_REDIRECTS[moduleSpecifier];
|
|
131
|
-
if (redirectedSpecifier) {
|
|
132
|
-
if (!warnedRedirects.has(moduleSpecifier)) {
|
|
133
|
-
warnedRedirects.add(moduleSpecifier);
|
|
134
|
-
logger_1.logger.warn(`Prerendering initial state imported '${moduleSpecifier}'. Using '${redirectedSpecifier}' instead.`);
|
|
135
|
-
}
|
|
136
|
-
return projectRequire(redirectedSpecifier);
|
|
137
|
-
}
|
|
138
|
-
return projectRequire(moduleSpecifier);
|
|
139
|
-
}
|
|
140
|
-
// Resolve the local module path
|
|
141
|
-
const resolvedPath = resolveModulePath(moduleSpecifier, currentDir);
|
|
142
|
-
if (!resolvedPath) {
|
|
143
|
-
throw new Error(`Cannot resolve module '${moduleSpecifier}' from '${currentDir}'`);
|
|
144
|
-
}
|
|
145
|
-
// Return cached module if already evaluated
|
|
146
|
-
if (moduleCache.has(resolvedPath)) {
|
|
147
|
-
return moduleCache.get(resolvedPath);
|
|
148
|
-
}
|
|
149
|
-
// Transpile and evaluate the module
|
|
150
|
-
const transpiledCode = transpileFile(resolvedPath, projectRoot);
|
|
151
|
-
const moduleDir = node_path_1.default.dirname(resolvedPath);
|
|
152
|
-
const mockModule = { exports: {} };
|
|
153
|
-
// Create require function bound to the module's directory
|
|
154
|
-
const boundRequire = (spec) => customRequire(spec, moduleDir);
|
|
155
|
-
const context = node_vm_1.default.createContext({
|
|
156
|
-
exports: mockModule.exports,
|
|
157
|
-
module: mockModule,
|
|
158
|
-
require: boundRequire,
|
|
159
|
-
__filename: resolvedPath,
|
|
160
|
-
__dirname: moduleDir,
|
|
161
|
-
console: console,
|
|
162
|
-
process: process,
|
|
163
|
-
});
|
|
164
|
-
// Cache before evaluation to handle circular dependencies
|
|
165
|
-
moduleCache.set(resolvedPath, mockModule.exports);
|
|
166
|
-
const script = new node_vm_1.default.Script(transpiledCode, { filename: resolvedPath });
|
|
167
|
-
script.runInContext(context);
|
|
168
|
-
// Update cache with final exports (in case module.exports was reassigned)
|
|
169
|
-
moduleCache.set(resolvedPath, mockModule.exports);
|
|
170
|
-
return mockModule.exports;
|
|
171
|
-
}
|
|
172
|
-
return customRequire(filePath, node_path_1.default.dirname(filePath));
|
|
37
|
+
function evaluateWidgetModuleExports(filePath, options) {
|
|
38
|
+
return resolveLoader(options).load(filePath);
|
|
173
39
|
}
|
|
174
40
|
/**
|
|
175
41
|
* Evaluate a widget file as a server-style WidgetVariants module and return its object export.
|
|
176
42
|
*/
|
|
177
|
-
function evaluateWidgetModule(
|
|
178
|
-
const
|
|
179
|
-
const widgetVariants = exports.default || exports;
|
|
43
|
+
function evaluateWidgetModule(filePath, options) {
|
|
44
|
+
const widgetVariants = resolveLoader(options).loadDefaultExport(filePath);
|
|
180
45
|
if (!widgetVariants || typeof widgetVariants !== 'object') {
|
|
181
46
|
throw new Error('Widget file must export a WidgetVariants object or have a default export of WidgetVariants');
|
|
182
47
|
}
|
|
@@ -192,11 +57,12 @@ function evaluateWidgetModule(projectRoot, filePath, warnedRedirects = new Set()
|
|
|
192
57
|
* @param widgets - Array of widget configurations
|
|
193
58
|
* @param projectRoot - Root directory of the Expo project
|
|
194
59
|
* @param renderer - The renderer function to use (voltra/server or voltra/android/server)
|
|
60
|
+
* @param platform - Platform being prebuilt
|
|
195
61
|
* @returns Map of widgetId -> (locale key -> prerendered JSON string)
|
|
196
62
|
*/
|
|
197
|
-
async function prerenderWidgetState(widgets, projectRoot, renderer) {
|
|
63
|
+
async function prerenderWidgetState(widgets, projectRoot, renderer, platform) {
|
|
198
64
|
const prerenderedStates = new Map();
|
|
199
|
-
const
|
|
65
|
+
const loader = createPrerenderWidgetModuleLoader(projectRoot, platform);
|
|
200
66
|
for (const widget of widgets) {
|
|
201
67
|
if (!widget.initialStatePath) {
|
|
202
68
|
continue;
|
|
@@ -209,7 +75,7 @@ async function prerenderWidgetState(widgets, projectRoot, renderer) {
|
|
|
209
75
|
try {
|
|
210
76
|
for (const [localeKey, relativePath] of Object.entries(perLocalePaths)) {
|
|
211
77
|
const absoluteWidgetPath = node_path_1.default.resolve(projectRoot, relativePath);
|
|
212
|
-
const widgetVariants = evaluateWidgetModule(projectRoot,
|
|
78
|
+
const widgetVariants = evaluateWidgetModule(absoluteWidgetPath, { projectRoot, platform, loader });
|
|
213
79
|
const prerenderedState = renderer(widgetVariants);
|
|
214
80
|
inner.set(localeKey, prerenderedState);
|
|
215
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerender.js","sourceRoot":"","sources":["../../../src/utils/prerender.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prerender.js","sourceRoot":"","sources":["../../../src/utils/prerender.ts"],"names":[],"mappings":";;;;;AAsCA,8EASC;AAaD,kEAEC;AAKD,oDAQC;AAeD,oDAqCC;AA/HD,0DAA4B;AAE5B,mDAAmH;AAGnH,qCAAiC;AACjC,+CAAoD;AA0BpD;;;;;GAKG;AACH,SAAgB,iCAAiC,CAC/C,WAAmB,EACnB,QAA8B;IAE9B,OAAO,IAAA,mCAAwB,EAAC;QAC9B,WAAW;QACX,QAAQ;QACR,SAAS,EAAE,CAAC,OAAO,E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B,EAAE,CAAA;QAErC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAA;QAEvC,IAAI,CAAC;YACH,KAAK,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;gBACvE,MAAM,kBAAkB,GAAG,mBAAI,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;gBAClE,MAAM,cAAc,GAAG,oBAAoB,CAAC,kBAAkB,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;gBAClG,MAAM,gBAAgB,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAA;gBACjD,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;YACxC,CAAC;YACD,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,wCAAwC,MAAM,CAAC,EAAE,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC/G,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,iBAAiB,CAAA;AAC1B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateWidgetServerUpdate = validateWidgetServerUpdate;
|
|
4
|
+
exports.resolveWidgetServerUpdate = resolveWidgetServerUpdate;
|
|
5
|
+
const serverUpdate_1 = require("./serverUpdate");
|
|
6
|
+
const logger_1 = require("./utils/logger");
|
|
7
|
+
function validateWidgetServerUpdate(serverUpdate, widgetId, rules) {
|
|
8
|
+
if (serverUpdate === undefined) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const context = `Widget '${widgetId}': serverUpdate`;
|
|
12
|
+
if (typeof serverUpdate !== 'object' || serverUpdate === null || Array.isArray(serverUpdate)) {
|
|
13
|
+
throw new Error(`${context} must be an object`);
|
|
14
|
+
}
|
|
15
|
+
const { url, intervalMinutes, refresh } = serverUpdate;
|
|
16
|
+
const resolvedUrl = (0, serverUpdate_1.resolveServerUpdateUrl)(url, context);
|
|
17
|
+
if (resolvedUrl.kind === 'invalid') {
|
|
18
|
+
throw new Error(resolvedUrl.error);
|
|
19
|
+
}
|
|
20
|
+
if (resolvedUrl.kind === 'insecure') {
|
|
21
|
+
logger_1.logger.warn(resolvedUrl.warning);
|
|
22
|
+
}
|
|
23
|
+
const interval = (0, serverUpdate_1.resolveServerUpdateInterval)({
|
|
24
|
+
intervalMinutes,
|
|
25
|
+
context,
|
|
26
|
+
hasEntry: rules.hasEntry,
|
|
27
|
+
defaultIntervalMinutes: rules.defaultIntervalMinutes,
|
|
28
|
+
minimumIntervalMinutes: rules.minimumIntervalMinutes,
|
|
29
|
+
});
|
|
30
|
+
if (interval.kind === 'invalid') {
|
|
31
|
+
throw new Error(interval.error);
|
|
32
|
+
}
|
|
33
|
+
if (interval.kind === 'clamped') {
|
|
34
|
+
logger_1.logger.warn(interval.warning);
|
|
35
|
+
}
|
|
36
|
+
const refreshError = (0, serverUpdate_1.validateServerUpdateRefresh)(refresh, context);
|
|
37
|
+
if (refreshError) {
|
|
38
|
+
throw new Error(refreshError);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Applies defaults to a validated `serverUpdate`. Generators call this instead of reading
|
|
43
|
+
* `intervalMinutes` directly, so the value written into a plist or a generated asset is the one
|
|
44
|
+
* the widget will actually be scheduled on.
|
|
45
|
+
*/
|
|
46
|
+
function resolveWidgetServerUpdate(serverUpdate, rules) {
|
|
47
|
+
const interval = (0, serverUpdate_1.resolveServerUpdateInterval)({
|
|
48
|
+
intervalMinutes: serverUpdate.intervalMinutes,
|
|
49
|
+
context: 'serverUpdate',
|
|
50
|
+
hasEntry: rules.hasEntry,
|
|
51
|
+
defaultIntervalMinutes: rules.defaultIntervalMinutes,
|
|
52
|
+
minimumIntervalMinutes: rules.minimumIntervalMinutes,
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
url: serverUpdate.url,
|
|
56
|
+
// An invalid interval cannot reach here — validateWidgetServerUpdate throws on it first — but
|
|
57
|
+
// if the two are ever called out of order, falling back to the platform's own default is less
|
|
58
|
+
// surprising than silently switching a payload widget to the Dynamic one.
|
|
59
|
+
intervalMinutes: interval.kind === 'invalid' ? rules.defaultIntervalMinutes : interval.intervalMinutes,
|
|
60
|
+
refresh: serverUpdate.refresh === true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=widgetServerUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgetServerUpdate.js","sourceRoot":"","sources":["../../src/widgetServerUpdate.ts"],"names":[],"mappings":";;AAiCA,gEAgDC;AAOD,8DAoBC;AA5GD,iDAAiH;AACjH,2CAAuC;AAgCvC,SAAgB,0BAA0B,CACxC,YAAqB,EACrB,QAAgB,EAChB,KAA8B;IAE9B,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAM;IACR,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,QAAQ,iBAAiB,CAAA;IAEpD,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QAC7F,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,oBAAoB,CAAC,CAAA;IACjD,CAAC;IAED,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,YAAwC,CAAA;IAElF,MAAM,WAAW,GAAG,IAAA,qCAAsB,EAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAExD,IAAI,W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;QACrB,8FAA8F;QAC9F,8FAA8F;QAC9F,0EAA0E;QAC1E,eAAe,EAAE,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe;QACtG,OAAO,EAAE,YAAY,CAAC,OAAO,KAAK,IAAI;KACvC,CAAA;AACH,CAAC"}
|
package/build/esm/constants.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** Extensions to try when resolving module paths for pre-rendering */
|
|
2
|
-
export const MODULE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', ''];
|
|
3
1
|
/** Maximum image size in bytes for widget / Live Activity assets (4KB limit) */
|
|
4
2
|
export const MAX_IMAGE_SIZE_BYTES = 4096;
|
|
5
3
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-live-activity.js","sourceRoot":"","sources":["../../src/dynamic-live-activity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAA"}
|
package/build/esm/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
export { MAX_IMAGE_SIZE_BYTES
|
|
1
|
+
export { MAX_IMAGE_SIZE_BYTES } from './constants';
|
|
2
|
+
export { getDynamicLiveActivityAttributesType } from './dynamic-live-activity';
|
|
3
|
+
export { DYNAMIC_WIDGET_SERVER_UPDATE_INTERVAL_MINUTES, isLocalHttpHost, resolveServerUpdateInterval, resolveServerUpdateUrl, validateServerUpdateRefresh, } from './serverUpdate';
|
|
4
|
+
export { resolveWidgetServerUpdate, validateWidgetServerUpdate } from './widgetServerUpdate';
|
|
2
5
|
export { assertValidLocaleKey, normalizeWidgetEntryPath, validateHomeScreenWidgetId, validateInitialStatePath, validateWidgetEntry, validateWidgetLabel, } from './validation';
|
|
3
6
|
export { addApplicationGroupsEntitlement } from './utils/entitlements';
|
|
4
7
|
export { resolveFontPaths } from './utils/fonts';
|
|
5
8
|
export { normalizeLocaleTag, pickLocalizedValue } from './utils/localePick';
|
|
6
9
|
export { logger } from './utils/logger';
|
|
7
|
-
export {
|
|
10
|
+
export { resolveInstalledPackageVersion } from './utils/packageVersion';
|
|
11
|
+
export { createPrerenderWidgetModuleLoader, evaluateWidgetModule, evaluateWidgetModuleExports, prerenderWidgetState, } from './utils/prerender';
|
|
8
12
|
export { isWidgetLocalizedMap, widgetLabelEnglish } from './utils/widgetLabel';
|
|
9
13
|
//# sourceMappingURL=index.js.map
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAA;AAc9E,OAAO,EACL,6CAA6C,EAC7C,eAAe,EACf,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAA;AAMvB,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAC5F,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAA;AAOvE,OAAO,EACL,iCAAiC,EACjC,oBAAoB,EACpB,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA"}
|