babylonjs-serializers 8.56.1 → 8.56.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babylon.threemfSerializer.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,cACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,wBAAyB,CAAC,aAAcJ,GACrB,iBAAZC,QACdA,QAAQ,yBAA2BD,EAAQG,QAAQ,cAEnDJ,EAAkB,YAAIC,EAAQD,EAAc,QAC7C,CATD,CASoB,oBAATO,KAAuBA,KAAyB,oBAAXC,OAAyBA,OAASC,MAAQC,G,iCCT1FP,EAAOD,QAAUQ,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaZ,QAGrB,IAAIC,EAASQ,EAAyBE,GAAY,CAGjDX,QAAS,CAAC,GAOX,OAHAc,EAAoBH,GAAUV,EAAQA,EAAOD,QAASU,GAG/CT,EAAOD,OACf,CCrBAU,EAAoBK,EAAI,CAACf,EAASgB,KACjC,IAAI,IAAIC,KAAOD,EACXN,EAAoBQ,EAAEF,EAAYC,KAASP,EAAoBQ,EAAElB,EAASiB,IAC5EE,OAAOC,eAAepB,EAASiB,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EP,EAAoBa,EAAI,WACvB,GAA0B,iBAAfC,WAAyB,OAAOA,WAC3C,IACC,OAAOjB,MAAQ,IAAIkB,SAAS,cAAb,EAChB,CAAE,MAAOC,GACR,GAAsB,iBAAXC,OAAqB,OAAOA,MACxC,CACA,CAPuB,GCAxBjB,EAAoBQ,EAAI,CAACU,EAAKC,IAAUV,OAAOW,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFn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,IAC7D/T,GAAKnH,KAAKkb,IAElB,CChBA,W","sources":["webpack://SERIALIZERS/webpack/universalModuleDefinition","webpack://SERIALIZERS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://SERIALIZERS/webpack/bootstrap","webpack://SERIALIZERS/webpack/runtime/define property getters","webpack://SERIALIZERS/webpack/runtime/global","webpack://SERIALIZERS/webpack/runtime/hasOwnProperty shorthand","webpack://SERIALIZERS/webpack/runtime/make namespace object","webpack://SERIALIZERS/../../../../node_modules/tslib/tslib.es6.mjs","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.interfaces.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.serializer.format.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.serializer.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.builder.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.interfaces.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.builder.string.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.builder.bytes.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.opc.interfaces.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.opc.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.builder.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.serializer.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/3mfSerializer.configuration.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/3mfSerializer.ts","webpack://SERIALIZERS/../../../lts/serializers/src/legacy/legacy-3mfSerializer.ts","webpack://SERIALIZERS/./src/3mf.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-serializers\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-serializers\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"SERIALIZERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__597__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__597__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n};\n","import type { IXmlSerializerFormatOptions } from \"./xml.serializer.format\";\r\n\r\n/** */\r\nexport interface IQualifiedName {\r\n /** */\r\n ns?: string;\r\n /** */\r\n name: string;\r\n}\r\n\r\n/** */\r\nexport interface IXmlBuilder {\r\n dec(version: string, encoding?: string, standalone?: boolean): IXmlBuilder;\r\n att(ns: string | null, n: string, v: string): IXmlBuilder;\r\n ele(ns: string | null, n: string): IXmlBuilder;\r\n text(txt: string): IXmlBuilder;\r\n end(): IXmlBuilder;\r\n}\r\n\r\n/**\r\n * @param x\r\n * @returns\r\n */\r\nexport function IsQualifiedName(x: unknown): x is { name: string } {\r\n return typeof (x as any)?.name === \"string\";\r\n}\r\n\r\nexport type XmlName = string | IQualifiedName;\r\n\r\ntype FieldKind = \"attr\" | \"elem\" | \"none\";\r\n\r\n/**\r\n *\r\n */\r\nexport interface IFormatter<T = any> {\r\n toString(value: T): string;\r\n}\r\n\r\nexport type FormatterCtor<T> = new (args: IXmlSerializerFormatOptions) => IFormatter<T>;\r\n\r\ntype FieldMeta = {\r\n kind: FieldKind;\r\n prop: string;\r\n name?: XmlName;\r\n ignore?: boolean;\r\n formatter?: FormatterCtor<any>;\r\n};\r\n\r\nconst XML_CLASS_META = Symbol(\"__xml:meta$__\");\r\nconst XML_CLASS_NAME = Symbol(\"__xml:name$__\");\r\n\r\nfunction AddXmlMeta(target: any, meta: FieldMeta) {\r\n const ctor = target.constructor;\r\n (ctor[XML_CLASS_META] ??= []).push(meta);\r\n}\r\n\r\n/**\r\n * @param name\r\n * @returns\r\n */\r\nexport function XmlName(name: XmlName) {\r\n return (ctor: Function) => {\r\n (ctor as any)[XML_CLASS_NAME] = name;\r\n };\r\n}\r\n\r\n/**\r\n * tell the serializer to ignore the property\r\n * @returns\r\n */\r\nexport function XmlIgnore() {\r\n return (target: any, prop: string) => AddXmlMeta(target, { kind: \"none\", prop, ignore: true });\r\n}\r\n\r\n/**\r\n * tell the serializer to serialize the property as attribute\r\n * @returns\r\n */\r\nexport function XmlAttr(opts?: { name: XmlName; formatter?: FormatterCtor<any> }) {\r\n return (target: any, prop: string) => AddXmlMeta(target, { kind: \"attr\", prop, ...opts });\r\n}\r\n\r\n/**\r\n * tell the serializer to serialize the property as element - this is the default behavior but shoud be\r\n * specified when wanted to update the default name of the classe or if the class is not decorated (without \\@XmlName)\r\n * @returns\r\n */\r\nexport function XmlElem(opts?: { name: XmlName }) {\r\n return (target: any, prop: string) => AddXmlMeta(target, { kind: \"elem\", prop, ...opts });\r\n}\r\n\r\n/**\r\n *\r\n * @param obj\r\n * @returns\r\n */\r\nexport function GetXmlFieldMeta(obj: any): FieldMeta[] {\r\n return (obj?.constructor?.[XML_CLASS_META] ?? []) as FieldMeta[];\r\n}\r\n\r\n/**\r\n *\r\n * @param obj\r\n * @returns\r\n */\r\nexport function GetXmlName(obj: any): XmlName | undefined {\r\n const n = obj?.constructor?.[XML_CLASS_NAME];\r\n return n ? (n as XmlName) : undefined;\r\n}\r\n\r\n/**\r\n *\r\n * @param s\r\n * @returns\r\n */\r\nfunction LooksLikeXmlNcName(s: string): boolean {\r\n // Approximation ASCII de NCName: pas de \":\" et demarre par lettre ou underscore\r\n // Puis lettres/chiffres/underscore/point/tiret.\r\n return /^[A-Za-z_][A-Za-z0-9._-]*$/.test(s);\r\n}\r\n\r\n/**\r\n *\r\n * @param qn\r\n * @returns\r\n */\r\nexport function XmlNameToParts(qn: XmlName): IQualifiedName {\r\n if (IsQualifiedName(qn)) {\r\n return qn;\r\n }\r\n const s = (qn ?? \"\").trim();\r\n if (!s) {\r\n return { name: \"\" };\r\n }\r\n const i = s.indexOf(\":\");\r\n if (i === -1) {\r\n return { name: s };\r\n }\r\n\r\n // Un QName XML ne doit contenir qu un seul \":\".\r\n // Si il y en a plusieurs, on considere que ce n est pas un QName.\r\n if (s.indexOf(\":\", i + 1) !== -1) {\r\n return { name: s };\r\n }\r\n\r\n const prefix = s.slice(0, i);\r\n const local = s.slice(i + 1);\r\n\r\n if (LooksLikeXmlNcName(prefix) && LooksLikeXmlNcName(local)) {\r\n return { ns: prefix, name: local };\r\n }\r\n return { name: s };\r\n}\r\n\r\n/**\r\n *\r\n * @param name\r\n * @param prefix\r\n * @returns\r\n */\r\nexport function ToQualifiedString(name: string, prefix?: string): string {\r\n return prefix ? `${prefix}:${name}` : name;\r\n}\r\n","import type { IFormatter } from \"./xml.interfaces\";\r\n\r\n/**\r\n *\r\n */\r\nexport interface IXmlSerializerNumberOptions {\r\n /**\r\n *\r\n */\r\n eps: number;\r\n /**\r\n *\r\n */\r\n maxDecimalsCap?: number; // default 15\r\n /**\r\n *\r\n */\r\n trimTrailingZeros?: boolean; // default true\r\n /**\r\n *\r\n */\r\n fixedDecimals?: number; // optional, overrides trim\r\n /**\r\n *\r\n */\r\n allowScientific?: boolean; // default false\r\n /**\r\n *\r\n */\r\n snapNearZero?: boolean; // default true\r\n /**\r\n *\r\n */\r\n zeroThreshold?: number; // default eps\r\n /**\r\n *\r\n */\r\n perAttributeEps?: Record<string, number>;\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport interface IXmlSerializerFormatOptions {\r\n /**\r\n *\r\n */\r\n number?: IXmlSerializerNumberOptions;\r\n}\r\n\r\nexport const DefaultXmlSerializerNumberOptions: Readonly<IXmlSerializerNumberOptions> = Object.freeze({\r\n eps: 1e-6,\r\n maxDecimalsCap: 15,\r\n trimTrailingZeros: true,\r\n // fixedDecimals: undefined,\r\n allowScientific: false,\r\n snapNearZero: true,\r\n // zeroThreshold defaults to eps if not provided\r\n // perAttributeEps: undefined,\r\n});\r\n\r\nexport const DefaultXmlSerializerFormatOptions: Readonly<IXmlSerializerFormatOptions> = Object.freeze({\r\n number: DefaultXmlSerializerNumberOptions,\r\n});\r\n\r\n/**\r\n *@param opts\r\n *@returns\r\n */\r\nexport function ResolveNumberOptions(opts?: IXmlSerializerNumberOptions): Required<\r\n Omit<IXmlSerializerNumberOptions, \"perAttributeEps\" | \"fixedDecimals\" | \"maxDecimalsCap\" | \"trimTrailingZeros\" | \"allowScientific\" | \"snapNearZero\" | \"zeroThreshold\">\r\n> &\r\n Pick<IXmlSerializerNumberOptions, \"perAttributeEps\" | \"fixedDecimals\"> & {\r\n maxDecimalsCap: number;\r\n trimTrailingZeros: boolean;\r\n allowScientific: boolean;\r\n snapNearZero: boolean;\r\n zeroThreshold: number;\r\n } {\r\n const eps = opts?.eps ?? DefaultXmlSerializerNumberOptions.eps;\r\n\r\n return {\r\n eps,\r\n maxDecimalsCap: opts?.maxDecimalsCap ?? DefaultXmlSerializerNumberOptions.maxDecimalsCap!,\r\n trimTrailingZeros: opts?.trimTrailingZeros ?? DefaultXmlSerializerNumberOptions.trimTrailingZeros!,\r\n fixedDecimals: opts?.fixedDecimals,\r\n allowScientific: opts?.allowScientific ?? DefaultXmlSerializerNumberOptions.allowScientific!,\r\n snapNearZero: opts?.snapNearZero ?? DefaultXmlSerializerNumberOptions.snapNearZero!,\r\n zeroThreshold: opts?.zeroThreshold ?? eps,\r\n perAttributeEps: opts?.perAttributeEps,\r\n };\r\n}\r\n\r\n/**\r\n *@param opts\r\n *@returns\r\n */\r\nexport function ResolveFormatOptions(opts?: IXmlSerializerFormatOptions) {\r\n return {\r\n number: ResolveNumberOptions(opts?.number),\r\n };\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class NumberFormatter implements IFormatter<number> {\r\n private _o: IXmlSerializerNumberOptions;\r\n\r\n /**\r\n *\r\n * @param o\r\n */\r\n public constructor(public o: IXmlSerializerFormatOptions) {\r\n this._o = o.number!;\r\n\r\n if (!Number.isFinite(this._o.eps) || this._o.eps <= 0) {\r\n throw new Error(\"opts.eps must be a finite, positive number\");\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param x\r\n * @returns\r\n */\r\n\r\n public toString(x: number): string {\r\n if (!Number.isFinite(x)) {\r\n throw new Error(`Cannot format non-finite number: ${x}`);\r\n }\r\n\r\n const opts = this._o;\r\n const maxDecimalsCap = this._clampInt(opts.maxDecimalsCap ?? 15, 0, 20);\r\n const trimTrailingZeros = opts.trimTrailingZeros ?? true;\r\n const snapNearZero = opts.snapNearZero ?? true;\r\n const zeroThreshold = opts.zeroThreshold ?? opts.eps;\r\n\r\n // Quantize to eps grid\r\n const inv = 1 / opts.eps;\r\n let q = Math.round(x * inv) / inv;\r\n\r\n // Normalize -0 to 0\r\n if (Object.is(q, -0)) {\r\n q = 0;\r\n }\r\n\r\n // Snap tiny values to 0 (helps size + stability)\r\n if (snapNearZero && Math.abs(q) <= zeroThreshold) {\r\n q = 0;\r\n }\r\n\r\n // Choose decimals policy\r\n let decimals: number;\r\n if (opts.fixedDecimals !== undefined) {\r\n decimals = this._clampInt(opts.fixedDecimals, 0, maxDecimalsCap);\r\n } else {\r\n // decimals needed for eps steps\r\n decimals = this._clampInt(Math.ceil(-Math.log10(opts.eps)), 0, maxDecimalsCap);\r\n }\r\n\r\n // Note: this implementation intentionally avoids scientific notation.\r\n // If allowScientific=true, you may want a different path (toPrecision).\r\n if (opts.allowScientific) {\r\n // Still avoid scientific here; keep deterministic fixed output.\r\n // If you really want scientific, implement a separate branch.\r\n }\r\n\r\n // Fast path when decimals = 0\r\n if (decimals === 0) {\r\n return String(Math.trunc(q));\r\n }\r\n\r\n // Start fixed, then optionally trim\r\n let s = q.toFixed(decimals);\r\n\r\n if (trimTrailingZeros && opts.fixedDecimals === undefined) {\r\n // Trim trailing zeros and optional trailing dot\r\n s = s\r\n .replace(/(\\.\\d*?[1-9])0+$/, \"$1\")\r\n .replace(/\\.0+$/, \"\")\r\n .replace(/\\.$/, \"\");\r\n }\r\n\r\n // Safety: ensure no scientific notation (should not happen with toFixed)\r\n if (/[eE]/.test(s)) {\r\n throw new Error(`Scientific notation not allowed in XML output: ${s}`);\r\n }\r\n\r\n return s;\r\n }\r\n\r\n private _clampInt(n: number, min: number, max: number): number {\r\n if (!Number.isFinite(n)) {\r\n return min;\r\n }\r\n n = Math.trunc(n);\r\n return Math.max(min, Math.min(max, n));\r\n }\r\n}\r\n","import { type IQualifiedName, XmlNameToParts, type IXmlBuilder, type XmlName, GetXmlName, ToQualifiedString, GetXmlFieldMeta } from \"./xml.interfaces\";\r\nimport { NumberFormatter, ResolveFormatOptions, type IXmlSerializerFormatOptions } from \"./xml.serializer.format\";\r\n\r\ntype Primitive = string | number | boolean | bigint | Date;\r\n\r\nfunction IsDate(x: any): x is Date {\r\n return x instanceof Date;\r\n}\r\n\r\nfunction IsString(x: any): x is string {\r\n return typeof x === \"string\";\r\n}\r\n\r\nfunction IsNumber(x: any): x is number {\r\n return typeof x === \"number\";\r\n}\r\n\r\nfunction IsPrimitive(x: any): x is Primitive {\r\n return typeof x === \"string\" || typeof x === \"number\" || typeof x === \"boolean\" || typeof x === \"bigint\" || IsDate(x);\r\n}\r\n\r\nfunction IsPrimitiveButString(x: any): x is Primitive {\r\n return typeof x === \"number\" || typeof x === \"boolean\" || typeof x === \"bigint\" || IsDate(x);\r\n}\r\n\r\n/**\r\n */\r\nexport class XmlSerializer {\r\n /** */\r\n private _format: IXmlSerializerFormatOptions;\r\n /** */\r\n private _builder: IXmlBuilder;\r\n /** */\r\n private _ns: Map<string, string> = new Map<string, string>();\r\n /** */\r\n private _prefixCount: number = 0;\r\n\r\n private _nFmt?: NumberFormatter;\r\n\r\n /**\r\n *\r\n * @param builder\r\n * @param format\r\n */\r\n public constructor(builder: IXmlBuilder, format?: IXmlSerializerFormatOptions) {\r\n this._builder = builder;\r\n this._format = ResolveFormatOptions(format);\r\n this._nFmt = new NumberFormatter(this._format);\r\n }\r\n\r\n /**\r\n *\r\n * @param ns\r\n * @returns\r\n */\r\n public withNamespace(...ns: XmlName[]): XmlSerializer {\r\n for (const s of ns) {\r\n this._assignNamespace(s);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param root\r\n * @param name\r\n */\r\n serialize(root: object, name?: XmlName) {\r\n name = name ?? GetXmlName(root);\r\n if (!name) {\r\n throw new Error(\"can not find name for given object\");\r\n }\r\n const currentName: IQualifiedName = XmlNameToParts(name);\r\n if (currentName.ns) {\r\n // ensure we register the root namespace as default if not already set...\r\n this._assignNamespace(currentName.ns, \"xmlns\");\r\n }\r\n this._gatherNamespaces(root, new WeakSet<object>());\r\n\r\n const doc = this._builder.ele(null, currentName.name);\r\n for (const [v, n] of Array.from(this._ns.entries())) {\r\n doc.att(\"xmlns\", n, v);\r\n }\r\n this._writeObjectContent(doc, root as Record<string, unknown>, new WeakSet<object>().add(root));\r\n this._builder.end();\r\n }\r\n\r\n private _writeObject(builder: IXmlBuilder, source: Record<string, unknown>, visited: WeakSet<object>): void {\r\n if (visited.has(source)) {\r\n return;\r\n }\r\n visited.add(source);\r\n\r\n if (Array.isArray(source)) {\r\n for (const item of source) {\r\n if (IsPrimitiveButString(item)) {\r\n continue;\r\n }\r\n if (IsString(item)) {\r\n this._builder.text(item);\r\n continue;\r\n }\r\n this._writeObject(builder, item, visited);\r\n }\r\n return;\r\n }\r\n\r\n const qname = GetXmlName(source);\r\n if (!qname) {\r\n return;\r\n }\r\n const currentName = XmlNameToParts(qname);\r\n const prefix = this._getPrefix(currentName);\r\n const tmp = ToQualifiedString(currentName.name, prefix);\r\n builder.ele(null, tmp);\r\n this._writeObjectContent(builder, source as Record<string, unknown>, visited);\r\n this._builder.end();\r\n }\r\n\r\n private _getPrefix(qn: IQualifiedName): string | undefined {\r\n if (qn.ns) {\r\n const p = this._ns.get(qn.ns.toLowerCase());\r\n if (p !== \"xmlns\") {\r\n return p;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n private _writeObjectContent(builder: IXmlBuilder, source: Record<string, unknown>, visited: WeakSet<object>): void {\r\n // gather meta and build index\r\n const metas = GetXmlFieldMeta(source) ?? [];\r\n const metaByProp = new Map<string, typeof metas>();\r\n\r\n for (const m of metas) {\r\n const arr = metaByProp.get(m.prop) ?? [];\r\n arr.push(m);\r\n metaByProp.set(m.prop, arr);\r\n }\r\n\r\n // ensure the att are processed first, otherwize, the tag might be closed...\r\n const keys = Object.keys(source).sort((a, b) => {\r\n const aHasAttr = (metaByProp.get(a) ?? []).some((m) => m.kind === \"attr\");\r\n const bHasAttr = (metaByProp.get(b) ?? []).some((m) => m.kind === \"attr\");\r\n if (aHasAttr === bHasAttr) {\r\n return 0;\r\n }\r\n return aHasAttr ? -1 : 1; // attr d abord\r\n });\r\n\r\n // We decide per property, using metadata if present\r\n for (const prop of keys) {\r\n const value: any = source[prop];\r\n if (value === null || value === undefined) {\r\n continue;\r\n }\r\n\r\n const propMetas = metaByProp.get(prop);\r\n if (propMetas) {\r\n const ignored = propMetas.some((m) => m.ignore === true || m.kind === \"none\");\r\n if (ignored) {\r\n continue;\r\n }\r\n\r\n for (const m of propMetas) {\r\n const name = m.name ?? m.prop.toLowerCase(); // if the name is not defined, we assume it's the lower case version of name of the property.\r\n if (name) {\r\n switch (m.kind) {\r\n case \"attr\": {\r\n let vStr: string | null = null;\r\n if (IsNumber(value) && this._nFmt) {\r\n vStr = this._nFmt.toString(value);\r\n }\r\n if (m.formatter) {\r\n // TODO : cache the created formatter to avoid to many allocation.\r\n const f = new m.formatter(this._format);\r\n vStr = f.toString(value);\r\n }\r\n vStr = vStr ?? value.toString();\r\n if (vStr) {\r\n const currentName = XmlNameToParts(name);\r\n const prefix = this._getPrefix(currentName);\r\n const tmp = ToQualifiedString(currentName.name, prefix);\r\n builder.att(null, tmp, vStr);\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n continue;\r\n }\r\n if (IsPrimitiveButString(value)) {\r\n continue;\r\n }\r\n if (IsString(value)) {\r\n this._builder.text(value);\r\n continue;\r\n }\r\n this._writeObject(builder, value, visited);\r\n }\r\n }\r\n\r\n // this is the first browse of the hierarchy to collect the namespaces and assign placeholder.( ns0, ns1,...)\r\n private _gatherNamespaces(tag: any, visited: WeakSet<object>): void {\r\n if (visited.has(tag)) {\r\n return;\r\n }\r\n visited.add(tag);\r\n\r\n if (Array.isArray(tag)) {\r\n for (const item of tag) {\r\n if (IsPrimitive(item)) {\r\n continue;\r\n }\r\n this._gatherNamespaces(item, visited);\r\n }\r\n return;\r\n }\r\n\r\n const qname = GetXmlName(tag);\r\n if (qname) {\r\n this._assignNamespace(qname);\r\n }\r\n\r\n // gather meta and build index\r\n const metas = GetXmlFieldMeta(tag) ?? [];\r\n const metaByProp = new Map<string, typeof metas>();\r\n\r\n for (const m of metas) {\r\n const arr = metaByProp.get(m.prop) ?? [];\r\n arr.push(m);\r\n metaByProp.set(m.prop, arr);\r\n }\r\n\r\n // We decide per property, using metadata if present\r\n const toVisit: object[] = [];\r\n\r\n for (const prop of Object.keys(tag)) {\r\n const value = tag[prop];\r\n if (value === null || value === undefined) {\r\n continue;\r\n }\r\n const propMetas = metaByProp.get(prop);\r\n if (propMetas) {\r\n const ignored = propMetas.some((m) => m.ignore === true || m.kind === \"none\");\r\n if (ignored) {\r\n continue;\r\n }\r\n\r\n for (const m of propMetas) {\r\n if (m.name) {\r\n this._assignNamespace(m.name);\r\n }\r\n }\r\n }\r\n toVisit.push(value);\r\n }\r\n\r\n for (const v of toVisit) {\r\n if (IsPrimitive(v)) {\r\n continue;\r\n }\r\n this._gatherNamespaces(v, visited);\r\n }\r\n }\r\n\r\n private _assignNamespace(qn: XmlName, prefix?: string) {\r\n const nqn = XmlNameToParts(qn);\r\n if (nqn?.ns) {\r\n const ns = nqn.ns.toLowerCase();\r\n if (!this._ns.get(ns)) {\r\n this._ns.set(ns, prefix ?? this._buildNsPrefix(ns));\r\n }\r\n return;\r\n }\r\n if (prefix === \"xmlns\") {\r\n const ns = nqn.name.toLowerCase();\r\n if (!this._ns.get(ns)) {\r\n this._ns.set(ns, prefix ?? this._buildNsPrefix(ns));\r\n }\r\n }\r\n }\r\n\r\n private _buildNsPrefix(_ns: string): string {\r\n let alreadyReferenced = false;\r\n let value: string;\r\n do {\r\n value = `ns${this._prefixCount++}`;\r\n for (const v of Array.from(this._ns.values())) {\r\n if (v === value) {\r\n alreadyReferenced = true;\r\n break;\r\n }\r\n }\r\n } while (alreadyReferenced);\r\n\r\n return value;\r\n }\r\n}\r\n","import type { IXmlBuilder } from \"./xml.interfaces\";\r\n\r\n/**\r\n */\r\nexport interface IXmlWriter {\r\n /**\r\n * @param data\r\n * @returns\r\n */\r\n write(...data: string[]): IXmlWriter;\r\n /** */\r\n count: number;\r\n /** */\r\n clear(): void;\r\n}\r\n\r\n/** */\r\nclass XmlSyntax {\r\n /** */\r\n public static OpenTag: string = \"<\";\r\n /** */\r\n public static CloseTag: string = \">\";\r\n /** */\r\n public static Slash: string = \"/\";\r\n /** */\r\n public static Question: string = \"?\";\r\n /** */\r\n public static Quote: string = '\"';\r\n /** */\r\n public static Equal: string = \"=\";\r\n /** */\r\n public static Space: string = \" \";\r\n /** */\r\n public static Semicolon: string = \":\";\r\n\r\n /** */\r\n public static Dec = \"<?xml\";\r\n /** */\r\n public static Xml = \"xml\";\r\n /** */\r\n public static Xmlns = \"xmlns\";\r\n /** */\r\n public static Xsi = \"xsi\";\r\n\r\n /** */\r\n public static VersionKeyword = \"version\";\r\n /** */\r\n public static EncodingKeyword = \"encoding\";\r\n /** */\r\n public static StandaloneKeyword = \"standalone\";\r\n}\r\n\r\n/** */\r\nexport enum TokenType {\r\n Declaration,\r\n Tag,\r\n Attribute,\r\n Text,\r\n}\r\n\r\n/** */\r\nexport class XmlBuilder implements IXmlBuilder {\r\n /** */\r\n static Context = class {\r\n /** */\r\n name: string = \"\";\r\n /** */\r\n closed: boolean = false;\r\n /** */\r\n lastToken: TokenType | null = null;\r\n /** */\r\n depth: number;\r\n\r\n // uri -> prefix\r\n ns2prefix: Map<string, string> = new Map();\r\n\r\n // prefix -> uri (for conflict checks)\r\n prefix2ns: Map<string, string> = new Map();\r\n\r\n // optional: default namespace uri\r\n defaultNs: string | null = null;\r\n\r\n /**\r\n *\r\n *@param name\r\n *@param depth\r\n */\r\n constructor(name: string, depth: number) {\r\n this.name = name;\r\n this.depth = depth;\r\n }\r\n };\r\n\r\n /** */\r\n private _w: IXmlWriter;\r\n /** */\r\n private _ctxStack: Array<InstanceType<typeof XmlBuilder.Context>> = [];\r\n /** */\r\n private _d: number = 0;\r\n\r\n public constructor(w: IXmlWriter) {\r\n this._w = w;\r\n }\r\n\r\n /**\r\n *\r\n * @param version\r\n * @param encoding\r\n * @param standalone\r\n * @returns\r\n */\r\n public dec(version: string, encoding?: string, standalone?: boolean): IXmlBuilder {\r\n this._w.write(XmlSyntax.Dec);\r\n this._writeAttStr(XmlSyntax.VersionKeyword, version);\r\n if (encoding) {\r\n this._writeAttStr(XmlSyntax.EncodingKeyword, encoding);\r\n }\r\n if (standalone !== undefined) {\r\n this._writeAttStr(XmlSyntax.StandaloneKeyword, standalone ? \"yes\" : \"no\");\r\n }\r\n this._w.write(XmlSyntax.Question, XmlSyntax.CloseTag);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param ns\r\n * @param n\r\n * @param v\r\n * @returns\r\n */\r\n public att(ns: string | null, n: string, v: string): IXmlBuilder {\r\n const ctx = this._peekContext();\r\n if (!ctx) {\r\n throw new Error(\"att() without open element\");\r\n }\r\n if (ctx.closed) {\r\n throw new Error(`att() after start tag closed for <${ctx.name}>`);\r\n }\r\n\r\n // explicit namespace declaration: xmlns or xmlns:prefix\r\n if (this._isXmlnsDecl(ns, n)) {\r\n if (n === XmlSyntax.Xmlns) {\r\n // default namespace\r\n ctx.defaultNs = v;\r\n // you can store default as empty prefix if you want\r\n this._registerNamespace(ctx, \"\", v);\r\n this._writeAttStr(XmlSyntax.Xmlns, v);\r\n } else {\r\n if (!ns) {\r\n const prefix = n.slice(6); // \"xmlns:\"\r\n this._registerNamespace(ctx, prefix, v);\r\n this._writeAttStr(n, v);\r\n } else {\r\n this._registerNamespace(ctx, n, v);\r\n this._writeAttStr(`${ns}:${n}`, v);\r\n }\r\n }\r\n ctx.lastToken = TokenType.Attribute;\r\n return this;\r\n }\r\n\r\n // normal attribute\r\n let qn = n;\r\n\r\n if (ns) {\r\n // treat ns as a namespace URI, not a prefix\r\n const p = this._ensurePrefixDeclared(ctx, ns);\r\n qn = `${p}:${n}`;\r\n }\r\n\r\n ctx.lastToken = TokenType.Attribute;\r\n this._writeAttStr(qn, v);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param ns\r\n * @param n\r\n * @returns\r\n */\r\n public ele(ns: string | null, n: string): IXmlBuilder {\r\n const ctx = this._peekContext();\r\n if (ctx) {\r\n this._closeOpenTagIfNeeded(ctx);\r\n }\r\n let qns = n;\r\n if (ns) {\r\n const p = this._lookupPrefix(ns) ?? ns;\r\n qns = `${p}:${n}`;\r\n }\r\n this._pushContext(qns, ++this._d);\r\n this._w.write(XmlSyntax.OpenTag, qns);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param txt\r\n * @returns\r\n */\r\n public text(txt: string): IXmlBuilder {\r\n const ctx = this._peekContext();\r\n if (!ctx) {\r\n throw new Error(\"text() without open element\");\r\n }\r\n this._closeOpenTagIfNeeded(ctx);\r\n ctx.lastToken = TokenType.Text;\r\n this._w.write(this._escText(txt));\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public end(): IXmlBuilder {\r\n const ctx = this._popContext();\r\n if (ctx) {\r\n this._d--;\r\n if (!ctx.closed) {\r\n this._w.write(XmlSyntax.Slash, XmlSyntax.CloseTag);\r\n } else {\r\n this._w.write(XmlSyntax.OpenTag, XmlSyntax.Slash, ctx.name, XmlSyntax.CloseTag);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n protected _pushContext(name: string, depth: number): InstanceType<typeof XmlBuilder.Context> {\r\n const ctx = new XmlBuilder.Context(name, depth);\r\n this._ctxStack.push(ctx);\r\n return ctx;\r\n }\r\n\r\n protected _popContext(): InstanceType<typeof XmlBuilder.Context> | undefined {\r\n return this._ctxStack.pop();\r\n }\r\n\r\n protected _peekContext(): InstanceType<typeof XmlBuilder.Context> | undefined {\r\n return this._ctxStack[this._ctxStack.length - 1];\r\n }\r\n\r\n protected get _contextDepth(): number {\r\n return this._ctxStack.length;\r\n }\r\n\r\n private _writeAttStr(name: string, value: string) {\r\n this._w.write(XmlSyntax.Space, name, XmlSyntax.Equal, XmlSyntax.Quote, this._escAttr(value), XmlSyntax.Quote);\r\n }\r\n\r\n private _lookupPrefix(ns: string): string | undefined {\r\n let i = this._ctxStack.length - 1;\r\n if (i >= 0) {\r\n do {\r\n const ctx = this._ctxStack[i--];\r\n const p = ctx.ns2prefix?.get(ns);\r\n if (p) {\r\n return p;\r\n }\r\n } while (i >= 0);\r\n }\r\n return undefined;\r\n }\r\n\r\n private _escText(s: string): string {\r\n return s.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\");\r\n }\r\n\r\n private _escAttr(s: string): string {\r\n return this._escText(s).replace(/\"/g, \""\").replace(/'/g, \"'\");\r\n }\r\n\r\n private _isXmlnsDecl(ns: string | null, n: string): boolean {\r\n if (ns) {\r\n return ns === XmlSyntax.Xmlns;\r\n }\r\n const l = n.length;\r\n const s = XmlSyntax.Xmlns.length;\r\n if (l >= s) {\r\n return n.startsWith(XmlSyntax.Xmlns) && (n.length == s || n[s] == XmlSyntax.Semicolon);\r\n }\r\n return false;\r\n }\r\n\r\n private _registerNamespace(ctx: InstanceType<typeof XmlBuilder.Context>, prefix: string, uri: string) {\r\n if (prefix === XmlSyntax.Xml || prefix === XmlSyntax.Xmlns) {\r\n throw new Error(`reserved prefix '${prefix}'`);\r\n }\r\n\r\n const existingUri = ctx.prefix2ns.get(prefix);\r\n if (existingUri && existingUri !== uri) {\r\n throw new Error(`prefix '${prefix}' already bound to a different namespace`);\r\n }\r\n\r\n const existingPrefix = ctx.ns2prefix.get(uri);\r\n if (!existingPrefix) {\r\n ctx.ns2prefix.set(uri, prefix);\r\n }\r\n\r\n ctx.prefix2ns.set(prefix, uri);\r\n }\r\n\r\n private _allocPrefix(ctx: InstanceType<typeof XmlBuilder.Context>): string {\r\n let i = 1;\r\n while (true) {\r\n const p = `ns${i++}`;\r\n if (!ctx.prefix2ns.has(p)) {\r\n return p;\r\n }\r\n }\r\n }\r\n\r\n private _ensurePrefixDeclared(ctx: InstanceType<typeof XmlBuilder.Context>, uri: string): string {\r\n const existing = this._lookupPrefix(uri);\r\n if (existing) {\r\n return existing;\r\n }\r\n\r\n if (ctx.closed) {\r\n throw new Error(`can not declare namespace after start tag closed for <${ctx.name}>`);\r\n }\r\n\r\n const prefix = this._allocPrefix(ctx);\r\n\r\n // write xmlns:prefix=\"uri\" and register it\r\n this._writeAttStr(`${XmlSyntax.Xmlns}:${prefix}`, uri);\r\n this._registerNamespace(ctx, prefix, uri);\r\n\r\n return prefix;\r\n }\r\n\r\n private _closeOpenTagIfNeeded(ctx: InstanceType<typeof XmlBuilder.Context>) {\r\n if (!ctx.closed) {\r\n this._w.write(XmlSyntax.CloseTag);\r\n ctx.closed = true;\r\n }\r\n }\r\n}\r\n","/**\r\n * XML namespace for the core 3MF model schema.\r\n * This is the default namespace used by <model> and most standard 3MF elements.\r\n */\r\nexport const ThreeDimModelNamespace = \"http://schemas.microsoft.com/3dmanufacturing/core/2015/02\";\r\n\r\n/**\r\n * XML namespace for the TriangleSets extension (2021/07).\r\n * This extension is used for more advanced triangle/property use cases.\r\n * Only declare/use it when you actually emit elements/attributes that require it.\r\n */\r\nexport const TriangleSetsNamespace = \"http://schemas.microsoft.com/3dmanufacturing/trianglesets/2021/07\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n\r\n/**\r\n * 3MF model units.\r\n * The unit affects interpretation of vertex coordinates (x,y,z).\r\n * Most pipelines use millimeter, but the writer should match the upstream scene unit expectations.\r\n */\r\nexport enum ST_Unit {\r\n micron = \"micron\",\r\n millimeter = \"millimeter\",\r\n centimeter = \"centimeter\",\r\n inch = \"inch\",\r\n foot = \"foot\",\r\n meter = \"meter\",\r\n}\r\n\r\n/**\r\n * In the XSD, ST_Matrix3D is a whitespace separated list of numbers.\r\n * The official 3MF core spec uses a 3x4 matrix (12 numbers).\r\n */\r\nexport type ST_Matrix3D = [number, number, number, number, number, number, number, number, number, number, number, number];\r\n\r\n/**\r\n *\r\n */\r\nexport interface IMatrix3d {\r\n /** */\r\n values: ST_Matrix3D;\r\n}\r\n\r\n/**\r\n * 3MF color value.\r\n * In the 3MF core spec, colors are typically expressed as sRGB hex strings: \"#RRGGBB\" (and sometimes \"#AARRGGBB\").\r\n * This type is kept as string because we serialize directly into XML and want to avoid coupling to a specific color class.\r\n */\r\nexport type ST_ColorValue = string;\r\n\r\n/**\r\n * URI reference type used by attributes like thumbnail.\r\n * Usually a relative package path inside the OPC container, for example \"/Metadata/thumbnail.png\".\r\n */\r\nexport type ST_UriReference = string;\r\n\r\n/**\r\n * Numeric type used for coordinates and similar scalar values.\r\n * 3MF stores numbers as XML attributes/text; here we represent them as JS numbers.\r\n */\r\nexport type ST_Number = number;\r\n\r\n/**\r\n * Resource identifiers used by <object id=\"...\">, property groups, etc.\r\n * This is usually a positive integer unique within the model.\r\n */\r\nexport type ST_ResourceID = number;\r\n\r\n/**\r\n * Resource index used to reference an entry within a resource list.\r\n * For example, triangle v1/v2/v3 reference indices into <vertices>.\r\n */\r\nexport type ST_ResourceIndex = number;\r\n\r\n/**\r\n * Standard 3MF object type.\r\n * This is optional in 3MF; if omitted, consumers often treat it as \"model\".\r\n */\r\nexport enum ST_ObjectType {\r\n model = \"model\",\r\n solidsupport = \"solidsupport\",\r\n support = \"support\",\r\n surface = \"surface\",\r\n other = \"other\",\r\n}\r\n\r\n/**\r\n * Generic metadata entry.\r\n * Metadata can appear at the model level (<metadata>) and inside metadata groups (<metadatagroup>).\r\n *\r\n * Notes:\r\n * - \"name\" is the metadata key.\r\n * - \"type\" is optional and can be a MIME type or a schema indicator depending on usage.\r\n * - \"preserve\" instructs consumers whether to keep metadata when modifying the model.\r\n */\r\nexport interface I3mfMetadata {\r\n /** Metadata key (required). */\r\n name: string;\r\n\r\n /** If true, indicates the metadata should be preserved by consumers (optional). */\r\n preserve?: boolean;\r\n\r\n /** Optional type information for the value. */\r\n type?: string;\r\n\r\n /** Metadata value (required). */\r\n value: string;\r\n}\r\n\r\n/**\r\n * A grouping element for metadata.\r\n * Used in some places where the schema allows a metadata group rather than raw metadata entries.\r\n */\r\nexport interface I3mfMetadataGroup {\r\n /** The list of metadata entries contained in the group. */\r\n metadata: Array<I3mfMetadata>;\r\n}\r\n\r\n/**\r\n * 3MF vertex.\r\n * Coordinates are expressed in the model unit (I3mfModel.unit).\r\n */\r\nexport interface I3mfVertex {\r\n /** X coordinate. */\r\n x: ST_Number;\r\n /** Y coordinate. */\r\n y: ST_Number;\r\n /** Z coordinate. */\r\n z: ST_Number;\r\n}\r\n\r\n/**\r\n * 3MF triangle.\r\n * v1/v2/v3 are indices into the vertices list (<vertices> \\<vertex .../\\>...</vertices>).\r\n *\r\n * Property assignment:\r\n * - pid and p1/p2/p3 are used to assign per-triangle or per-vertex properties (like materials or colors),\r\n * depending on which property group pid refers to.\r\n */\r\nexport interface I3mfTriangle {\r\n /** Index of first vertex in the vertices array. */\r\n v1: ST_ResourceIndex;\r\n /** Index of second vertex in the vertices array. */\r\n v2: ST_ResourceIndex;\r\n /** Index of third vertex in the vertices array. */\r\n v3: ST_ResourceIndex;\r\n\r\n /**\r\n * Optional per-vertex property indices for v1/v2/v3.\r\n * These are indices into the property group's entry list (the group referenced by pid).\r\n */\r\n p1?: ST_ResourceIndex;\r\n /** */\r\n p2?: ST_ResourceIndex;\r\n /** */\r\n p3?: ST_ResourceIndex;\r\n\r\n /**\r\n * Property group id for this triangle.\r\n * If present, it overrides the object-level pid for this specific triangle.\r\n */\r\n pid?: ST_ResourceID;\r\n}\r\n\r\n/**\r\n * Container for vertices.\r\n * Matches the XML structure <vertices>\\<vertex .../\\>...</vertices>.\r\n */\r\nexport interface I3mfVertices {\r\n /** Array of vertices. Order matters because triangles reference indices. */\r\n vertex: Array<I3mfVertex>;\r\n}\r\n\r\n/**\r\n * Container for triangles.\r\n * Matches the XML structure <triangles>\\<triangle .../\\>...</triangles>.\r\n */\r\nexport interface I3mfTriangles {\r\n /** Array of triangles. */\r\n triangle: Array<I3mfTriangle>;\r\n}\r\n\r\n/**\r\n * Mesh geometry content for an object.\r\n * Exactly one of: mesh content OR components content should be provided in an object.\r\n */\r\nexport interface I3mfMesh {\r\n /** Vertex list. */\r\n vertices: I3mfVertices;\r\n\r\n /** Triangle list. */\r\n triangles: I3mfTriangles;\r\n}\r\n\r\n/**\r\n * Component reference inside a composite object.\r\n * A composite object is an object whose content is <components> rather than <mesh>.\r\n *\r\n * objectid references another object in resources.\r\n * transform (3x4) positions that referenced object within the composite.\r\n */\r\nexport interface I3mfComponent {\r\n /** Referenced object id. */\r\n objectid: ST_ResourceID;\r\n\r\n /**\r\n * Optional transform applied to the referenced object within the component.\r\n * Represented as a 3x4 matrix.\r\n */\r\n transform?: IMatrix3d;\r\n}\r\n\r\n/**\r\n * Container for components.\r\n * Matches <components><component objectid=\"...\"/></components>.\r\n */\r\nexport interface I3mfComponents {\r\n /** Array of component references. */\r\n component: Array<I3mfComponent>;\r\n}\r\n\r\n/**\r\n * Object resource.\r\n * An object either contains a mesh (geometry) or components (composite object).\r\n *\r\n * Properties (pid/pindex):\r\n * - pid references a property group (e.g. basematerials id).\r\n * - pindex is an index within that group.\r\n * - If pindex is used, pid is required.\r\n *\r\n * Metadata:\r\n * - metadatagroup is optional and can store additional object-level metadata.\r\n */\r\nexport interface I3mfObject {\r\n /** Unique object id within the model. */\r\n id: ST_ResourceID;\r\n\r\n /** Optional object type hint. */\r\n type?: ST_ObjectType;\r\n\r\n /** Optional thumbnail reference (usually a package path). */\r\n thumbnail?: ST_UriReference;\r\n\r\n /** Optional part number (often used by manufacturing systems). */\r\n partnumber?: string;\r\n\r\n /** Optional human-readable name. */\r\n name?: string;\r\n\r\n /**\r\n * Property group reference.\r\n * Example: <basematerials id=\"5\"> ... </basematerials> then pid=5.\r\n * Required if pindex is specified.\r\n */\r\n pid?: ST_ResourceID;\r\n\r\n /**\r\n * Index inside the property group referenced by pid.\r\n * Meaning depends on the property group type (base materials, color group, etc.).\r\n */\r\n pindex?: ST_ResourceIndex;\r\n\r\n /** Optional grouped metadata for the object. */\r\n metadatagroup?: I3mfMetadataGroup;\r\n\r\n /**\r\n * Content of the object:\r\n * - Mesh geometry OR\r\n * - Components (composite object).\r\n *\r\n * In the 3MF XML schema, this corresponds to having either a <mesh> element or a <components> element.\r\n */\r\n content?: I3mfMesh | I3mfComponents;\r\n}\r\n\r\n/**\r\n * A single base material entry.\r\n * \"name\" is a label, \"displaycolor\" provides the color used for rendering previews.\r\n */\r\nexport interface I3mfBase {\r\n /** Material name/label. */\r\n name: string;\r\n\r\n /** Display color for the base material. */\r\n displaycolor: ST_ColorValue;\r\n}\r\n\r\n/**\r\n * Base materials property group.\r\n * Triangles or objects can reference this group via pid, and then a specific entry via pindex (or p1/p2/p3).\r\n */\r\nexport interface I3mfBaseMaterials {\r\n /** Property group id. Must be unique within resources. */\r\n id: ST_ResourceID;\r\n\r\n /** List of base material entries. */\r\n base: Array<I3mfBase>;\r\n}\r\n\r\n/**\r\n * Model resources container.\r\n * Holds object resources and optional property groups such as basematerials.\r\n */\r\nexport interface I3mfResources {\r\n /** All objects available for build items and components. */\r\n object: Array<I3mfObject>;\r\n\r\n /**\r\n * Optional base materials groups.\r\n * Other property groups may exist in 3MF (colors, textures, etc.) but are not modeled here.\r\n */\r\n basematerials?: Array<I3mfBaseMaterials>;\r\n}\r\n\r\n/**\r\n * Build item.\r\n * The build section describes what to \"print\" or \"instantiate\" from the resources.\r\n *\r\n * objectid references a resource object, and transform places it in the world.\r\n * partnumber and metadatagroup allow attaching build-item specific info.\r\n */\r\nexport interface I3mfItem {\r\n /** Referenced object id to build. */\r\n objectid: ST_ResourceID;\r\n\r\n /** Optional placement transform (3x4). */\r\n transform?: IMatrix3d;\r\n\r\n /** Optional part number at the build item level. */\r\n partnumber?: string;\r\n\r\n /** Optional build-item metadata. */\r\n metadatagroup?: I3mfMetadataGroup;\r\n}\r\n\r\n/**\r\n * Build container.\r\n * Contains all build items.\r\n */\r\nexport interface I3mfBuild {\r\n /** Array of build items. */\r\n item: Array<I3mfItem>;\r\n}\r\n\r\n/**\r\n * Root model element.\r\n *\r\n * Extensions:\r\n * - requiredextensions: a space-separated list of prefixes (or namespaces depending on your serializer conventions)\r\n * that are required to interpret the model.\r\n * - recommendedextensions: extensions that improve fidelity but are not required.\r\n *\r\n * Notes:\r\n * - resources and build are typically present in a valid printable model.\r\n * - metadata at the model level stores global information like title, author, etc.\r\n */\r\nexport interface I3mfModel {\r\n /** Unit used for all coordinates in the model. */\r\n unit?: ST_Unit;\r\n\r\n /** Declares extensions that must be understood by consumers. */\r\n requiredextensions?: string;\r\n\r\n /** Declares extensions that may be used for better results. */\r\n recommendedextensions?: string;\r\n\r\n /** Optional model-level metadata entries. */\r\n metadata?: Array<I3mfMetadata>;\r\n\r\n /** Optional resources section (objects, materials, etc.). */\r\n resources?: I3mfResources;\r\n\r\n /** Optional build section (what to instantiate/print). */\r\n build?: I3mfBuild;\r\n}\r\n","import type { IXmlWriter } from \"./xml.builder\";\r\n\r\n/** */\r\nexport class StringXmlWriter implements IXmlWriter {\r\n /** */\r\n public count = 0;\r\n private _chunks: string[] = [];\r\n\r\n /**\r\n * @param data\r\n * @returns\r\n */\r\n write(...data: string[]): IXmlWriter {\r\n if (data.length === 0) {\r\n return this;\r\n }\r\n\r\n // join once per call, keeps DOM out, very fast\r\n const s = data.join(\"\");\r\n this._chunks.push(s);\r\n this.count += s.length;\r\n return this;\r\n }\r\n\r\n /**\r\n * @returns\r\n */\r\n toString(): string {\r\n return this._chunks.join(\"\");\r\n }\r\n\r\n /**\r\n */\r\n clear(): void {\r\n this._chunks = [];\r\n this.count = 0;\r\n }\r\n}\r\n","import type { IXmlWriter } from \"./xml.builder\";\r\n\r\n/** */\r\nexport type ByteSink = {\r\n push(chunk: Uint8Array, final?: boolean): void;\r\n};\r\n\r\n/** */\r\nexport class Utf8XmlWriterToBytes implements IXmlWriter {\r\n /** */\r\n public count = 0;\r\n private _encoder = new TextEncoder();\r\n private _pending = \"\";\r\n private _pendingChars = 0;\r\n\r\n constructor(\r\n private readonly _sink: ByteSink,\r\n private readonly _opts: { flushChars?: number } = {}\r\n ) {}\r\n\r\n /**\r\n * @param data\r\n * @returns\r\n */\r\n write(...data: string[]): IXmlWriter {\r\n if (data.length === 0) {\r\n return this;\r\n }\r\n\r\n const s = data.join(\"\");\r\n if (s.length === 0) {\r\n return this;\r\n }\r\n\r\n this._pending += s;\r\n this._pendingChars += s.length;\r\n\r\n const limit = this._opts.flushChars ?? 64 * 1024;\r\n if (this._pendingChars >= limit) {\r\n this.flush();\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * @returns\r\n */\r\n flush(): this {\r\n if (this._pendingChars === 0) {\r\n return this;\r\n }\r\n\r\n const bytes = this._encoder.encode(this._pending);\r\n this._sink.push(bytes);\r\n this.count += bytes.length;\r\n\r\n this._pending = \"\";\r\n this._pendingChars = 0;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n */\r\n finish(): void {\r\n this.flush();\r\n this._sink.push(new Uint8Array(0), true);\r\n }\r\n\r\n /**\r\n */\r\n clear(): void {\r\n this._pending = \"\";\r\n this._pendingChars = 0;\r\n this.count = 0;\r\n }\r\n}\r\n","import type { I3mfModel } from \"./3mf.interfaces\";\n\nexport const OpenXmlContentTypesNamespace = \"http://schemas.openxmlformats.org/package/2006/content-types\";\nexport const OpenXmlRelationshipsNamespace = \"http://schemas.openxmlformats.org/package/2006/relationships\";\n\nexport enum KnownI3mfContentType {\n // OPC core\n Relationships = \"application/vnd.openxmlformats-package.relationships+xml\",\n\n // 3MF core\n Model = \"application/vnd.ms-package.3dmanufacturing-3dmodel+xml\",\n\n // Extensions officielles\n Materials = \"application/vnd.ms-package.3dmanufacturing-material+xml\",\n Colors = \"application/vnd.ms-package.3dmanufacturing-colors+xml\",\n Texture = \"application/vnd.ms-package.3dmanufacturing-texture+xml\",\n Texture2D = \"application/vnd.ms-package.3dmanufacturing-texture2d+xml\",\n Production = \"application/vnd.ms-package.3dmanufacturing-production+xml\",\n Slice = \"application/vnd.ms-package.3dmanufacturing-slice+xml\",\n BeamLattice = \"application/vnd.ms-package.3dmanufacturing-beamlattice+xml\",\n SecureContent = \"application/vnd.ms-package.3dmanufacturing-securecontent+xml\",\n\n // Assets\n Png = \"image/png\",\n Jpeg = \"image/jpeg\",\n Tiff = \"image/tiff\",\n Xml = \"application/xml\",\n}\n\nexport const RelationshipDirName = \"_rels/\";\nexport const Object3dDirName = \"3D/\";\nexport const ModelFileName = `3dmodel.model`;\nexport const RelationshipFileName = `.rels`;\nexport const ContentTypeFileName = \"[Content_Types].xml\";\n\n/**\n * Common OPC and 3MF relationship Type URIs.\n */\nexport class Known3mfRelationshipTypes {\n /**\n * 3MF core: points to the main .model part of the package\n */\n public static readonly ThreeDimModel = \"http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel\";\n\n /**\n * OPC core: points to a package thumbnail (often used by 3MF packages)\n */\n public static readonly Thumbnail = \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail\";\n\n /**\n * 3MF (print ticket): optional printing settings part (rarely used by slicers)\n */\n public static readonly PrintTicket = \"http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket\";\n\n /**\n * OPC core: indicates parts that must be preserved when editing the package\n */\n public static readonly MustPreserve = \"http://schemas.openxmlformats.org/package/2006/relationships/mustpreserve\";\n\n /**\n * Convenience set for quick checks\n */\n public static readonly Known: ReadonlySet<string> = new Set<string>([\n Known3mfRelationshipTypes.ThreeDimModel,\n Known3mfRelationshipTypes.Thumbnail,\n Known3mfRelationshipTypes.PrintTicket,\n Known3mfRelationshipTypes.MustPreserve,\n ]);\n\n /**\n * Test if the relationship Type is one of the common known URIs above\n * @param type\n * @returns true if the relationship Type is one of the common known URIs above\n */\n public static IsKnown(type: string): boolean {\n return Known3mfRelationshipTypes.Known.has(type);\n }\n\n /**\n * test if the relationship Type is the main 3MF model entry point\n * @param type\n * @returns true if the relationship Type is the main 3MF model entry point\n */\n public static IsThreeDimModel(type: string): boolean {\n return type === Known3mfRelationshipTypes.ThreeDimModel;\n }\n}\n\n/**\n *\n */\nexport interface I3mfContentTypes {\n /**\n *\n */\n items: I3mfContentType[];\n}\n\n/**\n *\n */\nexport interface I3mfContentType {\n /**\n *\n */\n ext: string;\n /**\n *\n */\n ct: string;\n}\n\n/**\n *\n */\nexport interface I3mfRelationships {\n /**\n *\n */\n items: I3mfRelationship[];\n}\n\n/**\n *\n */\nexport interface I3mfRelationship {\n /**\n *\n */\n id: string;\n\n /**\n *\n */\n type?: string;\n\n /**\n *\n */\n target?: string;\n}\n\n/**\n *\n */\nexport interface I3mfDocument {\n /**\n *\n */\n contentTypes: I3mfContentTypes;\n /**\n *\n */\n relationships: I3mfRelationships;\n /**\n *\n */\n model: I3mfModel;\n}\n","import { XmlAttr, XmlName } from \"../xml/xml.interfaces\";\nimport type { I3mfModel } from \"./3mf.interfaces\";\nimport { OpenXmlContentTypesNamespace, OpenXmlRelationshipsNamespace } from \"./3mf.opc.interfaces\";\nimport type { I3mfContentTypes, I3mfContentType, I3mfRelationships, I3mfRelationship, I3mfDocument } from \"./3mf.opc.interfaces\";\n\n/**\n *\n */\n@XmlName({ ns: OpenXmlContentTypesNamespace, name: \"Types\" })\nexport class ThreeMfContentTypes implements I3mfContentTypes {\n /**\n *\n */\n items: ThreeMfContentType[] = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: OpenXmlContentTypesNamespace, name: \"Default\" })\nexport class ThreeMfContentType implements I3mfContentType {\n /**\n *\n */\n @XmlAttr({ name: { ns: OpenXmlContentTypesNamespace, name: \"Extension\" } })\n ext: string;\n /**\n *\n */\n @XmlAttr({ name: { ns: OpenXmlContentTypesNamespace, name: \"ContentType\" } })\n ct: string;\n\n /**\n *\n * @param ext\n * @param ct\n */\n public constructor(ext: string, ct: string) {\n this.ext = ext;\n this.ct = ct;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: OpenXmlRelationshipsNamespace, name: \"Relationships\" })\nexport class ThreeMfRelationships implements I3mfRelationships {\n /**\n *\n */\n items: ThreeMfRelationship[] = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: OpenXmlRelationshipsNamespace, name: \"Relationship\" })\nexport class ThreeMfRelationship implements I3mfRelationship {\n /**\n *\n */\n @XmlAttr({ name: \"Id\" })\n id: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"Type\" })\n type?: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"Target\" })\n target?: string;\n\n constructor(id: string, type: string, target: string) {\n this.id = id;\n this.type = type;\n this.target = target;\n }\n}\n\n/**\n *\n */\nexport class ThreeMfDocument implements I3mfDocument {\n public constructor(\n public contentTypes: I3mfContentTypes,\n public relationships: I3mfRelationships,\n public model: I3mfModel\n ) {}\n}\n","import { type IFormatter, XmlAttr, XmlName } from \"../xml/xml.interfaces\";\nimport { type IXmlSerializerFormatOptions, NumberFormatter } from \"../xml/xml.serializer.format\";\nimport type {\n I3mfBase,\n I3mfBaseMaterials,\n I3mfBuild,\n I3mfComponent,\n I3mfComponents,\n I3mfItem,\n I3mfMesh,\n I3mfMetadata,\n I3mfMetadataGroup,\n I3mfModel,\n I3mfObject,\n I3mfResources,\n I3mfTriangle,\n I3mfTriangles,\n I3mfVertex,\n I3mfVertices,\n ST_ColorValue,\n ST_Number,\n ST_ResourceID,\n ST_ResourceIndex,\n ST_UriReference,\n IMatrix3d,\n ST_Matrix3D,\n} from \"./3mf.interfaces\";\nimport { ST_Unit, ThreeDimModelNamespace, ST_ObjectType } from \"./3mf.interfaces\";\n\n/**\n *\n */\nexport class Matrix3d implements IMatrix3d {\n /**\n *\n * @returns\n */\n public static Zero() {\n return new Matrix3d([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);\n }\n /**\n *\n * @param values\n */\n public constructor(public values: ST_Matrix3D) {}\n\n /**\n *\n * @returns\n */\n public toString(): string {\n return this.values.join(\" \");\n }\n}\n\n/**\n *\n */\nexport class MatrixFormatter implements IFormatter<Matrix3d> {\n /**\n *\n */\n _f: NumberFormatter;\n\n public constructor(public o: IXmlSerializerFormatOptions) {\n this._f = new NumberFormatter(o);\n }\n\n public toString(x: Matrix3d): string {\n return x.values.map((v) => this._f.toString(v)).join(\" \");\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"model\" })\nexport class ThreeMfModel implements I3mfModel {\n /**\n *\n */\n public static KnownMeta: Array<string> = [\"Title\", \"Designer\", \"Description\", \"Copyright\", \"LicenseTerms\", \"Rating\", \"CreationDate\", \"ModificationDate\", \"Application\"];\n\n /**\n *\n */\n @XmlAttr({ name: \"unit\" })\n unit: ST_Unit = ST_Unit.millimeter;\n\n /**\n *\n */\n @XmlAttr({ name: \"requiredextensions\" })\n requiredextensions?: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"recommendedextensions\" })\n recommendedextensions?: string;\n\n /**\n *\n */\n metadata?: Array<I3mfMetadata>;\n /**\n *\n */\n resources?: I3mfResources;\n /**\n *\n */\n build?: I3mfBuild;\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"meta\" })\nexport class ThreeMfMeta implements I3mfMetadata {\n /**\n *\n */\n @XmlAttr({ name: \"name\" })\n name: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"preserve\" })\n preserve?: boolean;\n\n /**\n *\n */\n @XmlAttr({ name: \"type\" })\n type?: string;\n\n /**\n *\n */\n value: string;\n\n /**\n *\n * @param name\n * @param value\n * @param preserve\n * @param type\n */\n public constructor(name: string, value: string, preserve?: boolean, type?: string) {\n this.name = name;\n this.value = value;\n this.preserve = preserve;\n this.type = type;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"metadatagroup\" })\nexport class ThreeMfMetadataGroup implements I3mfMetadataGroup {\n /**\n *\n */\n metadata: Array<I3mfMetadata> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"resources\" })\nexport class ThreeMfResources implements I3mfResources {\n /**\n *\n */\n object: Array<I3mfObject> = [];\n /**\n *\n */\n basematerials?: Array<I3mfBaseMaterials>;\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"object\" })\nexport class ThreeMfObject implements I3mfObject {\n /**\n *\n */\n @XmlAttr({ name: \"id\" })\n id: ST_ResourceID;\n\n /**\n *\n */\n @XmlAttr({ name: \"type\" })\n type?: ST_ObjectType;\n\n /**\n *\n */\n @XmlAttr({ name: \"thumbnail\" })\n thumbnail?: ST_UriReference;\n\n /**\n *\n */\n @XmlAttr({ name: \"partnumber\" })\n partnumber?: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"name\" })\n name?: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"pid\" })\n pid?: ST_ResourceID;\n\n /**\n *\n */\n @XmlAttr({ name: \"pindex\" })\n pindex?: ST_ResourceIndex;\n\n /**\n *\n */\n metadatagroup?: I3mfMetadataGroup;\n\n /**\n *\n */\n content?: I3mfMesh | I3mfComponents;\n\n public constructor(id: ST_ResourceID, type = ST_ObjectType.model) {\n this.id = id;\n this.type = type;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"mesh\" })\nexport class ThreeMfMesh implements I3mfMesh {\n /**\n *\n */\n vertices: I3mfVertices;\n /**\n *\n */\n triangles: I3mfTriangles;\n\n public constructor(vertices?: I3mfVertices, triangles?: I3mfTriangles) {\n this.vertices = vertices ?? new ThreeMfVertices();\n this.triangles = triangles ?? new ThreeMfTriangles();\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"vertices\" })\nexport class ThreeMfVertices implements I3mfVertices {\n /**\n *\n */\n vertex: Array<I3mfVertex> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"vertex\" })\nexport class ThreeMfVertex implements I3mfVertex {\n /**\n *\n */\n @XmlAttr({ name: \"x\" })\n x: ST_Number;\n\n /**\n *\n */\n @XmlAttr({ name: \"y\" })\n y: ST_Number;\n\n /**\n *\n */\n @XmlAttr({ name: \"z\" })\n z: ST_Number;\n\n public constructor(x: ST_Number = 0, y: ST_Number = 0, z: ST_Number = 0) {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"triangles\" })\nexport class ThreeMfTriangles implements I3mfTriangles {\n /**\n *\n */\n triangle: Array<I3mfTriangle> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"triangle\" })\nexport class ThreeMfTriangle implements I3mfTriangle {\n /**\n *\n */\n @XmlAttr({ name: \"v1\" })\n v1: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"v2\" })\n v2: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"v3\" })\n v3: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"p1\" })\n p1?: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"p2\" })\n p2?: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"p3\" })\n p3?: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"pid\" })\n pid?: ST_ResourceID;\n\n public constructor(v1: ST_ResourceIndex, v2: ST_ResourceIndex, v3: ST_ResourceIndex) {\n this.v1 = v1;\n this.v2 = v2;\n this.v3 = v3;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"components\" })\nexport class ThreeMfComponents implements I3mfComponents {\n /**\n *\n */\n component: Array<I3mfComponent> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"component\" })\nexport class ThreeMfComponent implements I3mfComponent {\n /**\n *\n */\n @XmlAttr({ name: \"objectid\" })\n objectid: ST_ResourceID;\n\n /**\n *\n */\n @XmlAttr({ name: \"transform\", formatter: MatrixFormatter })\n transform?: Matrix3d;\n\n public constructor(objectid: ST_ResourceID, transform?: Matrix3d) {\n this.objectid = objectid;\n this.transform = transform;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"basematerials\" })\nexport class ThreeMfBaseMaterials implements I3mfBaseMaterials {\n /**\n *\n */\n @XmlAttr({ name: \"id\" })\n id: ST_ResourceID;\n\n /**\n *\n */\n base: Array<I3mfBase> = [];\n\n public constructor(id: ST_ResourceID) {\n this.id = id;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"base\" })\nexport class ThreeMfBase implements I3mfBase {\n /**\n *\n */\n @XmlAttr({ name: \"name\" })\n name: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"displaycolor\" })\n displaycolor: ST_ColorValue;\n\n public constructor(name: string, displaycolor: ST_ColorValue) {\n this.name = name;\n this.displaycolor = displaycolor;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"build\" })\nexport class ThreeMfBuild implements I3mfBuild {\n /**\n *\n */\n item: Array<I3mfItem> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"item\" })\nexport class ThreeMfItem implements I3mfItem {\n /**\n *\n */\n @XmlAttr({ name: \"objectid\" })\n objectid: ST_ResourceID;\n\n /**\n *\n */\n @XmlAttr({ name: \"transform\", formatter: MatrixFormatter })\n transform?: Matrix3d;\n\n /**\n *\n */\n @XmlAttr({ name: \"partnumber\" })\n partnumber?: string;\n\n /**\n *\n */\n metadatagroup?: I3mfMetadataGroup;\n\n public constructor(objectid: ST_ResourceID, transform?: Matrix3d, partnumber?: string) {\n this.objectid = objectid;\n this.transform = transform;\n this.partnumber = partnumber;\n }\n}\n","// 3MF\r\nimport type { Matrix3d } from \"./3mf\";\r\nimport {\r\n ThreeMfBase,\r\n ThreeMfBaseMaterials,\r\n ThreeMfBuild,\r\n ThreeMfComponent,\r\n ThreeMfComponents,\r\n ThreeMfItem,\r\n ThreeMfMesh,\r\n ThreeMfMeta,\r\n ThreeMfModel,\r\n ThreeMfObject,\r\n ThreeMfResources,\r\n ThreeMfTriangle,\r\n ThreeMfTriangles,\r\n ThreeMfVertex,\r\n ThreeMfVertices,\r\n} from \"./3mf\";\r\nimport type {\r\n I3mfBaseMaterials,\r\n I3mfComponents,\r\n I3mfMesh,\r\n I3mfMetadata,\r\n I3mfModel,\r\n I3mfObject,\r\n I3mfTriangle,\r\n I3mfTriangles,\r\n I3mfVertex,\r\n I3mfVertices,\r\n ST_ResourceID,\r\n ST_ResourceIndex,\r\n ST_Unit,\r\n} from \"./3mf.interfaces\";\r\nimport { ST_ObjectType } from \"./3mf.interfaces\";\r\nimport { ThreeMfContentType, ThreeMfContentTypes, ThreeMfDocument, ThreeMfRelationship, ThreeMfRelationships } from \"./3mf.opc\";\r\nimport type { I3mfDocument } from \"./3mf.opc.interfaces\";\r\nimport {\r\n Known3mfRelationshipTypes,\r\n KnownI3mfContentType,\r\n ModelFileName,\r\n Object3dDirName,\r\n type I3mfContentType,\r\n type I3mfContentTypes,\r\n type I3mfRelationship,\r\n type I3mfRelationships,\r\n} from \"./3mf.opc.interfaces\";\r\nimport type { I3mfRGBAColor, I3mfVertexData, ThreeMfFloatArray, ThreeMfIndicesArray } from \"./3mf.types\";\r\n\r\nexport type VertexHandler = (vertex: I3mfVertex) => I3mfVertex;\r\nexport type TriangleHandler = (triangle: I3mfTriangle) => I3mfTriangle;\r\n\r\n/** */\r\nexport class ThreeMfObjectBuilder {\r\n /**\r\n *\r\n */\r\n protected _object: ThreeMfObject;\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param type\r\n */\r\n public constructor(id: ST_ResourceID, type: ST_ObjectType) {\r\n this._object = new ThreeMfObject(id, type);\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @returns\r\n */\r\n public withName(name: string): ThreeMfObjectBuilder {\r\n this._object.name = name;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param thumbnail\r\n * @returns\r\n */\r\n public withThumbnail(thumbnail: string): ThreeMfObjectBuilder {\r\n this._object.thumbnail = thumbnail;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param index\r\n * @returns\r\n */\r\n public withProperty(id: ST_ResourceIndex, index: number = 0): ThreeMfObjectBuilder {\r\n this._object.pid = id;\r\n this._object.id = index;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public build(): I3mfObject {\r\n return this._object;\r\n }\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param type\r\n */\r\n public reset(id: ST_ResourceID, type: ST_ObjectType) {\r\n this._object = new ThreeMfObject(id, type);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfComponentsBuilder extends ThreeMfObjectBuilder {\r\n /**\r\n *\r\n * @param id\r\n * @param type\r\n */\r\n public constructor(id: ST_ResourceID, type: ST_ObjectType = ST_ObjectType.model) {\r\n super(id, type);\r\n this._object.content = new ThreeMfComponents();\r\n }\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param t\r\n * @returns\r\n */\r\n public withComponent(id: ST_ResourceID, t?: Matrix3d): ThreeMfComponentsBuilder {\r\n (this._object.content as I3mfComponents).component.push(new ThreeMfComponent(id, t));\r\n return this;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfMeshBuilder extends ThreeMfObjectBuilder {\r\n /**\r\n *\r\n */\r\n _vh?: VertexHandler;\r\n /**\r\n *\r\n */\r\n _th?: TriangleHandler;\r\n\r\n /**\r\n *\r\n * @param id\r\n */\r\n public constructor(id: ST_ResourceID) {\r\n super(id, ST_ObjectType.model);\r\n }\r\n\r\n /**\r\n *\r\n * @param vertex\r\n * @param triangle\r\n * @returns\r\n */\r\n public withPostProcessHandlers(vertex: VertexHandler, triangle?: TriangleHandler): ThreeMfMeshBuilder {\r\n this._vh = vertex;\r\n this._th = triangle;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param data\r\n * @returns\r\n */\r\n withData(data: I3mfVertexData): ThreeMfMeshBuilder {\r\n this._object.content = this._buildMesh(data);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param i\r\n * @returns\r\n */\r\n withMaterial(id: ST_ResourceID, i: number): ThreeMfMeshBuilder {\r\n this._object.pid = id;\r\n this._object.pindex = i;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param data\r\n * @returns\r\n */\r\n private _buildMesh(data: I3mfVertexData): I3mfMesh {\r\n const vertices = this._buildVertices(data.positions);\r\n const triangles = this._buildTriangle(data.indices);\r\n return new ThreeMfMesh(vertices, triangles);\r\n }\r\n\r\n private _buildVertices(p: ThreeMfFloatArray | null): I3mfVertices {\r\n const container = new ThreeMfVertices();\r\n if (p) {\r\n for (let i = 0; i < p.length; ) {\r\n const x = p[i++];\r\n const y = p[i++];\r\n const z = p[i++];\r\n let v = new ThreeMfVertex(x, y, z);\r\n // might be optimized....\r\n if (this._vh) {\r\n v = this._vh(v);\r\n }\r\n container.vertex.push(v);\r\n }\r\n }\r\n return container;\r\n }\r\n\r\n private _buildTriangle(indice: ThreeMfIndicesArray | null): I3mfTriangles {\r\n const container = new ThreeMfTriangles();\r\n if (indice) {\r\n for (let i = 0; i < indice.length; ) {\r\n const a = indice[i++];\r\n const b = indice[i++];\r\n const c = indice[i++];\r\n let t = new ThreeMfTriangle(a, b, c);\r\n // might be optimized....\r\n if (this._th) {\r\n t = this._th(t);\r\n }\r\n container.triangle.push(t);\r\n }\r\n }\r\n return container;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfMaterialBuilder {\r\n private _m: I3mfBaseMaterials;\r\n\r\n public constructor(id: ST_ResourceID) {\r\n this._m = new ThreeMfBaseMaterials(id);\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param color\r\n * @returns\r\n */\r\n public withColor(name: string, color: I3mfRGBAColor): ThreeMfMaterialBuilder {\r\n this._m.base = this._m.base ?? [];\r\n let m = this._m.base.find((m) => m.name.toLowerCase() === name.toLowerCase());\r\n if (m) {\r\n m.displaycolor = this._rgbaToHex(color);\r\n return this;\r\n }\r\n m = new ThreeMfBase(name, this._rgbaToHex(color));\r\n this._m.base.push(m);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public build(): I3mfBaseMaterials {\r\n return this._m;\r\n }\r\n\r\n private _rgbaToHex(c: I3mfRGBAColor | { r: number; g: number; b: number; a?: number }): string {\r\n const toSRGB = (c: number) => Math.round(Math.min(255, Math.max(0, Math.pow(c, 1 / 2.2) * 255)));\r\n\r\n const r = toSRGB(c.r).toString(16).padStart(2, \"0\").toUpperCase();\r\n const g = toSRGB(c.g).toString(16).padStart(2, \"0\").toUpperCase();\r\n const b = toSRGB(c.b).toString(16).padStart(2, \"0\").toUpperCase();\r\n\r\n if (typeof (c as any).a === \"number\") {\r\n const a = Math.round(Math.min(255, Math.max(0, c.a! * 255)))\r\n .toString(16)\r\n .padStart(2, \"0\")\r\n .toUpperCase();\r\n return `#${r}${g}${b}${a}`;\r\n }\r\n\r\n return `#${r}${g}${b}`;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfModelBuilder {\r\n /**\r\n *\r\n */\r\n static KnownMetaSet = new Set(ThreeMfModel.KnownMeta.map((m) => m.toLowerCase()));\r\n\r\n /**\r\n *\r\n */\r\n _model: ThreeMfModel = new ThreeMfModel();\r\n /**\r\n *\r\n */\r\n _objects = new Map<string, I3mfObject>();\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param value\r\n * @param preserve\r\n * @param type\r\n * @returns\r\n */\r\n public withMetaData(name: string, value: string, preserve?: boolean, type?: string): ThreeMfModelBuilder {\r\n if (!this._model.metadata) {\r\n // lazzy\r\n this._model.metadata = new Array<I3mfMetadata>();\r\n }\r\n //const isKnownMeta = (s: string): boolean => TMFBuilder.knownMetaSet.has(s.toLowerCase());\r\n //const qn:IQName = xmlNameToParts(name);\r\n this._model.metadata.push(new ThreeMfMeta(name, value, preserve, type));\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param material\r\n * @returns\r\n */\r\n public withMaterial(material: I3mfBaseMaterials | ThreeMfMaterialBuilder): ThreeMfModelBuilder {\r\n if (material instanceof ThreeMfMaterialBuilder) {\r\n material = material.build();\r\n }\r\n if (material) {\r\n this._model.resources = this._model.resources ?? new ThreeMfResources();\r\n this._model.resources.basematerials = this._model.resources.basematerials ?? [];\r\n this._model.resources.basematerials.push(material);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param object\r\n * @returns\r\n */\r\n public withMesh(object: I3mfObject | ThreeMfMeshBuilder): ThreeMfModelBuilder {\r\n if (object instanceof ThreeMfMeshBuilder) {\r\n object = object.build();\r\n }\r\n this._model.resources = this._model.resources ?? new ThreeMfResources();\r\n this._model.resources.object.push(object);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param components\r\n * @returns\r\n */\r\n public withComponents(components: I3mfObject | ThreeMfComponentsBuilder): ThreeMfModelBuilder {\r\n if (components instanceof ThreeMfComponentsBuilder) {\r\n components = components.build();\r\n }\r\n this._model.resources = this._model.resources ?? new ThreeMfResources();\r\n this._model.resources.object.push(components);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param objectid\r\n * @param transform\r\n * @param partnumber\r\n * @returns\r\n */\r\n public withBuild(objectid: ST_ResourceID, transform?: Matrix3d, partnumber?: string): ThreeMfModelBuilder {\r\n this._model.build = this._model.build ?? new ThreeMfBuild();\r\n this._model.build.item?.push(new ThreeMfItem(objectid, transform, partnumber));\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param unit\r\n * @returns\r\n */\r\n public withUnit(unit: ST_Unit): ThreeMfModelBuilder {\r\n this._model.unit = unit;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public reset(): ThreeMfModelBuilder {\r\n this._model = new ThreeMfModel();\r\n this._objects = new Map<string, I3mfObject>();\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public build(): ThreeMfModel {\r\n // quick surface check..\r\n if (!this._model.resources?.object?.length) {\r\n throw new Error(\"Invalid state: resources MUST be defined \");\r\n }\r\n if (!this._model.build?.item?.length) {\r\n throw new Error(\"Invalid state: Build MUST be defined \");\r\n }\r\n return this._model;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfDocumentBuilder {\r\n private _cts?: I3mfContentTypes;\r\n private _rs?: I3mfRelationships;\r\n private _m?: I3mfModel;\r\n\r\n /**\r\n *\r\n * @param type\r\n * @returns\r\n */\r\n public withContentType(type: I3mfContentType): ThreeMfDocumentBuilder {\r\n if (!this._cts) {\r\n this._cts = new ThreeMfContentTypes();\r\n }\r\n const arr = this._cts.items;\r\n if (!arr.some((x) => x.ext === type.ext && x.ct === type.ct)) {\r\n arr.push(type);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param rel\r\n * @returns\r\n */\r\n public withRelationship(rel: I3mfRelationship): ThreeMfDocumentBuilder {\r\n if (!this._rs) {\r\n this._rs = new ThreeMfRelationships();\r\n }\r\n const arr = this._rs.items;\r\n if (!arr.some((x) => x.id === rel.id)) {\r\n arr.push(rel);\r\n }\r\n // here we ensure that the content type is declared.\r\n this.withContentType(new ThreeMfContentType(\"rels\", KnownI3mfContentType.Relationships));\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param m\r\n * @returns\r\n */\r\n public withModel(m: I3mfModel | ThreeMfModelBuilder): ThreeMfDocumentBuilder {\r\n if (m instanceof ThreeMfModelBuilder) {\r\n m = m.build();\r\n }\r\n this._m = m;\r\n // here we ensure that the content type is declared.\r\n this.withContentType(new ThreeMfContentType(\"model\", KnownI3mfContentType.Model));\r\n return this;\r\n }\r\n\r\n public build(): I3mfDocument {\r\n if (!this._m) {\r\n throw new Error(\"Invalid state: you Must provide at least a model.\");\r\n }\r\n\r\n // we automate the build of the relationship if not provided..\r\n const path = `${Object3dDirName}${ModelFileName}`;\r\n if (!this._rs) {\r\n const absolutePath = `/${path}`;\r\n this.withRelationship(new ThreeMfRelationship(`rel${0}`, Known3mfRelationshipTypes.ThreeDimModel, absolutePath));\r\n }\r\n\r\n return new ThreeMfDocument(this._cts!, this._rs!, this._m);\r\n }\r\n}\r\n","// 3MF\r\nimport { ThreeMfDocumentBuilder, ThreeMfModelBuilder } from \"./3mf.builder\";\r\nimport { ContentTypeFileName, ModelFileName, Object3dDirName, RelationshipDirName, RelationshipFileName, type I3mfDocument } from \"./3mf.opc.interfaces\";\r\nimport type { I3mfModel } from \"./3mf.interfaces\";\r\nimport { ST_Unit } from \"./3mf.interfaces\";\r\n\r\n// XML\r\nimport { XmlBuilder } from \"../xml/xml.builder\";\r\nimport { XmlSerializer } from \"../xml/xml.serializer\";\r\nimport { type ByteSink, Utf8XmlWriterToBytes } from \"../xml/xml.builder.bytes\";\r\n\r\n/**\r\n * Options controlling how meshes are exported into the 3MF model.\r\n *\r\n * Notes:\r\n * - These flags are kept generic here and are expected to be interpreted by the concrete serializer/model builder.\r\n * - Defaults are set in AbstractThreeMfSerializer.DEFAULT_3MF_EXPORTER_OPTIONS.\r\n */\r\nexport interface IThreeMfSerializerBaseOptions {\r\n /**\r\n * define the unit. Default is millimeter\r\n */\r\n unit?: ST_Unit;\r\n\r\n /**\r\n *\r\n */\r\n metadata?: Record<string, string>;\r\n}\r\n\r\n/**\r\n * Minimal contract for a 3MF serializer that can stream its output through a sink callback.\r\n *\r\n * The sink callback receives:\r\n * - err: any error produced by the serialization pipeline (if any)\r\n * - chunk: a chunk of bytes to append to the destination\r\n * - final: true when this is the last chunk\r\n *\r\n * Important:\r\n * - Implementations should call sink with final=true exactly once, or rely on the underlying zip lib to do so.\r\n * - Consumers may ignore final if they just buffer everything.\r\n */\r\nexport interface I3mfSerializer<T> {\r\n serializeAsync(sink: (err: any, chunk: Uint8Array, final: boolean) => void, ...meshes: Array<T>): Promise<void>;\r\n}\r\n\r\n/**\r\n * Base class for 3MF serialization.\r\n *\r\n * Responsibilities:\r\n * - Convert user meshes to a 3MF model (toModel).\r\n * - Wrap the 3MF document parts into an OPC container (zip) and stream bytes through the sink.\r\n *\r\n * Non-responsibilities:\r\n * - Providing/initializing the zip implementation (ensureZipLibReadyAsync is abstract).\r\n * - Defining how meshes map to 3MF objects (toModel is abstract).\r\n */\r\nexport abstract class AbstractThreeMfSerializer<T, O extends IThreeMfSerializerBaseOptions> implements I3mfSerializer<T> {\r\n private _o: O;\r\n\r\n /**\r\n * @param opts user-provided options overriding defaults.\r\n */\r\n public constructor(opts: O) {\r\n this._o = opts;\r\n }\r\n\r\n /**\r\n * Expose the resolved options (defaults + overrides) as readonly.\r\n */\r\n public get options(): Readonly<O> {\r\n return this._o;\r\n }\r\n\r\n /**\r\n * Generic 3MF binary serializer.\r\n * Pipeline overview:\r\n * 1. ensureZipLibReadyAsync provides a zip implementation (host-dependent).\r\n * 2. Convert meshes into an I3mfDocument (OPC parts + model).\r\n * 3. Create a zip target that streams through the provided sink.\r\n * 4. Serialize XML parts into zip entries.\r\n * 5. End the zip stream.\r\n * @param sink a callback receiving byte chunks; enables streaming without buffering the full archive in memory.\r\n * @param meshes the meshes to serialize.\r\n * @returns\r\n */\r\n public async serializeAsync(sink: (err: any, chunk: Uint8Array, final: boolean) => void, ...meshes: Array<T>): Promise<void> {\r\n // The zip library (e.g. fflate) may need dynamic import / polyfills depending on host.\r\n // This is delegated to the concrete serializer implementation.\r\n const lib = await this.ensureZipLibReadyAsync();\r\n\r\n // If no lib is available, we silently do nothing today.\r\n // Consider: throwing could be better to fail fast. Kept as-is to preserve current behavior.\r\n if (!lib) {\r\n return;\r\n }\r\n\r\n const zip = lib.Zip;\r\n const zipDeflate = lib.ZipDeflate;\r\n\r\n // We expect a \"fflate-like\" API. If it is missing, fail with an explicit error.\r\n if (!zip || !zipDeflate) {\r\n throw new Error(\"fflate Zip / ZipDeflate not available\");\r\n }\r\n\r\n /**\r\n * Adapt a fflate entry to our ByteSink interface used by Utf8XmlWriterToBytes.\r\n *\r\n * fflate entry.push(chunk, final) is the writer endpoint for compressed bytes.\r\n * @param entry\r\n * @returns\r\n */\r\n const makeByteSinkFromFflateEntry = function (entry: any): ByteSink {\r\n return { push: (chunk: any, final: any) => entry.push(chunk, final) };\r\n };\r\n\r\n /**\r\n * Serialize an in-memory XML object into a compressed zip entry.\r\n *\r\n * Notes:\r\n * - \"object\" here is expected to be a structure understood by XmlSerializer.\r\n * - Compression level 6 is a reasonable default for speed/size tradeoff.\r\n * @param target\r\n * @param name\r\n * @param object\r\n */\r\n const serializeEntry = function (target: any, name: string, object: any): void {\r\n const entry = new zipDeflate(name, { level: 6 });\r\n target.add(entry);\r\n\r\n // Convert XmlSerializer output into UTF-8 bytes and push to the zip entry.\r\n const sink = makeByteSinkFromFflateEntry(entry);\r\n const w = new Utf8XmlWriterToBytes(sink);\r\n\r\n // Build XML declaration and serialize.\r\n const b = new XmlBuilder(w).dec(\"1.0\", \"UTF-8\");\r\n const s = new XmlSerializer(b);\r\n s.serialize(object);\r\n\r\n // Ensure the writer flushes any pending bytes and closes the stream for this entry.\r\n w.finish();\r\n };\r\n\r\n // Convert meshes into a 3MF document (content types + relationships + model part).\r\n const doc = this.toDocument(...meshes);\r\n if (!doc) {\r\n // Nothing to write. Current behavior: no zip output.\r\n return;\r\n }\r\n\r\n // Create the zip container. It will forward produced bytes to the provided sink.\r\n const target = new zip(sink);\r\n\r\n // Save the root content types part.\r\n // In OPC, [Content_Types].xml defines the MIME/content types for the package parts.\r\n serializeEntry(target, ContentTypeFileName, doc.contentTypes);\r\n\r\n // Save relationships.\r\n // In OPC, relationships live under _rels and map parts to each other.\r\n serializeEntry(target, `${RelationshipDirName}${RelationshipFileName}`, doc.relationships);\r\n\r\n // Save the 3D model part.\r\n // In 3MF, the main model is typically under /3D/3dmodel.model.\r\n serializeEntry(target, `${Object3dDirName}${ModelFileName}`, doc.model);\r\n\r\n // Finalize the archive stream.\r\n // This should trigger the zip implementation to call sink(..., final=true) when done.\r\n target.end();\r\n }\r\n\r\n /**\r\n * Build a full 3MF OPC document from meshes.\r\n *\r\n * The default behavior uses ThreeMfDocumentBuilder with the model produced by toModel().\r\n * Override if you need custom parts (textures, thumbnails, print ticket, etc.).\r\n * @param meshes\r\n * @returns\r\n */\r\n public toDocument(...meshes: Array<T>): I3mfDocument | undefined {\r\n const b = new ThreeMfModelBuilder().withUnit(this._o?.unit ?? ST_Unit.millimeter);\r\n if (this.options.metadata) {\r\n for (const m in this.options.metadata) {\r\n b.withMetaData(m, this.options.metadata[m]);\r\n }\r\n }\r\n return new ThreeMfDocumentBuilder().withModel(this.toModel(b, ...meshes)).build();\r\n }\r\n\r\n /**\r\n * Convert input meshes into a 3MF model.\r\n *\r\n * Implementations typically:\r\n * - Create resources and objects.\r\n * - Define build items (instances) when exportInstances is enabled.\r\n * - Encode geometry and properties required by your pipeline.\r\n */\r\n public abstract toModel(builder: ThreeMfModelBuilder, ...meshes: Array<T>): I3mfModel;\r\n\r\n /**\r\n * Provide a zip implementation for the current host/runtime.\r\n *\r\n * This might be provided by the framework implementation, but it could differ depending on the host\r\n * (native, Node.js, browser, etc.).\r\n *\r\n * Expected shape (fflate-like):\r\n * - return [ Zip, ZipDeflate ] at minimum.\r\n *\r\n * Notes:\r\n * - In a browser, this might require bundler configuration or dynamic import.\r\n * - In Node.js, this might be a direct import of \"fflate\" or another compatible implementation.\r\n */\r\n public abstract ensureZipLibReadyAsync(): Promise<any>;\r\n}\r\n\r\n/**\r\n * Convenience helpers around serializers.\r\n */\r\nexport class ThreeMf {\r\n /**\r\n * Serialize to a single in-memory buffer.\r\n *\r\n * This is a helper that buffers all chunks produced by serializeAsync, then concatenates them.\r\n * Use serializeAsync directly if you want true streaming to a file/response.\r\n * @param s\r\n * @param meshes\r\n * @returns\r\n */\r\n public static async SerializeToMemoryAsync<A>(s: I3mfSerializer<A>, ...meshes: Array<A>): Promise<Uint8Array | undefined> {\r\n const chunks = new Array<Uint8Array>();\r\n let size = 0;\r\n\r\n // Sink used by the zip stream. We ignore `final` because we buffer everything anyway.\r\n // If `err` is used by the underlying zip lib, callers may want to detect/throw here.\r\n const sink = function (err: any, chunk: Uint8Array, _final: boolean) {\r\n // Current behavior: ignore err and keep accumulating.\r\n // Consider: if err is non-null, you might want to throw or record it.\r\n chunks.push(chunk);\r\n size += chunk.length;\r\n };\r\n\r\n await s.serializeAsync(sink, ...meshes);\r\n\r\n // If nothing was written, return undefined (matches current behavior).\r\n if (!size) {\r\n return undefined;\r\n }\r\n\r\n // Concatenate chunks into a single Uint8Array.\r\n const buffer = new Uint8Array(size);\r\n let off = 0;\r\n for (const c of chunks) {\r\n buffer.set(c, off);\r\n off += c.length;\r\n }\r\n return buffer;\r\n }\r\n}\r\n","/**\r\n * Class used to store configuration of the 3MF Serializer\r\n */\r\nexport class ThreeMfSerializerGlobalConfiguration {\r\n /**\r\n * Url to use to load the fflate library (for zip compression)\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static FFLATEUrl = \"https://unpkg.com/fflate@0.8.2\";\r\n}\r\n","// Babylonjs\r\nimport type { SubMesh } from \"core/Meshes\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { InstancedMesh } from \"core/Meshes/instancedMesh\";\r\nimport { Matrix } from \"core/Maths/math\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\n// 3MF\r\nimport { ThreeMfMeshBuilder, type ThreeMfModelBuilder } from \"./core/model/3mf.builder\";\r\nimport { Matrix3d } from \"./core/model/3mf\";\r\n\r\nimport { ST_Unit, type I3mfModel, type I3mfObject } from \"./core/model/3mf.interfaces\";\r\nimport type { I3mfVertexData } from \"./core/model/3mf.types\";\r\nimport { AbstractThreeMfSerializer, type IThreeMfSerializerBaseOptions } from \"./core/model/3mf.serializer\";\r\nimport { ThreeMfSerializerGlobalConfiguration } from \"./3mfSerializer.configuration\";\r\n\r\n/**\r\n * Factory for generating sequential resource IDs for 3MF objects.\r\n */\r\nclass IncrementalIdFactory {\r\n private _from: number;\r\n private _to: number;\r\n private _step: number;\r\n private _i: number;\r\n\r\n /**\r\n * Creates an ID factory with the specified range and increment.\r\n * @param from - Starting ID value\r\n * @param to - Minimum bound for ID generation (throws if exceeded)\r\n * @param step - Increment value for each ID\r\n */\r\n public constructor(from: number = 0, to: number = Number.MIN_SAFE_INTEGER, step: number = 1) {\r\n this._from = from;\r\n this._to = to;\r\n this._step = step;\r\n this._i = from;\r\n }\r\n\r\n /**\r\n * Generates the next ID in the sequence.\r\n * @returns The next ID value\r\n * @throws Error if ID generation exceeds the configured bounds\r\n */\r\n public next(): number {\r\n if (this._i < this._to) {\r\n throw new Error(\"ST_ResourceID out of bound\");\r\n }\r\n const v = this._i;\r\n this._i += this._step;\r\n return v;\r\n }\r\n\r\n /**\r\n * Resets the factory to start generating from the initial value again.\r\n * @returns This factory instance for chaining\r\n */\r\n public reset(): IncrementalIdFactory {\r\n this._i = this._from;\r\n return this;\r\n }\r\n}\r\n\r\n/**\r\n * Options controlling how meshes are exported into the 3MF model.\r\n *\r\n * Notes:\r\n * - These flags are kept generic here and are expected to be interpreted by the concrete serializer/model builder.\r\n * - Defaults are set in AbstractThreeMfSerializer.DEFAULT_3MF_EXPORTER_OPTIONS.\r\n */\r\nexport interface IThreeMfSerializerOptions extends IThreeMfSerializerBaseOptions {\r\n /**\r\n * If true, export mesh instances (multiple references to the same geometry) when supported.\r\n * If false, geometry may be duplicated depending on the concrete implementation.\r\n */\r\n exportInstances?: boolean;\r\n}\r\n\r\n/**\r\n * Babylon.js to 3MF serializer.\r\n *\r\n * This serializer converts Babylon meshes into a 3MF model, then relies on the base class\r\n * (AbstractThreeMfSerializer) to package the OPC parts into a zip stream.\r\n *\r\n * Design notes:\r\n * - First pass: export \"source\" meshes (non-instances) and build an index to map Babylon mesh/submesh to 3MF object id.\r\n * - Second pass (optional): export instances as additional build items referencing the original object ids.\r\n * - Submesh export is handled by extracting per-submesh vertex/index buffers so materials/colors can be preserved\r\n * by downstream steps that attach per-object properties.\r\n */\r\nexport class ThreeMfSerializer extends AbstractThreeMfSerializer<Mesh | InstancedMesh, IThreeMfSerializerOptions> {\r\n /**\r\n * Default serialization options: meter units, no instance export.\r\n */\r\n static DefaultOptions: IThreeMfSerializerOptions = { unit: ST_Unit.meter, exportInstances: false };\r\n\r\n /**\r\n * Babylon's vertex buffer semantic for positions.\r\n * Babylon uses string-based \"kind\" keys for vertex buffers.\r\n */\r\n private static _PositionKind = \"position\";\r\n\r\n /**\r\n * Cached promise so we only attempt to load fflate once.\r\n * This prevents multiple concurrent LoadScriptAsync calls.\r\n */\r\n private _fflateReadyPromise?: Promise<any>;\r\n\r\n /**\r\n * @param opts serializer options (merged with defaults in base class).\r\n */\r\n public constructor(opts: Partial<IThreeMfSerializerOptions> = {}) {\r\n super({ ...ThreeMfSerializer.DefaultOptions, ...opts });\r\n }\r\n\r\n /**\r\n * Build a 3MF model from Babylon meshes.\r\n *\r\n * Important: this method should not allocate huge intermediate data unless needed.\r\n * Submesh extraction does allocate new position/index arrays for each exported submesh.\r\n * @param builder\r\n * @param meshes\r\n * @returns\r\n */\r\n public override toModel(builder: ThreeMfModelBuilder, ...meshes: Array<Mesh | InstancedMesh>): I3mfModel {\r\n // avoid parasits..\r\n meshes = meshes.filter((m) => m instanceof Mesh || m instanceof InstancedMesh);\r\n\r\n const idFactory = new IncrementalIdFactory();\r\n\r\n const modelBuilder = builder;\r\n\r\n /**\r\n * Index mapping Babylon elements to the created 3MF object.\r\n *\r\n * Why:\r\n * - Instances need to reference the base object id.\r\n * - When exporting submeshes, instances should reference per-submesh objects rather than the whole mesh.\r\n *\r\n * Key type:\r\n * - When exportSubmeshes is true: we store entries for each SubMesh.\r\n * - Otherwise: we store entries for each Mesh.\r\n */\r\n const index = new Map<Mesh | SubMesh, I3mfObject>();\r\n\r\n /**\r\n * If exportInstances is enabled, we collect instanced meshes during the first pass and process them later.\r\n * If exportInstances is disabled, instances are ignored (they will not appear in the output).\r\n */\r\n const instances: Array<InstancedMesh> | null = this.options.exportInstances ? [] : null;\r\n\r\n // First pass: export base meshes (non-instances).\r\n // This creates the \"resource objects\" referenced by build items.\r\n for (let j = 0; j < meshes.length; j++) {\r\n const babylonMesh = meshes[j];\r\n if (babylonMesh instanceof InstancedMesh) {\r\n // Defer instance handling to the second pass.\r\n instances?.push(babylonMesh);\r\n continue;\r\n }\r\n\r\n const objectName = babylonMesh.name || `mesh${j}`;\r\n\r\n // Convert Babylon world matrix to 3MF build transform (3x4).\r\n // This transform will be attached to the build item referencing the created object.\r\n const worldTransform = babylonMesh.getWorldMatrix();\r\n const buildTransform = this._handleBabylonTo3mfMatrixTransformToRef(worldTransform, Matrix3d.Zero());\r\n\r\n // Submeshes can carry material/color boundaries in Babylon.\r\n // When exportSubmeshes is enabled, we export each submesh as its own 3MF object so\r\n // consumers can attach per-object properties (e.g. colors) later.\r\n const subMeshes = babylonMesh.subMeshes;\r\n if (subMeshes === undefined) {\r\n // very unlikely...\r\n continue;\r\n }\r\n\r\n // Babylon.js automatically creates one SubMesh covering the whole mesh if you don’t define any.\r\n const isStandalone = subMeshes.length == 1;\r\n for (let k = 0; k < subMeshes.length; k++) {\r\n const subMesh = subMeshes[k];\r\n\r\n const data = this._extractSubMesh(babylonMesh, subMesh);\r\n\r\n if (data) {\r\n const submeshName = isStandalone ? `${objectName}` : `${objectName}_${k}`;\r\n\r\n const object = new ThreeMfMeshBuilder(idFactory.next()).withData(data).withName(submeshName).build();\r\n\r\n // Add object to resources.\r\n modelBuilder.withMesh(object);\r\n\r\n // Add a build item referencing the object at the mesh world transform.\r\n modelBuilder.withBuild(object.id, buildTransform);\r\n\r\n // Cache mapping for instances (instances will reference this object id).\r\n index.set(subMesh, object);\r\n }\r\n }\r\n }\r\n\r\n // Second pass: export instances as additional build items.\r\n //\r\n // In 3MF terms:\r\n // - We do not duplicate geometry for each instance.\r\n // - We emit multiple build items referencing the same object id, each with its own transform.\r\n if (instances && instances.length) {\r\n // Group instances by their source mesh to keep related builds close in the XML.\r\n const grouped = this._groupBy(instances, (i) => i.sourceMesh);\r\n\r\n for (const [_babylonMesh, _instances] of Array.from(grouped.entries())) {\r\n if (!_instances || !_instances.length) {\r\n continue;\r\n }\r\n\r\n for (let j = 0; j < _instances.length; j++) {\r\n const mesh = _instances[j];\r\n const worldTransform = mesh.getWorldMatrix();\r\n\r\n // If we exported submeshes, the base \"resource objects\" are per-submesh.\r\n // For an instance we emit a build item per submesh object.\r\n const subMeshes = _babylonMesh.subMeshes;\r\n\r\n for (let k = 0; k < subMeshes.length; k++) {\r\n const subMesh = subMeshes[k];\r\n\r\n // Look up the 3MF object created for this submesh in the first pass.\r\n const objectRef = index.get(subMesh);\r\n\r\n if (objectRef) {\r\n modelBuilder.withBuild(objectRef.id, this._handleBabylonTo3mfMatrixTransformToRef(worldTransform, Matrix3d.Zero()));\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return modelBuilder.build();\r\n }\r\n\r\n /**\r\n * Ensure the zip library (fflate) is available in the current runtime.\r\n *\r\n * Host assumptions:\r\n * - This implementation relies on fflate being exposed on globalThis.fflate.\r\n * - If it is not present, it loads a script from ThreeMfSerializerGlobalConfiguration.FFLATEUrl using Babylon Tools.LoadScriptAsync.\r\n * @returns\r\n */\r\n public override async ensureZipLibReadyAsync(): Promise<any> {\r\n if (this._fflateReadyPromise) {\r\n return await this._fflateReadyPromise;\r\n }\r\n\r\n this._fflateReadyPromise = (async () => {\r\n // globalThis is the global object in all modern JS runtimes (browser, workers, Node, etc.).\r\n const g = globalThis as any;\r\n\r\n // If fflate is not already present, load it dynamically.\r\n // This assumes the loaded script sets globalThis.fflate.\r\n if (!g.fflate) {\r\n await Tools.LoadScriptAsync(ThreeMfSerializerGlobalConfiguration.FFLATEUrl);\r\n }\r\n\r\n return g.fflate;\r\n })();\r\n\r\n return await this._fflateReadyPromise;\r\n }\r\n\r\n /**\r\n * Extract a single SubMesh into a standalone vertex/index buffer pair.\r\n *\r\n * Why:\r\n * - 3MF mesh objects typically reference a contiguous vertex array and triangle indices.\r\n * - Babylon SubMesh references a slice of the global index buffer, but shares the vertex buffer.\r\n * - To serialize each submesh independently, we build a compacted vertex buffer containing only the used vertices\r\n * and remap indices accordingly.\r\n *\r\n * Complexity:\r\n * - O(indexCount) time, O(uniqueVerticesInSubmesh) additional memory.\r\n * @param mesh\r\n * @param sm\r\n * @returns\r\n */\r\n private _extractSubMesh(mesh: Mesh, sm: SubMesh): I3mfVertexData | undefined {\r\n const allInd = mesh.getIndices();\r\n if (!allInd) {\r\n return undefined;\r\n }\r\n\r\n const allPos = mesh.getVerticesData(ThreeMfSerializer._PositionKind);\r\n if (!allPos) {\r\n return undefined;\r\n }\r\n\r\n // Fast path: the submesh covers the full index buffer, so reuse the original arrays.\r\n // Note: This returns Babylon-owned arrays; if callers mutate, they will affect source mesh data.\r\n // Kept as-is to avoid extra allocations.\r\n if (sm.indexStart == 0 && sm.indexCount == allInd.length) {\r\n return {\r\n positions: allPos,\r\n indices: allInd,\r\n };\r\n }\r\n\r\n const indStart = sm.indexStart;\r\n\r\n // Map old vertex index -> new compacted vertex index.\r\n const map = new Map<number, number>();\r\n\r\n // Compacted positions (x,y,z repeated). We assemble into number[] then convert to Float32Array at the end.\r\n const newPositions: number[] = [];\r\n\r\n // Indices for the compacted vertex buffer.\r\n // Uint32Array is used to support large meshes; ensure downstream 3MF writer supports 32-bit indices if needed.\r\n const newIndices = new Uint32Array(sm.indexCount);\r\n\r\n for (let i = 0; i < sm.indexCount; i++) {\r\n const oldVi = allInd[indStart + i];\r\n\r\n let newVi = map.get(oldVi);\r\n if (newVi === undefined) {\r\n newVi = map.size;\r\n map.set(oldVi, newVi);\r\n\r\n // Copy the corresponding position (assumes positions are 3-floats per vertex).\r\n // If the source mesh uses a different stride or includes morph targets, this ignores them.\r\n const p = oldVi * 3;\r\n newPositions.push(allPos[p], allPos[p + 1], allPos[p + 2]);\r\n }\r\n\r\n newIndices[i] = newVi;\r\n }\r\n\r\n return {\r\n positions: new Float32Array(newPositions),\r\n indices: newIndices,\r\n };\r\n }\r\n\r\n /**\r\n * Group items by a computed key.\r\n * Used to group instances by sourceMesh so the resulting XML is easier to read and debug.\r\n * @param items\r\n * @param key\r\n * @returns\r\n */\r\n private _groupBy<T, K>(items: readonly T[], key: (v: T) => K): Map<K, T[]> {\r\n const m = new Map<K, T[]>();\r\n for (const it of items) {\r\n const k = key(it);\r\n const arr = m.get(k);\r\n if (arr) {\r\n arr.push(it);\r\n } else {\r\n m.set(k, [it]);\r\n }\r\n }\r\n return m;\r\n }\r\n\r\n /**\r\n * Basis conversion from Babylon coordinate system to the expected 3MF coordinate system.\r\n *\r\n * Here we rotate +90 degrees around X:\r\n * - This is commonly used to convert between Y-up and Z-up conventions.\r\n * - Verify this matches your pipeline (Babylon is typically left-handed Y-up).\r\n */\r\n private static readonly _R_BJS_TO_3MF = Matrix.RotationX(Math.PI / 2).multiply(Matrix.Scaling(1, -1, 1));\r\n\r\n /**\r\n * Converts a Babylon.js 4x4 matrix into a 3MF 3x4 transform matrix and writes the result into ref.\r\n *\r\n * Babylon.js conventions:\r\n * - Babylon exposes matrices with logical row/column indexing (M(row, column)).\r\n * - It stores the 16 coefficients in a contiguous array in row-major order:\r\n * [ M00, M01, M02, M03,\r\n * M10, M11, M12, M13,\r\n * M20, M21, M22, M23,\r\n * M30, M31, M32, M33 ]\r\n *\r\n * 3MF expectation:\r\n * - 3MF uses an affine transform represented as a 3x4 matrix (12 values).\r\n * - The values are taken from the first 3 columns of the 4x4 matrix, across the 4 rows:\r\n * m00 m01 m02 m10 m11 m12 m20 m21 m22 m30 m31 m32\r\n *\r\n * Steps:\r\n * 1) Compose Babylon transform with the basis change:\r\n * tmp = tBjs * _R_BJS_TO_3MF\r\n * 2) Extract the 12 coefficients in 3MF order from tmp.m.\r\n *\r\n * Interop note:\r\n * - Do not transpose here. We only reorder values to match the 3MF 3x4 serialization order.\r\n * - Transposition is only relevant when interfacing with code that assumes column-major storage.\r\n *\r\n * @param tBjs Babylon.js 4x4 matrix.\r\n * @param ref Output 3MF 3x4 matrix container (ref.values assigned).\r\n * @returns ref, for chaining.\r\n */\r\n private _handleBabylonTo3mfMatrixTransformToRef(tBjs: Matrix, ref: Matrix3d): Matrix3d {\r\n const tmp = tBjs.multiplyToRef(ThreeMfSerializer._R_BJS_TO_3MF, Matrix.Zero());\r\n const a = tmp.m;\r\n\r\n // a is Babylon row-major storage. Extract rows 0..3, cols 0..2 in 3MF order.\r\n // 3MF order: m00 m01 m02 m10 m11 m12 m20 m21 m22 m30 m31 m32\r\n ref.values = [a[0], a[1], a[2], a[4], a[5], a[6], a[8], a[9], a[10], a[12], a[13], a[14]];\r\n return ref;\r\n }\r\n}\r\n","/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nimport * as Serializers from \"serializers/3MF/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n const keys = [];\r\n for (const serializer in Serializers) {\r\n // Prevent Reassignment.\r\n if (keys.indexOf(serializer) > -1) {\r\n continue;\r\n }\r\n (<any>globalObject).BABYLON[serializer] = (<any>Serializers)[serializer];\r\n keys.push(serializer);\r\n }\r\n}\r\n\r\nexport * from \"serializers/3MF/index\";\r\n","import * as serializers from \"@lts/serializers/legacy/legacy-3mfSerializer\";\r\nexport { serializers };\r\nexport default serializers;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__597__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","extendStatics","b","setPrototypeOf","__proto__","Array","p","__extends","TypeError","String","__","constructor","create","__assign","assign","t","s","i","n","arguments","length","apply","__decorate","decorators","target","desc","c","getOwnPropertyDescriptor","Reflect","decorate","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","step","next","rejected","result","done","then","__generator","body","f","y","_","label","sent","trys","ops","Iterator","verb","iterator","v","op","pop","push","__spreadArray","to","from","pack","ar","l","slice","concat","IsQualifiedName","x","name","SuppressedError","XML_CLASS_META","XML_CLASS_NAME","AddXmlMeta","meta","ctor","XmlName","XmlIgnore","kind","ignore","XmlAttr","opts","XmlElem","GetXmlFieldMeta","GetXmlName","LooksLikeXmlNcName","test","XmlNameToParts","qn","trim","indexOf","prefix","local","ns","ToQualifiedString","DefaultXmlSerializerNumberOptions","freeze","eps","maxDecimalsCap","trimTrailingZeros","allowScientific","snapNearZero","DefaultXmlSerializerFormatOptions","number","ResolveNumberOptions","fixedDecimals","zeroThreshold","perAttributeEps","ResolveFormatOptions","_o","Number","isFinite","Error","toString","decimals","_clampInt","inv","q","Math","round","is","abs","ceil","log10","trunc","toFixed","replace","min","max","IsDate","Date","IsString","IsPrimitive","IsPrimitiveButString","TokenType","builder","format","_ns","Map","_prefixCount","_builder","_format","_nFmt","NumberFormatter","withNamespace","_assignNamespace","serialize","currentName","_gatherNamespaces","WeakSet","doc","ele","entries","att","_writeObjectContent","add","end","_writeObject","source","visited","has","isArray","item","text","qname","_getPrefix","tmp","toLowerCase","metas","metaByProp","m","arr","set","keys","sort","a","aHasAttr","some","bHasAttr","propMetas","ignored","vStr","formatter","tag","toVisit","nqn","_buildNsPrefix","alreadyReferenced","values","OpenTag","CloseTag","Slash","Question","Quote","Equal","Space","Semicolon","Dec","Xml","Xmlns","Xsi","VersionKeyword","EncodingKeyword","StandaloneKeyword","ST_Unit","ST_ObjectType","w","_ctxStack","_d","_w","dec","version","encoding","standalone","write","XmlSyntax","_writeAttStr","ctx","_peekContext","closed","_isXmlnsDecl","defaultNs","_registerNamespace","lastToken","Attribute","_ensurePrefixDeclared","_closeOpenTagIfNeeded","qns","_lookupPrefix","_pushContext","txt","Text","_escText","_popContext","depth","XmlBuilder","Context","_escAttr","ns2prefix","startsWith","uri","existingUri","prefix2ns","_allocPrefix","existing","count","_chunks","data","join","clear","_sink","_opts","_encoder","TextEncoder","_pending","_pendingChars","limit","flushChars","flush","bytes","encode","finish","Uint8Array","ThreeDimModelNamespace","TriangleSetsNamespace","KnownI3mfContentType","OpenXmlContentTypesNamespace","OpenXmlRelationshipsNamespace","RelationshipDirName","Object3dDirName","ModelFileName","RelationshipFileName","ContentTypeFileName","IsKnown","type","Known3mfRelationshipTypes","Known","IsThreeDimModel","ThreeDimModel","Thumbnail","PrintTicket","MustPreserve","Set","items","ThreeMfContentTypes","ext","ct","ThreeMfContentType","ThreeMfRelationships","id","ThreeMfRelationship","contentTypes","relationships","model","Zero","Matrix3d","_f","map","unit","millimeter","KnownMeta","ThreeMfModel","preserve","ThreeMfMeta","metadata","ThreeMfMetadataGroup","object","ThreeMfResources","ThreeMfObject","vertices","triangles","ThreeMfVertices","ThreeMfTriangles","ThreeMfMesh","vertex","z","ThreeMfVertex","triangle","v1","v2","v3","ThreeMfTriangle","component","ThreeMfComponents","objectid","transform","MatrixFormatter","ThreeMfComponent","base","ThreeMfBaseMaterials","displaycolor","ThreeMfBase","ThreeMfBuild","partnumber","ThreeMfItem","_object","withName","withThumbnail","thumbnail","withProperty","index","pid","build","reset","content","withComponent","ThreeMfObjectBuilder","withPostProcessHandlers","_vh","_th","withData","_buildMesh","withMaterial","pindex","_buildVertices","positions","_buildTriangle","indices","container","indice","_m","withColor","color","find","_rgbaToHex","toSRGB","pow","padStart","toUpperCase","_model","_objects","withMetaData","material","ThreeMfMaterialBuilder","resources","basematerials","withMesh","ThreeMfMeshBuilder","withComponents","components","ThreeMfComponentsBuilder","withBuild","withUnit","KnownMetaSet","withContentType","_cts","withRelationship","rel","_rs","Relationships","withModel","ThreeMfModelBuilder","Model","path","absolutePath","ThreeMfDocument","serializeAsync","sink","ensureZipLibReadyAsync","lib","zip","Zip","zipDeflate","ZipDeflate","makeByteSinkFromFflateEntry","entry","chunk","final","serializeEntry","level","Utf8XmlWriterToBytes","XmlSerializer","toDocument","meshes","options","ThreeMfDocumentBuilder","toModel","SerializeToMemoryAsync","chunks","size","err","_final","buffer","off","FFLATEUrl","MIN_SAFE_INTEGER","_from","_to","_step","_i","ThreeMfSerializer","DefaultOptions","filter","Mesh","InstancedMesh","idFactory","IncrementalIdFactory","modelBuilder","instances","exportInstances","j","babylonMesh","objectName","worldTransform","getWorldMatrix","buildTransform","_handleBabylonTo3mfMatrixTransformToRef","subMeshes","isStandalone","k","subMesh","_extractSubMesh","submeshName","grouped","_groupBy","sourceMesh","_babylonMesh","_instances","objectRef","_fflateReadyPromise","fflate","Tools","LoadScriptAsync","ThreeMfSerializerGlobalConfiguration","mesh","sm","allInd","getIndices","allPos","getVerticesData","_PositionKind","indexStart","indexCount","indStart","newPositions","newIndices","Uint32Array","oldVi","newVi","Float32Array","tBjs","ref","multiplyToRef","_R_BJS_TO_3MF","Matrix","meter","RotationX","PI","multiply","Scaling","AbstractThreeMfSerializer","globalObject","serializer","BABYLON"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"babylon.threemfSerializer.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,cACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,wBAAyB,CAAC,aAAcJ,GACrB,iBAAZC,QACdA,QAAQ,yBAA2BD,EAAQG,QAAQ,cAEnDJ,EAAkB,YAAIC,EAAQD,EAAc,QAC7C,CATD,CASoB,oBAATO,KAAuBA,KAAyB,oBAAXC,OAAyBA,OAASC,MAAQC,G,iCCT1FP,EAAOD,QAAUQ,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaZ,QAGrB,IAAIC,EAASQ,EAAyBE,GAAY,CAGjDX,QAAS,CAAC,GAOX,OAHAc,EAAoBH,GAAUV,EAAQA,EAAOD,QAASU,GAG/CT,EAAOD,OACf,CCrBAU,EAAoBK,EAAI,CAACf,EAASgB,K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,EAAAnD,eAA4C,CAAErI,KAAM9F,EAAQ0R,MAAO/C,iBAAiB,GAM5E,EAAA+B,cAAgB,WA6QP,EAAAc,cAAgB,GAAAC,OAAOE,UAAUjX,KAAKkX,GAAK,GAAGC,SAAS,GAAAJ,OAAOK,QAAQ,GAAI,EAAG,IAwCzG,C,CA/TA,CAAuCC,IClFjCC,QAAiC,IAAX,EAAA3f,EAAyB,EAAAA,EAA2B,oBAAXI,OAAyBA,YAASd,EACvG,QAA4B,IAAjBqgB,GAA8B,CACrC,IAAM/T,GAAO,GACb,IAAK,IAAMgU,MAAc,EAEjBhU,GAAKnF,QAAQmZ,KAAe,IAG1BD,GAAcE,QAAQD,IAAoB,EAAaA,IAC7DhU,GAAKnH,KAAKmb,IAElB,CChBA,W","sources":["webpack://SERIALIZERS/webpack/universalModuleDefinition","webpack://SERIALIZERS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://SERIALIZERS/webpack/bootstrap","webpack://SERIALIZERS/webpack/runtime/define property getters","webpack://SERIALIZERS/webpack/runtime/global","webpack://SERIALIZERS/webpack/runtime/hasOwnProperty shorthand","webpack://SERIALIZERS/webpack/runtime/make namespace object","webpack://SERIALIZERS/../../../../node_modules/tslib/tslib.es6.mjs","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.interfaces.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.serializer.format.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.serializer.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.builder.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.interfaces.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.builder.string.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/xml/xml.builder.bytes.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.opc.interfaces.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.opc.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.builder.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/core/model/3mf.serializer.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/3mfSerializer.configuration.ts","webpack://SERIALIZERS/../../../dev/serializers/src/3MF/3mfSerializer.ts","webpack://SERIALIZERS/../../../lts/serializers/src/legacy/legacy-3mfSerializer.ts","webpack://SERIALIZERS/./src/3mf.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-serializers\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-serializers\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"SERIALIZERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__597__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__597__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n};\n","import type { IXmlSerializerFormatOptions } from \"./xml.serializer.format\";\r\n\r\n/** */\r\nexport interface IQualifiedName {\r\n /** */\r\n ns?: string;\r\n /** */\r\n name: string;\r\n}\r\n\r\n/** */\r\nexport interface IXmlBuilder {\r\n dec(version: string, encoding?: string, standalone?: boolean): IXmlBuilder;\r\n att(ns: string | null, n: string, v: string): IXmlBuilder;\r\n ele(ns: string | null, n: string): IXmlBuilder;\r\n text(txt: string): IXmlBuilder;\r\n end(): IXmlBuilder;\r\n}\r\n\r\n/**\r\n * @param x\r\n * @returns\r\n */\r\nexport function IsQualifiedName(x: unknown): x is { name: string } {\r\n return typeof (x as any)?.name === \"string\";\r\n}\r\n\r\nexport type XmlName = string | IQualifiedName;\r\n\r\ntype FieldKind = \"attr\" | \"elem\" | \"none\";\r\n\r\n/**\r\n *\r\n */\r\nexport interface IFormatter<T = any> {\r\n toString(value: T): string;\r\n}\r\n\r\nexport type FormatterCtor<T> = new (args: IXmlSerializerFormatOptions) => IFormatter<T>;\r\n\r\ntype FieldMeta = {\r\n kind: FieldKind;\r\n prop: string;\r\n name?: XmlName;\r\n ignore?: boolean;\r\n formatter?: FormatterCtor<any>;\r\n};\r\n\r\nconst XML_CLASS_META = Symbol(\"__xml:meta$__\");\r\nconst XML_CLASS_NAME = Symbol(\"__xml:name$__\");\r\n\r\nfunction AddXmlMeta(target: any, meta: FieldMeta) {\r\n const ctor = target.constructor;\r\n (ctor[XML_CLASS_META] ??= []).push(meta);\r\n}\r\n\r\n/**\r\n * @param name\r\n * @returns\r\n */\r\nexport function XmlName(name: XmlName) {\r\n return (ctor: Function) => {\r\n (ctor as any)[XML_CLASS_NAME] = name;\r\n };\r\n}\r\n\r\n/**\r\n * tell the serializer to ignore the property\r\n * @returns\r\n */\r\nexport function XmlIgnore() {\r\n return (target: any, prop: string) => AddXmlMeta(target, { kind: \"none\", prop, ignore: true });\r\n}\r\n\r\n/**\r\n * tell the serializer to serialize the property as attribute\r\n * @returns\r\n */\r\nexport function XmlAttr(opts?: { name: XmlName; formatter?: FormatterCtor<any> }) {\r\n return (target: any, prop: string) => AddXmlMeta(target, { kind: \"attr\", prop, ...opts });\r\n}\r\n\r\n/**\r\n * tell the serializer to serialize the property as element - this is the default behavior but shoud be\r\n * specified when wanted to update the default name of the classe or if the class is not decorated (without \\@XmlName)\r\n * @returns\r\n */\r\nexport function XmlElem(opts?: { name: XmlName }) {\r\n return (target: any, prop: string) => AddXmlMeta(target, { kind: \"elem\", prop, ...opts });\r\n}\r\n\r\n/**\r\n *\r\n * @param obj\r\n * @returns\r\n */\r\nexport function GetXmlFieldMeta(obj: any): FieldMeta[] {\r\n return (obj?.constructor?.[XML_CLASS_META] ?? []) as FieldMeta[];\r\n}\r\n\r\n/**\r\n *\r\n * @param obj\r\n * @returns\r\n */\r\nexport function GetXmlName(obj: any): XmlName | undefined {\r\n const n = obj?.constructor?.[XML_CLASS_NAME];\r\n return n ? (n as XmlName) : undefined;\r\n}\r\n\r\n/**\r\n *\r\n * @param s\r\n * @returns\r\n */\r\nfunction LooksLikeXmlNcName(s: string): boolean {\r\n // Approximation ASCII de NCName: pas de \":\" et demarre par lettre ou underscore\r\n // Puis lettres/chiffres/underscore/point/tiret.\r\n return /^[A-Za-z_][A-Za-z0-9._-]*$/.test(s);\r\n}\r\n\r\n/**\r\n *\r\n * @param qn\r\n * @returns\r\n */\r\nexport function XmlNameToParts(qn: XmlName): IQualifiedName {\r\n if (IsQualifiedName(qn)) {\r\n return qn;\r\n }\r\n const s = (qn ?? \"\").trim();\r\n if (!s) {\r\n return { name: \"\" };\r\n }\r\n const i = s.indexOf(\":\");\r\n if (i === -1) {\r\n return { name: s };\r\n }\r\n\r\n // Un QName XML ne doit contenir qu un seul \":\".\r\n // Si il y en a plusieurs, on considere que ce n est pas un QName.\r\n if (s.indexOf(\":\", i + 1) !== -1) {\r\n return { name: s };\r\n }\r\n\r\n const prefix = s.slice(0, i);\r\n const local = s.slice(i + 1);\r\n\r\n if (LooksLikeXmlNcName(prefix) && LooksLikeXmlNcName(local)) {\r\n return { ns: prefix, name: local };\r\n }\r\n return { name: s };\r\n}\r\n\r\n/**\r\n *\r\n * @param name\r\n * @param prefix\r\n * @returns\r\n */\r\nexport function ToQualifiedString(name: string, prefix?: string): string {\r\n return prefix ? `${prefix}:${name}` : name;\r\n}\r\n","import type { IFormatter } from \"./xml.interfaces\";\r\n\r\n/**\r\n *\r\n */\r\nexport interface IXmlSerializerNumberOptions {\r\n /**\r\n *\r\n */\r\n eps: number;\r\n /**\r\n *\r\n */\r\n maxDecimalsCap?: number; // default 15\r\n /**\r\n *\r\n */\r\n trimTrailingZeros?: boolean; // default true\r\n /**\r\n *\r\n */\r\n fixedDecimals?: number; // optional, overrides trim\r\n /**\r\n *\r\n */\r\n allowScientific?: boolean; // default false\r\n /**\r\n *\r\n */\r\n snapNearZero?: boolean; // default true\r\n /**\r\n *\r\n */\r\n zeroThreshold?: number; // default eps\r\n /**\r\n *\r\n */\r\n perAttributeEps?: Record<string, number>;\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport interface IXmlSerializerFormatOptions {\r\n /**\r\n *\r\n */\r\n number?: IXmlSerializerNumberOptions;\r\n}\r\n\r\nexport const DefaultXmlSerializerNumberOptions: Readonly<IXmlSerializerNumberOptions> = Object.freeze({\r\n eps: 1e-6,\r\n maxDecimalsCap: 15,\r\n trimTrailingZeros: true,\r\n // fixedDecimals: undefined,\r\n allowScientific: false,\r\n snapNearZero: true,\r\n // zeroThreshold defaults to eps if not provided\r\n // perAttributeEps: undefined,\r\n});\r\n\r\nexport const DefaultXmlSerializerFormatOptions: Readonly<IXmlSerializerFormatOptions> = Object.freeze({\r\n number: DefaultXmlSerializerNumberOptions,\r\n});\r\n\r\n/**\r\n *@param opts\r\n *@returns\r\n */\r\nexport function ResolveNumberOptions(opts?: IXmlSerializerNumberOptions): Required<\r\n Omit<IXmlSerializerNumberOptions, \"perAttributeEps\" | \"fixedDecimals\" | \"maxDecimalsCap\" | \"trimTrailingZeros\" | \"allowScientific\" | \"snapNearZero\" | \"zeroThreshold\">\r\n> &\r\n Pick<IXmlSerializerNumberOptions, \"perAttributeEps\" | \"fixedDecimals\"> & {\r\n maxDecimalsCap: number;\r\n trimTrailingZeros: boolean;\r\n allowScientific: boolean;\r\n snapNearZero: boolean;\r\n zeroThreshold: number;\r\n } {\r\n const eps = opts?.eps ?? DefaultXmlSerializerNumberOptions.eps;\r\n\r\n return {\r\n eps,\r\n maxDecimalsCap: opts?.maxDecimalsCap ?? DefaultXmlSerializerNumberOptions.maxDecimalsCap!,\r\n trimTrailingZeros: opts?.trimTrailingZeros ?? DefaultXmlSerializerNumberOptions.trimTrailingZeros!,\r\n fixedDecimals: opts?.fixedDecimals,\r\n allowScientific: opts?.allowScientific ?? DefaultXmlSerializerNumberOptions.allowScientific!,\r\n snapNearZero: opts?.snapNearZero ?? DefaultXmlSerializerNumberOptions.snapNearZero!,\r\n zeroThreshold: opts?.zeroThreshold ?? eps,\r\n perAttributeEps: opts?.perAttributeEps,\r\n };\r\n}\r\n\r\n/**\r\n *@param opts\r\n *@returns\r\n */\r\nexport function ResolveFormatOptions(opts?: IXmlSerializerFormatOptions) {\r\n return {\r\n number: ResolveNumberOptions(opts?.number),\r\n };\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class NumberFormatter implements IFormatter<number> {\r\n private _o: IXmlSerializerNumberOptions;\r\n\r\n /**\r\n *\r\n * @param o\r\n */\r\n public constructor(public o: IXmlSerializerFormatOptions) {\r\n this._o = o.number!;\r\n\r\n if (!Number.isFinite(this._o.eps) || this._o.eps <= 0) {\r\n throw new Error(\"opts.eps must be a finite, positive number\");\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param x\r\n * @returns\r\n */\r\n\r\n public toString(x: number): string {\r\n if (!Number.isFinite(x)) {\r\n throw new Error(`Cannot format non-finite number: ${x}`);\r\n }\r\n\r\n const opts = this._o;\r\n const maxDecimalsCap = this._clampInt(opts.maxDecimalsCap ?? 15, 0, 20);\r\n const trimTrailingZeros = opts.trimTrailingZeros ?? true;\r\n const snapNearZero = opts.snapNearZero ?? true;\r\n const zeroThreshold = opts.zeroThreshold ?? opts.eps;\r\n\r\n // Quantize to eps grid\r\n const inv = 1 / opts.eps;\r\n let q = Math.round(x * inv) / inv;\r\n\r\n // Normalize -0 to 0\r\n if (Object.is(q, -0)) {\r\n q = 0;\r\n }\r\n\r\n // Snap tiny values to 0 (helps size + stability)\r\n if (snapNearZero && Math.abs(q) <= zeroThreshold) {\r\n q = 0;\r\n }\r\n\r\n // Choose decimals policy\r\n let decimals: number;\r\n if (opts.fixedDecimals !== undefined) {\r\n decimals = this._clampInt(opts.fixedDecimals, 0, maxDecimalsCap);\r\n } else {\r\n // decimals needed for eps steps\r\n decimals = this._clampInt(Math.ceil(-Math.log10(opts.eps)), 0, maxDecimalsCap);\r\n }\r\n\r\n // Note: this implementation intentionally avoids scientific notation.\r\n // If allowScientific=true, you may want a different path (toPrecision).\r\n if (opts.allowScientific) {\r\n // Still avoid scientific here; keep deterministic fixed output.\r\n // If you really want scientific, implement a separate branch.\r\n }\r\n\r\n // Fast path when decimals = 0\r\n if (decimals === 0) {\r\n return String(Math.trunc(q));\r\n }\r\n\r\n // Start fixed, then optionally trim\r\n let s = q.toFixed(decimals);\r\n\r\n if (trimTrailingZeros && opts.fixedDecimals === undefined) {\r\n // Trim trailing zeros and optional trailing dot\r\n s = s\r\n .replace(/(\\.\\d*?[1-9])0+$/, \"$1\")\r\n .replace(/\\.0+$/, \"\")\r\n .replace(/\\.$/, \"\");\r\n }\r\n\r\n // Safety: ensure no scientific notation (should not happen with toFixed)\r\n if (/[eE]/.test(s)) {\r\n throw new Error(`Scientific notation not allowed in XML output: ${s}`);\r\n }\r\n\r\n return s;\r\n }\r\n\r\n private _clampInt(n: number, min: number, max: number): number {\r\n if (!Number.isFinite(n)) {\r\n return min;\r\n }\r\n n = Math.trunc(n);\r\n return Math.max(min, Math.min(max, n));\r\n }\r\n}\r\n","import { type IQualifiedName, XmlNameToParts, type IXmlBuilder, type XmlName, GetXmlName, ToQualifiedString, GetXmlFieldMeta } from \"./xml.interfaces\";\r\nimport { NumberFormatter, ResolveFormatOptions, type IXmlSerializerFormatOptions } from \"./xml.serializer.format\";\r\n\r\ntype Primitive = string | number | boolean | bigint | Date;\r\n\r\nfunction IsDate(x: any): x is Date {\r\n return x instanceof Date;\r\n}\r\n\r\nfunction IsString(x: any): x is string {\r\n return typeof x === \"string\";\r\n}\r\n\r\nfunction IsNumber(x: any): x is number {\r\n return typeof x === \"number\";\r\n}\r\n\r\nfunction IsPrimitive(x: any): x is Primitive {\r\n return typeof x === \"string\" || typeof x === \"number\" || typeof x === \"boolean\" || typeof x === \"bigint\" || IsDate(x);\r\n}\r\n\r\nfunction IsPrimitiveButString(x: any): x is Primitive {\r\n return typeof x === \"number\" || typeof x === \"boolean\" || typeof x === \"bigint\" || IsDate(x);\r\n}\r\n\r\n/**\r\n */\r\nexport class XmlSerializer {\r\n /** */\r\n private _format: IXmlSerializerFormatOptions;\r\n /** */\r\n private _builder: IXmlBuilder;\r\n /** */\r\n private _ns: Map<string, string> = new Map<string, string>();\r\n /** */\r\n private _prefixCount: number = 0;\r\n\r\n private _nFmt?: NumberFormatter;\r\n\r\n /**\r\n *\r\n * @param builder\r\n * @param format\r\n */\r\n public constructor(builder: IXmlBuilder, format?: IXmlSerializerFormatOptions) {\r\n this._builder = builder;\r\n this._format = ResolveFormatOptions(format);\r\n this._nFmt = new NumberFormatter(this._format);\r\n }\r\n\r\n /**\r\n *\r\n * @param ns\r\n * @returns\r\n */\r\n public withNamespace(...ns: XmlName[]): XmlSerializer {\r\n for (const s of ns) {\r\n this._assignNamespace(s);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param root\r\n * @param name\r\n */\r\n serialize(root: object, name?: XmlName) {\r\n name = name ?? GetXmlName(root);\r\n if (!name) {\r\n throw new Error(\"can not find name for given object\");\r\n }\r\n const currentName: IQualifiedName = XmlNameToParts(name);\r\n if (currentName.ns) {\r\n // ensure we register the root namespace as default if not already set...\r\n this._assignNamespace(currentName.ns, \"xmlns\");\r\n }\r\n this._gatherNamespaces(root, new WeakSet<object>());\r\n\r\n const doc = this._builder.ele(null, currentName.name);\r\n for (const [v, n] of Array.from(this._ns.entries())) {\r\n doc.att(\"xmlns\", n, v);\r\n }\r\n this._writeObjectContent(doc, root as Record<string, unknown>, new WeakSet<object>().add(root));\r\n this._builder.end();\r\n }\r\n\r\n private _writeObject(builder: IXmlBuilder, source: Record<string, unknown>, visited: WeakSet<object>): void {\r\n if (visited.has(source)) {\r\n return;\r\n }\r\n visited.add(source);\r\n\r\n if (Array.isArray(source)) {\r\n for (const item of source) {\r\n if (IsPrimitiveButString(item)) {\r\n continue;\r\n }\r\n if (IsString(item)) {\r\n this._builder.text(item);\r\n continue;\r\n }\r\n this._writeObject(builder, item, visited);\r\n }\r\n return;\r\n }\r\n\r\n const qname = GetXmlName(source);\r\n if (!qname) {\r\n return;\r\n }\r\n const currentName = XmlNameToParts(qname);\r\n const prefix = this._getPrefix(currentName);\r\n const tmp = ToQualifiedString(currentName.name, prefix);\r\n builder.ele(null, tmp);\r\n this._writeObjectContent(builder, source as Record<string, unknown>, visited);\r\n this._builder.end();\r\n }\r\n\r\n private _getPrefix(qn: IQualifiedName): string | undefined {\r\n if (qn.ns) {\r\n const p = this._ns.get(qn.ns.toLowerCase());\r\n if (p !== \"xmlns\") {\r\n return p;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n private _writeObjectContent(builder: IXmlBuilder, source: Record<string, unknown>, visited: WeakSet<object>): void {\r\n // gather meta and build index\r\n const metas = GetXmlFieldMeta(source) ?? [];\r\n const metaByProp = new Map<string, typeof metas>();\r\n\r\n for (const m of metas) {\r\n const arr = metaByProp.get(m.prop) ?? [];\r\n arr.push(m);\r\n metaByProp.set(m.prop, arr);\r\n }\r\n\r\n // ensure the att are processed first, otherwize, the tag might be closed...\r\n const keys = Object.keys(source).sort((a, b) => {\r\n const aHasAttr = (metaByProp.get(a) ?? []).some((m) => m.kind === \"attr\");\r\n const bHasAttr = (metaByProp.get(b) ?? []).some((m) => m.kind === \"attr\");\r\n if (aHasAttr === bHasAttr) {\r\n return 0;\r\n }\r\n return aHasAttr ? -1 : 1; // attr d abord\r\n });\r\n\r\n // We decide per property, using metadata if present\r\n for (const prop of keys) {\r\n const value: any = source[prop];\r\n if (value === null || value === undefined) {\r\n continue;\r\n }\r\n\r\n const propMetas = metaByProp.get(prop);\r\n if (propMetas) {\r\n const ignored = propMetas.some((m) => m.ignore === true || m.kind === \"none\");\r\n if (ignored) {\r\n continue;\r\n }\r\n\r\n for (const m of propMetas) {\r\n const name = m.name ?? m.prop.toLowerCase(); // if the name is not defined, we assume it's the lower case version of name of the property.\r\n if (name) {\r\n switch (m.kind) {\r\n case \"attr\": {\r\n let vStr: string | null = null;\r\n if (IsNumber(value) && this._nFmt) {\r\n vStr = this._nFmt.toString(value);\r\n }\r\n if (m.formatter) {\r\n // TODO : cache the created formatter to avoid to many allocation.\r\n const f = new m.formatter(this._format);\r\n vStr = f.toString(value);\r\n }\r\n vStr = vStr ?? value.toString();\r\n if (vStr) {\r\n const currentName = XmlNameToParts(name);\r\n const prefix = this._getPrefix(currentName);\r\n const tmp = ToQualifiedString(currentName.name, prefix);\r\n builder.att(null, tmp, vStr);\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n continue;\r\n }\r\n if (IsPrimitiveButString(value)) {\r\n continue;\r\n }\r\n if (IsString(value)) {\r\n this._builder.text(value);\r\n continue;\r\n }\r\n this._writeObject(builder, value, visited);\r\n }\r\n }\r\n\r\n // this is the first browse of the hierarchy to collect the namespaces and assign placeholder.( ns0, ns1,...)\r\n private _gatherNamespaces(tag: any, visited: WeakSet<object>): void {\r\n if (visited.has(tag)) {\r\n return;\r\n }\r\n visited.add(tag);\r\n\r\n if (Array.isArray(tag)) {\r\n for (const item of tag) {\r\n if (IsPrimitive(item)) {\r\n continue;\r\n }\r\n this._gatherNamespaces(item, visited);\r\n }\r\n return;\r\n }\r\n\r\n const qname = GetXmlName(tag);\r\n if (qname) {\r\n this._assignNamespace(qname);\r\n }\r\n\r\n // gather meta and build index\r\n const metas = GetXmlFieldMeta(tag) ?? [];\r\n const metaByProp = new Map<string, typeof metas>();\r\n\r\n for (const m of metas) {\r\n const arr = metaByProp.get(m.prop) ?? [];\r\n arr.push(m);\r\n metaByProp.set(m.prop, arr);\r\n }\r\n\r\n // We decide per property, using metadata if present\r\n const toVisit: object[] = [];\r\n\r\n for (const prop of Object.keys(tag)) {\r\n const value = tag[prop];\r\n if (value === null || value === undefined) {\r\n continue;\r\n }\r\n const propMetas = metaByProp.get(prop);\r\n if (propMetas) {\r\n const ignored = propMetas.some((m) => m.ignore === true || m.kind === \"none\");\r\n if (ignored) {\r\n continue;\r\n }\r\n\r\n for (const m of propMetas) {\r\n if (m.name) {\r\n this._assignNamespace(m.name);\r\n }\r\n }\r\n }\r\n toVisit.push(value);\r\n }\r\n\r\n for (const v of toVisit) {\r\n if (IsPrimitive(v)) {\r\n continue;\r\n }\r\n this._gatherNamespaces(v, visited);\r\n }\r\n }\r\n\r\n private _assignNamespace(qn: XmlName, prefix?: string) {\r\n const nqn = XmlNameToParts(qn);\r\n if (nqn?.ns) {\r\n const ns = nqn.ns.toLowerCase();\r\n if (!this._ns.get(ns)) {\r\n this._ns.set(ns, prefix ?? this._buildNsPrefix(ns));\r\n }\r\n return;\r\n }\r\n if (prefix === \"xmlns\") {\r\n const ns = nqn.name.toLowerCase();\r\n if (!this._ns.get(ns)) {\r\n this._ns.set(ns, prefix ?? this._buildNsPrefix(ns));\r\n }\r\n }\r\n }\r\n\r\n private _buildNsPrefix(_ns: string): string {\r\n let alreadyReferenced = false;\r\n let value: string;\r\n do {\r\n value = `ns${this._prefixCount++}`;\r\n for (const v of Array.from(this._ns.values())) {\r\n if (v === value) {\r\n alreadyReferenced = true;\r\n break;\r\n }\r\n }\r\n } while (alreadyReferenced);\r\n\r\n return value;\r\n }\r\n}\r\n","import type { IXmlBuilder } from \"./xml.interfaces\";\r\n\r\n/**\r\n */\r\nexport interface IXmlWriter {\r\n /**\r\n * @param data\r\n * @returns\r\n */\r\n write(...data: string[]): IXmlWriter;\r\n /** */\r\n count: number;\r\n /** */\r\n clear(): void;\r\n}\r\n\r\n/** */\r\nclass XmlSyntax {\r\n /** */\r\n public static OpenTag: string = \"<\";\r\n /** */\r\n public static CloseTag: string = \">\";\r\n /** */\r\n public static Slash: string = \"/\";\r\n /** */\r\n public static Question: string = \"?\";\r\n /** */\r\n public static Quote: string = '\"';\r\n /** */\r\n public static Equal: string = \"=\";\r\n /** */\r\n public static Space: string = \" \";\r\n /** */\r\n public static Semicolon: string = \":\";\r\n\r\n /** */\r\n public static Dec = \"<?xml\";\r\n /** */\r\n public static Xml = \"xml\";\r\n /** */\r\n public static Xmlns = \"xmlns\";\r\n /** */\r\n public static Xsi = \"xsi\";\r\n\r\n /** */\r\n public static VersionKeyword = \"version\";\r\n /** */\r\n public static EncodingKeyword = \"encoding\";\r\n /** */\r\n public static StandaloneKeyword = \"standalone\";\r\n}\r\n\r\n/** */\r\nexport enum TokenType {\r\n Declaration,\r\n Tag,\r\n Attribute,\r\n Text,\r\n}\r\n\r\n/** */\r\nexport class XmlBuilder implements IXmlBuilder {\r\n /** */\r\n static Context = class {\r\n /** */\r\n name: string = \"\";\r\n /** */\r\n closed: boolean = false;\r\n /** */\r\n lastToken: TokenType | null = null;\r\n /** */\r\n depth: number;\r\n\r\n // uri -> prefix\r\n ns2prefix: Map<string, string> = new Map();\r\n\r\n // prefix -> uri (for conflict checks)\r\n prefix2ns: Map<string, string> = new Map();\r\n\r\n // optional: default namespace uri\r\n defaultNs: string | null = null;\r\n\r\n /**\r\n *\r\n *@param name\r\n *@param depth\r\n */\r\n constructor(name: string, depth: number) {\r\n this.name = name;\r\n this.depth = depth;\r\n }\r\n };\r\n\r\n /** */\r\n private _w: IXmlWriter;\r\n /** */\r\n private _ctxStack: Array<InstanceType<typeof XmlBuilder.Context>> = [];\r\n /** */\r\n private _d: number = 0;\r\n\r\n public constructor(w: IXmlWriter) {\r\n this._w = w;\r\n }\r\n\r\n /**\r\n *\r\n * @param version\r\n * @param encoding\r\n * @param standalone\r\n * @returns\r\n */\r\n public dec(version: string, encoding?: string, standalone?: boolean): IXmlBuilder {\r\n this._w.write(XmlSyntax.Dec);\r\n this._writeAttStr(XmlSyntax.VersionKeyword, version);\r\n if (encoding) {\r\n this._writeAttStr(XmlSyntax.EncodingKeyword, encoding);\r\n }\r\n if (standalone !== undefined) {\r\n this._writeAttStr(XmlSyntax.StandaloneKeyword, standalone ? \"yes\" : \"no\");\r\n }\r\n this._w.write(XmlSyntax.Question, XmlSyntax.CloseTag);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param ns\r\n * @param n\r\n * @param v\r\n * @returns\r\n */\r\n public att(ns: string | null, n: string, v: string): IXmlBuilder {\r\n const ctx = this._peekContext();\r\n if (!ctx) {\r\n throw new Error(\"att() without open element\");\r\n }\r\n if (ctx.closed) {\r\n throw new Error(`att() after start tag closed for <${ctx.name}>`);\r\n }\r\n\r\n // explicit namespace declaration: xmlns or xmlns:prefix\r\n if (this._isXmlnsDecl(ns, n)) {\r\n if (n === XmlSyntax.Xmlns) {\r\n // default namespace\r\n ctx.defaultNs = v;\r\n // you can store default as empty prefix if you want\r\n this._registerNamespace(ctx, \"\", v);\r\n this._writeAttStr(XmlSyntax.Xmlns, v);\r\n } else {\r\n if (!ns) {\r\n const prefix = n.slice(6); // \"xmlns:\"\r\n this._registerNamespace(ctx, prefix, v);\r\n this._writeAttStr(n, v);\r\n } else {\r\n this._registerNamespace(ctx, n, v);\r\n this._writeAttStr(`${ns}:${n}`, v);\r\n }\r\n }\r\n ctx.lastToken = TokenType.Attribute;\r\n return this;\r\n }\r\n\r\n // normal attribute\r\n let qn = n;\r\n\r\n if (ns) {\r\n // treat ns as a namespace URI, not a prefix\r\n const p = this._ensurePrefixDeclared(ctx, ns);\r\n qn = `${p}:${n}`;\r\n }\r\n\r\n ctx.lastToken = TokenType.Attribute;\r\n this._writeAttStr(qn, v);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param ns\r\n * @param n\r\n * @returns\r\n */\r\n public ele(ns: string | null, n: string): IXmlBuilder {\r\n const ctx = this._peekContext();\r\n if (ctx) {\r\n this._closeOpenTagIfNeeded(ctx);\r\n }\r\n let qns = n;\r\n if (ns) {\r\n const p = this._lookupPrefix(ns) ?? ns;\r\n qns = `${p}:${n}`;\r\n }\r\n this._pushContext(qns, ++this._d);\r\n this._w.write(XmlSyntax.OpenTag, qns);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param txt\r\n * @returns\r\n */\r\n public text(txt: string): IXmlBuilder {\r\n const ctx = this._peekContext();\r\n if (!ctx) {\r\n throw new Error(\"text() without open element\");\r\n }\r\n this._closeOpenTagIfNeeded(ctx);\r\n ctx.lastToken = TokenType.Text;\r\n this._w.write(this._escText(txt));\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public end(): IXmlBuilder {\r\n const ctx = this._popContext();\r\n if (ctx) {\r\n this._d--;\r\n if (!ctx.closed) {\r\n this._w.write(XmlSyntax.Slash, XmlSyntax.CloseTag);\r\n } else {\r\n this._w.write(XmlSyntax.OpenTag, XmlSyntax.Slash, ctx.name, XmlSyntax.CloseTag);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n protected _pushContext(name: string, depth: number): InstanceType<typeof XmlBuilder.Context> {\r\n const ctx = new XmlBuilder.Context(name, depth);\r\n this._ctxStack.push(ctx);\r\n return ctx;\r\n }\r\n\r\n protected _popContext(): InstanceType<typeof XmlBuilder.Context> | undefined {\r\n return this._ctxStack.pop();\r\n }\r\n\r\n protected _peekContext(): InstanceType<typeof XmlBuilder.Context> | undefined {\r\n return this._ctxStack[this._ctxStack.length - 1];\r\n }\r\n\r\n protected get _contextDepth(): number {\r\n return this._ctxStack.length;\r\n }\r\n\r\n private _writeAttStr(name: string, value: string) {\r\n this._w.write(XmlSyntax.Space, name, XmlSyntax.Equal, XmlSyntax.Quote, this._escAttr(value), XmlSyntax.Quote);\r\n }\r\n\r\n private _lookupPrefix(ns: string): string | undefined {\r\n let i = this._ctxStack.length - 1;\r\n if (i >= 0) {\r\n do {\r\n const ctx = this._ctxStack[i--];\r\n const p = ctx.ns2prefix?.get(ns);\r\n if (p) {\r\n return p;\r\n }\r\n } while (i >= 0);\r\n }\r\n return undefined;\r\n }\r\n\r\n private _escText(s: string): string {\r\n return s.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\");\r\n }\r\n\r\n private _escAttr(s: string): string {\r\n return this._escText(s).replace(/\"/g, \""\").replace(/'/g, \"'\");\r\n }\r\n\r\n private _isXmlnsDecl(ns: string | null, n: string): boolean {\r\n if (ns) {\r\n return ns === XmlSyntax.Xmlns;\r\n }\r\n const l = n.length;\r\n const s = XmlSyntax.Xmlns.length;\r\n if (l >= s) {\r\n return n.startsWith(XmlSyntax.Xmlns) && (n.length == s || n[s] == XmlSyntax.Semicolon);\r\n }\r\n return false;\r\n }\r\n\r\n private _registerNamespace(ctx: InstanceType<typeof XmlBuilder.Context>, prefix: string, uri: string) {\r\n if (prefix === XmlSyntax.Xml || prefix === XmlSyntax.Xmlns) {\r\n throw new Error(`reserved prefix '${prefix}'`);\r\n }\r\n\r\n const existingUri = ctx.prefix2ns.get(prefix);\r\n if (existingUri && existingUri !== uri) {\r\n throw new Error(`prefix '${prefix}' already bound to a different namespace`);\r\n }\r\n\r\n const existingPrefix = ctx.ns2prefix.get(uri);\r\n if (!existingPrefix) {\r\n ctx.ns2prefix.set(uri, prefix);\r\n }\r\n\r\n ctx.prefix2ns.set(prefix, uri);\r\n }\r\n\r\n private _allocPrefix(ctx: InstanceType<typeof XmlBuilder.Context>): string {\r\n let i = 1;\r\n while (true) {\r\n const p = `ns${i++}`;\r\n if (!ctx.prefix2ns.has(p)) {\r\n return p;\r\n }\r\n }\r\n }\r\n\r\n private _ensurePrefixDeclared(ctx: InstanceType<typeof XmlBuilder.Context>, uri: string): string {\r\n const existing = this._lookupPrefix(uri);\r\n if (existing) {\r\n return existing;\r\n }\r\n\r\n if (ctx.closed) {\r\n throw new Error(`can not declare namespace after start tag closed for <${ctx.name}>`);\r\n }\r\n\r\n const prefix = this._allocPrefix(ctx);\r\n\r\n // write xmlns:prefix=\"uri\" and register it\r\n this._writeAttStr(`${XmlSyntax.Xmlns}:${prefix}`, uri);\r\n this._registerNamespace(ctx, prefix, uri);\r\n\r\n return prefix;\r\n }\r\n\r\n private _closeOpenTagIfNeeded(ctx: InstanceType<typeof XmlBuilder.Context>) {\r\n if (!ctx.closed) {\r\n this._w.write(XmlSyntax.CloseTag);\r\n ctx.closed = true;\r\n }\r\n }\r\n}\r\n","/**\r\n * XML namespace for the core 3MF model schema.\r\n * This is the default namespace used by <model> and most standard 3MF elements.\r\n */\r\nexport const ThreeDimModelNamespace = \"http://schemas.microsoft.com/3dmanufacturing/core/2015/02\";\r\n\r\n/**\r\n * XML namespace for the TriangleSets extension (2021/07).\r\n * This extension is used for more advanced triangle/property use cases.\r\n * Only declare/use it when you actually emit elements/attributes that require it.\r\n */\r\nexport const TriangleSetsNamespace = \"http://schemas.microsoft.com/3dmanufacturing/trianglesets/2021/07\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n\r\n/**\r\n * 3MF model units.\r\n * The unit affects interpretation of vertex coordinates (x,y,z).\r\n * Most pipelines use millimeter, but the writer should match the upstream scene unit expectations.\r\n */\r\nexport enum ST_Unit {\r\n micron = \"micron\",\r\n millimeter = \"millimeter\",\r\n centimeter = \"centimeter\",\r\n inch = \"inch\",\r\n foot = \"foot\",\r\n meter = \"meter\",\r\n}\r\n\r\n/**\r\n * In the XSD, ST_Matrix3D is a whitespace separated list of numbers.\r\n * The official 3MF core spec uses a 3x4 matrix (12 numbers).\r\n */\r\nexport type ST_Matrix3D = [number, number, number, number, number, number, number, number, number, number, number, number];\r\n\r\n/**\r\n *\r\n */\r\nexport interface IMatrix3d {\r\n /** */\r\n values: ST_Matrix3D;\r\n}\r\n\r\n/**\r\n * 3MF color value.\r\n * In the 3MF core spec, colors are typically expressed as sRGB hex strings: \"#RRGGBB\" (and sometimes \"#AARRGGBB\").\r\n * This type is kept as string because we serialize directly into XML and want to avoid coupling to a specific color class.\r\n */\r\nexport type ST_ColorValue = string;\r\n\r\n/**\r\n * URI reference type used by attributes like thumbnail.\r\n * Usually a relative package path inside the OPC container, for example \"/Metadata/thumbnail.png\".\r\n */\r\nexport type ST_UriReference = string;\r\n\r\n/**\r\n * Numeric type used for coordinates and similar scalar values.\r\n * 3MF stores numbers as XML attributes/text; here we represent them as JS numbers.\r\n */\r\nexport type ST_Number = number;\r\n\r\n/**\r\n * Resource identifiers used by <object id=\"...\">, property groups, etc.\r\n * This is usually a positive integer unique within the model.\r\n */\r\nexport type ST_ResourceID = number;\r\n\r\n/**\r\n * Resource index used to reference an entry within a resource list.\r\n * For example, triangle v1/v2/v3 reference indices into <vertices>.\r\n */\r\nexport type ST_ResourceIndex = number;\r\n\r\n/**\r\n * Standard 3MF object type.\r\n * This is optional in 3MF; if omitted, consumers often treat it as \"model\".\r\n */\r\nexport enum ST_ObjectType {\r\n model = \"model\",\r\n solidsupport = \"solidsupport\",\r\n support = \"support\",\r\n surface = \"surface\",\r\n other = \"other\",\r\n}\r\n\r\n/**\r\n * Generic metadata entry.\r\n * Metadata can appear at the model level (<metadata>) and inside metadata groups (<metadatagroup>).\r\n *\r\n * Notes:\r\n * - \"name\" is the metadata key.\r\n * - \"type\" is optional and can be a MIME type or a schema indicator depending on usage.\r\n * - \"preserve\" instructs consumers whether to keep metadata when modifying the model.\r\n */\r\nexport interface I3mfMetadata {\r\n /** Metadata key (required). */\r\n name: string;\r\n\r\n /** If true, indicates the metadata should be preserved by consumers (optional). */\r\n preserve?: boolean;\r\n\r\n /** Optional type information for the value. */\r\n type?: string;\r\n\r\n /** Metadata value (required). */\r\n value: string;\r\n}\r\n\r\n/**\r\n * A grouping element for metadata.\r\n * Used in some places where the schema allows a metadata group rather than raw metadata entries.\r\n */\r\nexport interface I3mfMetadataGroup {\r\n /** The list of metadata entries contained in the group. */\r\n metadata: Array<I3mfMetadata>;\r\n}\r\n\r\n/**\r\n * 3MF vertex.\r\n * Coordinates are expressed in the model unit (I3mfModel.unit).\r\n */\r\nexport interface I3mfVertex {\r\n /** X coordinate. */\r\n x: ST_Number;\r\n /** Y coordinate. */\r\n y: ST_Number;\r\n /** Z coordinate. */\r\n z: ST_Number;\r\n}\r\n\r\n/**\r\n * 3MF triangle.\r\n * v1/v2/v3 are indices into the vertices list (<vertices> \\<vertex .../\\>...</vertices>).\r\n *\r\n * Property assignment:\r\n * - pid and p1/p2/p3 are used to assign per-triangle or per-vertex properties (like materials or colors),\r\n * depending on which property group pid refers to.\r\n */\r\nexport interface I3mfTriangle {\r\n /** Index of first vertex in the vertices array. */\r\n v1: ST_ResourceIndex;\r\n /** Index of second vertex in the vertices array. */\r\n v2: ST_ResourceIndex;\r\n /** Index of third vertex in the vertices array. */\r\n v3: ST_ResourceIndex;\r\n\r\n /**\r\n * Optional per-vertex property indices for v1/v2/v3.\r\n * These are indices into the property group's entry list (the group referenced by pid).\r\n */\r\n p1?: ST_ResourceIndex;\r\n /** */\r\n p2?: ST_ResourceIndex;\r\n /** */\r\n p3?: ST_ResourceIndex;\r\n\r\n /**\r\n * Property group id for this triangle.\r\n * If present, it overrides the object-level pid for this specific triangle.\r\n */\r\n pid?: ST_ResourceID;\r\n}\r\n\r\n/**\r\n * Container for vertices.\r\n * Matches the XML structure <vertices>\\<vertex .../\\>...</vertices>.\r\n */\r\nexport interface I3mfVertices {\r\n /** Array of vertices. Order matters because triangles reference indices. */\r\n vertex: Array<I3mfVertex>;\r\n}\r\n\r\n/**\r\n * Container for triangles.\r\n * Matches the XML structure <triangles>\\<triangle .../\\>...</triangles>.\r\n */\r\nexport interface I3mfTriangles {\r\n /** Array of triangles. */\r\n triangle: Array<I3mfTriangle>;\r\n}\r\n\r\n/**\r\n * Mesh geometry content for an object.\r\n * Exactly one of: mesh content OR components content should be provided in an object.\r\n */\r\nexport interface I3mfMesh {\r\n /** Vertex list. */\r\n vertices: I3mfVertices;\r\n\r\n /** Triangle list. */\r\n triangles: I3mfTriangles;\r\n}\r\n\r\n/**\r\n * Component reference inside a composite object.\r\n * A composite object is an object whose content is <components> rather than <mesh>.\r\n *\r\n * objectid references another object in resources.\r\n * transform (3x4) positions that referenced object within the composite.\r\n */\r\nexport interface I3mfComponent {\r\n /** Referenced object id. */\r\n objectid: ST_ResourceID;\r\n\r\n /**\r\n * Optional transform applied to the referenced object within the component.\r\n * Represented as a 3x4 matrix.\r\n */\r\n transform?: IMatrix3d;\r\n}\r\n\r\n/**\r\n * Container for components.\r\n * Matches <components><component objectid=\"...\"/></components>.\r\n */\r\nexport interface I3mfComponents {\r\n /** Array of component references. */\r\n component: Array<I3mfComponent>;\r\n}\r\n\r\n/**\r\n * Object resource.\r\n * An object either contains a mesh (geometry) or components (composite object).\r\n *\r\n * Properties (pid/pindex):\r\n * - pid references a property group (e.g. basematerials id).\r\n * - pindex is an index within that group.\r\n * - If pindex is used, pid is required.\r\n *\r\n * Metadata:\r\n * - metadatagroup is optional and can store additional object-level metadata.\r\n */\r\nexport interface I3mfObject {\r\n /** Unique object id within the model. */\r\n id: ST_ResourceID;\r\n\r\n /** Optional object type hint. */\r\n type?: ST_ObjectType;\r\n\r\n /** Optional thumbnail reference (usually a package path). */\r\n thumbnail?: ST_UriReference;\r\n\r\n /** Optional part number (often used by manufacturing systems). */\r\n partnumber?: string;\r\n\r\n /** Optional human-readable name. */\r\n name?: string;\r\n\r\n /**\r\n * Property group reference.\r\n * Example: <basematerials id=\"5\"> ... </basematerials> then pid=5.\r\n * Required if pindex is specified.\r\n */\r\n pid?: ST_ResourceID;\r\n\r\n /**\r\n * Index inside the property group referenced by pid.\r\n * Meaning depends on the property group type (base materials, color group, etc.).\r\n */\r\n pindex?: ST_ResourceIndex;\r\n\r\n /** Optional grouped metadata for the object. */\r\n metadatagroup?: I3mfMetadataGroup;\r\n\r\n /**\r\n * Content of the object:\r\n * - Mesh geometry OR\r\n * - Components (composite object).\r\n *\r\n * In the 3MF XML schema, this corresponds to having either a <mesh> element or a <components> element.\r\n */\r\n content?: I3mfMesh | I3mfComponents;\r\n}\r\n\r\n/**\r\n * A single base material entry.\r\n * \"name\" is a label, \"displaycolor\" provides the color used for rendering previews.\r\n */\r\nexport interface I3mfBase {\r\n /** Material name/label. */\r\n name: string;\r\n\r\n /** Display color for the base material. */\r\n displaycolor: ST_ColorValue;\r\n}\r\n\r\n/**\r\n * Base materials property group.\r\n * Triangles or objects can reference this group via pid, and then a specific entry via pindex (or p1/p2/p3).\r\n */\r\nexport interface I3mfBaseMaterials {\r\n /** Property group id. Must be unique within resources. */\r\n id: ST_ResourceID;\r\n\r\n /** List of base material entries. */\r\n base: Array<I3mfBase>;\r\n}\r\n\r\n/**\r\n * Model resources container.\r\n * Holds object resources and optional property groups such as basematerials.\r\n */\r\nexport interface I3mfResources {\r\n /** All objects available for build items and components. */\r\n object: Array<I3mfObject>;\r\n\r\n /**\r\n * Optional base materials groups.\r\n * Other property groups may exist in 3MF (colors, textures, etc.) but are not modeled here.\r\n */\r\n basematerials?: Array<I3mfBaseMaterials>;\r\n}\r\n\r\n/**\r\n * Build item.\r\n * The build section describes what to \"print\" or \"instantiate\" from the resources.\r\n *\r\n * objectid references a resource object, and transform places it in the world.\r\n * partnumber and metadatagroup allow attaching build-item specific info.\r\n */\r\nexport interface I3mfItem {\r\n /** Referenced object id to build. */\r\n objectid: ST_ResourceID;\r\n\r\n /** Optional placement transform (3x4). */\r\n transform?: IMatrix3d;\r\n\r\n /** Optional part number at the build item level. */\r\n partnumber?: string;\r\n\r\n /** Optional build-item metadata. */\r\n metadatagroup?: I3mfMetadataGroup;\r\n}\r\n\r\n/**\r\n * Build container.\r\n * Contains all build items.\r\n */\r\nexport interface I3mfBuild {\r\n /** Array of build items. */\r\n item: Array<I3mfItem>;\r\n}\r\n\r\n/**\r\n * Root model element.\r\n *\r\n * Extensions:\r\n * - requiredextensions: a space-separated list of prefixes (or namespaces depending on your serializer conventions)\r\n * that are required to interpret the model.\r\n * - recommendedextensions: extensions that improve fidelity but are not required.\r\n *\r\n * Notes:\r\n * - resources and build are typically present in a valid printable model.\r\n * - metadata at the model level stores global information like title, author, etc.\r\n */\r\nexport interface I3mfModel {\r\n /** Unit used for all coordinates in the model. */\r\n unit?: ST_Unit;\r\n\r\n /** Declares extensions that must be understood by consumers. */\r\n requiredextensions?: string;\r\n\r\n /** Declares extensions that may be used for better results. */\r\n recommendedextensions?: string;\r\n\r\n /** Optional model-level metadata entries. */\r\n metadata?: Array<I3mfMetadata>;\r\n\r\n /** Optional resources section (objects, materials, etc.). */\r\n resources?: I3mfResources;\r\n\r\n /** Optional build section (what to instantiate/print). */\r\n build?: I3mfBuild;\r\n}\r\n","import type { IXmlWriter } from \"./xml.builder\";\r\n\r\n/** */\r\nexport class StringXmlWriter implements IXmlWriter {\r\n /** */\r\n public count = 0;\r\n private _chunks: string[] = [];\r\n\r\n /**\r\n * @param data\r\n * @returns\r\n */\r\n write(...data: string[]): IXmlWriter {\r\n if (data.length === 0) {\r\n return this;\r\n }\r\n\r\n // join once per call, keeps DOM out, very fast\r\n const s = data.join(\"\");\r\n this._chunks.push(s);\r\n this.count += s.length;\r\n return this;\r\n }\r\n\r\n /**\r\n * @returns\r\n */\r\n toString(): string {\r\n return this._chunks.join(\"\");\r\n }\r\n\r\n /**\r\n */\r\n clear(): void {\r\n this._chunks = [];\r\n this.count = 0;\r\n }\r\n}\r\n","import type { IXmlWriter } from \"./xml.builder\";\r\n\r\n/** */\r\nexport type ByteSink = {\r\n push(chunk: Uint8Array, final?: boolean): void;\r\n};\r\n\r\n/** */\r\nexport class Utf8XmlWriterToBytes implements IXmlWriter {\r\n /** */\r\n public count = 0;\r\n private _encoder = new TextEncoder();\r\n private _pending = \"\";\r\n private _pendingChars = 0;\r\n\r\n constructor(\r\n private readonly _sink: ByteSink,\r\n private readonly _opts: { flushChars?: number } = {}\r\n ) {}\r\n\r\n /**\r\n * @param data\r\n * @returns\r\n */\r\n write(...data: string[]): IXmlWriter {\r\n if (data.length === 0) {\r\n return this;\r\n }\r\n\r\n const s = data.join(\"\");\r\n if (s.length === 0) {\r\n return this;\r\n }\r\n\r\n this._pending += s;\r\n this._pendingChars += s.length;\r\n\r\n const limit = this._opts.flushChars ?? 64 * 1024;\r\n if (this._pendingChars >= limit) {\r\n this.flush();\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * @returns\r\n */\r\n flush(): this {\r\n if (this._pendingChars === 0) {\r\n return this;\r\n }\r\n\r\n const bytes = this._encoder.encode(this._pending);\r\n this._sink.push(bytes);\r\n this.count += bytes.length;\r\n\r\n this._pending = \"\";\r\n this._pendingChars = 0;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n */\r\n finish(): void {\r\n this.flush();\r\n this._sink.push(new Uint8Array(0), true);\r\n }\r\n\r\n /**\r\n */\r\n clear(): void {\r\n this._pending = \"\";\r\n this._pendingChars = 0;\r\n this.count = 0;\r\n }\r\n}\r\n","import type { I3mfModel } from \"./3mf.interfaces\";\n\nexport const OpenXmlContentTypesNamespace = \"http://schemas.openxmlformats.org/package/2006/content-types\";\nexport const OpenXmlRelationshipsNamespace = \"http://schemas.openxmlformats.org/package/2006/relationships\";\n\nexport enum KnownI3mfContentType {\n // OPC core\n Relationships = \"application/vnd.openxmlformats-package.relationships+xml\",\n\n // 3MF core\n Model = \"application/vnd.ms-package.3dmanufacturing-3dmodel+xml\",\n\n // Extensions officielles\n Materials = \"application/vnd.ms-package.3dmanufacturing-material+xml\",\n Colors = \"application/vnd.ms-package.3dmanufacturing-colors+xml\",\n Texture = \"application/vnd.ms-package.3dmanufacturing-texture+xml\",\n Texture2D = \"application/vnd.ms-package.3dmanufacturing-texture2d+xml\",\n Production = \"application/vnd.ms-package.3dmanufacturing-production+xml\",\n Slice = \"application/vnd.ms-package.3dmanufacturing-slice+xml\",\n BeamLattice = \"application/vnd.ms-package.3dmanufacturing-beamlattice+xml\",\n SecureContent = \"application/vnd.ms-package.3dmanufacturing-securecontent+xml\",\n\n // Assets\n Png = \"image/png\",\n Jpeg = \"image/jpeg\",\n Tiff = \"image/tiff\",\n Xml = \"application/xml\",\n}\n\nexport const RelationshipDirName = \"_rels/\";\nexport const Object3dDirName = \"3D/\";\nexport const ModelFileName = `3dmodel.model`;\nexport const RelationshipFileName = `.rels`;\nexport const ContentTypeFileName = \"[Content_Types].xml\";\n\n/**\n * Common OPC and 3MF relationship Type URIs.\n */\nexport class Known3mfRelationshipTypes {\n /**\n * 3MF core: points to the main .model part of the package\n */\n public static readonly ThreeDimModel = \"http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel\";\n\n /**\n * OPC core: points to a package thumbnail (often used by 3MF packages)\n */\n public static readonly Thumbnail = \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail\";\n\n /**\n * 3MF (print ticket): optional printing settings part (rarely used by slicers)\n */\n public static readonly PrintTicket = \"http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket\";\n\n /**\n * OPC core: indicates parts that must be preserved when editing the package\n */\n public static readonly MustPreserve = \"http://schemas.openxmlformats.org/package/2006/relationships/mustpreserve\";\n\n /**\n * Convenience set for quick checks\n */\n public static readonly Known: ReadonlySet<string> = new Set<string>([\n Known3mfRelationshipTypes.ThreeDimModel,\n Known3mfRelationshipTypes.Thumbnail,\n Known3mfRelationshipTypes.PrintTicket,\n Known3mfRelationshipTypes.MustPreserve,\n ]);\n\n /**\n * Test if the relationship Type is one of the common known URIs above\n * @param type\n * @returns true if the relationship Type is one of the common known URIs above\n */\n public static IsKnown(type: string): boolean {\n return Known3mfRelationshipTypes.Known.has(type);\n }\n\n /**\n * test if the relationship Type is the main 3MF model entry point\n * @param type\n * @returns true if the relationship Type is the main 3MF model entry point\n */\n public static IsThreeDimModel(type: string): boolean {\n return type === Known3mfRelationshipTypes.ThreeDimModel;\n }\n}\n\n/**\n *\n */\nexport interface I3mfContentTypes {\n /**\n *\n */\n items: I3mfContentType[];\n}\n\n/**\n *\n */\nexport interface I3mfContentType {\n /**\n *\n */\n ext: string;\n /**\n *\n */\n ct: string;\n}\n\n/**\n *\n */\nexport interface I3mfRelationships {\n /**\n *\n */\n items: I3mfRelationship[];\n}\n\n/**\n *\n */\nexport interface I3mfRelationship {\n /**\n *\n */\n id: string;\n\n /**\n *\n */\n type?: string;\n\n /**\n *\n */\n target?: string;\n}\n\n/**\n *\n */\nexport interface I3mfDocument {\n /**\n *\n */\n contentTypes: I3mfContentTypes;\n /**\n *\n */\n relationships: I3mfRelationships;\n /**\n *\n */\n model: I3mfModel;\n}\n","import { XmlAttr, XmlName } from \"../xml/xml.interfaces\";\nimport type { I3mfModel } from \"./3mf.interfaces\";\nimport { OpenXmlContentTypesNamespace, OpenXmlRelationshipsNamespace } from \"./3mf.opc.interfaces\";\nimport type { I3mfContentTypes, I3mfContentType, I3mfRelationships, I3mfRelationship, I3mfDocument } from \"./3mf.opc.interfaces\";\n\n/**\n *\n */\n@XmlName({ ns: OpenXmlContentTypesNamespace, name: \"Types\" })\nexport class ThreeMfContentTypes implements I3mfContentTypes {\n /**\n *\n */\n items: ThreeMfContentType[] = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: OpenXmlContentTypesNamespace, name: \"Default\" })\nexport class ThreeMfContentType implements I3mfContentType {\n /**\n *\n */\n @XmlAttr({ name: { ns: OpenXmlContentTypesNamespace, name: \"Extension\" } })\n ext: string;\n /**\n *\n */\n @XmlAttr({ name: { ns: OpenXmlContentTypesNamespace, name: \"ContentType\" } })\n ct: string;\n\n /**\n *\n * @param ext\n * @param ct\n */\n public constructor(ext: string, ct: string) {\n this.ext = ext;\n this.ct = ct;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: OpenXmlRelationshipsNamespace, name: \"Relationships\" })\nexport class ThreeMfRelationships implements I3mfRelationships {\n /**\n *\n */\n items: ThreeMfRelationship[] = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: OpenXmlRelationshipsNamespace, name: \"Relationship\" })\nexport class ThreeMfRelationship implements I3mfRelationship {\n /**\n *\n */\n @XmlAttr({ name: \"Id\" })\n id: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"Type\" })\n type?: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"Target\" })\n target?: string;\n\n constructor(id: string, type: string, target: string) {\n this.id = id;\n this.type = type;\n this.target = target;\n }\n}\n\n/**\n *\n */\nexport class ThreeMfDocument implements I3mfDocument {\n public constructor(\n public contentTypes: I3mfContentTypes,\n public relationships: I3mfRelationships,\n public model: I3mfModel\n ) {}\n}\n","import { type IFormatter, XmlAttr, XmlName } from \"../xml/xml.interfaces\";\nimport { type IXmlSerializerFormatOptions, NumberFormatter } from \"../xml/xml.serializer.format\";\nimport type {\n I3mfBase,\n I3mfBaseMaterials,\n I3mfBuild,\n I3mfComponent,\n I3mfComponents,\n I3mfItem,\n I3mfMesh,\n I3mfMetadata,\n I3mfMetadataGroup,\n I3mfModel,\n I3mfObject,\n I3mfResources,\n I3mfTriangle,\n I3mfTriangles,\n I3mfVertex,\n I3mfVertices,\n ST_ColorValue,\n ST_Number,\n ST_ResourceID,\n ST_ResourceIndex,\n ST_UriReference,\n IMatrix3d,\n ST_Matrix3D,\n} from \"./3mf.interfaces\";\nimport { ST_Unit, ThreeDimModelNamespace, ST_ObjectType } from \"./3mf.interfaces\";\n\n/**\n *\n */\nexport class Matrix3d implements IMatrix3d {\n /**\n *\n * @returns\n */\n public static Zero() {\n return new Matrix3d([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);\n }\n /**\n *\n * @param values\n */\n public constructor(public values: ST_Matrix3D) {}\n\n /**\n *\n * @returns\n */\n public toString(): string {\n return this.values.join(\" \");\n }\n}\n\n/**\n *\n */\nexport class MatrixFormatter implements IFormatter<Matrix3d> {\n /**\n *\n */\n _f: NumberFormatter;\n\n public constructor(public o: IXmlSerializerFormatOptions) {\n this._f = new NumberFormatter(o);\n }\n\n public toString(x: Matrix3d): string {\n return x.values.map((v) => this._f.toString(v)).join(\" \");\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"model\" })\nexport class ThreeMfModel implements I3mfModel {\n /**\n *\n */\n public static KnownMeta: Array<string> = [\"Title\", \"Designer\", \"Description\", \"Copyright\", \"LicenseTerms\", \"Rating\", \"CreationDate\", \"ModificationDate\", \"Application\"];\n\n /**\n *\n */\n @XmlAttr({ name: \"unit\" })\n unit: ST_Unit = ST_Unit.millimeter;\n\n /**\n *\n */\n @XmlAttr({ name: \"requiredextensions\" })\n requiredextensions?: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"recommendedextensions\" })\n recommendedextensions?: string;\n\n /**\n *\n */\n metadata?: Array<I3mfMetadata>;\n /**\n *\n */\n resources?: I3mfResources;\n /**\n *\n */\n build?: I3mfBuild;\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"meta\" })\nexport class ThreeMfMeta implements I3mfMetadata {\n /**\n *\n */\n @XmlAttr({ name: \"name\" })\n name: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"preserve\" })\n preserve?: boolean;\n\n /**\n *\n */\n @XmlAttr({ name: \"type\" })\n type?: string;\n\n /**\n *\n */\n value: string;\n\n /**\n *\n * @param name\n * @param value\n * @param preserve\n * @param type\n */\n public constructor(name: string, value: string, preserve?: boolean, type?: string) {\n this.name = name;\n this.value = value;\n this.preserve = preserve;\n this.type = type;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"metadatagroup\" })\nexport class ThreeMfMetadataGroup implements I3mfMetadataGroup {\n /**\n *\n */\n metadata: Array<I3mfMetadata> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"resources\" })\nexport class ThreeMfResources implements I3mfResources {\n /**\n *\n */\n object: Array<I3mfObject> = [];\n /**\n *\n */\n basematerials?: Array<I3mfBaseMaterials>;\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"object\" })\nexport class ThreeMfObject implements I3mfObject {\n /**\n *\n */\n @XmlAttr({ name: \"id\" })\n id: ST_ResourceID;\n\n /**\n *\n */\n @XmlAttr({ name: \"type\" })\n type?: ST_ObjectType;\n\n /**\n *\n */\n @XmlAttr({ name: \"thumbnail\" })\n thumbnail?: ST_UriReference;\n\n /**\n *\n */\n @XmlAttr({ name: \"partnumber\" })\n partnumber?: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"name\" })\n name?: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"pid\" })\n pid?: ST_ResourceID;\n\n /**\n *\n */\n @XmlAttr({ name: \"pindex\" })\n pindex?: ST_ResourceIndex;\n\n /**\n *\n */\n metadatagroup?: I3mfMetadataGroup;\n\n /**\n *\n */\n content?: I3mfMesh | I3mfComponents;\n\n public constructor(id: ST_ResourceID, type = ST_ObjectType.model) {\n this.id = id;\n this.type = type;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"mesh\" })\nexport class ThreeMfMesh implements I3mfMesh {\n /**\n *\n */\n vertices: I3mfVertices;\n /**\n *\n */\n triangles: I3mfTriangles;\n\n public constructor(vertices?: I3mfVertices, triangles?: I3mfTriangles) {\n this.vertices = vertices ?? new ThreeMfVertices();\n this.triangles = triangles ?? new ThreeMfTriangles();\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"vertices\" })\nexport class ThreeMfVertices implements I3mfVertices {\n /**\n *\n */\n vertex: Array<I3mfVertex> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"vertex\" })\nexport class ThreeMfVertex implements I3mfVertex {\n /**\n *\n */\n @XmlAttr({ name: \"x\" })\n x: ST_Number;\n\n /**\n *\n */\n @XmlAttr({ name: \"y\" })\n y: ST_Number;\n\n /**\n *\n */\n @XmlAttr({ name: \"z\" })\n z: ST_Number;\n\n public constructor(x: ST_Number = 0, y: ST_Number = 0, z: ST_Number = 0) {\n this.x = x;\n this.y = y;\n this.z = z;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"triangles\" })\nexport class ThreeMfTriangles implements I3mfTriangles {\n /**\n *\n */\n triangle: Array<I3mfTriangle> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"triangle\" })\nexport class ThreeMfTriangle implements I3mfTriangle {\n /**\n *\n */\n @XmlAttr({ name: \"v1\" })\n v1: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"v2\" })\n v2: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"v3\" })\n v3: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"p1\" })\n p1?: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"p2\" })\n p2?: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"p3\" })\n p3?: ST_ResourceIndex;\n\n /**\n *\n */\n @XmlAttr({ name: \"pid\" })\n pid?: ST_ResourceID;\n\n public constructor(v1: ST_ResourceIndex, v2: ST_ResourceIndex, v3: ST_ResourceIndex) {\n this.v1 = v1;\n this.v2 = v2;\n this.v3 = v3;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"components\" })\nexport class ThreeMfComponents implements I3mfComponents {\n /**\n *\n */\n component: Array<I3mfComponent> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"component\" })\nexport class ThreeMfComponent implements I3mfComponent {\n /**\n *\n */\n @XmlAttr({ name: \"objectid\" })\n objectid: ST_ResourceID;\n\n /**\n *\n */\n @XmlAttr({ name: \"transform\", formatter: MatrixFormatter })\n transform?: Matrix3d;\n\n public constructor(objectid: ST_ResourceID, transform?: Matrix3d) {\n this.objectid = objectid;\n this.transform = transform;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"basematerials\" })\nexport class ThreeMfBaseMaterials implements I3mfBaseMaterials {\n /**\n *\n */\n @XmlAttr({ name: \"id\" })\n id: ST_ResourceID;\n\n /**\n *\n */\n base: Array<I3mfBase> = [];\n\n public constructor(id: ST_ResourceID) {\n this.id = id;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"base\" })\nexport class ThreeMfBase implements I3mfBase {\n /**\n *\n */\n @XmlAttr({ name: \"name\" })\n name: string;\n\n /**\n *\n */\n @XmlAttr({ name: \"displaycolor\" })\n displaycolor: ST_ColorValue;\n\n public constructor(name: string, displaycolor: ST_ColorValue) {\n this.name = name;\n this.displaycolor = displaycolor;\n }\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"build\" })\nexport class ThreeMfBuild implements I3mfBuild {\n /**\n *\n */\n item: Array<I3mfItem> = [];\n}\n\n/**\n *\n */\n@XmlName({ ns: ThreeDimModelNamespace, name: \"item\" })\nexport class ThreeMfItem implements I3mfItem {\n /**\n *\n */\n @XmlAttr({ name: \"objectid\" })\n objectid: ST_ResourceID;\n\n /**\n *\n */\n @XmlAttr({ name: \"transform\", formatter: MatrixFormatter })\n transform?: Matrix3d;\n\n /**\n *\n */\n @XmlAttr({ name: \"partnumber\" })\n partnumber?: string;\n\n /**\n *\n */\n metadatagroup?: I3mfMetadataGroup;\n\n public constructor(objectid: ST_ResourceID, transform?: Matrix3d, partnumber?: string) {\n this.objectid = objectid;\n this.transform = transform;\n this.partnumber = partnumber;\n }\n}\n","// 3MF\r\nimport type { Matrix3d } from \"./3mf\";\r\nimport {\r\n ThreeMfBase,\r\n ThreeMfBaseMaterials,\r\n ThreeMfBuild,\r\n ThreeMfComponent,\r\n ThreeMfComponents,\r\n ThreeMfItem,\r\n ThreeMfMesh,\r\n ThreeMfMeta,\r\n ThreeMfModel,\r\n ThreeMfObject,\r\n ThreeMfResources,\r\n ThreeMfTriangle,\r\n ThreeMfTriangles,\r\n ThreeMfVertex,\r\n ThreeMfVertices,\r\n} from \"./3mf\";\r\nimport type {\r\n I3mfBaseMaterials,\r\n I3mfComponents,\r\n I3mfMesh,\r\n I3mfMetadata,\r\n I3mfModel,\r\n I3mfObject,\r\n I3mfTriangle,\r\n I3mfTriangles,\r\n I3mfVertex,\r\n I3mfVertices,\r\n ST_ResourceID,\r\n ST_ResourceIndex,\r\n ST_Unit,\r\n} from \"./3mf.interfaces\";\r\nimport { ST_ObjectType } from \"./3mf.interfaces\";\r\nimport { ThreeMfContentType, ThreeMfContentTypes, ThreeMfDocument, ThreeMfRelationship, ThreeMfRelationships } from \"./3mf.opc\";\r\nimport type { I3mfDocument } from \"./3mf.opc.interfaces\";\r\nimport {\r\n Known3mfRelationshipTypes,\r\n KnownI3mfContentType,\r\n ModelFileName,\r\n Object3dDirName,\r\n type I3mfContentType,\r\n type I3mfContentTypes,\r\n type I3mfRelationship,\r\n type I3mfRelationships,\r\n} from \"./3mf.opc.interfaces\";\r\nimport type { I3mfRGBAColor, I3mfVertexData, ThreeMfFloatArray, ThreeMfIndicesArray } from \"./3mf.types\";\r\n\r\nexport type VertexHandler = (vertex: I3mfVertex) => I3mfVertex;\r\nexport type TriangleHandler = (triangle: I3mfTriangle) => I3mfTriangle;\r\n\r\n/** */\r\nexport class ThreeMfObjectBuilder {\r\n /**\r\n *\r\n */\r\n protected _object: ThreeMfObject;\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param type\r\n */\r\n public constructor(id: ST_ResourceID, type: ST_ObjectType) {\r\n this._object = new ThreeMfObject(id, type);\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @returns\r\n */\r\n public withName(name: string): ThreeMfObjectBuilder {\r\n this._object.name = name;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param thumbnail\r\n * @returns\r\n */\r\n public withThumbnail(thumbnail: string): ThreeMfObjectBuilder {\r\n this._object.thumbnail = thumbnail;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param index\r\n * @returns\r\n */\r\n public withProperty(id: ST_ResourceIndex, index: number = 0): ThreeMfObjectBuilder {\r\n this._object.pid = id;\r\n this._object.id = index;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public build(): I3mfObject {\r\n return this._object;\r\n }\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param type\r\n */\r\n public reset(id: ST_ResourceID, type: ST_ObjectType) {\r\n this._object = new ThreeMfObject(id, type);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfComponentsBuilder extends ThreeMfObjectBuilder {\r\n /**\r\n *\r\n * @param id\r\n * @param type\r\n */\r\n public constructor(id: ST_ResourceID, type: ST_ObjectType = ST_ObjectType.model) {\r\n super(id, type);\r\n this._object.content = new ThreeMfComponents();\r\n }\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param t\r\n * @returns\r\n */\r\n public withComponent(id: ST_ResourceID, t?: Matrix3d): ThreeMfComponentsBuilder {\r\n (this._object.content as I3mfComponents).component.push(new ThreeMfComponent(id, t));\r\n return this;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfMeshBuilder extends ThreeMfObjectBuilder {\r\n /**\r\n *\r\n */\r\n _vh?: VertexHandler;\r\n /**\r\n *\r\n */\r\n _th?: TriangleHandler;\r\n\r\n /**\r\n *\r\n * @param id\r\n */\r\n public constructor(id: ST_ResourceID) {\r\n super(id, ST_ObjectType.model);\r\n }\r\n\r\n /**\r\n *\r\n * @param vertex\r\n * @param triangle\r\n * @returns\r\n */\r\n public withPostProcessHandlers(vertex: VertexHandler, triangle?: TriangleHandler): ThreeMfMeshBuilder {\r\n this._vh = vertex;\r\n this._th = triangle;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param data\r\n * @returns\r\n */\r\n withData(data: I3mfVertexData): ThreeMfMeshBuilder {\r\n this._object.content = this._buildMesh(data);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param id\r\n * @param i\r\n * @returns\r\n */\r\n withMaterial(id: ST_ResourceID, i: number): ThreeMfMeshBuilder {\r\n this._object.pid = id;\r\n this._object.pindex = i;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param data\r\n * @returns\r\n */\r\n private _buildMesh(data: I3mfVertexData): I3mfMesh {\r\n const vertices = this._buildVertices(data.positions);\r\n const triangles = this._buildTriangle(data.indices);\r\n return new ThreeMfMesh(vertices, triangles);\r\n }\r\n\r\n private _buildVertices(p: ThreeMfFloatArray | null): I3mfVertices {\r\n const container = new ThreeMfVertices();\r\n if (p) {\r\n for (let i = 0; i < p.length; ) {\r\n const x = p[i++];\r\n const y = p[i++];\r\n const z = p[i++];\r\n let v = new ThreeMfVertex(x, y, z);\r\n // might be optimized....\r\n if (this._vh) {\r\n v = this._vh(v);\r\n }\r\n container.vertex.push(v);\r\n }\r\n }\r\n return container;\r\n }\r\n\r\n private _buildTriangle(indice: ThreeMfIndicesArray | null): I3mfTriangles {\r\n const container = new ThreeMfTriangles();\r\n if (indice) {\r\n for (let i = 0; i < indice.length; ) {\r\n const a = indice[i++];\r\n const b = indice[i++];\r\n const c = indice[i++];\r\n let t = new ThreeMfTriangle(a, b, c);\r\n // might be optimized....\r\n if (this._th) {\r\n t = this._th(t);\r\n }\r\n container.triangle.push(t);\r\n }\r\n }\r\n return container;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfMaterialBuilder {\r\n private _m: I3mfBaseMaterials;\r\n\r\n public constructor(id: ST_ResourceID) {\r\n this._m = new ThreeMfBaseMaterials(id);\r\n }\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param color\r\n * @returns\r\n */\r\n public withColor(name: string, color: I3mfRGBAColor): ThreeMfMaterialBuilder {\r\n this._m.base = this._m.base ?? [];\r\n let m = this._m.base.find((m) => m.name.toLowerCase() === name.toLowerCase());\r\n if (m) {\r\n m.displaycolor = this._rgbaToHex(color);\r\n return this;\r\n }\r\n m = new ThreeMfBase(name, this._rgbaToHex(color));\r\n this._m.base.push(m);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public build(): I3mfBaseMaterials {\r\n return this._m;\r\n }\r\n\r\n private _rgbaToHex(c: I3mfRGBAColor | { r: number; g: number; b: number; a?: number }): string {\r\n const toSRGB = (c: number) => Math.round(Math.min(255, Math.max(0, Math.pow(c, 1 / 2.2) * 255)));\r\n\r\n const r = toSRGB(c.r).toString(16).padStart(2, \"0\").toUpperCase();\r\n const g = toSRGB(c.g).toString(16).padStart(2, \"0\").toUpperCase();\r\n const b = toSRGB(c.b).toString(16).padStart(2, \"0\").toUpperCase();\r\n\r\n if (typeof (c as any).a === \"number\") {\r\n const a = Math.round(Math.min(255, Math.max(0, c.a! * 255)))\r\n .toString(16)\r\n .padStart(2, \"0\")\r\n .toUpperCase();\r\n return `#${r}${g}${b}${a}`;\r\n }\r\n\r\n return `#${r}${g}${b}`;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfModelBuilder {\r\n /**\r\n *\r\n */\r\n static KnownMetaSet = new Set(ThreeMfModel.KnownMeta.map((m) => m.toLowerCase()));\r\n\r\n /**\r\n *\r\n */\r\n _model: ThreeMfModel = new ThreeMfModel();\r\n /**\r\n *\r\n */\r\n _objects = new Map<string, I3mfObject>();\r\n\r\n /**\r\n *\r\n * @param name\r\n * @param value\r\n * @param preserve\r\n * @param type\r\n * @returns\r\n */\r\n public withMetaData(name: string, value: string, preserve?: boolean, type?: string): ThreeMfModelBuilder {\r\n if (!this._model.metadata) {\r\n // lazzy\r\n this._model.metadata = new Array<I3mfMetadata>();\r\n }\r\n //const isKnownMeta = (s: string): boolean => TMFBuilder.knownMetaSet.has(s.toLowerCase());\r\n //const qn:IQName = xmlNameToParts(name);\r\n this._model.metadata.push(new ThreeMfMeta(name, value, preserve, type));\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param material\r\n * @returns\r\n */\r\n public withMaterial(material: I3mfBaseMaterials | ThreeMfMaterialBuilder): ThreeMfModelBuilder {\r\n if (material instanceof ThreeMfMaterialBuilder) {\r\n material = material.build();\r\n }\r\n if (material) {\r\n this._model.resources = this._model.resources ?? new ThreeMfResources();\r\n this._model.resources.basematerials = this._model.resources.basematerials ?? [];\r\n this._model.resources.basematerials.push(material);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param object\r\n * @returns\r\n */\r\n public withMesh(object: I3mfObject | ThreeMfMeshBuilder): ThreeMfModelBuilder {\r\n if (object instanceof ThreeMfMeshBuilder) {\r\n object = object.build();\r\n }\r\n this._model.resources = this._model.resources ?? new ThreeMfResources();\r\n this._model.resources.object.push(object);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param components\r\n * @returns\r\n */\r\n public withComponents(components: I3mfObject | ThreeMfComponentsBuilder): ThreeMfModelBuilder {\r\n if (components instanceof ThreeMfComponentsBuilder) {\r\n components = components.build();\r\n }\r\n this._model.resources = this._model.resources ?? new ThreeMfResources();\r\n this._model.resources.object.push(components);\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param objectid\r\n * @param transform\r\n * @param partnumber\r\n * @returns\r\n */\r\n public withBuild(objectid: ST_ResourceID, transform?: Matrix3d, partnumber?: string): ThreeMfModelBuilder {\r\n this._model.build = this._model.build ?? new ThreeMfBuild();\r\n this._model.build.item?.push(new ThreeMfItem(objectid, transform, partnumber));\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param unit\r\n * @returns\r\n */\r\n public withUnit(unit: ST_Unit): ThreeMfModelBuilder {\r\n this._model.unit = unit;\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public reset(): ThreeMfModelBuilder {\r\n this._model = new ThreeMfModel();\r\n this._objects = new Map<string, I3mfObject>();\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public build(): ThreeMfModel {\r\n // quick surface check..\r\n if (!this._model.resources?.object?.length) {\r\n throw new Error(\"Invalid state: resources MUST be defined \");\r\n }\r\n if (!this._model.build?.item?.length) {\r\n throw new Error(\"Invalid state: Build MUST be defined \");\r\n }\r\n return this._model;\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\nexport class ThreeMfDocumentBuilder {\r\n private _cts?: I3mfContentTypes;\r\n private _rs?: I3mfRelationships;\r\n private _m?: I3mfModel;\r\n\r\n /**\r\n *\r\n * @param type\r\n * @returns\r\n */\r\n public withContentType(type: I3mfContentType): ThreeMfDocumentBuilder {\r\n if (!this._cts) {\r\n this._cts = new ThreeMfContentTypes();\r\n }\r\n const arr = this._cts.items;\r\n if (!arr.some((x) => x.ext === type.ext && x.ct === type.ct)) {\r\n arr.push(type);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param rel\r\n * @returns\r\n */\r\n public withRelationship(rel: I3mfRelationship): ThreeMfDocumentBuilder {\r\n if (!this._rs) {\r\n this._rs = new ThreeMfRelationships();\r\n }\r\n const arr = this._rs.items;\r\n if (!arr.some((x) => x.id === rel.id)) {\r\n arr.push(rel);\r\n }\r\n // here we ensure that the content type is declared.\r\n this.withContentType(new ThreeMfContentType(\"rels\", KnownI3mfContentType.Relationships));\r\n return this;\r\n }\r\n\r\n /**\r\n *\r\n * @param m\r\n * @returns\r\n */\r\n public withModel(m: I3mfModel | ThreeMfModelBuilder): ThreeMfDocumentBuilder {\r\n if (m instanceof ThreeMfModelBuilder) {\r\n m = m.build();\r\n }\r\n this._m = m;\r\n // here we ensure that the content type is declared.\r\n this.withContentType(new ThreeMfContentType(\"model\", KnownI3mfContentType.Model));\r\n return this;\r\n }\r\n\r\n public build(): I3mfDocument {\r\n if (!this._m) {\r\n throw new Error(\"Invalid state: you Must provide at least a model.\");\r\n }\r\n\r\n // we automate the build of the relationship if not provided..\r\n const path = `${Object3dDirName}${ModelFileName}`;\r\n if (!this._rs) {\r\n const absolutePath = `/${path}`;\r\n this.withRelationship(new ThreeMfRelationship(`rel${0}`, Known3mfRelationshipTypes.ThreeDimModel, absolutePath));\r\n }\r\n\r\n return new ThreeMfDocument(this._cts!, this._rs!, this._m);\r\n }\r\n}\r\n","// 3MF\r\nimport { ThreeMfDocumentBuilder, ThreeMfModelBuilder } from \"./3mf.builder\";\r\nimport { ContentTypeFileName, ModelFileName, Object3dDirName, RelationshipDirName, RelationshipFileName, type I3mfDocument } from \"./3mf.opc.interfaces\";\r\nimport type { I3mfModel } from \"./3mf.interfaces\";\r\nimport { ST_Unit } from \"./3mf.interfaces\";\r\n\r\n// XML\r\nimport { XmlBuilder } from \"../xml/xml.builder\";\r\nimport { XmlSerializer } from \"../xml/xml.serializer\";\r\nimport { type ByteSink, Utf8XmlWriterToBytes } from \"../xml/xml.builder.bytes\";\r\n\r\n/**\r\n * Options controlling how meshes are exported into the 3MF model.\r\n *\r\n * Notes:\r\n * - These flags are kept generic here and are expected to be interpreted by the concrete serializer/model builder.\r\n * - Defaults are set in AbstractThreeMfSerializer.DEFAULT_3MF_EXPORTER_OPTIONS.\r\n */\r\nexport interface IThreeMfSerializerBaseOptions {\r\n /**\r\n * define the unit. Default is millimeter\r\n */\r\n unit?: ST_Unit;\r\n\r\n /**\r\n *\r\n */\r\n metadata?: Record<string, string>;\r\n}\r\n\r\n/**\r\n * Minimal contract for a 3MF serializer that can stream its output through a sink callback.\r\n *\r\n * The sink callback receives:\r\n * - err: any error produced by the serialization pipeline (if any)\r\n * - chunk: a chunk of bytes to append to the destination\r\n * - final: true when this is the last chunk\r\n *\r\n * Important:\r\n * - Implementations should call sink with final=true exactly once, or rely on the underlying zip lib to do so.\r\n * - Consumers may ignore final if they just buffer everything.\r\n */\r\nexport interface I3mfSerializer<T> {\r\n serializeAsync(sink: (err: any, chunk: Uint8Array, final: boolean) => void, ...meshes: Array<T>): Promise<void>;\r\n}\r\n\r\n/**\r\n * Base class for 3MF serialization.\r\n *\r\n * Responsibilities:\r\n * - Convert user meshes to a 3MF model (toModel).\r\n * - Wrap the 3MF document parts into an OPC container (zip) and stream bytes through the sink.\r\n *\r\n * Non-responsibilities:\r\n * - Providing/initializing the zip implementation (ensureZipLibReadyAsync is abstract).\r\n * - Defining how meshes map to 3MF objects (toModel is abstract).\r\n */\r\nexport abstract class AbstractThreeMfSerializer<T, O extends IThreeMfSerializerBaseOptions> implements I3mfSerializer<T> {\r\n private _o: O;\r\n\r\n /**\r\n * @param opts user-provided options overriding defaults.\r\n */\r\n public constructor(opts: O) {\r\n this._o = opts;\r\n }\r\n\r\n /**\r\n * Expose the resolved options (defaults + overrides) as readonly.\r\n */\r\n public get options(): Readonly<O> {\r\n return this._o;\r\n }\r\n\r\n /**\r\n * Generic 3MF binary serializer.\r\n * Pipeline overview:\r\n * 1. ensureZipLibReadyAsync provides a zip implementation (host-dependent).\r\n * 2. Convert meshes into an I3mfDocument (OPC parts + model).\r\n * 3. Create a zip target that streams through the provided sink.\r\n * 4. Serialize XML parts into zip entries.\r\n * 5. End the zip stream.\r\n * @param sink a callback receiving byte chunks; enables streaming without buffering the full archive in memory.\r\n * @param meshes the meshes to serialize.\r\n * @returns\r\n */\r\n public async serializeAsync(sink: (err: any, chunk: Uint8Array, final: boolean) => void, ...meshes: Array<T>): Promise<void> {\r\n // The zip library (e.g. fflate) may need dynamic import / polyfills depending on host.\r\n // This is delegated to the concrete serializer implementation.\r\n const lib = await this.ensureZipLibReadyAsync();\r\n\r\n // If no lib is available, we silently do nothing today.\r\n // Consider: throwing could be better to fail fast. Kept as-is to preserve current behavior.\r\n if (!lib) {\r\n return;\r\n }\r\n\r\n const zip = lib.Zip;\r\n const zipDeflate = lib.ZipDeflate;\r\n\r\n // We expect a \"fflate-like\" API. If it is missing, fail with an explicit error.\r\n if (!zip || !zipDeflate) {\r\n throw new Error(\"fflate Zip / ZipDeflate not available\");\r\n }\r\n\r\n /**\r\n * Adapt a fflate entry to our ByteSink interface used by Utf8XmlWriterToBytes.\r\n *\r\n * fflate entry.push(chunk, final) is the writer endpoint for compressed bytes.\r\n * @param entry\r\n * @returns\r\n */\r\n const makeByteSinkFromFflateEntry = function (entry: any): ByteSink {\r\n return { push: (chunk: any, final: any) => entry.push(chunk, final) };\r\n };\r\n\r\n /**\r\n * Serialize an in-memory XML object into a compressed zip entry.\r\n *\r\n * Notes:\r\n * - \"object\" here is expected to be a structure understood by XmlSerializer.\r\n * - Compression level 6 is a reasonable default for speed/size tradeoff.\r\n * @param target\r\n * @param name\r\n * @param object\r\n */\r\n const serializeEntry = function (target: any, name: string, object: any): void {\r\n const entry = new zipDeflate(name, { level: 6 });\r\n target.add(entry);\r\n\r\n // Convert XmlSerializer output into UTF-8 bytes and push to the zip entry.\r\n const sink = makeByteSinkFromFflateEntry(entry);\r\n const w = new Utf8XmlWriterToBytes(sink);\r\n\r\n // Build XML declaration and serialize.\r\n const b = new XmlBuilder(w).dec(\"1.0\", \"UTF-8\");\r\n const s = new XmlSerializer(b);\r\n s.serialize(object);\r\n\r\n // Ensure the writer flushes any pending bytes and closes the stream for this entry.\r\n w.finish();\r\n };\r\n\r\n // Convert meshes into a 3MF document (content types + relationships + model part).\r\n const doc = this.toDocument(...meshes);\r\n if (!doc) {\r\n // Nothing to write. Current behavior: no zip output.\r\n return;\r\n }\r\n\r\n // Create the zip container. It will forward produced bytes to the provided sink.\r\n const target = new zip(sink);\r\n\r\n // Save the root content types part.\r\n // In OPC, [Content_Types].xml defines the MIME/content types for the package parts.\r\n serializeEntry(target, ContentTypeFileName, doc.contentTypes);\r\n\r\n // Save relationships.\r\n // In OPC, relationships live under _rels and map parts to each other.\r\n serializeEntry(target, `${RelationshipDirName}${RelationshipFileName}`, doc.relationships);\r\n\r\n // Save the 3D model part.\r\n // In 3MF, the main model is typically under /3D/3dmodel.model.\r\n serializeEntry(target, `${Object3dDirName}${ModelFileName}`, doc.model);\r\n\r\n // Finalize the archive stream.\r\n // This should trigger the zip implementation to call sink(..., final=true) when done.\r\n target.end();\r\n }\r\n\r\n /**\r\n * Build a full 3MF OPC document from meshes.\r\n *\r\n * The default behavior uses ThreeMfDocumentBuilder with the model produced by toModel().\r\n * Override if you need custom parts (textures, thumbnails, print ticket, etc.).\r\n * @param meshes\r\n * @returns\r\n */\r\n public toDocument(...meshes: Array<T>): I3mfDocument | undefined {\r\n const b = new ThreeMfModelBuilder().withUnit(this._o?.unit ?? ST_Unit.millimeter);\r\n if (this.options.metadata) {\r\n for (const m in this.options.metadata) {\r\n b.withMetaData(m, this.options.metadata[m]);\r\n }\r\n }\r\n return new ThreeMfDocumentBuilder().withModel(this.toModel(b, ...meshes)).build();\r\n }\r\n\r\n /**\r\n * Convert input meshes into a 3MF model.\r\n *\r\n * Implementations typically:\r\n * - Create resources and objects.\r\n * - Define build items (instances) when exportInstances is enabled.\r\n * - Encode geometry and properties required by your pipeline.\r\n */\r\n public abstract toModel(builder: ThreeMfModelBuilder, ...meshes: Array<T>): I3mfModel;\r\n\r\n /**\r\n * Provide a zip implementation for the current host/runtime.\r\n *\r\n * This might be provided by the framework implementation, but it could differ depending on the host\r\n * (native, Node.js, browser, etc.).\r\n *\r\n * Expected shape (fflate-like):\r\n * - return [ Zip, ZipDeflate ] at minimum.\r\n *\r\n * Notes:\r\n * - In a browser, this might require bundler configuration or dynamic import.\r\n * - In Node.js, this might be a direct import of \"fflate\" or another compatible implementation.\r\n */\r\n public abstract ensureZipLibReadyAsync(): Promise<any>;\r\n}\r\n\r\n/**\r\n * Convenience helpers around serializers.\r\n */\r\nexport class ThreeMf {\r\n /**\r\n * Serialize to a single in-memory buffer.\r\n *\r\n * This is a helper that buffers all chunks produced by serializeAsync, then concatenates them.\r\n * Use serializeAsync directly if you want true streaming to a file/response.\r\n * @param s\r\n * @param meshes\r\n * @returns\r\n */\r\n public static async SerializeToMemoryAsync<A>(s: I3mfSerializer<A>, ...meshes: Array<A>): Promise<Uint8Array | undefined> {\r\n const chunks = new Array<Uint8Array>();\r\n let size = 0;\r\n\r\n // Sink used by the zip stream. We ignore `final` because we buffer everything anyway.\r\n // If `err` is used by the underlying zip lib, callers may want to detect/throw here.\r\n const sink = function (err: any, chunk: Uint8Array, _final: boolean) {\r\n // Current behavior: ignore err and keep accumulating.\r\n // Consider: if err is non-null, you might want to throw or record it.\r\n chunks.push(chunk);\r\n size += chunk.length;\r\n };\r\n\r\n await s.serializeAsync(sink, ...meshes);\r\n\r\n // If nothing was written, return undefined (matches current behavior).\r\n if (!size) {\r\n return undefined;\r\n }\r\n\r\n // Concatenate chunks into a single Uint8Array.\r\n const buffer = new Uint8Array(size);\r\n let off = 0;\r\n for (const c of chunks) {\r\n buffer.set(c, off);\r\n off += c.length;\r\n }\r\n return buffer;\r\n }\r\n}\r\n","/**\r\n * Class used to store configuration of the 3MF Serializer\r\n */\r\nexport class ThreeMfSerializerGlobalConfiguration {\r\n /**\r\n * Url to use to load the fflate library (for zip compression)\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static FFLATEUrl = \"https://unpkg.com/fflate@0.8.2\";\r\n}\r\n","// Babylonjs\r\nimport type { SubMesh } from \"core/Meshes\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { InstancedMesh } from \"core/Meshes/instancedMesh\";\r\nimport { Matrix } from \"core/Maths/math\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\n// 3MF\r\nimport { ThreeMfMeshBuilder, type ThreeMfModelBuilder } from \"./core/model/3mf.builder\";\r\nimport { Matrix3d } from \"./core/model/3mf\";\r\n\r\nimport { ST_Unit, type I3mfModel, type I3mfObject } from \"./core/model/3mf.interfaces\";\r\nimport type { I3mfVertexData } from \"./core/model/3mf.types\";\r\nimport { AbstractThreeMfSerializer, type IThreeMfSerializerBaseOptions } from \"./core/model/3mf.serializer\";\r\nimport { ThreeMfSerializerGlobalConfiguration } from \"./3mfSerializer.configuration\";\r\n\r\n/**\r\n * Factory for generating sequential resource IDs for 3MF objects.\r\n */\r\nclass IncrementalIdFactory {\r\n private _from: number;\r\n private _to: number;\r\n private _step: number;\r\n private _i: number;\r\n\r\n /**\r\n * Creates an ID factory with the specified range and increment.\r\n * @param from - Starting ID value\r\n * @param to - Minimum bound for ID generation (throws if exceeded)\r\n * @param step - Increment value for each ID\r\n */\r\n public constructor(from: number = 0, to: number = Number.MIN_SAFE_INTEGER, step: number = 1) {\r\n this._from = from;\r\n this._to = to;\r\n this._step = step;\r\n this._i = from;\r\n }\r\n\r\n /**\r\n * Generates the next ID in the sequence.\r\n * @returns The next ID value\r\n * @throws Error if ID generation exceeds the configured bounds\r\n */\r\n public next(): number {\r\n if (this._i < this._to) {\r\n throw new Error(\"ST_ResourceID out of bound\");\r\n }\r\n const v = this._i;\r\n this._i += this._step;\r\n return v;\r\n }\r\n\r\n /**\r\n * Resets the factory to start generating from the initial value again.\r\n * @returns This factory instance for chaining\r\n */\r\n public reset(): IncrementalIdFactory {\r\n this._i = this._from;\r\n return this;\r\n }\r\n}\r\n\r\n/**\r\n * Options controlling how meshes are exported into the 3MF model.\r\n *\r\n * Notes:\r\n * - These flags are kept generic here and are expected to be interpreted by the concrete serializer/model builder.\r\n * - Defaults are set in AbstractThreeMfSerializer.DEFAULT_3MF_EXPORTER_OPTIONS.\r\n */\r\nexport interface IThreeMfSerializerOptions extends IThreeMfSerializerBaseOptions {\r\n /**\r\n * If true, export mesh instances (multiple references to the same geometry) when supported.\r\n * If false, geometry may be duplicated depending on the concrete implementation.\r\n */\r\n exportInstances?: boolean;\r\n}\r\n\r\n/**\r\n * Babylon.js to 3MF serializer.\r\n *\r\n * This serializer converts Babylon meshes into a 3MF model, then relies on the base class\r\n * (AbstractThreeMfSerializer) to package the OPC parts into a zip stream.\r\n *\r\n * Design notes:\r\n * - First pass: export \"source\" meshes (non-instances) and build an index to map Babylon mesh/submesh to 3MF object id.\r\n * - Second pass (optional): export instances as additional build items referencing the original object ids.\r\n * - Submesh export is handled by extracting per-submesh vertex/index buffers so materials/colors can be preserved\r\n * by downstream steps that attach per-object properties.\r\n */\r\nexport class ThreeMfSerializer extends AbstractThreeMfSerializer<Mesh | InstancedMesh, IThreeMfSerializerOptions> {\r\n /**\r\n * Default serialization options: meter units, no instance export.\r\n */\r\n static DefaultOptions: IThreeMfSerializerOptions = { unit: ST_Unit.meter, exportInstances: false };\r\n\r\n /**\r\n * Babylon's vertex buffer semantic for positions.\r\n * Babylon uses string-based \"kind\" keys for vertex buffers.\r\n */\r\n private static _PositionKind = \"position\";\r\n\r\n /**\r\n * Cached promise so we only attempt to load fflate once.\r\n * This prevents multiple concurrent LoadScriptAsync calls.\r\n */\r\n private _fflateReadyPromise?: Promise<any>;\r\n\r\n /**\r\n * @param opts serializer options (merged with defaults in base class).\r\n */\r\n public constructor(opts: Partial<IThreeMfSerializerOptions> = {}) {\r\n super({ ...ThreeMfSerializer.DefaultOptions, ...opts });\r\n }\r\n\r\n /**\r\n * Build a 3MF model from Babylon meshes.\r\n *\r\n * Important: this method should not allocate huge intermediate data unless needed.\r\n * Submesh extraction does allocate new position/index arrays for each exported submesh.\r\n * @param builder\r\n * @param meshes\r\n * @returns\r\n */\r\n public override toModel(builder: ThreeMfModelBuilder, ...meshes: Array<Mesh | InstancedMesh>): I3mfModel {\r\n // avoid parasits..\r\n meshes = meshes.filter((m) => m instanceof Mesh || m instanceof InstancedMesh);\r\n\r\n const idFactory = new IncrementalIdFactory();\r\n\r\n const modelBuilder = builder;\r\n\r\n /**\r\n * Index mapping Babylon elements to the created 3MF object.\r\n *\r\n * Why:\r\n * - Instances need to reference the base object id.\r\n * - When exporting submeshes, instances should reference per-submesh objects rather than the whole mesh.\r\n *\r\n * Key type:\r\n * - When exportSubmeshes is true: we store entries for each SubMesh.\r\n * - Otherwise: we store entries for each Mesh.\r\n */\r\n const index = new Map<Mesh | SubMesh, I3mfObject>();\r\n\r\n /**\r\n * If exportInstances is enabled, we collect instanced meshes during the first pass and process them later.\r\n * If exportInstances is disabled, instances are ignored (they will not appear in the output).\r\n */\r\n const instances: Array<InstancedMesh> | null = this.options.exportInstances ? [] : null;\r\n\r\n // First pass: export base meshes (non-instances).\r\n // This creates the \"resource objects\" referenced by build items.\r\n for (let j = 0; j < meshes.length; j++) {\r\n const babylonMesh = meshes[j];\r\n if (babylonMesh instanceof InstancedMesh) {\r\n // Defer instance handling to the second pass.\r\n instances?.push(babylonMesh);\r\n continue;\r\n }\r\n\r\n const objectName = babylonMesh.name || `mesh${j}`;\r\n\r\n // Convert Babylon world matrix to 3MF build transform (3x4).\r\n // This transform will be attached to the build item referencing the created object.\r\n const worldTransform = babylonMesh.getWorldMatrix();\r\n const buildTransform = this._handleBabylonTo3mfMatrixTransformToRef(worldTransform, Matrix3d.Zero());\r\n\r\n // Submeshes can carry material/color boundaries in Babylon.\r\n // When exportSubmeshes is enabled, we export each submesh as its own 3MF object so\r\n // consumers can attach per-object properties (e.g. colors) later.\r\n const subMeshes = babylonMesh.subMeshes;\r\n if (subMeshes === undefined) {\r\n // very unlikely...\r\n continue;\r\n }\r\n\r\n // Babylon.js automatically creates one SubMesh covering the whole mesh if you don’t define any.\r\n const isStandalone = subMeshes.length == 1;\r\n for (let k = 0; k < subMeshes.length; k++) {\r\n const subMesh = subMeshes[k];\r\n\r\n const data = this._extractSubMesh(babylonMesh, subMesh);\r\n\r\n if (data) {\r\n const submeshName = isStandalone ? `${objectName}` : `${objectName}_${k}`;\r\n\r\n const object = new ThreeMfMeshBuilder(idFactory.next()).withData(data).withName(submeshName).build();\r\n\r\n // Add object to resources.\r\n modelBuilder.withMesh(object);\r\n\r\n // Add a build item referencing the object at the mesh world transform.\r\n modelBuilder.withBuild(object.id, buildTransform);\r\n\r\n // Cache mapping for instances (instances will reference this object id).\r\n index.set(subMesh, object);\r\n }\r\n }\r\n }\r\n\r\n // Second pass: export instances as additional build items.\r\n //\r\n // In 3MF terms:\r\n // - We do not duplicate geometry for each instance.\r\n // - We emit multiple build items referencing the same object id, each with its own transform.\r\n if (instances && instances.length) {\r\n // Group instances by their source mesh to keep related builds close in the XML.\r\n const grouped = this._groupBy(instances, (i) => i.sourceMesh);\r\n\r\n for (const [_babylonMesh, _instances] of Array.from(grouped.entries())) {\r\n if (!_instances || !_instances.length) {\r\n continue;\r\n }\r\n\r\n for (let j = 0; j < _instances.length; j++) {\r\n const mesh = _instances[j];\r\n const worldTransform = mesh.getWorldMatrix();\r\n\r\n // If we exported submeshes, the base \"resource objects\" are per-submesh.\r\n // For an instance we emit a build item per submesh object.\r\n const subMeshes = _babylonMesh.subMeshes;\r\n\r\n for (let k = 0; k < subMeshes.length; k++) {\r\n const subMesh = subMeshes[k];\r\n\r\n // Look up the 3MF object created for this submesh in the first pass.\r\n const objectRef = index.get(subMesh);\r\n\r\n if (objectRef) {\r\n modelBuilder.withBuild(objectRef.id, this._handleBabylonTo3mfMatrixTransformToRef(worldTransform, Matrix3d.Zero()));\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return modelBuilder.build();\r\n }\r\n\r\n /**\r\n * Ensure the zip library (fflate) is available in the current runtime.\r\n *\r\n * Host assumptions:\r\n * - This implementation relies on fflate being exposed on globalThis.fflate.\r\n * - If it is not present, it loads a script from ThreeMfSerializerGlobalConfiguration.FFLATEUrl using Babylon Tools.LoadScriptAsync.\r\n * @returns\r\n */\r\n public override async ensureZipLibReadyAsync(): Promise<any> {\r\n if (this._fflateReadyPromise) {\r\n return await this._fflateReadyPromise;\r\n }\r\n\r\n this._fflateReadyPromise = (async () => {\r\n // globalThis is the global object in all modern JS runtimes (browser, workers, Node, etc.).\r\n const g = globalThis as any;\r\n\r\n // If fflate is not already present, load it dynamically.\r\n // This assumes the loaded script sets globalThis.fflate.\r\n if (!g.fflate) {\r\n await Tools.LoadScriptAsync(ThreeMfSerializerGlobalConfiguration.FFLATEUrl);\r\n }\r\n\r\n return g.fflate;\r\n })();\r\n\r\n return await this._fflateReadyPromise;\r\n }\r\n\r\n /**\r\n * Extract a single SubMesh into a standalone vertex/index buffer pair.\r\n *\r\n * Why:\r\n * - 3MF mesh objects typically reference a contiguous vertex array and triangle indices.\r\n * - Babylon SubMesh references a slice of the global index buffer, but shares the vertex buffer.\r\n * - To serialize each submesh independently, we build a compacted vertex buffer containing only the used vertices\r\n * and remap indices accordingly.\r\n *\r\n * Complexity:\r\n * - O(indexCount) time, O(uniqueVerticesInSubmesh) additional memory.\r\n * @param mesh\r\n * @param sm\r\n * @returns\r\n */\r\n private _extractSubMesh(mesh: Mesh, sm: SubMesh): I3mfVertexData | undefined {\r\n const allInd = mesh.getIndices();\r\n if (!allInd) {\r\n return undefined;\r\n }\r\n\r\n const allPos = mesh.getVerticesData(ThreeMfSerializer._PositionKind);\r\n if (!allPos) {\r\n return undefined;\r\n }\r\n\r\n // Fast path: the submesh covers the full index buffer, so reuse the original arrays.\r\n // Note: This returns Babylon-owned arrays; if callers mutate, they will affect source mesh data.\r\n // Kept as-is to avoid extra allocations.\r\n if (sm.indexStart == 0 && sm.indexCount == allInd.length) {\r\n return {\r\n positions: allPos,\r\n indices: allInd,\r\n };\r\n }\r\n\r\n const indStart = sm.indexStart;\r\n\r\n // Map old vertex index -> new compacted vertex index.\r\n const map = new Map<number, number>();\r\n\r\n // Compacted positions (x,y,z repeated). We assemble into number[] then convert to Float32Array at the end.\r\n const newPositions: number[] = [];\r\n\r\n // Indices for the compacted vertex buffer.\r\n // Uint32Array is used to support large meshes; ensure downstream 3MF writer supports 32-bit indices if needed.\r\n const newIndices = new Uint32Array(sm.indexCount);\r\n\r\n for (let i = 0; i < sm.indexCount; i++) {\r\n const oldVi = allInd[indStart + i];\r\n\r\n let newVi = map.get(oldVi);\r\n if (newVi === undefined) {\r\n newVi = map.size;\r\n map.set(oldVi, newVi);\r\n\r\n // Copy the corresponding position (assumes positions are 3-floats per vertex).\r\n // If the source mesh uses a different stride or includes morph targets, this ignores them.\r\n const p = oldVi * 3;\r\n newPositions.push(allPos[p], allPos[p + 1], allPos[p + 2]);\r\n }\r\n\r\n newIndices[i] = newVi;\r\n }\r\n\r\n return {\r\n positions: new Float32Array(newPositions),\r\n indices: newIndices,\r\n };\r\n }\r\n\r\n /**\r\n * Group items by a computed key.\r\n * Used to group instances by sourceMesh so the resulting XML is easier to read and debug.\r\n * @param items\r\n * @param key\r\n * @returns\r\n */\r\n private _groupBy<T, K>(items: readonly T[], key: (v: T) => K): Map<K, T[]> {\r\n const m = new Map<K, T[]>();\r\n for (const it of items) {\r\n const k = key(it);\r\n const arr = m.get(k);\r\n if (arr) {\r\n arr.push(it);\r\n } else {\r\n m.set(k, [it]);\r\n }\r\n }\r\n return m;\r\n }\r\n\r\n /**\r\n * Basis conversion from Babylon coordinate system to the expected 3MF coordinate system.\r\n *\r\n * Here we rotate +90 degrees around X:\r\n * - This is commonly used to convert between Y-up and Z-up conventions.\r\n * - Verify this matches your pipeline (Babylon is typically left-handed Y-up).\r\n */\r\n private static readonly _R_BJS_TO_3MF = Matrix.RotationX(Math.PI / 2).multiply(Matrix.Scaling(1, -1, 1));\r\n\r\n /**\r\n * Converts a Babylon.js 4x4 matrix into a 3MF 3x4 transform matrix and writes the result into ref.\r\n *\r\n * Babylon.js conventions:\r\n * - Babylon exposes matrices with logical row/column indexing (M(row, column)).\r\n * - It stores the 16 coefficients in a contiguous array in row-major order:\r\n * [ M00, M01, M02, M03,\r\n * M10, M11, M12, M13,\r\n * M20, M21, M22, M23,\r\n * M30, M31, M32, M33 ]\r\n *\r\n * 3MF expectation:\r\n * - 3MF uses an affine transform represented as a 3x4 matrix (12 values).\r\n * - The values are taken from the first 3 columns of the 4x4 matrix, across the 4 rows:\r\n * m00 m01 m02 m10 m11 m12 m20 m21 m22 m30 m31 m32\r\n *\r\n * Steps:\r\n * 1) Compose Babylon transform with the basis change:\r\n * tmp = tBjs * _R_BJS_TO_3MF\r\n * 2) Extract the 12 coefficients in 3MF order from tmp.m.\r\n *\r\n * Interop note:\r\n * - Do not transpose here. We only reorder values to match the 3MF 3x4 serialization order.\r\n * - Transposition is only relevant when interfacing with code that assumes column-major storage.\r\n *\r\n * @param tBjs Babylon.js 4x4 matrix.\r\n * @param ref Output 3MF 3x4 matrix container (ref.values assigned).\r\n * @returns ref, for chaining.\r\n */\r\n private _handleBabylonTo3mfMatrixTransformToRef(tBjs: Matrix, ref: Matrix3d): Matrix3d {\r\n const tmp = tBjs.multiplyToRef(ThreeMfSerializer._R_BJS_TO_3MF, Matrix.Zero());\r\n const a = tmp.m;\r\n\r\n // a is Babylon row-major storage. Extract rows 0..3, cols 0..2 in 3MF order.\r\n // 3MF order: m00 m01 m02 m10 m11 m12 m20 m21 m22 m30 m31 m32\r\n ref.values = [a[0], a[1], a[2], a[4], a[5], a[6], a[8], a[9], a[10], a[12], a[13], a[14]];\r\n return ref;\r\n }\r\n}\r\n","/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nimport * as Serializers from \"serializers/3MF/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n const keys = [];\r\n for (const serializer in Serializers) {\r\n // Prevent Reassignment.\r\n if (keys.indexOf(serializer) > -1) {\r\n continue;\r\n }\r\n (<any>globalObject).BABYLON[serializer] = (<any>Serializers)[serializer];\r\n keys.push(serializer);\r\n }\r\n}\r\n\r\nexport * from \"serializers/3MF/index\";\r\n","import * as serializers from \"@lts/serializers/legacy/legacy-3mfSerializer\";\r\nexport { serializers };\r\nexport default serializers;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__597__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","extendStatics","b","setPrototypeOf","__proto__","Array","p","__extends","TypeError","String","__","constructor","create","__assign","assign","t","s","i","n","arguments","length","apply","__decorate","decorators","target","desc","c","getOwnPropertyDescriptor","Reflect","decorate","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","step","next","rejected","result","done","then","__generator","body","f","y","_","label","sent","trys","ops","Iterator","verb","iterator","v","op","pop","push","__spreadArray","to","from","pack","ar","l","slice","concat","IsQualifiedName","x","name","SuppressedError","XML_CLASS_META","XML_CLASS_NAME","AddXmlMeta","meta","ctor","XmlName","XmlIgnore","kind","ignore","XmlAttr","opts","XmlElem","GetXmlFieldMeta","GetXmlName","LooksLikeXmlNcName","test","XmlNameToParts","qn","trim","indexOf","prefix","local","ns","ToQualifiedString","DefaultXmlSerializerNumberOptions","freeze","eps","maxDecimalsCap","trimTrailingZeros","allowScientific","snapNearZero","DefaultXmlSerializerFormatOptions","number","ResolveNumberOptions","fixedDecimals","zeroThreshold","perAttributeEps","ResolveFormatOptions","_o","Number","isFinite","Error","toString","decimals","_clampInt","inv","q","Math","round","is","abs","ceil","log10","trunc","toFixed","replace","min","max","IsDate","Date","IsString","IsPrimitive","IsPrimitiveButString","TokenType","builder","format","_ns","Map","_prefixCount","_builder","_format","_nFmt","NumberFormatter","withNamespace","_assignNamespace","serialize","currentName","_gatherNamespaces","WeakSet","doc","ele","entries","att","_writeObjectContent","add","end","_writeObject","source","visited","has","isArray","item","text","qname","_getPrefix","tmp","toLowerCase","metas","metaByProp","m","arr","set","keys","sort","a","aHasAttr","some","bHasAttr","propMetas","ignored","vStr","formatter","tag","toVisit","nqn","_buildNsPrefix","alreadyReferenced","values","OpenTag","CloseTag","Slash","Question","Quote","Equal","Space","Semicolon","Dec","Xml","Xmlns","Xsi","VersionKeyword","EncodingKeyword","StandaloneKeyword","ST_Unit","ST_ObjectType","w","_ctxStack","_d","_w","dec","version","encoding","standalone","write","XmlSyntax","_writeAttStr","ctx","_peekContext","closed","_isXmlnsDecl","defaultNs","_registerNamespace","lastToken","Attribute","_ensurePrefixDeclared","_closeOpenTagIfNeeded","qns","_lookupPrefix","_pushContext","txt","Text","_escText","_popContext","depth","XmlBuilder","Context","_escAttr","ns2prefix","startsWith","uri","existingUri","prefix2ns","_allocPrefix","existing","count","_chunks","data","join","clear","_sink","_opts","_encoder","TextEncoder","_pending","_pendingChars","limit","flushChars","flush","bytes","encode","finish","Uint8Array","ThreeDimModelNamespace","TriangleSetsNamespace","KnownI3mfContentType","OpenXmlContentTypesNamespace","OpenXmlRelationshipsNamespace","RelationshipDirName","Object3dDirName","ModelFileName","RelationshipFileName","ContentTypeFileName","IsKnown","type","Known3mfRelationshipTypes","Known","IsThreeDimModel","ThreeDimModel","Thumbnail","PrintTicket","MustPreserve","Set","items","ThreeMfContentTypes","ext","ct","ThreeMfContentType","ThreeMfRelationships","id","ThreeMfRelationship","contentTypes","relationships","model","Zero","Matrix3d","_f","map","unit","millimeter","KnownMeta","ThreeMfModel","preserve","ThreeMfMeta","metadata","ThreeMfMetadataGroup","object","ThreeMfResources","ThreeMfObject","vertices","triangles","ThreeMfVertices","ThreeMfTriangles","ThreeMfMesh","vertex","z","ThreeMfVertex","triangle","v1","v2","v3","ThreeMfTriangle","component","ThreeMfComponents","objectid","transform","MatrixFormatter","ThreeMfComponent","base","ThreeMfBaseMaterials","displaycolor","ThreeMfBase","ThreeMfBuild","partnumber","ThreeMfItem","_object","withName","withThumbnail","thumbnail","withProperty","index","pid","build","reset","content","withComponent","ThreeMfObjectBuilder","withPostProcessHandlers","_vh","_th","withData","_buildMesh","withMaterial","pindex","_buildVertices","positions","_buildTriangle","indices","container","indice","_m","withColor","color","find","_rgbaToHex","toSRGB","pow","padStart","toUpperCase","_model","_objects","withMetaData","material","ThreeMfMaterialBuilder","resources","basematerials","withMesh","ThreeMfMeshBuilder","withComponents","components","ThreeMfComponentsBuilder","withBuild","withUnit","KnownMetaSet","withContentType","_cts","withRelationship","rel","_rs","Relationships","withModel","ThreeMfModelBuilder","Model","path","absolutePath","ThreeMfDocument","serializeAsync","sink","ensureZipLibReadyAsync","lib","zip","Zip","zipDeflate","ZipDeflate","makeByteSinkFromFflateEntry","entry","chunk","final","serializeEntry","level","Utf8XmlWriterToBytes","XmlSerializer","toDocument","meshes","options","ThreeMfDocumentBuilder","toModel","SerializeToMemoryAsync","chunks","size","err","_final","buffer","off","FFLATEUrl","MIN_SAFE_INTEGER","_from","_to","_step","_i","ThreeMfSerializer","DefaultOptions","filter","Mesh","InstancedMesh","idFactory","IncrementalIdFactory","modelBuilder","instances","exportInstances","j","babylonMesh","objectName","worldTransform","getWorldMatrix","buildTransform","_handleBabylonTo3mfMatrixTransformToRef","subMeshes","isStandalone","k","subMesh","_extractSubMesh","submeshName","grouped","_groupBy","sourceMesh","_babylonMesh","_instances","objectRef","_fflateReadyPromise","fflate","Tools","LoadScriptAsync","ThreeMfSerializerGlobalConfiguration","mesh","sm","allInd","getIndices","allPos","getVerticesData","_PositionKind","indexStart","indexCount","indStart","newPositions","newIndices","Uint32Array","oldVi","newVi","Float32Array","it","tBjs","ref","multiplyToRef","_R_BJS_TO_3MF","Matrix","meter","RotationX","PI","multiply","Scaling","AbstractThreeMfSerializer","globalObject","serializer","BABYLON"],"sourceRoot":""}
|