@iwsdk/create 0.3.2 → 0.4.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/dist/cli.js +122 -74
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -19808,7 +19808,7 @@ async function installMSE() {
|
|
|
19808
19808
|
* This source code is licensed under the MIT license found in the
|
|
19809
19809
|
* LICENSE file in the root directory of this source tree.
|
|
19810
19810
|
*/
|
|
19811
|
-
async function promptFlow(nameArg) {
|
|
19811
|
+
async function promptFlow(nameArg, defaults = {}) {
|
|
19812
19812
|
let cancelled = false;
|
|
19813
19813
|
const onCancel = () => {
|
|
19814
19814
|
cancelled = true;
|
|
@@ -19849,41 +19849,58 @@ async function promptFlow(nameArg) {
|
|
|
19849
19849
|
const resolvedAiTools = aiTools?.includes('none')
|
|
19850
19850
|
? []
|
|
19851
19851
|
: aiTools || [];
|
|
19852
|
-
const { language
|
|
19853
|
-
|
|
19854
|
-
|
|
19855
|
-
|
|
19856
|
-
|
|
19857
|
-
|
|
19858
|
-
|
|
19859
|
-
|
|
19860
|
-
|
|
19861
|
-
|
|
19862
|
-
|
|
19863
|
-
|
|
19852
|
+
const { language } = await prompts$1({
|
|
19853
|
+
type: 'select',
|
|
19854
|
+
name: 'language',
|
|
19855
|
+
message: 'Which language do you want to use?',
|
|
19856
|
+
choices: [
|
|
19857
|
+
{ title: 'TypeScript', value: 'ts' },
|
|
19858
|
+
{ title: 'JavaScript', value: 'js' },
|
|
19859
|
+
],
|
|
19860
|
+
initial: 0,
|
|
19861
|
+
}, { onCancel });
|
|
19862
|
+
if (cancelled) {
|
|
19863
|
+
throw new Error('Input cancelled');
|
|
19864
|
+
}
|
|
19865
|
+
const xrEnabled = defaults.xrEnabled ??
|
|
19866
|
+
!!(await prompts$1({
|
|
19867
|
+
type: 'toggle',
|
|
19868
|
+
name: 'xrEnabled',
|
|
19869
|
+
message: 'Enable XR support?',
|
|
19870
|
+
initial: true,
|
|
19871
|
+
active: 'Yes',
|
|
19872
|
+
inactive: 'No',
|
|
19873
|
+
}, { onCancel })).xrEnabled;
|
|
19874
|
+
if (cancelled) {
|
|
19875
|
+
throw new Error('Input cancelled');
|
|
19876
|
+
}
|
|
19877
|
+
const { mode = 'vr' } = xrEnabled
|
|
19878
|
+
? await prompts$1({
|
|
19864
19879
|
type: 'select',
|
|
19865
19880
|
name: 'mode',
|
|
19866
|
-
message: 'What type of experience are you building?',
|
|
19881
|
+
message: 'What type of XR experience are you building?',
|
|
19867
19882
|
choices: [
|
|
19868
19883
|
{ title: 'Virtual Reality', value: 'vr' },
|
|
19869
19884
|
{ title: 'Augmented Reality', value: 'ar' },
|
|
19870
19885
|
],
|
|
19871
19886
|
initial: 0,
|
|
19872
|
-
},
|
|
19873
|
-
|
|
19887
|
+
}, { onCancel })
|
|
19888
|
+
: { mode: 'vr' };
|
|
19874
19889
|
if (cancelled) {
|
|
19875
19890
|
throw new Error('Input cancelled');
|
|
19876
19891
|
}
|
|
19877
|
-
const xrFeatureKeys =
|
|
19878
|
-
? [
|
|
19879
|
-
:
|
|
19880
|
-
'handTracking',
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
|
|
19885
|
-
|
|
19886
|
-
|
|
19892
|
+
const xrFeatureKeys = !xrEnabled
|
|
19893
|
+
? []
|
|
19894
|
+
: mode === 'vr'
|
|
19895
|
+
? ['handTracking', 'layers']
|
|
19896
|
+
: [
|
|
19897
|
+
'handTracking',
|
|
19898
|
+
'anchors',
|
|
19899
|
+
'hitTest',
|
|
19900
|
+
'planeDetection',
|
|
19901
|
+
'meshDetection',
|
|
19902
|
+
'layers',
|
|
19903
|
+
];
|
|
19887
19904
|
const xrFeatureStates = {};
|
|
19888
19905
|
for (const key of xrFeatureKeys) {
|
|
19889
19906
|
const initial = mode === 'ar' ? 1 : key === 'handTracking' || key === 'layers' ? 1 : 0;
|
|
@@ -19924,7 +19941,7 @@ async function promptFlow(nameArg) {
|
|
|
19924
19941
|
let locomotionUseWorker = undefined;
|
|
19925
19942
|
let sceneUnderstandingEnabled = false;
|
|
19926
19943
|
let environmentRaycastEnabled = false;
|
|
19927
|
-
if (mode === 'vr') {
|
|
19944
|
+
if (xrEnabled && mode === 'vr') {
|
|
19928
19945
|
// Locomotion (VR only)
|
|
19929
19946
|
const ans = await prompts$1({
|
|
19930
19947
|
type: 'toggle',
|
|
@@ -19955,7 +19972,7 @@ async function promptFlow(nameArg) {
|
|
|
19955
19972
|
locomotionUseWorker = !!followUp.useWorker;
|
|
19956
19973
|
}
|
|
19957
19974
|
}
|
|
19958
|
-
else {
|
|
19975
|
+
else if (xrEnabled) {
|
|
19959
19976
|
// AR: Scene Understanding first (requires room scanning)
|
|
19960
19977
|
const sceneAns = await prompts$1({
|
|
19961
19978
|
type: 'toggle',
|
|
@@ -19983,17 +20000,20 @@ async function promptFlow(nameArg) {
|
|
|
19983
20000
|
}
|
|
19984
20001
|
environmentRaycastEnabled = !!raycastAns.environmentRaycastEnabled;
|
|
19985
20002
|
}
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
|
|
19989
|
-
|
|
19990
|
-
|
|
19991
|
-
|
|
19992
|
-
|
|
19993
|
-
|
|
19994
|
-
|
|
19995
|
-
|
|
19996
|
-
|
|
20003
|
+
let grabbingEnabled = false;
|
|
20004
|
+
if (xrEnabled) {
|
|
20005
|
+
const grabbingAnswer = await prompts$1({
|
|
20006
|
+
type: 'toggle',
|
|
20007
|
+
name: 'grabbingEnabled',
|
|
20008
|
+
message: 'Enable grabbing (one/two-hand, distance)?',
|
|
20009
|
+
initial: true,
|
|
20010
|
+
active: 'Yes',
|
|
20011
|
+
inactive: 'No',
|
|
20012
|
+
}, { onCancel });
|
|
20013
|
+
if (cancelled) {
|
|
20014
|
+
throw new Error('Input cancelled');
|
|
20015
|
+
}
|
|
20016
|
+
grabbingEnabled = !!grabbingAnswer.grabbingEnabled;
|
|
19997
20017
|
}
|
|
19998
20018
|
// Physics (default: disabled)
|
|
19999
20019
|
const { physicsEnabled } = await prompts$1({
|
|
@@ -20066,6 +20086,7 @@ async function promptFlow(nameArg) {
|
|
|
20066
20086
|
id,
|
|
20067
20087
|
installNow,
|
|
20068
20088
|
metaspatial,
|
|
20089
|
+
xrEnabled,
|
|
20069
20090
|
mode,
|
|
20070
20091
|
language,
|
|
20071
20092
|
features: [],
|
|
@@ -20415,8 +20436,8 @@ async function scaffoldProject(recipes, outDir) {
|
|
|
20415
20436
|
}
|
|
20416
20437
|
}
|
|
20417
20438
|
|
|
20418
|
-
const VERSION = "0.
|
|
20419
|
-
const NODE_ENGINE = ">=20.19.0";
|
|
20439
|
+
const VERSION = "0.4.0";
|
|
20440
|
+
const NODE_ENGINE = ">=20.19.0 <21.0.0-0 || >=22.12.0 <23.0.0-0 || >=24.0.0";
|
|
20420
20441
|
|
|
20421
20442
|
/**
|
|
20422
20443
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -20466,6 +20487,10 @@ async function fetchRecipeByFileName(fileName, base = DEFAULT_ASSETS_BASE) {
|
|
|
20466
20487
|
* references between packages (e.g., core → glxf) resolve correctly.
|
|
20467
20488
|
*/
|
|
20468
20489
|
const SDK_PACKAGES_DIR = '.sdk-packages';
|
|
20490
|
+
/**
|
|
20491
|
+
* Default CDN URL for the canary SDK bundle.
|
|
20492
|
+
*/
|
|
20493
|
+
const DEFAULT_BUNDLE_URL = 'https://d1erq8v22udnml.cloudfront.net/sdk-bundle';
|
|
20469
20494
|
/**
|
|
20470
20495
|
* Prepend a base URL to relative `url` edits in a recipe.
|
|
20471
20496
|
* Absolute URLs pass through unchanged (backwards compatible).
|
|
@@ -20540,13 +20565,13 @@ class NpmSource {
|
|
|
20540
20565
|
* Resolves @iwsdk/* packages to local file: paths after downloading tarballs.
|
|
20541
20566
|
*/
|
|
20542
20567
|
class BundleSource {
|
|
20543
|
-
constructor(
|
|
20568
|
+
constructor(bundleUrl) {
|
|
20544
20569
|
this.isBundleMode = true;
|
|
20545
20570
|
this.manifest = null;
|
|
20546
|
-
if (!
|
|
20547
|
-
throw new Error(
|
|
20571
|
+
if (!bundleUrl.startsWith('http://') && !bundleUrl.startsWith('https://')) {
|
|
20572
|
+
throw new Error(`Bundle URL must be an HTTP or HTTPS URL. Got: "${bundleUrl}"`);
|
|
20548
20573
|
}
|
|
20549
|
-
this.baseUrl =
|
|
20574
|
+
this.baseUrl = bundleUrl;
|
|
20550
20575
|
}
|
|
20551
20576
|
async prepare() {
|
|
20552
20577
|
const manifestContent = await this.readContent('bundle.json');
|
|
@@ -20626,13 +20651,18 @@ class BundleSource {
|
|
|
20626
20651
|
}
|
|
20627
20652
|
}
|
|
20628
20653
|
/**
|
|
20629
|
-
* Factory: create the appropriate source based on the --
|
|
20654
|
+
* Factory: create the appropriate source based on the --canary flag.
|
|
20655
|
+
*
|
|
20656
|
+
* - `undefined` / `false` → NpmSource (default)
|
|
20657
|
+
* - `true` (bare --canary) → BundleSource with DEFAULT_BUNDLE_URL
|
|
20658
|
+
* - `string` → BundleSource with the provided URL
|
|
20630
20659
|
*/
|
|
20631
|
-
function resolveSource(
|
|
20632
|
-
if (!
|
|
20660
|
+
function resolveSource(canaryFlag) {
|
|
20661
|
+
if (!canaryFlag) {
|
|
20633
20662
|
return new NpmSource();
|
|
20634
20663
|
}
|
|
20635
|
-
|
|
20664
|
+
const url = typeof canaryFlag === 'string' ? canaryFlag : DEFAULT_BUNDLE_URL;
|
|
20665
|
+
return new BundleSource(url);
|
|
20636
20666
|
}
|
|
20637
20667
|
|
|
20638
20668
|
/**
|
|
@@ -20678,10 +20708,12 @@ IWSDK Create CLI v${VERSION}\nNode ${process.version}`;
|
|
|
20678
20708
|
.description('Official CLI for creating Immersive Web SDK projects')
|
|
20679
20709
|
.version(version)
|
|
20680
20710
|
.argument('[name]', 'Project name')
|
|
20681
|
-
.option('--
|
|
20711
|
+
.option('--canary [url]', 'Use canary SDK bundle (optionally from a custom URL)')
|
|
20682
20712
|
.option('-y, --yes', 'Use defaults and skip prompts')
|
|
20683
20713
|
.option('--mode <mode>', 'Experience mode: vr or ar', 'vr')
|
|
20684
20714
|
.option('--language <lang>', 'Language: ts or js', 'ts')
|
|
20715
|
+
.option('--xr', 'Enable XR support', true)
|
|
20716
|
+
.option('--no-xr', 'Disable XR support for a browser-only 3D project')
|
|
20685
20717
|
.option('--metaspatial', 'Use Meta Spatial Editor workflow', false)
|
|
20686
20718
|
.option('--no-metaspatial', 'Use manual workflow (default)')
|
|
20687
20719
|
.option('--install', 'Install dependencies after scaffolding', true)
|
|
@@ -20718,11 +20750,11 @@ IWSDK Create CLI v${VERSION}\nNode ${process.version}`;
|
|
|
20718
20750
|
console.error(chalk.red(`Invalid --language "${cliOpts.language}". Must be "ts" or "js".`));
|
|
20719
20751
|
process.exit(1);
|
|
20720
20752
|
}
|
|
20721
|
-
if (cliOpts.
|
|
20722
|
-
const isUrl = cliOpts.
|
|
20723
|
-
cliOpts.
|
|
20753
|
+
if (typeof cliOpts.canary === 'string') {
|
|
20754
|
+
const isUrl = cliOpts.canary.startsWith('http://') ||
|
|
20755
|
+
cliOpts.canary.startsWith('https://');
|
|
20724
20756
|
if (!isUrl) {
|
|
20725
|
-
console.error(chalk.red(`--
|
|
20757
|
+
console.error(chalk.red(`--canary URL must be an HTTP or HTTPS URL. Got: "${cliOpts.canary}".`));
|
|
20726
20758
|
process.exit(1);
|
|
20727
20759
|
}
|
|
20728
20760
|
}
|
|
@@ -20758,6 +20790,7 @@ IWSDK Create CLI v${VERSION}\nNode ${process.version}`;
|
|
|
20758
20790
|
if (cliOpts.yes) {
|
|
20759
20791
|
const mode = (cliOpts.mode || 'vr');
|
|
20760
20792
|
const language = (cliOpts.language || 'ts');
|
|
20793
|
+
const xrEnabled = cliOpts.xr ?? true;
|
|
20761
20794
|
const metaspatial = cliOpts.metaspatial ?? false;
|
|
20762
20795
|
// Meta Spatial Editor is only available as a GUI app on macOS/Windows.
|
|
20763
20796
|
// The Linux CLI can build metaspatial projects but cannot author content.
|
|
@@ -20775,7 +20808,7 @@ IWSDK Create CLI v${VERSION}\nNode ${process.version}`;
|
|
|
20775
20808
|
const aiTools = rawAiTools.includes('none')
|
|
20776
20809
|
? []
|
|
20777
20810
|
: rawAiTools.filter((t) => validAiTools.includes(t));
|
|
20778
|
-
const locomotionEnabled = mode === 'vr' ? (cliOpts.locomotion ?? true) : false;
|
|
20811
|
+
const locomotionEnabled = xrEnabled && mode === 'vr' ? (cliOpts.locomotion ?? true) : false;
|
|
20779
20812
|
// MSE detection for scripted mode (no auto-install — requires TOS consent)
|
|
20780
20813
|
let mseInstallResult;
|
|
20781
20814
|
if (metaspatial) {
|
|
@@ -20805,41 +20838,49 @@ IWSDK Create CLI v${VERSION}\nNode ${process.version}`;
|
|
|
20805
20838
|
id: variantId,
|
|
20806
20839
|
installNow: cliOpts.install ?? true,
|
|
20807
20840
|
metaspatial,
|
|
20841
|
+
xrEnabled,
|
|
20808
20842
|
mode,
|
|
20809
20843
|
language,
|
|
20810
20844
|
features: [],
|
|
20811
20845
|
featureFlags: {
|
|
20812
20846
|
locomotionEnabled,
|
|
20813
20847
|
locomotionUseWorker: locomotionEnabled ? true : undefined,
|
|
20814
|
-
grabbingEnabled: cliOpts.grabbing ?? true,
|
|
20848
|
+
grabbingEnabled: xrEnabled ? (cliOpts.grabbing ?? true) : false,
|
|
20815
20849
|
physicsEnabled: cliOpts.physics ?? false,
|
|
20816
|
-
sceneUnderstandingEnabled: mode === 'ar'
|
|
20817
|
-
|
|
20850
|
+
sceneUnderstandingEnabled: xrEnabled && mode === 'ar'
|
|
20851
|
+
? (cliOpts.sceneUnderstanding ?? true)
|
|
20852
|
+
: false,
|
|
20853
|
+
environmentRaycastEnabled: xrEnabled && mode === 'ar'
|
|
20854
|
+
? (cliOpts.environmentRaycast ?? true)
|
|
20855
|
+
: false,
|
|
20818
20856
|
},
|
|
20819
20857
|
gitInit: cliOpts.git ?? true,
|
|
20820
20858
|
aiTools,
|
|
20821
|
-
xrFeatureStates:
|
|
20822
|
-
? {
|
|
20823
|
-
|
|
20824
|
-
|
|
20825
|
-
|
|
20826
|
-
|
|
20827
|
-
|
|
20828
|
-
|
|
20829
|
-
|
|
20830
|
-
|
|
20859
|
+
xrFeatureStates: !xrEnabled
|
|
20860
|
+
? {}
|
|
20861
|
+
: mode === 'ar'
|
|
20862
|
+
? {
|
|
20863
|
+
handTracking: 'optional',
|
|
20864
|
+
anchors: 'optional',
|
|
20865
|
+
hitTest: 'optional',
|
|
20866
|
+
planeDetection: 'optional',
|
|
20867
|
+
meshDetection: 'optional',
|
|
20868
|
+
layers: 'optional',
|
|
20869
|
+
}
|
|
20870
|
+
: { handTracking: 'optional', layers: 'optional' },
|
|
20831
20871
|
mseInstallResult,
|
|
20832
20872
|
};
|
|
20833
20873
|
}
|
|
20834
20874
|
else {
|
|
20835
|
-
|
|
20875
|
+
const xrFlagProvided = process.argv.includes('--xr') || process.argv.includes('--no-xr');
|
|
20876
|
+
res = await promptFlow(nameArg, xrFlagProvided ? { xrEnabled: cliOpts.xr ?? true } : {});
|
|
20836
20877
|
}
|
|
20837
20878
|
// Validate project name (both interactive and non-interactive paths)
|
|
20838
20879
|
if (!/^[a-zA-Z0-9._@-]+$/.test(res.name)) {
|
|
20839
20880
|
throw new Error(`Invalid project name "${res.name}". ` +
|
|
20840
20881
|
'Use only letters, numbers, hyphens, underscores, dots, and @.');
|
|
20841
20882
|
}
|
|
20842
|
-
const source = resolveSource(cliOpts.
|
|
20883
|
+
const source = resolveSource(cliOpts.canary);
|
|
20843
20884
|
// Prepare source (downloads tgz files for remote bundles)
|
|
20844
20885
|
if (source.isBundleMode) {
|
|
20845
20886
|
const prepSpinner = ora({
|
|
@@ -20881,9 +20922,9 @@ IWSDK Create CLI v${VERSION}\nNode ${process.version}`;
|
|
|
20881
20922
|
resolvedRecipe.edits['@appName'] = res.name;
|
|
20882
20923
|
// World features (stringified JS object-literal expected by recipes)
|
|
20883
20924
|
const ff = res.featureFlags || {
|
|
20884
|
-
locomotionEnabled: res.mode === 'vr',
|
|
20925
|
+
locomotionEnabled: res.xrEnabled && res.mode === 'vr',
|
|
20885
20926
|
locomotionUseWorker: true,
|
|
20886
|
-
grabbingEnabled:
|
|
20927
|
+
grabbingEnabled: res.xrEnabled,
|
|
20887
20928
|
physicsEnabled: false,
|
|
20888
20929
|
sceneUnderstandingEnabled: false,
|
|
20889
20930
|
environmentRaycastEnabled: false,
|
|
@@ -20893,8 +20934,12 @@ IWSDK Create CLI v${VERSION}\nNode ${process.version}`;
|
|
|
20893
20934
|
? '{ useWorker: true }'
|
|
20894
20935
|
: 'true'
|
|
20895
20936
|
: 'false';
|
|
20896
|
-
const sceneUnderstandingLiteral = res.mode === 'ar' && ff.sceneUnderstandingEnabled
|
|
20897
|
-
|
|
20937
|
+
const sceneUnderstandingLiteral = res.xrEnabled && res.mode === 'ar' && ff.sceneUnderstandingEnabled
|
|
20938
|
+
? 'true'
|
|
20939
|
+
: 'false';
|
|
20940
|
+
const environmentRaycastLiteral = res.xrEnabled && res.mode === 'ar' && ff.environmentRaycastEnabled
|
|
20941
|
+
? 'true'
|
|
20942
|
+
: 'false';
|
|
20898
20943
|
resolvedRecipe.edits['@appFeaturesStr'] =
|
|
20899
20944
|
`{ locomotion: ${locomotionLiteral}, grabbing: ${ff.grabbingEnabled ? 'true' : 'false'}, physics: ${ff.physicsEnabled ? 'true' : 'false'}, sceneUnderstanding: ${sceneUnderstandingLiteral}, environmentRaycast: ${environmentRaycastLiteral} }`;
|
|
20900
20945
|
// XR features (tri-state -> JS object literal)
|
|
@@ -20909,6 +20954,9 @@ IWSDK Create CLI v${VERSION}\nNode ${process.version}`;
|
|
|
20909
20954
|
}
|
|
20910
20955
|
const xrLiteral = `{ ${entries.join(', ')} }`;
|
|
20911
20956
|
resolvedRecipe.edits['@xrFeaturesStr'] = xrLiteral;
|
|
20957
|
+
resolvedRecipe.edits['@xrConfigStr'] = res.xrEnabled
|
|
20958
|
+
? `{ sessionMode: SessionMode.Immersive${res.mode === 'ar' ? 'AR' : 'VR'}, offer: 'always', features: ${xrLiteral} }`
|
|
20959
|
+
: 'false';
|
|
20912
20960
|
const outDir = join(process.cwd(), res.name);
|
|
20913
20961
|
// Check if target directory already exists and is non-empty
|
|
20914
20962
|
if (fs$2.existsSync(outDir) && fs$2.readdirSync(outDir).length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iwsdk/create",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Interactive CLI to scaffold Immersive Web SDK starter apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"url": "git+https://github.com/facebook/immersive-web-sdk.git"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=20.19.0"
|
|
29
|
+
"node": ">=20.19.0 <21.0.0-0 || >=22.12.0 <23.0.0-0 || >=24.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@pmndrs/chef": "^0.1.9",
|