mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-13 04:50:56 +00:00
dev: update puter.js imports to work in cli
This is a step towards getting puter.js to run in node instead of just in the browser. In node, all the relative imports need to end with the file extension, and the "type" option in package.json needs to match the import mechanism used. It was also necessary to migrate webpack.config.js to ESM syntax, which I would not have done if the tooling didn't force me to.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start-server": "npx http-server --cors -c-1",
|
||||
"start-webpack": "webpack && webpack --output-filename puter.dev.js --watch --devtool source-map",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
import puter from './index.js';
|
||||
@@ -33,7 +33,7 @@ import Perms from './modules/Perms.js';
|
||||
// (using defaultGUIOrigin breaks locally-hosted apps)
|
||||
const PROD_ORIGIN = 'https://puter.com';
|
||||
|
||||
window.puter = (function() {
|
||||
export default window.puter = (function() {
|
||||
'use strict';
|
||||
|
||||
class Puter{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as utils from '../utils.js';
|
||||
import putility from "@heyputer/putility";
|
||||
import { TeePromise } from "@heyputer/putility/src/libs/promise";
|
||||
import { TeePromise } from "@heyputer/putility/src/libs/promise.js";
|
||||
import getAbsolutePathForApp from '../../modules/FileSystem/utils/getAbsolutePathForApp.js';
|
||||
import { TFilesystem } from './definitions.js';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import putility from "@heyputer/putility";
|
||||
import { RWLock } from "@heyputer/putility/src/libs/promise";
|
||||
import { ProxyFilesystem, TFilesystem } from "./definitions";
|
||||
import { uuidv4 } from "../utils";
|
||||
import { RWLock } from "@heyputer/putility/src/libs/promise.js";
|
||||
import { ProxyFilesystem, TFilesystem } from "./definitions.js";
|
||||
import { uuidv4 } from "../utils.js";
|
||||
|
||||
export const ROOT_UUID = '00000000-0000-0000-0000-000000000000';
|
||||
const TTL = 5 * 1000;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import putility from "@heyputer/putility";
|
||||
import { TFilesystem } from "./definitions";
|
||||
import { TFilesystem } from "./definitions.js";
|
||||
|
||||
const example = {
|
||||
"id": "f485f1ba-de07-422c-8c4b-c2da057d4a44",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import putility from "@heyputer/putility";
|
||||
import EventListener from "./EventListener";
|
||||
import EventListener from "./EventListener.js";
|
||||
|
||||
// TODO: this inheritance is an anti-pattern; we should use
|
||||
// a trait or mixin for event emitters.
|
||||
|
||||
@@ -417,4 +417,4 @@ class PuterDialog extends HTMLElement {
|
||||
}
|
||||
customElements.define('puter-dialog', PuterDialog);
|
||||
|
||||
module.exports = PuterDialog;
|
||||
export default PuterDialog;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { $SCOPE, CallbackManager, Dehydrator, Hydrator } from "../lib/xdrpc";
|
||||
import { $SCOPE, CallbackManager, Dehydrator, Hydrator } from "../lib/xdrpc.js";
|
||||
|
||||
/**
|
||||
* The Util module exposes utilities within puter.js itself.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* This file uses https://github.com/MercuryWorkshop/rustls-wasm authored by GitHub:@r58Playz under the MIT License
|
||||
*/
|
||||
|
||||
import { PSocket } from "./PSocket";
|
||||
import { PSocket } from "./PSocket.js";
|
||||
|
||||
let rustls = undefined;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import putility from "@heyputer/putility";
|
||||
import { PuterAPIFilesystem } from "../lib/filesystem/APIFS";
|
||||
import { CachedFilesystem } from "../lib/filesystem/CacheFS";
|
||||
import { ProxyFilesystem, TFilesystem } from "../lib/filesystem/definitions";
|
||||
import { PuterAPIFilesystem } from "../lib/filesystem/APIFS.js";
|
||||
import { CachedFilesystem } from "../lib/filesystem/CacheFS.js";
|
||||
import { ProxyFilesystem, TFilesystem } from "../lib/filesystem/definitions.js";
|
||||
import io from '../lib/socket.io/socket.io.esm.min.js';
|
||||
import { PostMessageFilesystem } from "../lib/filesystem/PostMessageFS.js";
|
||||
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
import path from 'node:path';
|
||||
import webpack from 'webpack';
|
||||
|
||||
// '__dirname' isn't defined by default in ES modules.
|
||||
// We didn't really want to migrate this file to ESM because
|
||||
// it's config for tooling that only runs in node, but alas
|
||||
// if package.json says "type": "module" then we have to use
|
||||
// ESM syntax everywhere unless we rename this to a .cjs file
|
||||
// and add an extra flag everywhere we use webpack.
|
||||
import { fileURLToPath } from 'url';
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
console.log('ENV CHECK!!!', process.env.PUTER_ORIGIN, process.env.PUTER_API_ORIGIN);
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
entry: './src/index.js',
|
||||
output: {
|
||||
filename: 'puter.js',
|
||||
|
||||
Reference in New Issue
Block a user